2 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
3 Free Software Foundation, Inc.
4 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
6 National Institute of Advanced Industrial Science and Technology (AIST)
7 Registration Number H14PRO021
9 This file is part of GNU Emacs.
11 GNU Emacs is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3, or (at your option)
16 GNU Emacs is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with GNU Emacs; see the file COPYING. If not, write to
23 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 Boston, MA 02110-1301, USA. */
26 /* #define FONTSET_DEBUG */
40 #include "dispextern.h"
52 #include "termhooks.h"
56 #define xassert(X) do {if (!(X)) abort ();} while (0)
64 A fontset is a collection of font related information to give
65 similar appearance (style, size, etc) of characters. There are two
66 kinds of fontsets; base and realized. A base fontset is created by
67 new-fontset from Emacs Lisp explicitly. A realized fontset is
68 created implicitly when a face is realized for ASCII characters. A
69 face is also realized for multibyte characters based on an ASCII
70 face. All of the multibyte faces based on the same ASCII face
71 share the same realized fontset.
73 A fontset object is implemented by a char-table.
75 An element of a base fontset is:
77 (INDEX . (FOUNDRY . REGISTRY ))
78 FONTNAME is a font name pattern for the corresponding character.
79 FOUNDRY and REGISTRY are respectively foundry and registry fields of
80 a font name for the corresponding character. INDEX specifies for
81 which character (or generic character) the element is defined. It
82 may be different from an index to access this element. For
83 instance, if a fontset defines some font for all characters of
84 charset `japanese-jisx0208', INDEX is the generic character of this
85 charset. REGISTRY is the
87 An element of a realized fontset is FACE-ID which is a face to use
88 for displaying the corresponding character.
90 All single byte characters (ASCII and 8bit-unibyte) share the same
91 element in a fontset. The element is stored in the first element
94 To access or set each element, use macros FONTSET_REF and
95 FONTSET_SET respectively for efficiency.
97 A fontset has 3 extra slots.
99 The 1st slot is an ID number of the fontset.
101 The 2nd slot is a name of the fontset. This is nil for a realized
104 The 3rd slot is a frame that the fontset belongs to. This is nil
107 A parent of a base fontset is nil. A parent of a realized fontset
110 All fontsets are recorded in Vfontset_table.
115 There's a special fontset named `default fontset' which defines a
116 default fontname pattern. When a base fontset doesn't specify a
117 font for a specific character, the corresponding value in the
118 default fontset is used. The format is the same as a base fontset.
120 The parent of a realized fontset created for such a face that has
121 no fontset is the default fontset.
124 These structures are hidden from the other codes than this file.
125 The other codes handle fontsets only by their ID numbers. They
126 usually use variable name `fontset' for IDs. But, in this file, we
127 always use variable name `id' for IDs, and name `fontset' for the
128 actual fontset objects.
132 /********** VARIABLES and FUNCTION PROTOTYPES **********/
134 extern Lisp_Object Qfont
;
135 Lisp_Object Qfontset
;
137 /* Vector containing all fontsets. */
138 static Lisp_Object Vfontset_table
;
140 /* Next possibly free fontset ID. Usually this keeps the minimum
141 fontset ID not yet used. */
142 static int next_fontset_id
;
144 /* The default fontset. This gives default FAMILY and REGISTRY of
145 font for each characters. */
146 static Lisp_Object Vdefault_fontset
;
148 /* Alist of font specifications. It override the font specification
149 in the default fontset. */
150 static Lisp_Object Voverriding_fontspec_alist
;
152 Lisp_Object Vfont_encoding_alist
;
153 Lisp_Object Vuse_default_ascent
;
154 Lisp_Object Vignore_relative_composition
;
155 Lisp_Object Valternate_fontname_alist
;
156 Lisp_Object Vfontset_alias_alist
;
157 Lisp_Object Vvertical_centering_font_regexp
;
159 /* The following six are declarations of callback functions depending
160 on window system. See the comments in src/fontset.h for more
163 /* Return a pointer to struct font_info of font FONT_IDX of frame F. */
164 struct font_info
*(*get_font_info_func
) P_ ((FRAME_PTR f
, int font_idx
));
166 /* Return a list of font names which matches PATTERN. See the documentation
167 of `x-list-fonts' for more details. */
168 Lisp_Object (*list_fonts_func
) P_ ((struct frame
*f
,
173 /* Load a font named NAME for frame F and return a pointer to the
174 information of the loaded font. If loading is failed, return 0. */
175 struct font_info
*(*load_font_func
) P_ ((FRAME_PTR f
, char *name
, int));
177 /* Return a pointer to struct font_info of a font named NAME for frame F. */
178 struct font_info
*(*query_font_func
) P_ ((FRAME_PTR f
, char *name
));
180 /* Additional function for setting fontset or changing fontset
181 contents of frame F. */
182 void (*set_frame_fontset_func
) P_ ((FRAME_PTR f
, Lisp_Object arg
,
183 Lisp_Object oldval
));
185 /* To find a CCL program, fs_load_font calls this function.
186 The argument is a pointer to the struct font_info.
187 This function set the member `encoder' of the structure. */
188 void (*find_ccl_program_func
) P_ ((struct font_info
*));
190 /* Check if any window system is used now. */
191 void (*check_window_system_func
) P_ ((void));
194 /* Prototype declarations for static functions. */
195 static Lisp_Object fontset_ref
P_ ((Lisp_Object
, int));
196 static Lisp_Object lookup_overriding_fontspec
P_ ((Lisp_Object
, int));
197 static void fontset_set
P_ ((Lisp_Object
, int, Lisp_Object
));
198 static Lisp_Object make_fontset
P_ ((Lisp_Object
, Lisp_Object
, Lisp_Object
));
199 static int fontset_id_valid_p
P_ ((int));
200 static Lisp_Object fontset_pattern_regexp
P_ ((Lisp_Object
));
201 static Lisp_Object font_family_registry
P_ ((Lisp_Object
, int));
202 static Lisp_Object regularize_fontname
P_ ((Lisp_Object
));
205 /********** MACROS AND FUNCTIONS TO HANDLE FONTSET **********/
207 /* Return the fontset with ID. No check of ID's validness. */
208 #define FONTSET_FROM_ID(id) AREF (Vfontset_table, id)
210 /* Macros to access special values of FONTSET. */
211 #define FONTSET_ID(fontset) XCHAR_TABLE (fontset)->extras[0]
212 #define FONTSET_NAME(fontset) XCHAR_TABLE (fontset)->extras[1]
213 #define FONTSET_FRAME(fontset) XCHAR_TABLE (fontset)->extras[2]
214 #define FONTSET_ASCII(fontset) XCHAR_TABLE (fontset)->contents[0]
215 #define FONTSET_BASE(fontset) XCHAR_TABLE (fontset)->parent
217 #define BASE_FONTSET_P(fontset) NILP (FONTSET_BASE(fontset))
220 /* Return the element of FONTSET (char-table) at index C (character). */
222 #define FONTSET_REF(fontset, c) fontset_ref (fontset, c)
225 fontset_ref (fontset
, c
)
230 Lisp_Object elt
, defalt
;
232 if (SINGLE_BYTE_CHAR_P (c
))
233 return FONTSET_ASCII (fontset
);
235 SPLIT_CHAR (c
, charset
, c1
, c2
);
236 elt
= XCHAR_TABLE (fontset
)->contents
[charset
+ 128];
237 if (!SUB_CHAR_TABLE_P (elt
))
239 defalt
= XCHAR_TABLE (elt
)->defalt
;
241 || (elt
= XCHAR_TABLE (elt
)->contents
[c1
],
244 if (!SUB_CHAR_TABLE_P (elt
))
246 defalt
= XCHAR_TABLE (elt
)->defalt
;
248 || (elt
= XCHAR_TABLE (elt
)->contents
[c2
],
256 lookup_overriding_fontspec (frame
, c
)
262 for (tail
= Voverriding_fontspec_alist
; CONSP (tail
); tail
= XCDR (tail
))
264 Lisp_Object val
, target
, elt
;
269 /* Now VAL is (NO-FRAME-LIST OK-FRAME-LIST CHAR FONTNAME). */
270 if (NILP (Fmemq (frame
, XCAR (val
)))
271 && (CHAR_TABLE_P (target
)
272 ? ! NILP (CHAR_TABLE_REF (target
, c
))
273 : XINT (target
) == CHAR_CHARSET (c
)))
277 if (NILP (Fmemq (frame
, XCAR (val
))))
279 if (! face_font_available_p (XFRAME (frame
), XCDR (elt
)))
281 val
= XCDR (XCAR (tail
));
282 XSETCAR (val
, Fcons (frame
, XCAR (val
)));
285 XSETCAR (val
, Fcons (frame
, XCAR (val
)));
287 if (NILP (XCAR (elt
)))
288 XSETCAR (elt
, make_number (c
));
295 #define FONTSET_REF_VIA_BASE(fontset, c) fontset_ref_via_base (fontset, &c)
298 fontset_ref_via_base (fontset
, c
)
305 if (SINGLE_BYTE_CHAR_P (*c
))
306 return FONTSET_ASCII (fontset
);
309 if (! EQ (FONTSET_BASE (fontset
), Vdefault_fontset
))
310 elt
= FONTSET_REF (FONTSET_BASE (fontset
), *c
);
312 elt
= lookup_overriding_fontspec (FONTSET_FRAME (fontset
), *c
);
314 elt
= FONTSET_REF (Vdefault_fontset
, *c
);
318 *c
= XINT (XCAR (elt
));
319 SPLIT_CHAR (*c
, charset
, c1
, c2
);
320 elt
= XCHAR_TABLE (fontset
)->contents
[charset
+ 128];
322 return (SUB_CHAR_TABLE_P (elt
) ? XCHAR_TABLE (elt
)->defalt
: elt
);
323 if (!SUB_CHAR_TABLE_P (elt
))
325 elt
= XCHAR_TABLE (elt
)->contents
[c1
];
327 return (SUB_CHAR_TABLE_P (elt
) ? XCHAR_TABLE (elt
)->defalt
: elt
);
328 if (!SUB_CHAR_TABLE_P (elt
))
330 elt
= XCHAR_TABLE (elt
)->contents
[c2
];
335 /* Store into the element of FONTSET at index C the value NEWELT. */
336 #define FONTSET_SET(fontset, c, newelt) fontset_set(fontset, c, newelt)
339 fontset_set (fontset
, c
, newelt
)
344 int charset
, code
[3];
348 if (SINGLE_BYTE_CHAR_P (c
))
350 FONTSET_ASCII (fontset
) = newelt
;
354 SPLIT_CHAR (c
, charset
, code
[0], code
[1]);
355 code
[2] = 0; /* anchor */
356 elt
= &XCHAR_TABLE (fontset
)->contents
[charset
+ 128];
357 for (i
= 0; code
[i
] > 0; i
++)
359 if (!SUB_CHAR_TABLE_P (*elt
))
361 Lisp_Object val
= *elt
;
362 *elt
= make_sub_char_table (Qnil
);
363 XCHAR_TABLE (*elt
)->defalt
= val
;
365 elt
= &XCHAR_TABLE (*elt
)->contents
[code
[i
]];
367 if (SUB_CHAR_TABLE_P (*elt
))
368 XCHAR_TABLE (*elt
)->defalt
= newelt
;
374 /* Return a newly created fontset with NAME. If BASE is nil, make a
375 base fontset. Otherwise make a realized fontset whose parent is
379 make_fontset (frame
, name
, base
)
380 Lisp_Object frame
, name
, base
;
383 int size
= ASIZE (Vfontset_table
);
384 int id
= next_fontset_id
;
386 /* Find a free slot in Vfontset_table. Usually, next_fontset_id is
387 the next available fontset ID. So it is expected that this loop
388 terminates quickly. In addition, as the last element of
389 Vfontset_table is always nil, we don't have to check the range of
391 while (!NILP (AREF (Vfontset_table
, id
))) id
++;
398 tem
= Fmake_vector (make_number (size
+ 8), Qnil
);
399 for (i
= 0; i
< size
; i
++)
400 AREF (tem
, i
) = AREF (Vfontset_table
, i
);
401 Vfontset_table
= tem
;
404 fontset
= Fmake_char_table (Qfontset
, Qnil
);
406 FONTSET_ID (fontset
) = make_number (id
);
407 FONTSET_NAME (fontset
) = name
;
408 FONTSET_FRAME (fontset
) = frame
;
409 FONTSET_BASE (fontset
) = base
;
411 AREF (Vfontset_table
, id
) = fontset
;
412 next_fontset_id
= id
+ 1;
417 /* Return 1 if ID is a valid fontset id, else return 0. */
420 fontset_id_valid_p (id
)
423 return (id
>= 0 && id
< ASIZE (Vfontset_table
) - 1);
427 /* Extract `family' and `registry' string from FONTNAME and a cons of
428 them. Actually, `family' may also contain `foundry', `registry'
429 may also contain `encoding' of FONTNAME. But, if FONTNAME doesn't
430 conform to XLFD nor explicitely specifies the other fields
431 (i.e. not using wildcard `*'), return FONTNAME. If FORCE is
432 nonzero, specifications of the other fields are ignored, and return
433 a cons as far as FONTNAME conform to XLFD. */
436 font_family_registry (fontname
, force
)
437 Lisp_Object fontname
;
440 Lisp_Object family
, registry
;
441 const char *p
= SDATA (fontname
);
448 if (!force
&& i
>= 2 && i
<= 11 && *p
!= '*' && p
[1] != '-')
455 family
= make_unibyte_string (sep
[0], sep
[2] - 1 - sep
[0]);
456 registry
= make_unibyte_string (sep
[12], p
- sep
[12]);
457 return Fcons (family
, registry
);
461 /********** INTERFACES TO xfaces.c and dispextern.h **********/
463 /* Return name of the fontset with ID. */
470 fontset
= FONTSET_FROM_ID (id
);
471 return FONTSET_NAME (fontset
);
475 /* Return ASCII font name of the fontset with ID. */
481 Lisp_Object fontset
, elt
;
482 fontset
= FONTSET_FROM_ID (id
);
483 elt
= FONTSET_ASCII (fontset
);
488 /* Free fontset of FACE. Called from free_realized_face. */
491 free_face_fontset (f
, face
)
495 if (fontset_id_valid_p (face
->fontset
))
497 AREF (Vfontset_table
, face
->fontset
) = Qnil
;
498 if (face
->fontset
< next_fontset_id
)
499 next_fontset_id
= face
->fontset
;
504 /* Return 1 if FACE is suitable for displaying character C.
505 Otherwise return 0. Called from the macro FACE_SUITABLE_FOR_CHAR_P
506 when C is not a single byte character.. */
509 face_suitable_for_char_p (face
, c
)
513 Lisp_Object fontset
, elt
;
515 if (SINGLE_BYTE_CHAR_P (c
))
516 return (face
== face
->ascii_face
);
518 xassert (fontset_id_valid_p (face
->fontset
));
519 fontset
= FONTSET_FROM_ID (face
->fontset
);
520 xassert (!BASE_FONTSET_P (fontset
));
522 elt
= FONTSET_REF_VIA_BASE (fontset
, c
);
523 return (!NILP (elt
) && face
->id
== XFASTINT (elt
));
527 /* Return ID of face suitable for displaying character C on frame F.
528 The selection of face is done based on the fontset of FACE. FACE
529 should already have been realized for ASCII characters. Called
530 from the macro FACE_FOR_CHAR when C is not a single byte character. */
533 face_for_char (f
, face
, c
)
538 Lisp_Object fontset
, elt
;
541 xassert (fontset_id_valid_p (face
->fontset
));
542 fontset
= FONTSET_FROM_ID (face
->fontset
);
543 xassert (!BASE_FONTSET_P (fontset
));
545 elt
= FONTSET_REF_VIA_BASE (fontset
, c
);
549 /* No face is recorded for C in the fontset of FACE. Make a new
550 realized face for C that has the same fontset. */
551 face_id
= lookup_face (f
, face
->lface
, c
, face
);
553 /* Record the face ID in FONTSET at the same index as the
554 information in the base fontset. */
555 FONTSET_SET (fontset
, c
, make_number (face_id
));
560 /* Make a realized fontset for ASCII face FACE on frame F from the
561 base fontset BASE_FONTSET_ID. If BASE_FONTSET_ID is -1, use the
562 default fontset as the base. Value is the id of the new fontset.
563 Called from realize_x_face. */
566 make_fontset_for_ascii_face (f
, base_fontset_id
)
570 Lisp_Object base_fontset
, fontset
, frame
;
572 XSETFRAME (frame
, f
);
573 if (base_fontset_id
>= 0)
575 base_fontset
= FONTSET_FROM_ID (base_fontset_id
);
576 if (!BASE_FONTSET_P (base_fontset
))
577 base_fontset
= FONTSET_BASE (base_fontset
);
578 xassert (BASE_FONTSET_P (base_fontset
));
581 base_fontset
= Vdefault_fontset
;
583 fontset
= make_fontset (frame
, Qnil
, base_fontset
);
584 return XINT (FONTSET_ID (fontset
));
588 /* Return the font name pattern for C that is recorded in the fontset
589 with ID. If a font name pattern is specified (instead of a cons of
590 family and registry), check if a font can be opened by that pattern
591 to get the fullname. If a font is opened, return that name.
592 Otherwise, return nil. If ID is -1, or the fontset doesn't contain
593 information about C, get the registry and encoding of C from the
594 default fontset. Called from choose_face_font. */
597 fontset_font_pattern (f
, id
, c
)
601 Lisp_Object fontset
, elt
;
602 struct font_info
*fontp
;
605 if (fontset_id_valid_p (id
))
607 fontset
= FONTSET_FROM_ID (id
);
608 xassert (!BASE_FONTSET_P (fontset
));
609 fontset
= FONTSET_BASE (fontset
);
610 if (! EQ (fontset
, Vdefault_fontset
))
611 elt
= FONTSET_REF (fontset
, c
);
617 XSETFRAME (frame
, f
);
618 elt
= lookup_overriding_fontspec (frame
, c
);
621 elt
= FONTSET_REF (Vdefault_fontset
, c
);
625 if (CONSP (XCDR (elt
)))
628 /* The fontset specifies only a font name pattern (not cons of
629 family and registry). If a font can be opened by that pattern,
630 return the name of opened font. Otherwise return nil. The
631 exception is a font for single byte characters. In that case, we
632 return a cons of FAMILY and REGISTRY extracted from the opened
635 xassert (STRINGP (elt
));
636 fontp
= FS_LOAD_FONT (f
, c
, SDATA (elt
), -1);
640 return font_family_registry (build_string (fontp
->full_name
),
641 SINGLE_BYTE_CHAR_P (c
));
645 #if defined(WINDOWSNT) && defined (_MSC_VER)
646 #pragma optimize("", off)
649 /* Load a font named FONTNAME to display character C on frame F.
650 Return a pointer to the struct font_info of the loaded font. If
651 loading fails, return NULL. If FACE is non-zero and a fontset is
652 assigned to it, record FACE->id in the fontset for C. If FONTNAME
653 is NULL, the name is taken from the fontset of FACE or what
657 fs_load_font (f
, c
, fontname
, id
, face
)
665 Lisp_Object list
, elt
, fullname
;
667 struct font_info
*fontp
;
668 int charset
= CHAR_CHARSET (c
);
675 fontset
= FONTSET_FROM_ID (id
);
678 && !BASE_FONTSET_P (fontset
))
680 elt
= FONTSET_REF_VIA_BASE (fontset
, c
);
683 /* A suitable face for C is already recorded, which means
684 that a proper font is already loaded. */
685 int face_id
= XINT (elt
);
687 xassert (face_id
== face
->id
);
688 face
= FACE_FROM_ID (f
, face_id
);
689 return (*get_font_info_func
) (f
, face
->font_info_id
);
692 if (!fontname
&& charset
== CHARSET_ASCII
)
694 elt
= FONTSET_ASCII (fontset
);
695 fontname
= SDATA (XCDR (elt
));
700 /* No way to get fontname. */
703 fontp
= (*load_font_func
) (f
, fontname
, size
);
707 /* Fill in members (charset, vertical_centering, encoding, etc) of
708 font_info structure that are not set by (*load_font_func). */
709 fontp
->charset
= charset
;
711 fullname
= build_string (fontp
->full_name
);
712 fontp
->vertical_centering
713 = (STRINGP (Vvertical_centering_font_regexp
)
714 && (fast_string_match_ignore_case
715 (Vvertical_centering_font_regexp
, fullname
) >= 0));
717 if (fontp
->encoding
[1] != FONT_ENCODING_NOT_DECIDED
)
719 /* The font itself tells which code points to be used. Use this
720 encoding for all other charsets. */
723 fontp
->encoding
[0] = fontp
->encoding
[1];
724 for (i
= MIN_CHARSET_OFFICIAL_DIMENSION1
; i
<= MAX_CHARSET
; i
++)
725 fontp
->encoding
[i
] = fontp
->encoding
[1];
729 /* The font itself doesn't have information about encoding. */
732 /* By default, encoding of ASCII chars is 0 (i.e. 0x00..0x7F),
733 others is 1 (i.e. 0x80..0xFF). */
734 fontp
->encoding
[0] = 0;
735 for (i
= MIN_CHARSET_OFFICIAL_DIMENSION1
; i
<= MAX_CHARSET
; i
++)
736 fontp
->encoding
[i
] = 1;
737 /* Then override them by a specification in Vfont_encoding_alist. */
738 for (list
= Vfont_encoding_alist
; CONSP (list
); list
= XCDR (list
))
742 && STRINGP (XCAR (elt
)) && CONSP (XCDR (elt
))
743 && (fast_string_match_ignore_case (XCAR (elt
), fullname
) >= 0))
747 for (tmp
= XCDR (elt
); CONSP (tmp
); tmp
= XCDR (tmp
))
748 if (CONSP (XCAR (tmp
))
749 && ((i
= get_charset_id (XCAR (XCAR (tmp
))))
751 && INTEGERP (XCDR (XCAR (tmp
)))
752 && XFASTINT (XCDR (XCAR (tmp
))) < 4)
754 = XFASTINT (XCDR (XCAR (tmp
)));
759 if (! fontp
->font_encoder
&& find_ccl_program_func
)
760 (*find_ccl_program_func
) (fontp
);
762 /* If we loaded a font for a face that has fontset, record the face
763 ID in the fontset for C. */
766 && !BASE_FONTSET_P (fontset
))
767 FONTSET_SET (fontset
, c
, make_number (face
->id
));
771 #if defined(WINDOWSNT) && defined (_MSC_VER)
772 #pragma optimize("", on)
775 /* Set the ASCII font of the default fontset to FONTNAME if that is
778 set_default_ascii_font (fontname
)
779 Lisp_Object fontname
;
781 if (! CONSP (FONTSET_ASCII (Vdefault_fontset
)))
783 int id
= fs_query_fontset (fontname
, 2);
786 fontname
= XCDR (FONTSET_ASCII (FONTSET_FROM_ID (id
)));
787 FONTSET_ASCII (Vdefault_fontset
)
788 = Fcons (make_number (0), fontname
);
793 /* Cache data used by fontset_pattern_regexp. The car part is a
794 pattern string containing at least one wild card, the cdr part is
795 the corresponding regular expression. */
796 static Lisp_Object Vcached_fontset_data
;
798 #define CACHED_FONTSET_NAME (SDATA (XCAR (Vcached_fontset_data)))
799 #define CACHED_FONTSET_REGEX (XCDR (Vcached_fontset_data))
801 /* If fontset name PATTERN contains any wild card, return regular
802 expression corresponding to PATTERN. */
805 fontset_pattern_regexp (pattern
)
808 if (!index (SDATA (pattern
), '*')
809 && !index (SDATA (pattern
), '?'))
810 /* PATTERN does not contain any wild cards. */
813 if (!CONSP (Vcached_fontset_data
)
814 || strcmp (SDATA (pattern
), CACHED_FONTSET_NAME
))
816 /* We must at first update the cached data. */
817 unsigned char *regex
, *p0
, *p1
;
818 int ndashes
= 0, nstars
= 0;
820 for (p0
= SDATA (pattern
); *p0
; p0
++)
828 /* If PATTERN is not full XLFD we conert "*" to ".*". Otherwise
829 we convert "*" to "[^-]*" which is much faster in regular
830 expression matching. */
832 p1
= regex
= (unsigned char *) alloca (SBYTES (pattern
) + 2 * nstars
+ 1);
834 p1
= regex
= (unsigned char *) alloca (SBYTES (pattern
) + 5 * nstars
+ 1);
837 for (p0
= SDATA (pattern
); *p0
; p0
++)
844 *p1
++ = '[', *p1
++ = '^', *p1
++ = '-', *p1
++ = ']';
855 Vcached_fontset_data
= Fcons (build_string (SDATA (pattern
)),
856 build_string (regex
));
859 return CACHED_FONTSET_REGEX
;
862 /* Return ID of the base fontset named NAME. If there's no such
863 fontset, return -1. NAME_PATTERN specifies how to treat NAME as this:
864 0: pattern containing '*' and '?' as wildcards
865 1: regular expression
866 2: literal fontset name
870 fs_query_fontset (name
, name_pattern
)
877 name
= Fdowncase (name
);
878 if (name_pattern
!= 1)
880 tem
= Frassoc (name
, Vfontset_alias_alist
);
881 if (CONSP (tem
) && STRINGP (XCAR (tem
)))
883 else if (name_pattern
== 0)
885 tem
= fontset_pattern_regexp (name
);
894 for (i
= 0; i
< ASIZE (Vfontset_table
); i
++)
896 Lisp_Object fontset
, this_name
;
898 fontset
= FONTSET_FROM_ID (i
);
900 || !BASE_FONTSET_P (fontset
))
903 this_name
= FONTSET_NAME (fontset
);
904 if (name_pattern
== 1
905 ? fast_string_match (name
, this_name
) >= 0
906 : !strcmp (SDATA (name
), SDATA (this_name
)))
913 DEFUN ("query-fontset", Fquery_fontset
, Squery_fontset
, 1, 2, 0,
914 doc
: /* Return the name of a fontset that matches PATTERN.
915 The value is nil if there is no matching fontset.
916 PATTERN can contain `*' or `?' as a wildcard
917 just as X font name matching algorithm allows.
918 If REGEXPP is non-nil, PATTERN is a regular expression. */)
920 Lisp_Object pattern
, regexpp
;
925 (*check_window_system_func
) ();
927 CHECK_STRING (pattern
);
929 if (SCHARS (pattern
) == 0)
932 id
= fs_query_fontset (pattern
, !NILP (regexpp
));
936 fontset
= FONTSET_FROM_ID (id
);
937 return FONTSET_NAME (fontset
);
940 /* Return a list of base fontset names matching PATTERN on frame F.
941 If SIZE is not 0, it is the size (maximum bound width) of fontsets
945 list_fontsets (f
, pattern
, size
)
950 Lisp_Object frame
, regexp
, val
;
953 XSETFRAME (frame
, f
);
955 regexp
= fontset_pattern_regexp (pattern
);
958 for (id
= 0; id
< ASIZE (Vfontset_table
); id
++)
960 Lisp_Object fontset
, name
;
962 fontset
= FONTSET_FROM_ID (id
);
964 || !BASE_FONTSET_P (fontset
)
965 || !EQ (frame
, FONTSET_FRAME (fontset
)))
967 name
= FONTSET_NAME (fontset
);
970 ? (fast_string_match (regexp
, name
) < 0)
971 : strcmp (SDATA (pattern
), SDATA (name
)))
976 struct font_info
*fontp
;
977 fontp
= FS_LOAD_FONT (f
, 0, NULL
, id
);
978 if (!fontp
|| size
!= fontp
->size
)
981 val
= Fcons (Fcopy_sequence (FONTSET_NAME (fontset
)), val
);
987 DEFUN ("new-fontset", Fnew_fontset
, Snew_fontset
, 2, 2, 0,
988 doc
: /* Create a new fontset NAME that contains font information in FONTLIST.
989 FONTLIST is an alist of charsets vs corresponding font name patterns. */)
991 Lisp_Object name
, fontlist
;
993 Lisp_Object fontset
, elements
, ascii_font
;
994 Lisp_Object tem
, tail
, elt
;
997 (*check_window_system_func
) ();
1000 CHECK_LIST (fontlist
);
1002 name
= Fdowncase (name
);
1003 id
= fs_query_fontset (name
, 2);
1006 fontset
= FONTSET_FROM_ID (id
);
1007 tem
= FONTSET_NAME (fontset
);
1008 error ("Fontset `%s' matches the existing fontset `%s'",
1009 SDATA (name
), SDATA (tem
));
1012 /* Check the validity of FONTLIST while creating a template for
1013 fontset elements. */
1014 elements
= ascii_font
= Qnil
;
1015 for (tail
= fontlist
; CONSP (tail
); tail
= XCDR (tail
))
1021 || (charset
= get_charset_id (XCAR (tem
))) < 0
1022 || (!STRINGP (XCDR (tem
)) && !CONSP (XCDR (tem
))))
1023 error ("Elements of fontlist must be a cons of charset and font name pattern");
1027 tem
= Fdowncase (tem
);
1029 tem
= Fcons (Fdowncase (Fcar (tem
)), Fdowncase (Fcdr (tem
)));
1030 if (charset
== CHARSET_ASCII
)
1034 c
= MAKE_CHAR (charset
, 0, 0);
1035 elements
= Fcons (Fcons (make_number (c
), tem
), elements
);
1039 if (NILP (ascii_font
))
1040 error ("No ASCII font in the fontlist");
1042 fontset
= make_fontset (Qnil
, name
, Qnil
);
1043 FONTSET_ASCII (fontset
) = Fcons (make_number (0), ascii_font
);
1044 for (; CONSP (elements
); elements
= XCDR (elements
))
1046 elt
= XCAR (elements
);
1049 tem
= font_family_registry (tem
, 0);
1050 tem
= Fcons (XCAR (elt
), tem
);
1051 FONTSET_SET (fontset
, XINT (XCAR (elt
)), tem
);
1058 /* Clear all elements of FONTSET for multibyte characters. */
1061 clear_fontset_elements (fontset
)
1062 Lisp_Object fontset
;
1066 for (i
= CHAR_TABLE_SINGLE_BYTE_SLOTS
; i
< CHAR_TABLE_ORDINARY_SLOTS
; i
++)
1067 XCHAR_TABLE (fontset
)->contents
[i
] = Qnil
;
1071 /* Check validity of NAME as a fontset name and return the
1072 corresponding fontset. If not valid, signal an error.
1073 If NAME is nil, return Vdefault_fontset. */
1076 check_fontset_name (name
)
1081 if (EQ (name
, Qnil
))
1082 return Vdefault_fontset
;
1084 CHECK_STRING (name
);
1085 /* First try NAME as literal. */
1086 id
= fs_query_fontset (name
, 2);
1088 /* For backward compatibility, try again NAME as pattern. */
1089 id
= fs_query_fontset (name
, 0);
1091 error ("Fontset `%s' does not exist", SDATA (name
));
1092 return FONTSET_FROM_ID (id
);
1095 /* Downcase FONTNAME or car and cdr of FONTNAME. If FONTNAME is a
1096 string, maybe change FONTNAME to (FAMILY . REGISTRY). */
1099 regularize_fontname (Lisp_Object fontname
)
1101 Lisp_Object family
, registry
;
1103 if (STRINGP (fontname
))
1104 return font_family_registry (Fdowncase (fontname
), 0);
1106 CHECK_CONS (fontname
);
1107 family
= XCAR (fontname
);
1108 registry
= XCDR (fontname
);
1111 CHECK_STRING (family
);
1112 family
= Fdowncase (family
);
1114 if (!NILP (registry
))
1116 CHECK_STRING (registry
);
1117 registry
= Fdowncase (registry
);
1119 return Fcons (family
, registry
);
1122 DEFUN ("set-fontset-font", Fset_fontset_font
, Sset_fontset_font
, 3, 4, 0,
1123 doc
: /* Modify fontset NAME to use FONTNAME for CHARACTER.
1125 If NAME is nil, modify the default fontset.
1126 CHARACTER may be a cons; (FROM . TO), where FROM and TO are
1127 non-generic characters. In that case, use FONTNAME
1128 for all characters in the range FROM and TO (inclusive).
1129 CHARACTER may be a charset. In that case, use FONTNAME
1130 for all character in the charsets.
1132 FONTNAME may be a cons; (FAMILY . REGISTRY), where FAMILY is a family
1133 name of a font, REGISTRY is a registry name of a font. */)
1134 (name
, character
, fontname
, frame
)
1135 Lisp_Object name
, character
, fontname
, frame
;
1137 Lisp_Object fontset
, elt
;
1138 Lisp_Object realized
;
1142 fontset
= check_fontset_name (name
);
1144 if (CONSP (character
))
1146 /* CH should be (FROM . TO) where FROM and TO are non-generic
1148 CHECK_NUMBER_CAR (character
);
1149 CHECK_NUMBER_CDR (character
);
1150 from
= XINT (XCAR (character
));
1151 to
= XINT (XCDR (character
));
1152 if (!char_valid_p (from
, 0) || !char_valid_p (to
, 0))
1153 error ("Character range should be by non-generic characters");
1155 && (SINGLE_BYTE_CHAR_P (from
) || SINGLE_BYTE_CHAR_P (to
)))
1156 error ("Can't change font for a single byte character");
1158 else if (SYMBOLP (character
))
1160 elt
= Fget (character
, Qcharset
);
1161 if (!VECTORP (elt
) || ASIZE (elt
) < 1 || !NATNUMP (AREF (elt
, 0)))
1162 error ("Invalid charset: %s", SDATA (SYMBOL_NAME (character
)));
1163 from
= MAKE_CHAR (XINT (AREF (elt
, 0)), 0, 0);
1168 CHECK_NUMBER (character
);
1169 from
= XINT (character
);
1172 if (!char_valid_p (from
, 1))
1173 invalid_character (from
);
1174 if (SINGLE_BYTE_CHAR_P (from
))
1175 error ("Can't change font for a single byte character");
1178 if (!char_valid_p (to
, 1))
1179 invalid_character (to
);
1180 if (SINGLE_BYTE_CHAR_P (to
))
1181 error ("Can't change font for a single byte character");
1184 /* The arg FRAME is kept for backward compatibility. We only check
1187 CHECK_LIVE_FRAME (frame
);
1189 elt
= Fcons (make_number (from
), regularize_fontname (fontname
));
1190 for (; from
<= to
; from
++)
1191 FONTSET_SET (fontset
, from
, elt
);
1192 Foptimize_char_table (fontset
);
1194 /* If there's a realized fontset REALIZED whose parent is FONTSET,
1195 clear all the elements of REALIZED and free all multibyte faces
1196 whose fontset is REALIZED. This way, the specified character(s)
1197 are surely redisplayed by a correct font. */
1198 for (id
= 0; id
< ASIZE (Vfontset_table
); id
++)
1200 realized
= AREF (Vfontset_table
, id
);
1201 if (!NILP (realized
)
1202 && !BASE_FONTSET_P (realized
)
1203 && EQ (FONTSET_BASE (realized
), fontset
))
1205 FRAME_PTR f
= XFRAME (FONTSET_FRAME (realized
));
1206 clear_fontset_elements (realized
);
1207 free_realized_multibyte_face (f
, id
);
1214 DEFUN ("font-info", Ffont_info
, Sfont_info
, 1, 2, 0,
1215 doc
: /* Return information about a font named NAME on frame FRAME.
1216 If FRAME is omitted or nil, use the selected frame.
1217 The returned value is a vector of OPENED-NAME, FULL-NAME, CHARSET, SIZE,
1218 HEIGHT, BASELINE-OFFSET, RELATIVE-COMPOSE, and DEFAULT-ASCENT,
1220 OPENED-NAME is the name used for opening the font,
1221 FULL-NAME is the full name of the font,
1222 SIZE is the maximum bound width of the font,
1223 HEIGHT is the height of the font,
1224 BASELINE-OFFSET is the upward offset pixels from ASCII baseline,
1225 RELATIVE-COMPOSE and DEFAULT-ASCENT are the numbers controlling
1226 how to compose characters.
1227 If the named font is not yet loaded, return nil. */)
1229 Lisp_Object name
, frame
;
1232 struct font_info
*fontp
;
1235 (*check_window_system_func
) ();
1237 CHECK_STRING (name
);
1238 name
= Fdowncase (name
);
1240 frame
= selected_frame
;
1241 CHECK_LIVE_FRAME (frame
);
1244 if (!query_font_func
)
1245 error ("Font query function is not supported");
1247 fontp
= (*query_font_func
) (f
, SDATA (name
));
1251 info
= Fmake_vector (make_number (7), Qnil
);
1253 XVECTOR (info
)->contents
[0] = build_string (fontp
->name
);
1254 XVECTOR (info
)->contents
[1] = build_string (fontp
->full_name
);
1255 XVECTOR (info
)->contents
[2] = make_number (fontp
->size
);
1256 XVECTOR (info
)->contents
[3] = make_number (fontp
->height
);
1257 XVECTOR (info
)->contents
[4] = make_number (fontp
->baseline_offset
);
1258 XVECTOR (info
)->contents
[5] = make_number (fontp
->relative_compose
);
1259 XVECTOR (info
)->contents
[6] = make_number (fontp
->default_ascent
);
1265 /* Return a cons (FONT-NAME . GLYPH-CODE).
1266 FONT-NAME is the font name for the character at POSITION in the current
1267 buffer. This is computed from all the text properties and overlays
1268 that apply to POSITION. POSTION may be nil, in which case,
1269 FONT-NAME is the font name for display the character CH with the
1272 GLYPH-CODE is the glyph code in the font to use for the character.
1274 If the 2nd optional arg CH is non-nil, it is a character to check
1275 the font instead of the character at POSITION.
1277 It returns nil in the following cases:
1279 (1) The window system doesn't have a font for the character (thus
1280 it is displayed by an empty box).
1282 (2) The character code is invalid.
1284 (3) If POSITION is not nil, and the current buffer is not displayed
1287 In addition, the returned font name may not take into account of
1288 such redisplay engine hooks as what used in jit-lock-mode if
1289 POSITION is currently not visible. */
1292 DEFUN ("internal-char-font", Finternal_char_font
, Sinternal_char_font
, 1, 2, 0,
1293 doc
: /* For internal use only. */)
1295 Lisp_Object position
, ch
;
1297 int pos
, pos_byte
, dummy
;
1303 if (NILP (position
))
1307 f
= XFRAME (selected_frame
);
1308 face_id
= DEFAULT_FACE_ID
;
1315 CHECK_NUMBER_COERCE_MARKER (position
);
1316 pos
= XINT (position
);
1317 if (pos
< BEGV
|| pos
>= ZV
)
1318 args_out_of_range_3 (position
, make_number (BEGV
), make_number (ZV
));
1319 pos_byte
= CHAR_TO_BYTE (pos
);
1321 c
= FETCH_CHAR (pos_byte
);
1327 window
= Fget_buffer_window (Fcurrent_buffer (), Qnil
);
1330 w
= XWINDOW (window
);
1331 f
= XFRAME (w
->frame
);
1332 face_id
= face_at_buffer_position (w
, pos
, -1, -1, &dummy
, pos
+ 100, 0);
1334 if (! CHAR_VALID_P (c
, 0))
1336 face_id
= FACE_FOR_CHAR (f
, FACE_FROM_ID (f
, face_id
), c
);
1337 face
= FACE_FROM_ID (f
, face_id
);
1338 if (! face
->font
|| ! face
->font_name
)
1342 struct font_info
*fontp
= (*get_font_info_func
) (f
, face
->font_info_id
);
1344 int c1
, c2
, charset
;
1346 SPLIT_CHAR (c
, charset
, c1
, c2
);
1348 STORE_XCHAR2B (&char2b
, c1
, c2
);
1350 STORE_XCHAR2B (&char2b
, 0, c1
);
1351 FRAME_RIF (f
)->encode_char (c
, &char2b
, fontp
, NULL
);
1352 code
= (XCHAR2B_BYTE1 (&char2b
) << 8) | XCHAR2B_BYTE2 (&char2b
);
1354 return Fcons (build_string (face
->font_name
), make_number (code
));
1358 /* Called from Ffontset_info via map_char_table on each leaf of
1359 fontset. ARG is a copy of the default fontset. The current leaf
1360 is indexed by CHARACTER and has value ELT. This function override
1361 the copy by ELT if ELT is not nil. */
1364 override_font_info (fontset
, character
, elt
)
1365 Lisp_Object fontset
, character
, elt
;
1368 Faset (fontset
, character
, elt
);
1371 /* Called from Ffontset_info via map_char_table on each leaf of
1372 fontset. ARG is a list (LAST FONT-INFO ...), where LAST is `(last
1373 ARG)' and FONT-INFOs have this form:
1374 (CHAR FONT-SPEC) or ((FROM . TO) FONT-SPEC)
1375 The current leaf is indexed by CHARACTER and has value ELT. This
1376 function add the information of the current leaf to ARG by
1377 appending a new element or modifying the last element. */
1380 accumulate_font_info (arg
, character
, elt
)
1381 Lisp_Object arg
, character
, elt
;
1383 Lisp_Object last
, last_char
, last_elt
;
1385 if (!CONSP (elt
) && !SINGLE_BYTE_CHAR_P (XINT (character
)))
1386 elt
= FONTSET_REF (Vdefault_fontset
, XINT (character
));
1390 last_char
= XCAR (XCAR (last
));
1391 last_elt
= XCAR (XCDR (XCAR (last
)));
1393 if (!NILP (Fequal (elt
, last_elt
)))
1395 int this_charset
= CHAR_CHARSET (XINT (character
));
1397 if (CONSP (last_char
)) /* LAST_CHAR == (FROM . TO) */
1399 if (this_charset
== CHAR_CHARSET (XINT (XCAR (last_char
))))
1401 XSETCDR (last_char
, character
);
1405 else if (XINT (last_char
) == XINT (character
))
1407 else if (this_charset
== CHAR_CHARSET (XINT (last_char
)))
1409 XSETCAR (XCAR (last
), Fcons (last_char
, character
));
1413 XSETCDR (last
, Fcons (Fcons (character
, Fcons (elt
, Qnil
)), Qnil
));
1414 XSETCAR (arg
, XCDR (last
));
1418 DEFUN ("fontset-info", Ffontset_info
, Sfontset_info
, 1, 2, 0,
1419 doc
: /* Return information about a fontset named NAME on frame FRAME.
1420 If NAME is nil, return information about the default fontset.
1421 The value is a vector:
1422 [ SIZE HEIGHT ((CHARSET-OR-RANGE FONT-SPEC OPENED ...) ...) ],
1424 SIZE is the maximum bound width of ASCII font in the fontset,
1425 HEIGHT is the maximum bound height of ASCII font in the fontset,
1426 CHARSET-OR-RANGE is a charset, a character (may be a generic character)
1427 or a cons of two characters specifying the range of characters.
1428 FONT-SPEC is a fontname pattern string or a cons (FAMILY . REGISTRY),
1429 where FAMILY is a `FAMILY' field of a XLFD font name,
1430 REGISTRY is a `CHARSET_REGISTRY' field of a XLFD font name.
1431 FAMILY may contain a `FOUNDRY' field at the head.
1432 REGISTRY may contain a `CHARSET_ENCODING' field at the tail.
1433 OPENEDs are names of fonts actually opened.
1434 If the ASCII font is not yet opened, SIZE and HEIGHT are 0.
1435 If FRAME is omitted, it defaults to the currently selected frame. */)
1437 Lisp_Object name
, frame
;
1439 Lisp_Object fontset
;
1442 Lisp_Object val
, tail
, elt
;
1443 Lisp_Object
*realized
;
1444 struct font_info
*fontp
= NULL
;
1448 (*check_window_system_func
) ();
1450 fontset
= check_fontset_name (name
);
1453 frame
= selected_frame
;
1454 CHECK_LIVE_FRAME (frame
);
1457 /* Recode realized fontsets whose base is FONTSET in the table
1459 realized
= (Lisp_Object
*) alloca (sizeof (Lisp_Object
)
1460 * ASIZE (Vfontset_table
));
1461 for (i
= 0; i
< ASIZE (Vfontset_table
); i
++)
1463 elt
= FONTSET_FROM_ID (i
);
1465 && EQ (FONTSET_BASE (elt
), fontset
))
1466 realized
[n_realized
++] = elt
;
1469 if (! EQ (fontset
, Vdefault_fontset
))
1471 /* Merge FONTSET onto the default fontset. */
1472 val
= Fcopy_sequence (Vdefault_fontset
);
1473 map_char_table (override_font_info
, Qnil
, fontset
, fontset
, val
, 0, indices
);
1477 /* Accumulate information of the fontset in VAL. The format is
1478 (LAST FONT-INFO FONT-INFO ...), where FONT-INFO is (CHAR-OR-RANGE
1479 FONT-SPEC). See the comment for accumulate_font_info for the
1481 val
= Fcons (Fcons (make_number (0),
1482 Fcons (XCDR (FONTSET_ASCII (fontset
)), Qnil
)),
1484 val
= Fcons (val
, val
);
1485 map_char_table (accumulate_font_info
, Qnil
, fontset
, fontset
, val
, 0, indices
);
1488 /* For each FONT-INFO, if CHAR_OR_RANGE (car part) is a generic
1489 character for a charset, replace it with the charset symbol. If
1490 fonts are opened for FONT-SPEC, append the names of the fonts to
1492 for (tail
= val
; CONSP (tail
); tail
= XCDR (tail
))
1496 if (INTEGERP (XCAR (elt
)))
1498 int charset
, c1
, c2
;
1499 c
= XINT (XCAR (elt
));
1500 SPLIT_CHAR (c
, charset
, c1
, c2
);
1502 XSETCAR (elt
, CHARSET_SYMBOL (charset
));
1505 c
= XINT (XCAR (XCAR (elt
)));
1506 for (i
= 0; i
< n_realized
; i
++)
1508 Lisp_Object face_id
, font
;
1511 face_id
= FONTSET_REF_VIA_BASE (realized
[i
], c
);
1512 if (INTEGERP (face_id
))
1514 face
= FACE_FROM_ID (f
, XINT (face_id
));
1515 if (face
&& face
->font
&& face
->font_name
)
1517 font
= build_string (face
->font_name
);
1518 if (NILP (Fmember (font
, XCDR (XCDR (elt
)))))
1519 XSETCDR (XCDR (elt
), Fcons (font
, XCDR (XCDR (elt
))));
1525 elt
= Fcdr (Fcdr (Fassq (CHARSET_SYMBOL (CHARSET_ASCII
), val
)));
1529 fontp
= (*query_font_func
) (f
, SDATA (elt
));
1531 val
= Fmake_vector (make_number (3), val
);
1532 AREF (val
, 0) = fontp
? make_number (fontp
->size
) : make_number (0);
1533 AREF (val
, 1) = fontp
? make_number (fontp
->height
) : make_number (0);
1537 DEFUN ("fontset-font", Ffontset_font
, Sfontset_font
, 2, 2, 0,
1538 doc
: /* Return a font name pattern for character CH in fontset NAME.
1539 If NAME is nil, find a font name pattern in the default fontset. */)
1541 Lisp_Object name
, ch
;
1544 Lisp_Object fontset
, elt
;
1546 fontset
= check_fontset_name (name
);
1550 if (!char_valid_p (c
, 1))
1551 invalid_character (c
);
1553 elt
= FONTSET_REF (fontset
, c
);
1560 DEFUN ("fontset-list", Ffontset_list
, Sfontset_list
, 0, 0, 0,
1561 doc
: /* Return a list of all defined fontset names. */)
1564 Lisp_Object fontset
, list
;
1568 for (i
= 0; i
< ASIZE (Vfontset_table
); i
++)
1570 fontset
= FONTSET_FROM_ID (i
);
1572 && BASE_FONTSET_P (fontset
))
1573 list
= Fcons (FONTSET_NAME (fontset
), list
);
1579 DEFUN ("set-overriding-fontspec-internal", Fset_overriding_fontspec_internal
,
1580 Sset_overriding_fontspec_internal
, 1, 1, 0,
1581 doc
: /* Internal use only.
1583 FONTLIST is an alist of TARGET vs FONTNAME, where TARGET is a charset
1584 or a char-table, FONTNAME have the same meanings as in
1587 It overrides the font specifications for each TARGET in the default
1588 fontset by the corresponding FONTNAME.
1590 If TARGET is a charset, targets are all characters in the charset. If
1591 TARGET is a char-table, targets are characters whose value is non-nil
1594 It is intended that this function is called only from
1595 `set-language-environment'. */)
1597 Lisp_Object fontlist
;
1601 fontlist
= Fcopy_sequence (fontlist
);
1602 /* Now FONTLIST is ((TARGET . FONTNAME) ...). Reform it to ((TARGET
1603 nil nil nil FONTSPEC) ...), where TARGET is a charset-id or a
1605 for (tail
= fontlist
; CONSP (tail
); tail
= XCDR (tail
))
1607 Lisp_Object elt
, target
;
1610 target
= Fcar (elt
);
1611 elt
= Fcons (Qnil
, regularize_fontname (Fcdr (elt
)));
1612 if (! CHAR_TABLE_P (target
))
1616 CHECK_SYMBOL (target
);
1617 charset
= get_charset_id (target
);
1619 error ("Invalid charset %s", SDATA (SYMBOL_NAME (target
)));
1620 target
= make_number (charset
);
1621 c
= MAKE_CHAR (charset
, 0, 0);
1622 XSETCAR (elt
, make_number (c
));
1624 elt
= Fcons (target
, Fcons (Qnil
, Fcons (Qnil
, elt
)));
1625 XSETCAR (tail
, elt
);
1627 if (! NILP (Fequal (fontlist
, Voverriding_fontspec_alist
)))
1629 Voverriding_fontspec_alist
= fontlist
;
1630 clear_face_cache (0);
1631 ++windows_or_buffers_changed
;
1638 if (!load_font_func
)
1639 /* Window system initializer should have set proper functions. */
1642 Qfontset
= intern ("fontset");
1643 staticpro (&Qfontset
);
1644 Fput (Qfontset
, Qchar_table_extra_slots
, make_number (3));
1646 Vcached_fontset_data
= Qnil
;
1647 staticpro (&Vcached_fontset_data
);
1649 Vfontset_table
= Fmake_vector (make_number (32), Qnil
);
1650 staticpro (&Vfontset_table
);
1652 Vdefault_fontset
= Fmake_char_table (Qfontset
, Qnil
);
1653 staticpro (&Vdefault_fontset
);
1654 FONTSET_ID (Vdefault_fontset
) = make_number (0);
1655 FONTSET_NAME (Vdefault_fontset
)
1656 = build_string ("-*-*-*-*-*-*-*-*-*-*-*-*-fontset-default");
1657 AREF (Vfontset_table
, 0) = Vdefault_fontset
;
1658 next_fontset_id
= 1;
1660 Voverriding_fontspec_alist
= Qnil
;
1661 staticpro (&Voverriding_fontspec_alist
);
1663 DEFVAR_LISP ("font-encoding-alist", &Vfont_encoding_alist
,
1664 doc
: /* Alist of fontname patterns vs corresponding encoding info.
1665 Each element looks like (REGEXP . ENCODING-INFO),
1666 where ENCODING-INFO is an alist of CHARSET vs ENCODING.
1667 ENCODING is one of the following integer values:
1668 0: code points 0x20..0x7F or 0x2020..0x7F7F are used,
1669 1: code points 0xA0..0xFF or 0xA0A0..0xFFFF are used,
1670 2: code points 0x20A0..0x7FFF are used,
1671 3: code points 0xA020..0xFF7F are used. */);
1672 Vfont_encoding_alist
= Qnil
;
1673 Vfont_encoding_alist
1674 = Fcons (Fcons (build_string ("JISX0201"),
1675 Fcons (Fcons (intern ("latin-jisx0201"), make_number (0)),
1677 Vfont_encoding_alist
);
1678 Vfont_encoding_alist
1679 = Fcons (Fcons (build_string ("ISO8859-1"),
1680 Fcons (Fcons (intern ("ascii"), make_number (0)),
1682 Vfont_encoding_alist
);
1684 DEFVAR_LISP ("use-default-ascent", &Vuse_default_ascent
,
1685 doc
: /* Char table of characters whose ascent values should be ignored.
1686 If an entry for a character is non-nil, the ascent value of the glyph
1687 is assumed to be what specified by _MULE_DEFAULT_ASCENT property of a font.
1689 This affects how a composite character which contains
1690 such a character is displayed on screen. */);
1691 Vuse_default_ascent
= Qnil
;
1693 DEFVAR_LISP ("ignore-relative-composition", &Vignore_relative_composition
,
1694 doc
: /* Char table of characters which is not composed relatively.
1695 If an entry for a character is non-nil, a composition sequence
1696 which contains that character is displayed so that
1697 the glyph of that character is put without considering
1698 an ascent and descent value of a previous character. */);
1699 Vignore_relative_composition
= Qnil
;
1701 DEFVAR_LISP ("alternate-fontname-alist", &Valternate_fontname_alist
,
1702 doc
: /* Alist of fontname vs list of the alternate fontnames.
1703 When a specified font name is not found, the corresponding
1704 alternate fontnames (if any) are tried instead. */);
1705 Valternate_fontname_alist
= Qnil
;
1707 DEFVAR_LISP ("fontset-alias-alist", &Vfontset_alias_alist
,
1708 doc
: /* Alist of fontset names vs the aliases. */);
1709 Vfontset_alias_alist
= Fcons (Fcons (FONTSET_NAME (Vdefault_fontset
),
1710 build_string ("fontset-default")),
1713 DEFVAR_LISP ("vertical-centering-font-regexp",
1714 &Vvertical_centering_font_regexp
,
1715 doc
: /* *Regexp matching font names that require vertical centering on display.
1716 When a character is displayed with such fonts, the character is displayed
1717 at the vertical center of lines. */);
1718 Vvertical_centering_font_regexp
= Qnil
;
1720 defsubr (&Squery_fontset
);
1721 defsubr (&Snew_fontset
);
1722 defsubr (&Sset_fontset_font
);
1723 defsubr (&Sfont_info
);
1724 defsubr (&Sinternal_char_font
);
1725 defsubr (&Sfontset_info
);
1726 defsubr (&Sfontset_font
);
1727 defsubr (&Sfontset_list
);
1728 defsubr (&Sset_overriding_fontspec_internal
);
1731 /* arch-tag: ea861585-2f5f-4e5b-9849-d04a9c3a3537
1732 (do not change this comment) */