aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2009-01-09 14:18:59 +0000
committerChong Yidong2009-01-09 14:18:59 +0000
commitc2aa555a1c09d7b96caec5e1ad8bb39d15a34d58 (patch)
tree633e10fc60da295b6d52e3355e4406b54dcb46f5
parent1c1282fbc4795a5af3cdef9df53041406471b7c9 (diff)
downloademacs-c2aa555a1c09d7b96caec5e1ad8bb39d15a34d58.tar.gz
emacs-c2aa555a1c09d7b96caec5e1ad8bb39d15a34d58.zip
(Font Lookup): Remove obsolete function
x-font-family-list. x-list-fonts accepts Fontconfig/GTK syntax. (Low-Level Font): Rename from Fonts, move to end of Faces section. (Font Selection): Reorder order of variable descriptions. Minor clarifications.
-rw-r--r--doc/lispref/display.texi429
1 files changed, 200 insertions, 229 deletions
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index bf034813277..cc358fe65b8 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -1789,12 +1789,12 @@ particular face name a special meaning in one frame if you wish.
1789* Face Remapping:: Remapping faces to alternative definitions. 1789* Face Remapping:: Remapping faces to alternative definitions.
1790* Face Functions:: How to define and examine faces. 1790* Face Functions:: How to define and examine faces.
1791* 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. 1792* Font Selection:: Finding the best available font for a face.
1794* Font Lookup:: Looking up the names of available fonts 1793* Font Lookup:: Looking up the names of available fonts
1795 and information about them. 1794 and information about them.
1796* Fontsets:: A fontset is a collection of fonts 1795* Fontsets:: A fontset is a collection of fonts
1797 that handle a range of character sets. 1796 that handle a range of character sets.
1797* Low-Level Font:: Lisp representation for character display fonts.
1798@end menu 1798@end menu
1799 1799
1800@node Defining Faces 1800@node Defining Faces
@@ -2616,189 +2616,48 @@ For efficiency, we recommend writing these functions so that they
2616usually assign faces to around 400 to 600 characters at each call. 2616usually assign faces to around 400 to 600 characters at each call.
2617@end defvar 2617@end defvar
2618 2618
2619@node Fonts 2619@node Font Selection
2620@subsection Fonts 2620@subsection Font Selection
2621 2621
2622 Before Emacs can draw a character on a particular display, it must 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 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 2624term @dfn{font} has nothing to do with Font Lock (@pxref{Font Lock
2625Mode}).}. Normally, Emacs automatically chooses a font for displaying 2625Mode}).}. Normally, Emacs automatically chooses a font based on the
2626a character based on the faces assigned to that 2626faces assigned to that character---specifically, the face attributes
2627character---specifically, the face attributes @code{:family}, 2627@code{:family}, @code{:weight}, @code{:slant}, and @code{:width}
2628@code{:weight}, @code{:slant}, and @code{:width}. The choice of font 2628(@pxref{Face Attributes}). The choice of font also depends on the
2629also depends on the character to be displayed; some fonts can only 2629character to be displayed; some fonts can only display a limited set
2630display a limited set of characters. Normally, it is not necessary to 2630of characters. If no available font exactly fits the requirements,
2631manipulate fonts directly. In case you need to do so, this section 2631Emacs looks for the @dfn{closest matching font}. The variables in
2632explains how. 2632this section control how Emacs makes this selection.
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 2633
2669@defun font-spec &rest arguments 2634@defvar face-font-family-alternatives
2670Return a new font spec using the specifications in @var{arguments}, 2635If a given family is specified but does not exist, this variable
2671which should come in @code{property}-@code{value} pairs. The possible 2636specifies alternative font families to try. Each element should have
2672specifications are as follows: 2637this form:
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 2638
2781@node Font Selection 2639@example
2782@subsection Font Selection 2640(@var{family} @var{alternate-families}@dots{})
2641@end example
2783 2642
2784 Emacs tries to find an available font to display each character 2643If @var{family} is specified but not available, Emacs will try the other
2785based on the face attributes and the character's registry and 2644families given in @var{alternate-families}, one by one, until it finds a
2786encoding. If there is a font that matches exactly, it is used, of 2645family that does exist.
2787course. The hard case is when no available font exactly fits the 2646@end defvar
2788specification. Then Emacs looks for one that is ``close''---one
2789attribute at a time. You can specify the order to consider the
2790attributes. In the case where a specified font family is not
2791available, you can specify a set of mappings for alternatives to try.
2792 2647
2793@defvar face-font-selection-order 2648@defvar face-font-selection-order
2794This variable specifies the order of importance of the face attributes 2649If there is no font that exactly matches all desired face attributes
2795@code{:width}, @code{:height}, @code{:weight}, and @code{:slant}. The 2650(@code{:width}, @code{:height}, @code{:weight}, and @code{:slant}),
2796value should be a list containing those four symbols, in order of 2651this variable specifies the order in which these attributes should be
2797decreasing importance. 2652considered when selecting the closest matching font. The value should
2653be a list containing those four attribute symbols, in order of
2654decreasing importance. The default is @code{(:width :height :weight
2655:slant)}.
2798 2656
2799Font selection first finds the best available matches for the first 2657Font selection first finds the best available matches for the first
2800attribute listed; then, among the fonts which are best in that way, it 2658attribute in the list; then, among the fonts which are best in that
2801searches for the best matches in the second attribute, and so on. 2659way, it searches for the best matches in the second attribute, and so
2660on.
2802 2661
2803The attributes @code{:weight} and @code{:width} have symbolic values in 2662The attributes @code{:weight} and @code{:width} have symbolic values in
2804a range centered around @code{normal}. Matches that are more extreme 2663a range centered around @code{normal}. Matches that are more extreme
@@ -2806,11 +2665,6 @@ a range centered around @code{normal}. Matches that are more extreme
2806less extreme (closer to @code{normal}); this is designed to ensure that 2665less extreme (closer to @code{normal}); this is designed to ensure that
2807non-normal faces contrast with normal ones, whenever possible. 2666non-normal faces contrast with normal ones, whenever possible.
2808 2667
2809The default is @code{(:width :height :weight :slant)}, which means first
2810find the fonts closest to the specified @code{:width}, then---among the
2811fonts with that width---find a best match for the specified font height,
2812and so on.
2813
2814One example of a case where this variable makes a difference is when the 2668One example of a case where this variable makes a difference is when the
2815default font has no italic equivalent. With the default ordering, the 2669default font has no italic equivalent. With the default ordering, the
2816@code{italic} face will use a non-italic font that is similar to the 2670@code{italic} face will use a non-italic font that is similar to the
@@ -2819,20 +2673,6 @@ default one. But if you put @code{:slant} before @code{:height}, the
2819quite right. 2673quite right.
2820@end defvar 2674@end defvar
2821 2675
2822@defvar face-font-family-alternatives
2823This variable lets you specify alternative font families to try, if a
2824given family is specified and doesn't exist. Each element should have
2825this form:
2826
2827@example
2828(@var{family} @var{alternate-families}@dots{})
2829@end example
2830
2831If @var{family} is specified but not available, Emacs will try the other
2832families given in @var{alternate-families}, one by one, until it finds a
2833family that does exist.
2834@end defvar
2835
2836@defvar face-font-registry-alternatives 2676@defvar face-font-registry-alternatives
2837This variable lets you specify alternative font registries to try, if a 2677This variable lets you specify alternative font registries to try, if a
2838given registry is specified and doesn't exist. Each element should have 2678given registry is specified and doesn't exist. Each element should have
@@ -2848,8 +2688,7 @@ until it finds a registry that does exist.
2848@end defvar 2688@end defvar
2849 2689
2850 Emacs can make use of scalable fonts, but by default it does not use 2690 Emacs can make use of scalable fonts, but by default it does not use
2851them, since the use of too many or too big scalable fonts can crash 2691them.
2852XFree86 servers.
2853 2692
2854@defvar scalable-fonts-allowed 2693@defvar scalable-fonts-allowed
2855This variable controls which scalable fonts to use. A value of 2694This variable controls which scalable fonts to use. A value of
@@ -2886,25 +2725,25 @@ nominal heights and widths would suggest.
2886@node Font Lookup 2725@node Font Lookup
2887@subsection Looking Up Fonts 2726@subsection Looking Up Fonts
2888 2727
2889@defun x-list-fonts pattern &optional face frame maximum 2728@defun x-list-fonts name &optional reference-face frame maximum
2890This function returns a list of available font names that match 2729This function returns a list of available font names that match
2891@var{pattern}. If the optional arguments @var{face} and @var{frame} are 2730@var{name}. @var{name} should be a string containing a font name in
2892specified, then the list is limited to fonts that are the same size as 2731either the Fontconfig, GTK, or XLFD format (@pxref{Font X,, Font
2893@var{face} currently is on @var{frame}. 2732Specification Options, emacs, The GNU Emacs Manual}). Within an XLFD
2894 2733string, wildcard characters may be used: the @samp{*} character
2895The argument @var{pattern} should be a string, perhaps with wildcard 2734matches any substring, and the @samp{?} character matches any single
2896characters: the @samp{*} character matches any substring, and the 2735character. Case is ignored when matching font names.
2897@samp{?} character matches any single character. Pattern matching 2736
2898of font names ignores case. 2737If the optional arguments @var{reference-face} and @var{frame} are
2899 2738specified, the returned list includes only fonts that are the same
2900If you specify @var{face} and @var{frame}, @var{face} should be a face name 2739size as @var{reference-face} (a face name) currently is on the frame
2901(a symbol) and @var{frame} should be a frame. 2740@var{frame}.
2902 2741
2903The optional argument @var{maximum} sets a limit on how many fonts to 2742The optional argument @var{maximum} sets a limit on how many fonts to
2904return. If this is non-@code{nil}, then the return value is truncated 2743return. If it is non-@code{nil}, then the return value is truncated
2905after the first @var{maximum} matching fonts. Specifying a small value 2744after the first @var{maximum} matching fonts. Specifying a small
2906for @var{maximum} can make this function much faster, in cases where 2745value for @var{maximum} can make this function much faster, in cases
2907many fonts match the pattern. 2746where many fonts match the pattern.
2908@end defun 2747@end defun
2909 2748
2910@defun x-family-fonts &optional family frame 2749@defun x-family-fonts &optional family frame
@@ -2918,7 +2757,7 @@ The list describes the display that @var{frame} is on; if @var{frame} is
2918omitted or @code{nil}, it applies to the selected frame's display 2757omitted or @code{nil}, it applies to the selected frame's display
2919(@pxref{Input Focus}). 2758(@pxref{Input Focus}).
2920 2759
2921The list contains a vector of the following form for each font: 2760Each element in the list is a vector of the following form:
2922 2761
2923@example 2762@example
2924[@var{family} @var{width} @var{point-size} @var{weight} @var{slant} 2763[@var{family} @var{width} @var{point-size} @var{weight} @var{slant}
@@ -2933,24 +2772,6 @@ The last three elements give additional information about the font.
2933@var{full} is the full name of the font, and 2772@var{full} is the full name of the font, and
2934@var{registry-and-encoding} is a string giving the registry and 2773@var{registry-and-encoding} is a string giving the registry and
2935encoding of the font. 2774encoding of the font.
2936
2937The result list is sorted according to the current face font sort order.
2938@end defun
2939
2940@defun x-font-family-list &optional frame
2941This function returns a list of the font families available for
2942@var{frame}'s display. If @var{frame} is omitted or @code{nil}, it
2943describes the selected frame's display (@pxref{Input Focus}).
2944
2945The value is a list of elements of this form:
2946
2947@example
2948(@var{family} . @var{fixed-p})
2949@end example
2950
2951@noindent
2952Here @var{family} is a font family, and @var{fixed-p} is
2953non-@code{nil} if fonts of that family are fixed-pitch.
2954@end defun 2775@end defun
2955 2776
2956@defvar font-list-limit 2777@defvar font-list-limit
@@ -3095,6 +2916,156 @@ Fontsets can specify a font on a per-character basis; when the fontset
3095does that, this function's value may not be accurate. 2916does that, this function's value may not be accurate.
3096@end defun 2917@end defun
3097 2918
2919@node Low-Level Font
2920@subsection Low-Level Font Representation
2921
2922 Normally, it is not necessary to manipulate fonts directly. In case
2923you need to do so, this section explains how.
2924
2925 In Emacs Lisp, fonts are represented using three different Lisp
2926qobject types: @dfn{font objects}, @dfn{font specs}, and @dfn{font
2927entities}.
2928
2929@defun fontp object &optional type
2930Return @code{t} if @var{object} is a font object, font spec, or font
2931entity. Otherwise, return @code{nil}.
2932
2933The optional argument @var{type}, if non-@code{nil}, determines the
2934exact type of Lisp object to check for. In that case, @var{type}
2935should be one of @code{font-object}, @code{font-spec}, or
2936@code{font-entity}.
2937@end defun
2938
2939 A font object is a Lisp object that represents a font that Emacs has
2940@dfn{opened}. Font objects cannot be modified in Lisp, but they can
2941be inspected. If you call @code{set-face-attribute} and pass a font
2942spec, font entity, or font name string as the value of the
2943@code{:font} attribute, Emacs opens the best ``matching'' font that is
2944available for display. It then stores the corresponding font object
2945as the actual value of the @code{:font} attribute for that face.
2946
2947@defun font-at position &optional window string
2948Return the font object that is being used to display the character at
2949position @var{position} in the window @var{window}. If @var{window}
2950is @code{nil}, it defaults to the selected window. If @var{string} is
2951@code{nil}, @var{position} specifies a position in the current buffer;
2952otherwise, @var{string} should be a string, and @var{position}
2953specifies a position in that string.
2954@end defun
2955
2956 A font spec is a Lisp object that contains a set of specifications
2957that can be used to find a font. More than one font may match the
2958specifications in a font spec.
2959
2960@defun font-spec &rest arguments
2961Return a new font spec using the specifications in @var{arguments},
2962which should come in @code{property}-@code{value} pairs. The possible
2963specifications are as follows:
2964
2965@table @code
2966@item :name
2967The font name (a string), in either XLFD, Fontconfig, or GTK format.
2968@xref{Font X,, Font Specification Options, emacs, The GNU Emacs
2969Manual}.
2970
2971@item :family
2972@itemx :foundry
2973@itemx :weight
2974@itemx :slant
2975@itemx :width
2976These have the same meanings as the face attributes of the same name.
2977@xref{Face Attributes}.
2978
2979@item :size
2980The font size---either a non-negative integer that specifies the pixel
2981size, or a floating point number that specifies the point size.
2982
2983@item :adstyle
2984Additional typographic style information for the font, such as
2985@samp{sans}. The value should be a string or a symbol.
2986
2987@item :registry
2988The charset registry and encoding of the font, such as
2989@samp{iso8859-1}. The value should be a string or a symbol.
2990
2991@item :script
2992The script that the font must support (a symbol).
2993@end table
2994@end defun
2995
2996@defun font-put font-spec property value
2997Set the font property @var{property} in the font-spec @var{font-spec}
2998to @var{value}.
2999@end defun
3000
3001 A font entity is a reference to a font that need not be open. Its
3002properties are intermediate between a font object and a font spec:
3003like a font object, and unlike a font spec, it refers to a single,
3004specific font. Unlike a font object, creating a font entity does not
3005load the contents of that font into computer memory.
3006
3007@defun find-font font-spec &optional frame
3008This function returns a font entity that best matches the font spec
3009@var{font-spec} on frame @var{frame}. If @var{frame} is @code{nil},
3010it defaults to the selected frame.
3011@end defun
3012
3013@defun list-fonts font-spec &optional frame num prefer
3014This function returns a list of all font entities that match the font
3015spec @var{font-spec}.
3016
3017The optional argument @var{frame}, if non-@code{nil}, specifies the
3018frame on which the fonts are to be displayed. The optional argument
3019@var{num}, if non-@code{nil}, should be an integer that specifies the
3020maximum length of the returned list. The optional argument
3021@var{prefer}, if non-@code{nil}, should be another font spec, which is
3022used to control the order of the returned list; the returned font
3023entities are sorted in order of decreasing ``closeness'' to that font
3024spec.
3025@end defun
3026
3027 The following functions can be used to obtain information about a
3028font. For these functions, the @var{font} argument can be a font
3029object, a font entity, or a font spec.
3030
3031@defun font-get font property
3032This function returns the value of the font property @var{property}
3033for @var{font}.
3034
3035If @var{font} is a font spec and the font spec does not specify
3036@var{property}, the return value is @code{nil}. If @var{font} is a
3037font object or font entity, the value for the @var{:script} property
3038may be a list of scripts supported by the font.
3039@end defun
3040
3041@defun font-face-attributes font &optional frame
3042This function returns a list of face attributes corresponding to
3043@var{font}. The optional argument @var{frame} specifies the frame on
3044which the font is to be displayed. If it is @code{nil}, the selected
3045frame is used. The return value has the form
3046
3047@smallexample
3048(:family @var{family} :height @var{height} :weight @var{weight}
3049 :slant @var{slant} :width @var{width})
3050@end smallexample
3051
3052where the values of @var{family}, @var{height}, @var{weight},
3053@var{slant}, and @var{width} are face attribute values. Some of these
3054key-attribute pairs may be omitted from the list if they are not
3055specified by @var{font}.
3056@end defun
3057
3058@defun font-xlfd-name font &optional fold-wildcards
3059This function returns the XLFD (X Logical Font Descriptor), a string,
3060matching @var{font}. @xref{Font X,, Font Specification Options,
3061emacs, The GNU Emacs Manual}, for information about XLFDs. If the
3062name is too long for an XLFD (which can contain at most 255
3063characters), the function returns @code{nil}.
3064
3065If the optional argument @var{fold-wildcards} is non-@code{nil},
3066consecutive wildcards in the XLFD are folded into one.
3067@end defun
3068
3098@node Fringes 3069@node Fringes
3099@section Fringes 3070@section Fringes
3100@cindex fringes 3071@cindex fringes