Mercurial > emacs
comparison doc/lispref/display.texi @ 101033:652cf1b0fd5a
(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.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Fri, 09 Jan 2009 14:18:59 +0000 |
parents | 80faf5dfb6cd |
children | d380142646c0 |
comparison
equal
deleted
inserted
replaced
101032:097a50a78f81 | 101033:652cf1b0fd5a |
---|---|
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 * 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 |
1801 @subsection Defining Faces | 1801 @subsection Defining Faces |
1802 | 1802 |
2614 | 2614 |
2615 For efficiency, we recommend writing these functions so that they | 2615 For efficiency, we recommend writing these functions so that they |
2616 usually assign faces to around 400 to 600 characters at each call. | 2616 usually 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 |
2623 select a @dfn{font} for that character@footnote{In this context, the | 2623 select a @dfn{font} for that character@footnote{In this context, the |
2624 term @dfn{font} has nothing to do with Font Lock (@pxref{Font Lock | 2624 term @dfn{font} has nothing to do with Font Lock (@pxref{Font Lock |
2625 Mode}).}. Normally, Emacs automatically chooses a font for displaying | 2625 Mode}).}. Normally, Emacs automatically chooses a font based on the |
2626 a character based on the faces assigned to that | 2626 faces assigned to that character---specifically, the face attributes |
2627 character---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 |
2629 also depends on the character to be displayed; some fonts can only | 2629 character to be displayed; some fonts can only display a limited set |
2630 display a limited set of characters. Normally, it is not necessary to | 2630 of characters. If no available font exactly fits the requirements, |
2631 manipulate fonts directly. In case you need to do so, this section | 2631 Emacs looks for the @dfn{closest matching font}. The variables in |
2632 explains how. | 2632 this section control how Emacs makes this selection. |
2633 | |
2634 @defvar face-font-family-alternatives | |
2635 If a given family is specified but does not exist, this variable | |
2636 specifies alternative font families to try. Each element should have | |
2637 this form: | |
2638 | |
2639 @example | |
2640 (@var{family} @var{alternate-families}@dots{}) | |
2641 @end example | |
2642 | |
2643 If @var{family} is specified but not available, Emacs will try the other | |
2644 families given in @var{alternate-families}, one by one, until it finds a | |
2645 family that does exist. | |
2646 @end defvar | |
2647 | |
2648 @defvar face-font-selection-order | |
2649 If there is no font that exactly matches all desired face attributes | |
2650 (@code{:width}, @code{:height}, @code{:weight}, and @code{:slant}), | |
2651 this variable specifies the order in which these attributes should be | |
2652 considered when selecting the closest matching font. The value should | |
2653 be a list containing those four attribute symbols, in order of | |
2654 decreasing importance. The default is @code{(:width :height :weight | |
2655 :slant)}. | |
2656 | |
2657 Font selection first finds the best available matches for the first | |
2658 attribute in the list; then, among the fonts which are best in that | |
2659 way, it searches for the best matches in the second attribute, and so | |
2660 on. | |
2661 | |
2662 The attributes @code{:weight} and @code{:width} have symbolic values in | |
2663 a range centered around @code{normal}. Matches that are more extreme | |
2664 (farther from @code{normal}) are somewhat preferred to matches that are | |
2665 less extreme (closer to @code{normal}); this is designed to ensure that | |
2666 non-normal faces contrast with normal ones, whenever possible. | |
2667 | |
2668 One example of a case where this variable makes a difference is when the | |
2669 default font has no italic equivalent. With the default ordering, the | |
2670 @code{italic} face will use a non-italic font that is similar to the | |
2671 default one. But if you put @code{:slant} before @code{:height}, the | |
2672 @code{italic} face will use an italic font, even if its height is not | |
2673 quite right. | |
2674 @end defvar | |
2675 | |
2676 @defvar face-font-registry-alternatives | |
2677 This variable lets you specify alternative font registries to try, if a | |
2678 given registry is specified and doesn't exist. Each element should have | |
2679 this form: | |
2680 | |
2681 @example | |
2682 (@var{registry} @var{alternate-registries}@dots{}) | |
2683 @end example | |
2684 | |
2685 If @var{registry} is specified but not available, Emacs will try the | |
2686 other registries given in @var{alternate-registries}, one by one, | |
2687 until it finds a registry that does exist. | |
2688 @end defvar | |
2689 | |
2690 Emacs can make use of scalable fonts, but by default it does not use | |
2691 them. | |
2692 | |
2693 @defvar scalable-fonts-allowed | |
2694 This variable controls which scalable fonts to use. A value of | |
2695 @code{nil}, the default, means do not use scalable fonts. @code{t} | |
2696 means to use any scalable font that seems appropriate for the text. | |
2697 | |
2698 Otherwise, the value must be a list of regular expressions. Then a | |
2699 scalable font is enabled for use if its name matches any regular | |
2700 expression in the list. For example, | |
2701 | |
2702 @example | |
2703 (setq scalable-fonts-allowed '("muleindian-2$")) | |
2704 @end example | |
2705 | |
2706 @noindent | |
2707 allows the use of scalable fonts with registry @code{muleindian-2}. | |
2708 @end defvar | |
2709 | |
2710 @defvar face-font-rescale-alist | |
2711 This variable specifies scaling for certain faces. Its value should | |
2712 be a list of elements of the form | |
2713 | |
2714 @example | |
2715 (@var{fontname-regexp} . @var{scale-factor}) | |
2716 @end example | |
2717 | |
2718 If @var{fontname-regexp} matches the font name that is about to be | |
2719 used, this says to choose a larger similar font according to the | |
2720 factor @var{scale-factor}. You would use this feature to normalize | |
2721 the font size if certain fonts are bigger or smaller than their | |
2722 nominal heights and widths would suggest. | |
2723 @end defvar | |
2724 | |
2725 @node Font Lookup | |
2726 @subsection Looking Up Fonts | |
2727 | |
2728 @defun x-list-fonts name &optional reference-face frame maximum | |
2729 This function returns a list of available font names that match | |
2730 @var{name}. @var{name} should be a string containing a font name in | |
2731 either the Fontconfig, GTK, or XLFD format (@pxref{Font X,, Font | |
2732 Specification Options, emacs, The GNU Emacs Manual}). Within an XLFD | |
2733 string, wildcard characters may be used: the @samp{*} character | |
2734 matches any substring, and the @samp{?} character matches any single | |
2735 character. Case is ignored when matching font names. | |
2736 | |
2737 If the optional arguments @var{reference-face} and @var{frame} are | |
2738 specified, the returned list includes only fonts that are the same | |
2739 size as @var{reference-face} (a face name) currently is on the frame | |
2740 @var{frame}. | |
2741 | |
2742 The optional argument @var{maximum} sets a limit on how many fonts to | |
2743 return. If it is non-@code{nil}, then the return value is truncated | |
2744 after the first @var{maximum} matching fonts. Specifying a small | |
2745 value for @var{maximum} can make this function much faster, in cases | |
2746 where many fonts match the pattern. | |
2747 @end defun | |
2748 | |
2749 @defun x-family-fonts &optional family frame | |
2750 This function returns a list describing the available fonts for family | |
2751 @var{family} on @var{frame}. If @var{family} is omitted or @code{nil}, | |
2752 this list applies to all families, and therefore, it contains all | |
2753 available fonts. Otherwise, @var{family} must be a string; it may | |
2754 contain the wildcards @samp{?} and @samp{*}. | |
2755 | |
2756 The list describes the display that @var{frame} is on; if @var{frame} is | |
2757 omitted or @code{nil}, it applies to the selected frame's display | |
2758 (@pxref{Input Focus}). | |
2759 | |
2760 Each element in the list is a vector of the following form: | |
2761 | |
2762 @example | |
2763 [@var{family} @var{width} @var{point-size} @var{weight} @var{slant} | |
2764 @var{fixed-p} @var{full} @var{registry-and-encoding}] | |
2765 @end example | |
2766 | |
2767 The first five elements correspond to face attributes; if you | |
2768 specify these attributes for a face, it will use this font. | |
2769 | |
2770 The last three elements give additional information about the font. | |
2771 @var{fixed-p} is non-@code{nil} if the font is fixed-pitch. | |
2772 @var{full} is the full name of the font, and | |
2773 @var{registry-and-encoding} is a string giving the registry and | |
2774 encoding of the font. | |
2775 @end defun | |
2776 | |
2777 @defvar font-list-limit | |
2778 This variable specifies maximum number of fonts to consider in font | |
2779 matching. The function @code{x-family-fonts} will not return more than | |
2780 that many fonts, and font selection will consider only that many fonts | |
2781 when searching a matching font for face attributes. The default is | |
2782 currently 100. | |
2783 @end defvar | |
2784 | |
2785 @node Fontsets | |
2786 @subsection Fontsets | |
2787 | |
2788 A @dfn{fontset} is a list of fonts, each assigned to a range of | |
2789 character codes. An individual font cannot display the whole range of | |
2790 characters that Emacs supports, but a fontset can. Fontsets have names, | |
2791 just as fonts do, and you can use a fontset name in place of a font name | |
2792 when you specify the ``font'' for a frame or a face. Here is | |
2793 information about defining a fontset under Lisp program control. | |
2794 | |
2795 @defun create-fontset-from-fontset-spec fontset-spec &optional style-variant-p noerror | |
2796 This function defines a new fontset according to the specification | |
2797 string @var{fontset-spec}. The string should have this format: | |
2798 | |
2799 @smallexample | |
2800 @var{fontpattern}, @r{[}@var{charset}:@var{font}@r{]@dots{}} | |
2801 @end smallexample | |
2802 | |
2803 @noindent | |
2804 Whitespace characters before and after the commas are ignored. | |
2805 | |
2806 The first part of the string, @var{fontpattern}, should have the form of | |
2807 a standard X font name, except that the last two fields should be | |
2808 @samp{fontset-@var{alias}}. | |
2809 | |
2810 The new fontset has two names, one long and one short. The long name is | |
2811 @var{fontpattern} in its entirety. The short name is | |
2812 @samp{fontset-@var{alias}}. You can refer to the fontset by either | |
2813 name. If a fontset with the same name already exists, an error is | |
2814 signaled, unless @var{noerror} is non-@code{nil}, in which case this | |
2815 function does nothing. | |
2816 | |
2817 If optional argument @var{style-variant-p} is non-@code{nil}, that says | |
2818 to create bold, italic and bold-italic variants of the fontset as well. | |
2819 These variant fontsets do not have a short name, only a long one, which | |
2820 is made by altering @var{fontpattern} to indicate the bold or italic | |
2821 status. | |
2822 | |
2823 The specification string also says which fonts to use in the fontset. | |
2824 See below for the details. | |
2825 @end defun | |
2826 | |
2827 The construct @samp{@var{charset}:@var{font}} specifies which font to | |
2828 use (in this fontset) for one particular character set. Here, | |
2829 @var{charset} is the name of a character set, and @var{font} is the font | |
2830 to use for that character set. You can use this construct any number of | |
2831 times in the specification string. | |
2832 | |
2833 For the remaining character sets, those that you don't specify | |
2834 explicitly, Emacs chooses a font based on @var{fontpattern}: it replaces | |
2835 @samp{fontset-@var{alias}} with a value that names one character set. | |
2836 For the @acronym{ASCII} character set, @samp{fontset-@var{alias}} is replaced | |
2837 with @samp{ISO8859-1}. | |
2838 | |
2839 In addition, when several consecutive fields are wildcards, Emacs | |
2840 collapses them into a single wildcard. This is to prevent use of | |
2841 auto-scaled fonts. Fonts made by scaling larger fonts are not usable | |
2842 for editing, and scaling a smaller font is not useful because it is | |
2843 better to use the smaller font in its own size, which Emacs does. | |
2844 | |
2845 Thus if @var{fontpattern} is this, | |
2846 | |
2847 @example | |
2848 -*-fixed-medium-r-normal-*-24-*-*-*-*-*-fontset-24 | |
2849 @end example | |
2850 | |
2851 @noindent | |
2852 the font specification for @acronym{ASCII} characters would be this: | |
2853 | |
2854 @example | |
2855 -*-fixed-medium-r-normal-*-24-*-ISO8859-1 | |
2856 @end example | |
2857 | |
2858 @noindent | |
2859 and the font specification for Chinese GB2312 characters would be this: | |
2860 | |
2861 @example | |
2862 -*-fixed-medium-r-normal-*-24-*-gb2312*-* | |
2863 @end example | |
2864 | |
2865 You may not have any Chinese font matching the above font | |
2866 specification. Most X distributions include only Chinese fonts that | |
2867 have @samp{song ti} or @samp{fangsong ti} in the @var{family} field. In | |
2868 such a case, @samp{Fontset-@var{n}} can be specified as below: | |
2869 | |
2870 @smallexample | |
2871 Emacs.Fontset-0: -*-fixed-medium-r-normal-*-24-*-*-*-*-*-fontset-24,\ | |
2872 chinese-gb2312:-*-*-medium-r-normal-*-24-*-gb2312*-* | |
2873 @end smallexample | |
2874 | |
2875 @noindent | |
2876 Then, the font specifications for all but Chinese GB2312 characters have | |
2877 @samp{fixed} in the @var{family} field, and the font specification for | |
2878 Chinese GB2312 characters has a wild card @samp{*} in the @var{family} | |
2879 field. | |
2880 | |
2881 @defun set-fontset-font name character fontname &optional frame | |
2882 This function modifies the existing fontset @var{name} to | |
2883 use the font name @var{fontname} for the character @var{character}. | |
2884 | |
2885 If @var{name} is @code{nil}, this function modifies the default | |
2886 fontset, whose short name is @samp{fontset-default}. | |
2887 | |
2888 @var{character} may be a cons; @code{(@var{from} . @var{to})}, where | |
2889 @var{from} and @var{to} are character codepoints. In that case, use | |
2890 @var{fontname} for all characters in the range @var{from} and @var{to} | |
2891 (inclusive). | |
2892 | |
2893 @var{character} may be a charset. In that case, use | |
2894 @var{fontname} for all character in the charsets. | |
2895 | |
2896 @var{fontname} may be a cons; @code{(@var{family} . @var{registry})}, | |
2897 where @var{family} is a family name of a font (possibly including a | |
2898 foundry name at the head), @var{registry} is a registry name of a font | |
2899 (possibly including an encoding name at the tail). | |
2900 | |
2901 For instance, this changes the default fontset to use a font of which | |
2902 registry name is @samp{JISX0208.1983} for all characters belonging to | |
2903 the charset @code{japanese-jisx0208}. | |
2904 | |
2905 @smallexample | |
2906 (set-fontset-font nil 'japanese-jisx0208 '(nil . "JISX0208.1983")) | |
2907 @end smallexample | |
2908 @end defun | |
2909 | |
2910 @defun char-displayable-p char | |
2911 This function returns @code{t} if Emacs ought to be able to display | |
2912 @var{char}. More precisely, if the selected frame's fontset has a | |
2913 font to display the character set that @var{char} belongs to. | |
2914 | |
2915 Fontsets can specify a font on a per-character basis; when the fontset | |
2916 does that, this function's value may not be accurate. | |
2917 @end defun | |
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 | |
2923 you need to do so, this section explains how. | |
2633 | 2924 |
2634 In Emacs Lisp, fonts are represented using three different Lisp | 2925 In Emacs Lisp, fonts are represented using three different Lisp |
2635 object types: @dfn{font objects}, @dfn{font specs}, and @dfn{font | 2926 qobject types: @dfn{font objects}, @dfn{font specs}, and @dfn{font |
2636 entities}. | 2927 entities}. |
2637 | 2928 |
2638 @defun fontp object &optional type | 2929 @defun fontp object &optional type |
2639 Return @code{t} if @var{object} is a font object, font spec, or font | 2930 Return @code{t} if @var{object} is a font object, font spec, or font |
2640 entity. Otherwise, return @code{nil}. | 2931 entity. Otherwise, return @code{nil}. |
2645 @code{font-entity}. | 2936 @code{font-entity}. |
2646 @end defun | 2937 @end defun |
2647 | 2938 |
2648 A font object is a Lisp object that represents a font that Emacs has | 2939 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 | 2940 @dfn{opened}. Font objects cannot be modified in Lisp, but they can |
2650 be inspected. For instance, if you call @code{set-face-attribute} and | 2941 be inspected. If you call @code{set-face-attribute} and pass a font |
2651 pass a font spec, font entity, or font name string as the value of the | 2942 spec, font entity, or font name string as the value of the |
2652 @code{:font} attribute, Emacs opens the best ``matching'' font that is | 2943 @code{:font} attribute, Emacs opens the best ``matching'' font that is |
2653 available for display. It then stores the corresponding font object | 2944 available for display. It then stores the corresponding font object |
2654 as the actual value of the @code{:font} attribute for that face. | 2945 as the actual value of the @code{:font} attribute for that face. |
2655 | 2946 |
2656 @defun font-at position &optional window string | 2947 @defun font-at position &optional window string |
2671 which should come in @code{property}-@code{value} pairs. The possible | 2962 which should come in @code{property}-@code{value} pairs. The possible |
2672 specifications are as follows: | 2963 specifications are as follows: |
2673 | 2964 |
2674 @table @code | 2965 @table @code |
2675 @item :name | 2966 @item :name |
2676 The font name string, in either XLFD, Fontconfig, or GTK format. | 2967 The font name (a string), in either XLFD, Fontconfig, or GTK format. |
2677 @xref{Font X,, Font Specification Options, emacs, The GNU Emacs | 2968 @xref{Font X,, Font Specification Options, emacs, The GNU Emacs |
2678 Manual}. | 2969 Manual}. |
2679 | 2970 |
2680 @item :family | 2971 @item :family |
2681 @itemx :foundry | 2972 @itemx :foundry |
2705 @defun font-put font-spec property value | 2996 @defun font-put font-spec property value |
2706 Set the font property @var{property} in the font-spec @var{font-spec} | 2997 Set the font property @var{property} in the font-spec @var{font-spec} |
2707 to @var{value}. | 2998 to @var{value}. |
2708 @end defun | 2999 @end defun |
2709 | 3000 |
2710 A font entity is a reference to a font that need not have been | 3001 A font entity is a reference to a font that need not be open. Its |
2711 opened. Its properties are intermediate between a font object and a | 3002 properties are intermediate between a font object and a font spec: |
2712 font spec: like a font object, and unlike a font spec, it refers to a | 3003 like a font object, and unlike a font spec, it refers to a single, |
2713 single, specific font. Unlike a font object, it can be modified in | 3004 specific font. Unlike a font object, creating a font entity does not |
2714 Lisp, and creating a font entity does not load the contents of that | 3005 load the contents of that font into computer memory. |
2715 font into computer memory. | |
2716 | 3006 |
2717 @defun find-font font-spec &optional frame | 3007 @defun find-font font-spec &optional frame |
2718 Return a font entity that best matches the font spec @var{font-spec} | 3008 This function returns a font entity that best matches the font spec |
2719 on frame @var{frame}. If @var{frame} is @code{nil}, it defaults to | 3009 @var{font-spec} on frame @var{frame}. If @var{frame} is @code{nil}, |
2720 the selected frame. | 3010 it defaults to the selected frame. |
2721 @end defun | 3011 @end defun |
2722 | 3012 |
2723 @defun list-fonts font-spec &optional frame num prefer | 3013 @defun list-fonts font-spec &optional frame num prefer |
2724 This function returns a list of all font entities that match the font | 3014 This function returns a list of all font entities that match the font |
2725 spec @var{font-spec}. | 3015 spec @var{font-spec}. |
2726 | 3016 |
2727 The optional argument @var{frame}, if non-@code{nil}, specifies the | 3017 The optional argument @var{frame}, if non-@code{nil}, specifies the |
2728 frame on which the fonts are to be displayed. The optional argument | 3018 frame 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 | 3019 @var{num}, if non-@code{nil}, should be an integer that specifies the |
2730 function returns a list of at most @var{num} font entities. The | 3020 maximum length of the returned list. The optional argument |
2731 optional argument @var{prefer}, if non-@code{nil}, should be another | 3021 @var{prefer}, if non-@code{nil}, should be another font spec, which is |
2732 font spec, which is used to control the order of the returned list; | 3022 used to control the order of the returned list; the returned font |
2733 the returned font entities are sorted in order of decreasing | 3023 entities are sorted in order of decreasing ``closeness'' to that font |
2734 ``closeness'' to that font spec. | 3024 spec. |
2735 @end defun | 3025 @end defun |
2736 | 3026 |
2737 The following functions can be used to obtain information about font | 3027 The following functions can be used to obtain information about a |
2738 objects, font entities, and font specs alike: | 3028 font. For these functions, the @var{font} argument can be a font |
3029 object, a font entity, or a font spec. | |
2739 | 3030 |
2740 @defun font-get font property | 3031 @defun font-get font property |
2741 This function returns the value of the font property @var{property} | 3032 This function returns the value of the font property @var{property} |
2742 for @var{font}, which should be either a font object, font spec, or | 3033 for @var{font}. |
2743 font entity. | |
2744 | 3034 |
2745 If @var{font} is a font spec and the font spec does not specify | 3035 If @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 | 3036 @var{property}, the return value is @code{nil}. If @var{font} is a |
2747 font object or font entity, the value for the @var{:script} property | 3037 font object or font entity, the value for the @var{:script} property |
2748 may be a list of scripts supported by the font. | 3038 may be a list of scripts supported by the font. |
2749 @end defun | 3039 @end defun |
2750 | 3040 |
2751 @defun font-face-attributes font &optional frame | 3041 @defun font-face-attributes font &optional frame |
2752 This function returns a list of face attributes corresponding to | 3042 This function returns a list of face attributes corresponding to |
2753 @var{font} , which should be either a font name, a font object, a font | 3043 @var{font}. The optional argument @var{frame} specifies the frame on |
2754 spec, or a font entity. The optional argument @var{frame} specifies | 3044 which the font is to be displayed. If it is @code{nil}, the selected |
2755 the frame on which the font is to be displayed. If it is @code{nil}, | 3045 frame is used. The return value has the form |
2756 the selected frame is used. The return value has the form | |
2757 | 3046 |
2758 @smallexample | 3047 @smallexample |
2759 (:family @var{family} :height @var{height} :weight @var{weight} | 3048 (:family @var{family} :height @var{height} :weight @var{weight} |
2760 :slant @var{slant} :width @var{width}) | 3049 :slant @var{slant} :width @var{width}) |
2761 @end smallexample | 3050 @end smallexample |
2767 @end defun | 3056 @end defun |
2768 | 3057 |
2769 @defun font-xlfd-name font &optional fold-wildcards | 3058 @defun font-xlfd-name font &optional fold-wildcards |
2770 This function returns the XLFD (X Logical Font Descriptor), a string, | 3059 This function returns the XLFD (X Logical Font Descriptor), a string, |
2771 matching @var{font}. @xref{Font X,, Font Specification Options, | 3060 matching @var{font}. @xref{Font X,, Font Specification Options, |
2772 emacs, The GNU Emacs Manual}, for information about XLFDs. @var{font} | 3061 emacs, The GNU Emacs Manual}, for information about XLFDs. If the |
2773 should be a font spec, font entity, or font object. If the name is | 3062 name is too long for an XLFD (which can contain at most 255 |
2774 too long for an XLFD (which can contain at most 255 characters), the | 3063 characters), the function returns @code{nil}. |
2775 function returns @code{nil}. | |
2776 | 3064 |
2777 If the optional argument @var{fold-wildcards} is non-@code{nil}, | 3065 If the optional argument @var{fold-wildcards} is non-@code{nil}, |
2778 consecutive wildcards in the XLFD are folded into one. | 3066 consecutive wildcards in the XLFD are folded into one. |
2779 @end defun | |
2780 | |
2781 @node Font Selection | |
2782 @subsection Font Selection | |
2783 | |
2784 Emacs tries to find an available font to display each character | |
2785 based on the face attributes and the character's registry and | |
2786 encoding. If there is a font that matches exactly, it is used, of | |
2787 course. The hard case is when no available font exactly fits the | |
2788 specification. Then Emacs looks for one that is ``close''---one | |
2789 attribute at a time. You can specify the order to consider the | |
2790 attributes. In the case where a specified font family is not | |
2791 available, you can specify a set of mappings for alternatives to try. | |
2792 | |
2793 @defvar face-font-selection-order | |
2794 This variable specifies the order of importance of the face attributes | |
2795 @code{:width}, @code{:height}, @code{:weight}, and @code{:slant}. The | |
2796 value should be a list containing those four symbols, in order of | |
2797 decreasing importance. | |
2798 | |
2799 Font selection first finds the best available matches for the first | |
2800 attribute listed; then, among the fonts which are best in that way, it | |
2801 searches for the best matches in the second attribute, and so on. | |
2802 | |
2803 The attributes @code{:weight} and @code{:width} have symbolic values in | |
2804 a range centered around @code{normal}. Matches that are more extreme | |
2805 (farther from @code{normal}) are somewhat preferred to matches that are | |
2806 less extreme (closer to @code{normal}); this is designed to ensure that | |
2807 non-normal faces contrast with normal ones, whenever possible. | |
2808 | |
2809 The default is @code{(:width :height :weight :slant)}, which means first | |
2810 find the fonts closest to the specified @code{:width}, then---among the | |
2811 fonts with that width---find a best match for the specified font height, | |
2812 and so on. | |
2813 | |
2814 One example of a case where this variable makes a difference is when the | |
2815 default 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 | |
2817 default one. But if you put @code{:slant} before @code{:height}, the | |
2818 @code{italic} face will use an italic font, even if its height is not | |
2819 quite right. | |
2820 @end defvar | |
2821 | |
2822 @defvar face-font-family-alternatives | |
2823 This variable lets you specify alternative font families to try, if a | |
2824 given family is specified and doesn't exist. Each element should have | |
2825 this form: | |
2826 | |
2827 @example | |
2828 (@var{family} @var{alternate-families}@dots{}) | |
2829 @end example | |
2830 | |
2831 If @var{family} is specified but not available, Emacs will try the other | |
2832 families given in @var{alternate-families}, one by one, until it finds a | |
2833 family that does exist. | |
2834 @end defvar | |
2835 | |
2836 @defvar face-font-registry-alternatives | |
2837 This variable lets you specify alternative font registries to try, if a | |
2838 given registry is specified and doesn't exist. Each element should have | |
2839 this form: | |
2840 | |
2841 @example | |
2842 (@var{registry} @var{alternate-registries}@dots{}) | |
2843 @end example | |
2844 | |
2845 If @var{registry} is specified but not available, Emacs will try the | |
2846 other registries given in @var{alternate-registries}, one by one, | |
2847 until it finds a registry that does exist. | |
2848 @end defvar | |
2849 | |
2850 Emacs can make use of scalable fonts, but by default it does not use | |
2851 them, since the use of too many or too big scalable fonts can crash | |
2852 XFree86 servers. | |
2853 | |
2854 @defvar scalable-fonts-allowed | |
2855 This variable controls which scalable fonts to use. A value of | |
2856 @code{nil}, the default, means do not use scalable fonts. @code{t} | |
2857 means to use any scalable font that seems appropriate for the text. | |
2858 | |
2859 Otherwise, the value must be a list of regular expressions. Then a | |
2860 scalable font is enabled for use if its name matches any regular | |
2861 expression in the list. For example, | |
2862 | |
2863 @example | |
2864 (setq scalable-fonts-allowed '("muleindian-2$")) | |
2865 @end example | |
2866 | |
2867 @noindent | |
2868 allows the use of scalable fonts with registry @code{muleindian-2}. | |
2869 @end defvar | |
2870 | |
2871 @defvar face-font-rescale-alist | |
2872 This variable specifies scaling for certain faces. Its value should | |
2873 be a list of elements of the form | |
2874 | |
2875 @example | |
2876 (@var{fontname-regexp} . @var{scale-factor}) | |
2877 @end example | |
2878 | |
2879 If @var{fontname-regexp} matches the font name that is about to be | |
2880 used, this says to choose a larger similar font according to the | |
2881 factor @var{scale-factor}. You would use this feature to normalize | |
2882 the font size if certain fonts are bigger or smaller than their | |
2883 nominal heights and widths would suggest. | |
2884 @end defvar | |
2885 | |
2886 @node Font Lookup | |
2887 @subsection Looking Up Fonts | |
2888 | |
2889 @defun x-list-fonts pattern &optional face frame maximum | |
2890 This function returns a list of available font names that match | |
2891 @var{pattern}. If the optional arguments @var{face} and @var{frame} are | |
2892 specified, then the list is limited to fonts that are the same size as | |
2893 @var{face} currently is on @var{frame}. | |
2894 | |
2895 The argument @var{pattern} should be a string, perhaps with wildcard | |
2896 characters: the @samp{*} character matches any substring, and the | |
2897 @samp{?} character matches any single character. Pattern matching | |
2898 of font names ignores case. | |
2899 | |
2900 If you specify @var{face} and @var{frame}, @var{face} should be a face name | |
2901 (a symbol) and @var{frame} should be a frame. | |
2902 | |
2903 The optional argument @var{maximum} sets a limit on how many fonts to | |
2904 return. If this is non-@code{nil}, then the return value is truncated | |
2905 after the first @var{maximum} matching fonts. Specifying a small value | |
2906 for @var{maximum} can make this function much faster, in cases where | |
2907 many fonts match the pattern. | |
2908 @end defun | |
2909 | |
2910 @defun x-family-fonts &optional family frame | |
2911 This function returns a list describing the available fonts for family | |
2912 @var{family} on @var{frame}. If @var{family} is omitted or @code{nil}, | |
2913 this list applies to all families, and therefore, it contains all | |
2914 available fonts. Otherwise, @var{family} must be a string; it may | |
2915 contain the wildcards @samp{?} and @samp{*}. | |
2916 | |
2917 The list describes the display that @var{frame} is on; if @var{frame} is | |
2918 omitted or @code{nil}, it applies to the selected frame's display | |
2919 (@pxref{Input Focus}). | |
2920 | |
2921 The list contains a vector of the following form for each font: | |
2922 | |
2923 @example | |
2924 [@var{family} @var{width} @var{point-size} @var{weight} @var{slant} | |
2925 @var{fixed-p} @var{full} @var{registry-and-encoding}] | |
2926 @end example | |
2927 | |
2928 The first five elements correspond to face attributes; if you | |
2929 specify these attributes for a face, it will use this font. | |
2930 | |
2931 The last three elements give additional information about the font. | |
2932 @var{fixed-p} is non-@code{nil} if the font is fixed-pitch. | |
2933 @var{full} is the full name of the font, and | |
2934 @var{registry-and-encoding} is a string giving the registry and | |
2935 encoding of the font. | |
2936 | |
2937 The result list is sorted according to the current face font sort order. | |
2938 @end defun | |
2939 | |
2940 @defun x-font-family-list &optional frame | |
2941 This function returns a list of the font families available for | |
2942 @var{frame}'s display. If @var{frame} is omitted or @code{nil}, it | |
2943 describes the selected frame's display (@pxref{Input Focus}). | |
2944 | |
2945 The value is a list of elements of this form: | |
2946 | |
2947 @example | |
2948 (@var{family} . @var{fixed-p}) | |
2949 @end example | |
2950 | |
2951 @noindent | |
2952 Here @var{family} is a font family, and @var{fixed-p} is | |
2953 non-@code{nil} if fonts of that family are fixed-pitch. | |
2954 @end defun | |
2955 | |
2956 @defvar font-list-limit | |
2957 This variable specifies maximum number of fonts to consider in font | |
2958 matching. The function @code{x-family-fonts} will not return more than | |
2959 that many fonts, and font selection will consider only that many fonts | |
2960 when searching a matching font for face attributes. The default is | |
2961 currently 100. | |
2962 @end defvar | |
2963 | |
2964 @node Fontsets | |
2965 @subsection Fontsets | |
2966 | |
2967 A @dfn{fontset} is a list of fonts, each assigned to a range of | |
2968 character codes. An individual font cannot display the whole range of | |
2969 characters that Emacs supports, but a fontset can. Fontsets have names, | |
2970 just as fonts do, and you can use a fontset name in place of a font name | |
2971 when you specify the ``font'' for a frame or a face. Here is | |
2972 information about defining a fontset under Lisp program control. | |
2973 | |
2974 @defun create-fontset-from-fontset-spec fontset-spec &optional style-variant-p noerror | |
2975 This function defines a new fontset according to the specification | |
2976 string @var{fontset-spec}. The string should have this format: | |
2977 | |
2978 @smallexample | |
2979 @var{fontpattern}, @r{[}@var{charset}:@var{font}@r{]@dots{}} | |
2980 @end smallexample | |
2981 | |
2982 @noindent | |
2983 Whitespace characters before and after the commas are ignored. | |
2984 | |
2985 The first part of the string, @var{fontpattern}, should have the form of | |
2986 a standard X font name, except that the last two fields should be | |
2987 @samp{fontset-@var{alias}}. | |
2988 | |
2989 The new fontset has two names, one long and one short. The long name is | |
2990 @var{fontpattern} in its entirety. The short name is | |
2991 @samp{fontset-@var{alias}}. You can refer to the fontset by either | |
2992 name. If a fontset with the same name already exists, an error is | |
2993 signaled, unless @var{noerror} is non-@code{nil}, in which case this | |
2994 function does nothing. | |
2995 | |
2996 If optional argument @var{style-variant-p} is non-@code{nil}, that says | |
2997 to create bold, italic and bold-italic variants of the fontset as well. | |
2998 These variant fontsets do not have a short name, only a long one, which | |
2999 is made by altering @var{fontpattern} to indicate the bold or italic | |
3000 status. | |
3001 | |
3002 The specification string also says which fonts to use in the fontset. | |
3003 See below for the details. | |
3004 @end defun | |
3005 | |
3006 The construct @samp{@var{charset}:@var{font}} specifies which font to | |
3007 use (in this fontset) for one particular character set. Here, | |
3008 @var{charset} is the name of a character set, and @var{font} is the font | |
3009 to use for that character set. You can use this construct any number of | |
3010 times in the specification string. | |
3011 | |
3012 For the remaining character sets, those that you don't specify | |
3013 explicitly, Emacs chooses a font based on @var{fontpattern}: it replaces | |
3014 @samp{fontset-@var{alias}} with a value that names one character set. | |
3015 For the @acronym{ASCII} character set, @samp{fontset-@var{alias}} is replaced | |
3016 with @samp{ISO8859-1}. | |
3017 | |
3018 In addition, when several consecutive fields are wildcards, Emacs | |
3019 collapses them into a single wildcard. This is to prevent use of | |
3020 auto-scaled fonts. Fonts made by scaling larger fonts are not usable | |
3021 for editing, and scaling a smaller font is not useful because it is | |
3022 better to use the smaller font in its own size, which Emacs does. | |
3023 | |
3024 Thus if @var{fontpattern} is this, | |
3025 | |
3026 @example | |
3027 -*-fixed-medium-r-normal-*-24-*-*-*-*-*-fontset-24 | |
3028 @end example | |
3029 | |
3030 @noindent | |
3031 the font specification for @acronym{ASCII} characters would be this: | |
3032 | |
3033 @example | |
3034 -*-fixed-medium-r-normal-*-24-*-ISO8859-1 | |
3035 @end example | |
3036 | |
3037 @noindent | |
3038 and the font specification for Chinese GB2312 characters would be this: | |
3039 | |
3040 @example | |
3041 -*-fixed-medium-r-normal-*-24-*-gb2312*-* | |
3042 @end example | |
3043 | |
3044 You may not have any Chinese font matching the above font | |
3045 specification. Most X distributions include only Chinese fonts that | |
3046 have @samp{song ti} or @samp{fangsong ti} in the @var{family} field. In | |
3047 such a case, @samp{Fontset-@var{n}} can be specified as below: | |
3048 | |
3049 @smallexample | |
3050 Emacs.Fontset-0: -*-fixed-medium-r-normal-*-24-*-*-*-*-*-fontset-24,\ | |
3051 chinese-gb2312:-*-*-medium-r-normal-*-24-*-gb2312*-* | |
3052 @end smallexample | |
3053 | |
3054 @noindent | |
3055 Then, the font specifications for all but Chinese GB2312 characters have | |
3056 @samp{fixed} in the @var{family} field, and the font specification for | |
3057 Chinese GB2312 characters has a wild card @samp{*} in the @var{family} | |
3058 field. | |
3059 | |
3060 @defun set-fontset-font name character fontname &optional frame | |
3061 This function modifies the existing fontset @var{name} to | |
3062 use the font name @var{fontname} for the character @var{character}. | |
3063 | |
3064 If @var{name} is @code{nil}, this function modifies the default | |
3065 fontset, whose short name is @samp{fontset-default}. | |
3066 | |
3067 @var{character} may be a cons; @code{(@var{from} . @var{to})}, where | |
3068 @var{from} and @var{to} are character codepoints. In that case, use | |
3069 @var{fontname} for all characters in the range @var{from} and @var{to} | |
3070 (inclusive). | |
3071 | |
3072 @var{character} may be a charset. In that case, use | |
3073 @var{fontname} for all character in the charsets. | |
3074 | |
3075 @var{fontname} may be a cons; @code{(@var{family} . @var{registry})}, | |
3076 where @var{family} is a family name of a font (possibly including a | |
3077 foundry name at the head), @var{registry} is a registry name of a font | |
3078 (possibly including an encoding name at the tail). | |
3079 | |
3080 For instance, this changes the default fontset to use a font of which | |
3081 registry name is @samp{JISX0208.1983} for all characters belonging to | |
3082 the charset @code{japanese-jisx0208}. | |
3083 | |
3084 @smallexample | |
3085 (set-fontset-font nil 'japanese-jisx0208 '(nil . "JISX0208.1983")) | |
3086 @end smallexample | |
3087 @end defun | |
3088 | |
3089 @defun char-displayable-p char | |
3090 This function returns @code{t} if Emacs ought to be able to display | |
3091 @var{char}. More precisely, if the selected frame's fontset has a | |
3092 font to display the character set that @var{char} belongs to. | |
3093 | |
3094 Fontsets can specify a font on a per-character basis; when the fontset | |
3095 does that, this function's value may not be accurate. | |
3096 @end defun | 3067 @end defun |
3097 | 3068 |
3098 @node Fringes | 3069 @node Fringes |
3099 @section Fringes | 3070 @section Fringes |
3100 @cindex fringes | 3071 @cindex fringes |