aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2009-01-08 20:58:13 +0000
committerChong Yidong2009-01-08 20:58:13 +0000
commit9185bf498e6f594940f2913cdf93e60966af3523 (patch)
tree9b1ffa412afebc4a620f1f5c1a826a004f4bf445
parent606061b9f7c8ec51d0d28648248695e4594f95e5 (diff)
downloademacs-9185bf498e6f594940f2913cdf93e60966af3523.tar.gz
emacs-9185bf498e6f594940f2913cdf93e60966af3523.zip
(Faces): Put Font Selection node after Auto Faces.
(Face Attributes): Don't link to Font Lookup. Document font-family-list. (Fonts): New node.
-rw-r--r--doc/lispref/display.texi421
1 files changed, 291 insertions, 130 deletions
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 0625285603d..bf034813277 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -1787,9 +1787,10 @@ particular face name a special meaning in one frame if you wish.
1787* Attribute Functions:: Functions to examine and set face attributes. 1787* Attribute Functions:: Functions to examine and set face attributes.
1788* Displaying Faces:: How Emacs combines the faces specified for a character. 1788* Displaying Faces:: How Emacs combines the faces specified for a character.
1789* Face Remapping:: Remapping faces to alternative definitions. 1789* Face Remapping:: Remapping faces to alternative definitions.
1790* Font Selection:: Finding the best available font for a face.
1791* Face Functions:: How to define and examine faces. 1790* Face Functions:: How to define and examine faces.
1792* Auto Faces:: Hook for automatic face assignment. 1791* Auto Faces:: Hook for automatic face assignment.
1792* Fonts:: Lisp representation for character display fonts.
1793* Font Selection:: Finding the best available font for a face.
1793* Font Lookup:: Looking up the names of available fonts 1794* Font Lookup:: Looking up the names of available fonts
1794 and information about them. 1795 and information about them.
1795* Fontsets:: A fontset is a collection of fonts 1796* Fontsets:: A fontset is a collection of fonts
@@ -1961,14 +1962,16 @@ attribute is ignored.
1961 1962
1962@table @code 1963@table @code
1963@item :family 1964@item :family
1964Font family name (@pxref{Font Lookup}), or fontset name 1965Font family name or fontset name (a string). If you specify a font
1965(@pxref{Fontsets}). If you specify a font family name, the wild-card 1966family name, the wild-card characters @samp{*} and @samp{?} are
1966characters @samp{*} and @samp{?} are allowed. @xref{Font Lookup}. 1967allowed. The function @code{font-family-list}, described below,
1968returns a list of available family names. @xref{Fontsets}, for
1969information about fontsets.
1967 1970
1968@item :foundry 1971@item :foundry
1969The @dfn{font foundry} in which the font family specified by the 1972The name of the @dfn{font foundry} in which the font family specified
1970@code{:family} attribute is located. The wild-card characters 1973by the @code{:family} attribute is located (a string). The wild-card
1971@samp{*} and @samp{?} are allowed. @xref{Font Lookup}. 1974characters @samp{*} and @samp{?} are allowed.
1972 1975
1973@item :width 1976@item :width
1974Relative proportionate character width, also known as the character 1977Relative proportionate character width, also known as the character
@@ -2082,19 +2085,20 @@ Normally you do not need to set the stipple attribute, because it is
2082used automatically to handle certain shades of gray. 2085used automatically to handle certain shades of gray.
2083 2086
2084@item :font 2087@item :font
2085The font used to display the face. Its value should be a font object 2088The font used to display the face. Its value should be a font object.
2086(@pxref{Font Lookup}). 2089@xref{Font Selection}, for information about font objects.
2087 2090
2088When specifying this attribute using @code{set-face-attribute} 2091When specifying this attribute using @code{set-face-attribute}
2089(@pxref{Attribute Functions}), you may supply a font spec, a font 2092(@pxref{Attribute Functions}), you may also supply a font spec, a font
2090entity, or a string. Emacs converts such values to an appropriate 2093entity, or a string. Emacs converts such values to an appropriate
2091font object, and stores that font object internally. If you specify a 2094font object, and stores that font object as the actual attribute
2092string, the contents of the string should be an XLFD font name 2095value. If you specify a string, the contents of the string should be
2093(@pxref{Font X,, Font Specification Options, emacs, The GNU Emacs 2096a font name (@pxref{Font X,, Font Specification Options, emacs, The
2094Manual}); if the XLFD contains wildcards, Emacs chooses the first font 2097GNU Emacs Manual}); if the font name is an XLFD containing wildcards,
2095matching those wildcards. Specifying this attribute also changes the 2098Emacs chooses the first font matching those wildcards. Specifying
2096values of the @code{:family}, @code{:foundry}, @code{:width}, 2099this attribute also changes the values of the @code{:family},
2097@code{:height}, @code{:weight}, and @code{:slant} attributes. 2100@code{:foundry}, @code{:width}, @code{:height}, @code{:weight}, and
2101@code{:slant} attributes.
2098 2102
2099@item :inherit 2103@item :inherit
2100The name of a face from which to inherit attributes, or a list of face 2104The name of a face from which to inherit attributes, or a list of face
@@ -2114,6 +2118,12 @@ to @code{normal}. Setting @code{:italic} to @code{t} is equivalent to
2114setting the @code{:slant} attribute to @code{italic}, and setting it 2118setting the @code{:slant} attribute to @code{italic}, and setting it
2115to @code{nil} is equivalent to setting @code{:slant} to @code{normal}. 2119to @code{nil} is equivalent to setting @code{:slant} to @code{normal}.
2116 2120
2121@defun font-family-list &optional frame
2122This function returns a list of available font family names. The
2123optional argument @var{frame} specifies the frame on which the text is
2124to be displayed; if it is @code{nil}, the selected frame is used.
2125@end defun
2126
2117@defvar x-bitmap-file-path 2127@defvar x-bitmap-file-path
2118This variable specifies a list of directories for searching 2128This variable specifies a list of directories for searching
2119for bitmap files, for the @code{:stipple} attribute. 2129for bitmap files, for the @code{:stipple} attribute.
@@ -2512,27 +2522,273 @@ This function sets the ``base remapping'' of @var{face} to its default
2512value, which inherits from @var{face}'s global definition. 2522value, which inherits from @var{face}'s global definition.
2513@end defun 2523@end defun
2514 2524
2525@node Face Functions
2526@subsection Functions for Working with Faces
2527
2528 Here are additional functions for creating and working with faces.
2529
2530@defun make-face name
2531This function defines a new face named @var{name}, initially with all
2532attributes @code{nil}. It does nothing if there is already a face named
2533@var{name}.
2534@end defun
2535
2536@defun face-list
2537This function returns a list of all defined face names.
2538@end defun
2539
2540@defun copy-face old-face new-name &optional frame new-frame
2541This function defines a face named @var{new-name} as a copy of the existing
2542face named @var{old-face}. It creates the face @var{new-name} if that
2543doesn't already exist.
2544
2545If the optional argument @var{frame} is given, this function applies
2546only to that frame. Otherwise it applies to each frame individually,
2547copying attributes from @var{old-face} in each frame to @var{new-face}
2548in the same frame.
2549
2550If the optional argument @var{new-frame} is given, then @code{copy-face}
2551copies the attributes of @var{old-face} in @var{frame} to @var{new-name}
2552in @var{new-frame}.
2553@end defun
2554
2555@defun face-id face
2556This function returns the @dfn{face number} of face @var{face}. This
2557is a number that uniquely identifies a face at low levels within
2558Emacs. It is seldom necessary to refer to a face by its face number.
2559@end defun
2560
2561@defun face-documentation face
2562This function returns the documentation string of face @var{face}, or
2563@code{nil} if none was specified for it.
2564@end defun
2565
2566@defun face-equal face1 face2 &optional frame
2567This returns @code{t} if the faces @var{face1} and @var{face2} have the
2568same attributes for display.
2569@end defun
2570
2571@defun face-differs-from-default-p face &optional frame
2572This returns non-@code{nil} if the face @var{face} displays
2573differently from the default face.
2574@end defun
2575
2576@cindex face alias
2577A @dfn{face alias} provides an equivalent name for a face. You can
2578define a face alias by giving the alias symbol the @code{face-alias}
2579property, with a value of the target face name. The following example
2580makes @code{modeline} an alias for the @code{mode-line} face.
2581
2582@example
2583(put 'modeline 'face-alias 'mode-line)
2584@end example
2585
2586@node Auto Faces
2587@subsection Automatic Face Assignment
2588@cindex automatic face assignment
2589@cindex faces, automatic choice
2590
2591 This hook is used for automatically assigning faces to text in the
2592buffer. It is part of the implementation of Jit-Lock mode, used by
2593Font-Lock.
2594
2595@defvar fontification-functions
2596This variable holds a list of functions that are called by Emacs
2597redisplay as needed to assign faces automatically to text in the buffer.
2598
2599The functions are called in the order listed, with one argument, a
2600buffer position @var{pos}. Each function should attempt to assign faces
2601to the text in the current buffer starting at @var{pos}.
2602
2603Each function should record the faces they assign by setting the
2604@code{face} property. It should also add a non-@code{nil}
2605@code{fontified} property for all the text it has assigned faces to.
2606That property tells redisplay that faces have been assigned to that text
2607already.
2608
2609It is probably a good idea for each function to do nothing if the
2610character after @var{pos} already has a non-@code{nil} @code{fontified}
2611property, but this is not required. If one function overrides the
2612assignments made by a previous one, the properties as they are
2613after the last function finishes are the ones that really matter.
2614
2615For efficiency, we recommend writing these functions so that they
2616usually assign faces to around 400 to 600 characters at each call.
2617@end defvar
2618
2619@node Fonts
2620@subsection Fonts
2621
2622 Before Emacs can draw a character on a particular display, it must
2623select a @dfn{font} for that character@footnote{In this context, the
2624term @dfn{font} has nothing to do with Font Lock (@pxref{Font Lock
2625Mode}).}. Normally, Emacs automatically chooses a font for displaying
2626a character based on the faces assigned to that
2627character---specifically, the face attributes @code{:family},
2628@code{:weight}, @code{:slant}, and @code{:width}. The choice of font
2629also depends on the character to be displayed; some fonts can only
2630display a limited set of characters. Normally, it is not necessary to
2631manipulate fonts directly. In case you need to do so, this section
2632explains how.
2633
2634 In Emacs Lisp, fonts are represented using three different Lisp
2635object types: @dfn{font objects}, @dfn{font specs}, and @dfn{font
2636entities}.
2637
2638@defun fontp object &optional type
2639Return @code{t} if @var{object} is a font object, font spec, or font
2640entity. Otherwise, return @code{nil}.
2641
2642The optional argument @var{type}, if non-@code{nil}, determines the
2643exact type of Lisp object to check for. In that case, @var{type}
2644should be one of @code{font-object}, @code{font-spec}, or
2645@code{font-entity}.
2646@end defun
2647
2648 A font object is a Lisp object that represents a font that Emacs has
2649@dfn{opened}. Font objects cannot be modified in Lisp, but they can
2650be inspected. For instance, if you call @code{set-face-attribute} and
2651pass a font spec, font entity, or font name string as the value of the
2652@code{:font} attribute, Emacs opens the best ``matching'' font that is
2653available for display. It then stores the corresponding font object
2654as the actual value of the @code{:font} attribute for that face.
2655
2656@defun font-at position &optional window string
2657Return the font object that is being used to display the character at
2658position @var{position} in the window @var{window}. If @var{window}
2659is @code{nil}, it defaults to the selected window. If @var{string} is
2660@code{nil}, @var{position} specifies a position in the current buffer;
2661otherwise, @var{string} should be a string, and @var{position}
2662specifies a position in that string.
2663@end defun
2664
2665 A font spec is a Lisp object that contains a set of specifications
2666that can be used to find a font. More than one font may match the
2667specifications in a font spec.
2668
2669@defun font-spec &rest arguments
2670Return a new font spec using the specifications in @var{arguments},
2671which should come in @code{property}-@code{value} pairs. The possible
2672specifications are as follows:
2673
2674@table @code
2675@item :name
2676The font name string, in either XLFD, Fontconfig, or GTK format.
2677@xref{Font X,, Font Specification Options, emacs, The GNU Emacs
2678Manual}.
2679
2680@item :family
2681@itemx :foundry
2682@itemx :weight
2683@itemx :slant
2684@itemx :width
2685These have the same meanings as the face attributes of the same name.
2686@xref{Face Attributes}.
2687
2688@item :size
2689The font size---either a non-negative integer that specifies the pixel
2690size, or a floating point number that specifies the point size.
2691
2692@item :adstyle
2693Additional typographic style information for the font, such as
2694@samp{sans}. The value should be a string or a symbol.
2695
2696@item :registry
2697The charset registry and encoding of the font, such as
2698@samp{iso8859-1}. The value should be a string or a symbol.
2699
2700@item :script
2701The script that the font must support (a symbol).
2702@end table
2703@end defun
2704
2705@defun font-put font-spec property value
2706Set the font property @var{property} in the font-spec @var{font-spec}
2707to @var{value}.
2708@end defun
2709
2710 A font entity is a reference to a font that need not have been
2711opened. Its properties are intermediate between a font object and a
2712font spec: like a font object, and unlike a font spec, it refers to a
2713single, specific font. Unlike a font object, it can be modified in
2714Lisp, and creating a font entity does not load the contents of that
2715font into computer memory.
2716
2717@defun find-font font-spec &optional frame
2718Return a font entity that best matches the font spec @var{font-spec}
2719on frame @var{frame}. If @var{frame} is @code{nil}, it defaults to
2720the selected frame.
2721@end defun
2722
2723@defun list-fonts font-spec &optional frame num prefer
2724This function returns a list of all font entities that match the font
2725spec @var{font-spec}.
2726
2727The optional argument @var{frame}, if non-@code{nil}, specifies the
2728frame on which the fonts are to be displayed. The optional argument
2729@var{num}, if non-@code{nil}, should be an integer; in that case, the
2730function returns a list of at most @var{num} font entities. The
2731optional argument @var{prefer}, if non-@code{nil}, should be another
2732font spec, which is used to control the order of the returned list;
2733the returned font entities are sorted in order of decreasing
2734``closeness'' to that font spec.
2735@end defun
2736
2737 The following functions can be used to obtain information about font
2738objects, font entities, and font specs alike:
2739
2740@defun font-get font property
2741This function returns the value of the font property @var{property}
2742for @var{font}, which should be either a font object, font spec, or
2743font entity.
2744
2745If @var{font} is a font spec and the font spec does not specify
2746@var{property}, the return value is @code{nil}. If @var{font} is a
2747font object or font entity, the value for the @var{:script} property
2748may be a list of scripts supported by the font.
2749@end defun
2750
2751@defun font-face-attributes font &optional frame
2752This function returns a list of face attributes corresponding to
2753@var{font} , which should be either a font name, a font object, a font
2754spec, or a font entity. The optional argument @var{frame} specifies
2755the frame on which the font is to be displayed. If it is @code{nil},
2756the selected frame is used. The return value has the form
2757
2758@smallexample
2759(:family @var{family} :height @var{height} :weight @var{weight}
2760 :slant @var{slant} :width @var{width})
2761@end smallexample
2762
2763where the values of @var{family}, @var{height}, @var{weight},
2764@var{slant}, and @var{width} are face attribute values. Some of these
2765key-attribute pairs may be omitted from the list if they are not
2766specified by @var{font}.
2767@end defun
2768
2769@defun font-xlfd-name font &optional fold-wildcards
2770This function returns the XLFD (X Logical Font Descriptor), a string,
2771matching @var{font}. @xref{Font X,, Font Specification Options,
2772emacs, The GNU Emacs Manual}, for information about XLFDs. @var{font}
2773should be a font spec, font entity, or font object. If the name is
2774too long for an XLFD (which can contain at most 255 characters), the
2775function returns @code{nil}.
2776
2777If the optional argument @var{fold-wildcards} is non-@code{nil},
2778consecutive wildcards in the XLFD are folded into one.
2779@end defun
2780
2515@node Font Selection 2781@node Font Selection
2516@subsection Font Selection 2782@subsection Font Selection
2517 2783
2518 @dfn{Selecting a font} means mapping the specified face attributes for 2784 Emacs tries to find an available font to display each character
2519a character to a font that is available on a particular display. The 2785based on the face attributes and the character's registry and
2520face attributes, as determined by face merging, specify most of the 2786encoding. If there is a font that matches exactly, it is used, of
2521font choice, but not all. Part of the choice depends on what character 2787course. The hard case is when no available font exactly fits the
2522it is. 2788specification. Then Emacs looks for one that is ``close''---one
2523 2789attribute at a time. You can specify the order to consider the
2524 If the face specifies a fontset name, that fontset determines a 2790attributes. In the case where a specified font family is not
2525pattern for fonts of the given charset. If the face specifies a font 2791available, you can specify a set of mappings for alternatives to try.
2526family, a font pattern is constructed.
2527
2528 Emacs tries to find an available font for the given face attributes
2529and character's registry and encoding. If there is a font that matches
2530exactly, it is used, of course. The hard case is when no available font
2531exactly fits the specification. Then Emacs looks for one that is
2532``close''---one attribute at a time. You can specify the order to
2533consider the attributes. In the case where a specified font family is
2534not available, you can specify a set of mappings for alternatives to
2535try.
2536 2792
2537@defvar face-font-selection-order 2793@defvar face-font-selection-order
2538This variable specifies the order of importance of the face attributes 2794This variable specifies the order of importance of the face attributes
@@ -2627,101 +2883,6 @@ the font size if certain fonts are bigger or smaller than their
2627nominal heights and widths would suggest. 2883nominal heights and widths would suggest.
2628@end defvar 2884@end defvar
2629 2885
2630@node Face Functions
2631@subsection Functions for Working with Faces
2632
2633 Here are additional functions for creating and working with faces.
2634
2635@defun make-face name
2636This function defines a new face named @var{name}, initially with all
2637attributes @code{nil}. It does nothing if there is already a face named
2638@var{name}.
2639@end defun
2640
2641@defun face-list
2642This function returns a list of all defined face names.
2643@end defun
2644
2645@defun copy-face old-face new-name &optional frame new-frame
2646This function defines a face named @var{new-name} as a copy of the existing
2647face named @var{old-face}. It creates the face @var{new-name} if that
2648doesn't already exist.
2649
2650If the optional argument @var{frame} is given, this function applies
2651only to that frame. Otherwise it applies to each frame individually,
2652copying attributes from @var{old-face} in each frame to @var{new-face}
2653in the same frame.
2654
2655If the optional argument @var{new-frame} is given, then @code{copy-face}
2656copies the attributes of @var{old-face} in @var{frame} to @var{new-name}
2657in @var{new-frame}.
2658@end defun
2659
2660@defun face-id face
2661This function returns the @dfn{face number} of face @var{face}. This
2662is a number that uniquely identifies a face at low levels within
2663Emacs. It is seldom necessary to refer to a face by its face number.
2664@end defun
2665
2666@defun face-documentation face
2667This function returns the documentation string of face @var{face}, or
2668@code{nil} if none was specified for it.
2669@end defun
2670
2671@defun face-equal face1 face2 &optional frame
2672This returns @code{t} if the faces @var{face1} and @var{face2} have the
2673same attributes for display.
2674@end defun
2675
2676@defun face-differs-from-default-p face &optional frame
2677This returns non-@code{nil} if the face @var{face} displays
2678differently from the default face.
2679@end defun
2680
2681@cindex face alias
2682A @dfn{face alias} provides an equivalent name for a face. You can
2683define a face alias by giving the alias symbol the @code{face-alias}
2684property, with a value of the target face name. The following example
2685makes @code{modeline} an alias for the @code{mode-line} face.
2686
2687@example
2688(put 'modeline 'face-alias 'mode-line)
2689@end example
2690
2691
2692@node Auto Faces
2693@subsection Automatic Face Assignment
2694@cindex automatic face assignment
2695@cindex faces, automatic choice
2696
2697 This hook is used for automatically assigning faces to text in the
2698buffer. It is part of the implementation of Jit-Lock mode, used by
2699Font-Lock.
2700
2701@defvar fontification-functions
2702This variable holds a list of functions that are called by Emacs
2703redisplay as needed to assign faces automatically to text in the buffer.
2704
2705The functions are called in the order listed, with one argument, a
2706buffer position @var{pos}. Each function should attempt to assign faces
2707to the text in the current buffer starting at @var{pos}.
2708
2709Each function should record the faces they assign by setting the
2710@code{face} property. It should also add a non-@code{nil}
2711@code{fontified} property for all the text it has assigned faces to.
2712That property tells redisplay that faces have been assigned to that text
2713already.
2714
2715It is probably a good idea for each function to do nothing if the
2716character after @var{pos} already has a non-@code{nil} @code{fontified}
2717property, but this is not required. If one function overrides the
2718assignments made by a previous one, the properties as they are
2719after the last function finishes are the ones that really matter.
2720
2721For efficiency, we recommend writing these functions so that they
2722usually assign faces to around 400 to 600 characters at each call.
2723@end defvar
2724
2725@node Font Lookup 2886@node Font Lookup
2726@subsection Looking Up Fonts 2887@subsection Looking Up Fonts
2727 2888