3 Copyright (C) 1995 Free Software Foundation, Inc.
4 Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
6 This file is part of GNU Emacs.
8 GNU Emacs is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU Emacs is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Emacs; see the file COPYING. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
26 #endif /* HAVE_ALLOCA_H */
33 Lisp_Object Vglobal_fontset_alist
;
34 Lisp_Object Vfont_encoding_alist
;
35 Lisp_Object Vuse_default_ascent
;
36 Lisp_Object Valternative_fontname_alist
;
38 /* We had better have our own strcasecmp function because some system
40 static char my_strcasetbl
[256];
42 /* Compare two strings S0 and S1 while ignoring differences in case.
43 Return 1 if they differ, else return 0. */
45 my_strcasecmp (s0
, s1
)
46 unsigned char *s0
, *s1
;
49 if (my_strcasetbl
[*s0
++] != my_strcasetbl
[*s1
++]) return 1;
53 /* The following six are window system dependent functions. See
54 the comments in src/fontset.h for more detail. */
56 /* Return a pointer to struct font_info of font FONT_IDX of frame F. */
57 struct font_info
*(*get_font_info_func
) (/* FRAME_PTR f; int font_idx */);
59 /* Return a list of font names which matches PATTERN. See the document of
60 `x-list-fonts' for more detail. */
61 Lisp_Object (*list_fonts_func
) (/* Lisp_Object pattern, face, frame, width */);
63 /* Load a font named NAME for frame F and return a pointer to the
64 information of the loaded font. If loading is failed, return 0. */
65 struct font_info
*(*load_font_func
) (/* FRAME_PTR f; char *name */);
67 /* Return a pointer to struct font_info of a font named NAME for frame F. */
68 struct font_info
*(*query_font_func
) (/* FRAME_PTR f; char *name */);
70 /* Additional function for setting fontset or changing fontset
71 contents of frame F. */
72 void (*set_frame_fontset_func
) (/* FRAME_PTR f; Lisp_Object arg, oldval */);
74 /* Check if any window system is used now. */
75 void (*check_window_system_func
) ();
80 struct fontset_data
*fontset_data
81 = (struct fontset_data
*) xmalloc (sizeof (struct fontset_data
));
83 bzero (fontset_data
, sizeof (struct fontset_data
));
89 free_fontset_data (fontset_data
)
90 struct fontset_data
*fontset_data
;
94 for (i
= 0; i
< fontset_data
->n_fontsets
; i
++)
98 xfree (fontset_data
->fontset_table
[i
]->name
);
99 for (j
= 0; j
<= MAX_CHARSET
; j
++)
100 if (fontset_data
->fontset_table
[i
]->fontname
[j
])
101 xfree (fontset_data
->fontset_table
[i
]->fontname
[j
]);
102 xfree (fontset_data
->fontset_table
[i
]);
104 xfree (fontset_data
->fontset_table
);
106 xfree (fontset_data
);
109 /* Load a font named FONTNAME for displaying CHARSET on frame F.
110 All fonts for frame F is stored in a table pointed by FONT_TABLE.
111 Return a pointer to the struct font_info of the loaded font.
112 If loading fails, return 0;
113 If FONTNAME is NULL, the name is taken from the information of FONTSET.
114 If FONTSET is given, try to load a font whose size matches that of
115 FONTSET, and, the font index is stored in the table for FONTSET. */
118 fs_load_font (f
, font_table
, charset
, fontname
, fontset
)
120 struct font_info
*font_table
;
121 int charset
, fontset
;
124 Lisp_Object font_list
;
125 Lisp_Object list
, elt
;
128 struct fontset_info
*fontsetp
= 0;
129 struct font_info
*fontp
;
131 if (fontset
>= 0 && fontset
< FRAME_FONTSET_DATA (f
)->n_fontsets
)
133 fontsetp
= FRAME_FONTSET_DATA (f
)->fontset_table
[fontset
];
134 font_idx
= fontsetp
->font_indexes
[charset
];
136 /* We have already loaded a font. */
137 return font_table
+ font_idx
;
138 else if (font_idx
== FONT_NOT_FOUND
)
139 /* We have already tried loading a font and failed. */
142 fontname
= fontsetp
->fontname
[charset
];
146 /* No way to get fontname. */
149 /* If a fontset is specified and we have already loaded some fonts
150 in the fontset, we need a font of appropriate size to be used
152 if (fontsetp
&& fontsetp
->size
)
153 size
= fontsetp
->size
* CHARSET_WIDTH (charset
);
155 fontp
= (*load_font_func
) (f
, fontname
, size
);
160 fontsetp
->font_indexes
[charset
] = FONT_NOT_FOUND
;
164 /* Fill in fields (CHARSET, ENCODING, and FONT_ENCODER) which are
165 not set by (*load_font_func). */
166 fontp
->charset
= charset
;
168 if (fontp
->encoding
[1] >= 0)
170 /* The font itself tells which code points to be used. Use this
171 encoding for all other charsets. */
174 fontp
->encoding
[0] = fontp
->encoding
[1];
175 for (i
= MIN_CHARSET_OFFICIAL_DIMENSION1
; i
<= MAX_CHARSET
; i
++)
176 fontp
->encoding
[i
] = fontp
->encoding
[1];
180 /* The font itself doesn't tell which code points to be used. */
183 /* At first, set 1 (means 0xA0..0xFF) as the default. */
184 fontp
->encoding
[0] = 1;
185 for (i
= MIN_CHARSET_OFFICIAL_DIMENSION1
; i
<= MAX_CHARSET
; i
++)
186 fontp
->encoding
[i
] = 1;
187 /* Then override them by a specification in Vfont_encoding_alist. */
188 for (list
= Vfont_encoding_alist
; CONSP (list
); list
= XCONS (list
)->cdr
)
190 elt
= XCONS (list
)->car
;
192 && STRINGP (XCONS (elt
)->car
) && CONSP (XCONS (elt
)->cdr
)
193 && (fast_string_match_ignore_case (XCONS (elt
)->car
, fontname
)
198 for (tmp
= XCONS (elt
)->cdr
; CONSP (tmp
); tmp
= XCONS (tmp
)->cdr
)
199 if (CONSP (XCONS (tmp
)->car
)
200 && ((i
= get_charset_id (XCONS (XCONS (tmp
)->car
)->car
))
202 && INTEGERP (XCONS (XCONS (tmp
)->car
)->cdr
)
203 && XFASTINT (XCONS (XCONS (tmp
)->car
)->cdr
) < 4)
205 = XFASTINT (XCONS (XCONS (tmp
)->car
)->cdr
);
210 fontp
->font_encoder
= (struct ccl_program
*) 0;
211 for (list
= Vfont_ccl_encoder_alist
; CONSP (list
); list
= XCONS (list
)->cdr
)
213 elt
= XCONS (list
)->car
;
215 && STRINGP (XCONS (elt
)->car
) && VECTORP (XCONS (elt
)->cdr
)
216 && fast_string_match_ignore_case (XCONS (elt
)->car
, fontname
) >= 0)
219 = (struct ccl_program
*) xmalloc (sizeof (struct ccl_program
));
220 setup_ccl_program (fontp
->font_encoder
, XCONS (elt
)->cdr
);
227 fontsetp
->font_indexes
[charset
] = fontp
->font_idx
;
228 if (fontsetp
->size
== 0)
229 fontsetp
->size
= fontp
->size
/ CHARSET_WIDTH (charset
);
231 if (charset
== CHARSET_ASCII
232 && fontsetp
->size
!= fontp
->size
)
234 /* When loading ASCII font of the different size from the
235 size of FONTSET, we have to update the size of FONTSET.
236 Since changing the size of FONTSET may make some fonts
237 already loaded inappropriate to be used in FONTSET, we
238 must delete the record of such fonts. In that case, we
239 also have to calculate the height of FONTSET from the
243 fontsetp
->size
= fontp
->size
;
244 fontsetp
->height
= fontp
->height
;
245 for (i
= CHARSET_ASCII
+ 1; i
<= MAX_CHARSET
; i
++)
247 font_idx
= fontsetp
->font_indexes
[i
];
250 struct font_info
*fontp2
= font_table
+ font_idx
;
252 if (fontp2
->size
!= fontp
->size
* CHARSET_WIDTH (i
))
253 fontsetp
->font_indexes
[i
] = FONT_NOT_OPENED
;
254 /* The following code should be disabled until Emacs
255 supports variable height lines. */
257 else if (fontsetp
->height
< fontp
->height
)
258 fontsetp
->height
= fontp
->height
;
263 else if (fontsetp
->height
< fontp
->height
)
264 fontsetp
->height
= fontp
->height
;
270 /* Return ID of the fontset named NAME on frame F. */
273 fs_query_fontset (f
, name
)
277 struct fontset_data
*fontset_data
= FRAME_FONTSET_DATA (f
);
280 for (i
= 0; i
< fontset_data
->n_fontsets
; i
++)
281 if (!my_strcasecmp(name
, fontset_data
->fontset_table
[i
]->name
))
286 /* Register a fontset specified by FONTSET_INFO for frame FRAME.
287 Return the fontset ID if successfully registered, else return -1.
288 FONTSET_INFO is a cons of name of the fontset and FONTLIST, where
289 FONTLIST is an alist of charsets vs fontnames. */
292 fs_register_fontset (f
, fontset_info
)
294 Lisp_Object fontset_info
;
296 struct fontset_data
*fontset_data
= FRAME_FONTSET_DATA (f
);
297 Lisp_Object name
, fontlist
;
299 struct fontset_info
*fontsetp
;
302 if (!CONSP (fontset_info
)
303 || !STRINGP (XCONS (fontset_info
)->car
)
304 || !CONSP (XCONS (fontset_info
)->cdr
))
305 /* Invalid data in FONTSET_INFO. */
308 name
= XCONS (fontset_info
)->car
;
309 if ((fontset
= fs_query_fontset (f
, XSTRING (name
)->data
)) >= 0)
310 /* This fontset already exists on frame F. */
313 fontsetp
= (struct fontset_info
*) xmalloc (sizeof (struct fontset_info
));
315 fontsetp
->name
= (char *) xmalloc (XSTRING (name
)->size
+ 1);
316 bcopy(XSTRING (name
)->data
, fontsetp
->name
, XSTRING (name
)->size
+ 1);
318 fontsetp
->size
= fontsetp
->height
= 0;
320 for (i
= 0; i
<= MAX_CHARSET
; i
++)
322 fontsetp
->fontname
[i
] = (char *) 0;
323 fontsetp
->font_indexes
[i
] = FONT_NOT_OPENED
;
326 for (fontlist
= XCONS (fontset_info
)->cdr
; CONSP (fontlist
);
327 fontlist
= XCONS (fontlist
)->cdr
)
329 Lisp_Object tem
= Fcar (fontlist
);
333 && (charset
= get_charset_id (XCONS (tem
)->car
)) >= 0
334 && STRINGP (XCONS (tem
)->cdr
))
336 fontsetp
->fontname
[charset
]
337 = (char *) xmalloc (XSTRING (XCONS (tem
)->cdr
)->size
+ 1);
338 bcopy (XSTRING (XCONS (tem
)->cdr
)->data
,
339 fontsetp
->fontname
[charset
],
340 XSTRING (XCONS (tem
)->cdr
)->size
+ 1);
343 /* Broken or invalid data structure. */
347 /* Do we need to create the table? */
348 if (fontset_data
->fontset_table_size
== 0)
350 fontset_data
->fontset_table_size
= 8;
351 fontset_data
->fontset_table
352 = (struct fontset_info
**) xmalloc (fontset_data
->fontset_table_size
353 * sizeof (struct fontset_info
*));
355 /* Do we need to grow the table? */
356 else if (fontset_data
->n_fontsets
>= fontset_data
->fontset_table_size
)
358 fontset_data
->fontset_table_size
+= 8;
359 fontset_data
->fontset_table
360 = (struct fontset_info
**) xrealloc (fontset_data
->fontset_table
,
361 fontset_data
->fontset_table_size
362 * sizeof (struct fontset_info
*));
364 fontset
= fontset_data
->n_fontsets
++;
365 fontset_data
->fontset_table
[fontset
] = fontsetp
;
370 /* Cache data used by fontset_pattern_regexp. The car part is a
371 pattern string containing at least one wild card, the cdr part is
372 the corresponding regular expression. */
373 static Lisp_Object Vcached_fontset_data
;
375 #define CACHED_FONTSET_NAME (XSTRING (XCONS (Vcached_fontset_data)->car)->data)
376 #define CACHED_FONTSET_REGEX (XCONS (Vcached_fontset_data)->cdr)
378 /* If fontset name PATTERN contains any wild card, return regular
379 expression corresponding to PATTERN. */
382 fontset_pattern_regexp (pattern
)
387 if (!index (XSTRING (pattern
)->data
, '*')
388 && !index (XSTRING (pattern
)->data
, '?'))
389 /* PATTERN does not contain any wild cards. */
391 if (XSTRING (pattern
)->size
> 8
392 && ! bcmp (XSTRING (pattern
)->data
, "fontset-", 8))
393 /* Just a nickname of a fontset is specified. */
399 if (!CONSP (Vcached_fontset_data
)
400 || strcmp (XSTRING (pattern
)->data
, CACHED_FONTSET_NAME
))
402 /* We must at first update the cached data. */
403 char *regex
= (char *) alloca (XSTRING (pattern
)->size
* 2 + 3);
404 char *p0
, *p1
= regex
;
408 /* Just prepend ".*-" to PATTERN. */
409 *p1
++= '.'; *p1
++= '*', *p1
++= '-';
410 bcopy (XSTRING (pattern
)->data
, p1
, XSTRING (pattern
)->size
);
411 p1
+= XSTRING (pattern
)->size
;
415 /* Convert "*" to ".*", "?" to ".". */
417 for (p0
= XSTRING (pattern
)->data
; *p0
; p0
++)
433 Vcached_fontset_data
= Fcons (build_string (XSTRING (pattern
)->data
),
434 build_string (regex
));
437 return CACHED_FONTSET_REGEX
;
440 DEFUN ("query-fontset", Fquery_fontset
, Squery_fontset
, 1, 1, 0,
441 "Return a fontset name which matches PATTERN, nil if no matching fontset.\n\
442 PATTERN can contain `*' or `?' as a wild card\n\
443 just like X's font name matching algorithm allows.")
447 Lisp_Object regexp
, tem
;
449 (*check_window_system_func
) ();
451 CHECK_STRING (pattern
, 0);
453 if (XSTRING (pattern
)->size
== 0)
456 regexp
= fontset_pattern_regexp (pattern
);
458 for (tem
= Vglobal_fontset_alist
; CONSP (tem
); tem
= XCONS (tem
)->cdr
)
460 Lisp_Object fontset_name
= XCONS (XCONS (tem
)->car
)->car
;
463 if (fast_string_match_ignore_case (regexp
,
464 XSTRING (fontset_name
)->data
)
470 if (!my_strcasecmp (XSTRING (pattern
)->data
,
471 XSTRING (fontset_name
)->data
))
479 Lisp_Object
Fframe_char_width ();
481 /* Return a list of names of available fontsets matching PATTERN on
482 frame F. If SIZE is not 0, it is the size (maximum bound width) of
483 fontsets to be listed. */
486 list_fontsets (f
, pattern
, size
)
492 Lisp_Object regexp
, val
;
494 regexp
= fontset_pattern_regexp (pattern
);
497 for (i
= 0; i
< FRAME_FONTSET_DATA (f
)->n_fontsets
; i
++)
499 struct fontset_info
*fontsetp
= FRAME_FONTSET_DATA (f
)->fontset_table
[i
];
500 int name_matched
= 0;
501 int size_matched
= 0;
505 if (fast_string_match_ignore_case (regexp
, fontsetp
->name
) >= 0)
510 if (!my_strcasecmp (XSTRING (pattern
)->data
, fontsetp
->name
))
516 if (!size
|| fontsetp
->size
== size
)
518 else if (fontsetp
->size
== 0)
520 /* No font of this fontset has loaded yet. Try loading
524 for (j
= 0; j
<= MAX_CHARSET
; j
++)
525 if (fontsetp
->fontname
[j
])
527 if ((*load_font_func
) (f
, fontsetp
->fontname
[j
], size
))
534 val
= Fcons (build_string (fontsetp
->name
), val
);
541 DEFUN ("new-fontset", Fnew_fontset
, Snew_fontset
, 2, 2, 0,
542 "Create a new fontset NAME which contains fonts in FONTLIST.\n\
543 FONTLIST is an alist of charsets vs corresponding font names.")
545 Lisp_Object name
, fontlist
;
547 Lisp_Object fullname
, fontset_info
;
550 (*check_window_system_func
) ();
552 CHECK_STRING (name
, 0);
553 CHECK_LIST (fontlist
, 1);
555 fullname
= Fquery_fontset (name
);
556 if (!NILP (fullname
))
557 error ("Fontset \"%s\" matches the existing fontset \"%s\"",
558 XSTRING (name
)->data
, XSTRING (fullname
)->data
);
560 /* Check the validity of FONTLIST. */
561 for (tail
= fontlist
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
563 Lisp_Object tem
= XCONS (tail
)->car
;
567 || (charset
= get_charset_id (XCONS (tem
)->car
)) < 0
568 || !STRINGP (XCONS (tem
)->cdr
))
569 error ("Elements of fontlist must be a cons of charset and font name");
572 fontset_info
= Fcons (name
, fontlist
);
573 Vglobal_fontset_alist
= Fcons (fontset_info
, Vglobal_fontset_alist
);
575 /* Register this fontset for all existing frames. */
577 Lisp_Object framelist
, frame
;
579 FOR_EACH_FRAME (framelist
, frame
)
580 if (!FRAME_TERMCAP_P (XFRAME (frame
)))
581 fs_register_fontset (XFRAME (frame
), fontset_info
);
587 extern Lisp_Object
Fframe_parameters ();
588 extern Lisp_Object Qfont
;
589 Lisp_Object Qfontset
;
591 DEFUN ("set-fontset-font", Fset_fontset_font
, Sset_fontset_font
, 3, 4, 0,
592 "Set FONTNAME for a font of CHARSET in fontset NAME on frame FRAME.\n\
593 If FRAME is omitted or nil, all frames are affected.")
594 (name
, charset_symbol
, fontname
, frame
)
595 Lisp_Object name
, charset_symbol
, fontname
, frame
;
598 Lisp_Object fullname
, fontlist
;
600 (*check_window_system_func
) ();
602 CHECK_STRING (name
, 0);
603 CHECK_SYMBOL (charset_symbol
, 1);
604 CHECK_STRING (fontname
, 2);
606 CHECK_LIVE_FRAME (frame
, 3);
608 if ((charset
= get_charset_id (charset_symbol
)) < 0)
609 error ("Invalid charset: %s", XSYMBOL (charset_symbol
)->name
->data
);
611 fullname
= Fquery_fontset (name
);
613 error ("Fontset \"%s\" does not exist", XSTRING (name
)->data
);
615 /* If FRAME is not specified, we must, at first, update contents of
616 `global-fontset-alist' for a frame created in the future. */
619 Lisp_Object fontset_info
= Fassoc (fullname
, Vglobal_fontset_alist
);
620 Lisp_Object tem
= Fassq (charset_symbol
, XCONS (fontset_info
)->cdr
);
623 XCONS (fontset_info
)->cdr
624 = Fcons (Fcons (charset_symbol
, fontname
),
625 XCONS (fontset_info
)->cdr
);
627 XCONS (tem
)->cdr
= fontname
;
630 /* Then, update information in the specified frame or all existing
633 Lisp_Object framelist
, tem
;
635 FOR_EACH_FRAME (framelist
, tem
)
636 if (!FRAME_TERMCAP_P (XFRAME (tem
))
637 && (NILP (frame
) || EQ (frame
, tem
)))
639 FRAME_PTR f
= XFRAME (tem
);
640 int fontset
= fs_query_fontset (f
, XSTRING (fullname
)->data
);
641 struct fontset_info
*fontsetp
642 = FRAME_FONTSET_DATA (f
)->fontset_table
[fontset
];
644 if (fontsetp
->fontname
[charset
])
645 xfree (fontsetp
->fontname
[charset
]);
646 fontsetp
->fontname
[charset
]
647 = (char *) xmalloc (XSTRING (fontname
)->size
+ 1);
648 bcopy (XSTRING (fontname
)->data
, fontsetp
->fontname
[charset
],
649 XSTRING (fontname
)->size
+ 1);
650 fontsetp
->font_indexes
[charset
] = FONT_NOT_OPENED
;
652 if (charset
== CHARSET_ASCII
)
654 Lisp_Object font_param
= Fassq (Qfont
, Fframe_parameters (tem
));
656 if (set_frame_fontset_func
657 && !NILP (font_param
)
658 && !strcmp (XSTRING (fullname
)->data
,
659 XSTRING (XCONS (font_param
)->cdr
)->data
))
660 /* This fontset is the default fontset on frame TEM.
661 We may have to resize this frame because of new
663 (*set_frame_fontset_func
) (f
, fullname
, Qnil
);
671 DEFUN ("font-info", Ffont_info
, Sfont_info
, 1, 2, 0,
672 "Return information about a font named NAME on frame FRAME.\n\
673 If FRAME is omitted or nil, use the selected frame.\n\
674 The returned value is a vector of OPENED-NAME, FULL-NAME, CHARSET, SIZE,\n\
675 HEIGHT, BASELINE-OFFSET, RELATIVE-COMPOSE, and DEFAULT-ASCENT,\n\
677 OPENED-NAME is the name used for opening the font,\n\
678 FULL-NAME is the full name of the font,\n\
679 CHARSET is the charset displayed by the font,\n\
680 SIZE is the minimum bound width of the font,\n\
681 HEIGHT is the height of the font,\n\
682 BASELINE-OFFSET is the upward offset pixels from ASCII baseline,\n\
683 RELATIVE-COMPOSE and DEFAULT-ASCENT are the numbers controlling\n\
684 how to compose characters.\n\
685 If the named font is not yet loaded, return nil.")
687 Lisp_Object name
, frame
;
690 struct font_info
*fontp
;
693 (*check_window_system_func
) ();
695 CHECK_STRING (name
, 0);
700 CHECK_LIVE_FRAME (frame
, 1);
704 if (!query_font_func
)
705 error ("Font query function is not supported");
707 fontp
= (*query_font_func
) (f
, XSTRING (name
)->data
);
711 info
= Fmake_vector (make_number (7), Qnil
);
713 XVECTOR (info
)->contents
[0] = build_string (fontp
->name
);
714 XVECTOR (info
)->contents
[1] = build_string (fontp
->full_name
);
715 XVECTOR (info
)->contents
[2] = CHARSET_SYMBOL (fontp
->charset
);
716 XVECTOR (info
)->contents
[3] = make_number (fontp
->size
);
717 XVECTOR (info
)->contents
[4] = make_number (fontp
->height
);
718 XVECTOR (info
)->contents
[5] = make_number (fontp
->baseline_offset
);
719 XVECTOR (info
)->contents
[6] = make_number (fontp
->relative_compose
);
720 XVECTOR (info
)->contents
[7] = make_number (fontp
->default_ascent
);
725 DEFUN ("fontset-info", Ffontset_info
, Sfontset_info
, 1, 2, 0,
726 "Return information about a fontset named NAME on frame FRAME.\n\
727 If FRAME is omitted or nil, use the selected frame.\n\
728 The returned value is a vector of SIZE, HEIGHT, and FONT-LIST,\n\
730 SIZE is the minimum bound width of ASCII font of the fontset,\n\
731 HEIGHT is the height of the tallest font in the fontset, and\n\
732 FONT-LIST is an alist of the format:\n\
733 (CHARSET REQUESTED-FONT-NAME LOADED-FONT-NAME).\n\
734 LOADED-FONT-NAME t means the font is not yet loaded, nil means the\n\
737 Lisp_Object name
, frame
;
741 struct fontset_info
*fontsetp
;
742 Lisp_Object info
, val
;
745 (*check_window_system_func
) ();
747 CHECK_STRING(name
, 0);
752 CHECK_LIVE_FRAME (frame
, 1);
756 fontset
= fs_query_fontset (f
, XSTRING (name
)->data
);
758 error ("Fontset \"%s\" does not exist", XSTRING (name
)->data
);
760 info
= Fmake_vector (make_number (3), Qnil
);
762 fontsetp
= FRAME_FONTSET_DATA (f
)->fontset_table
[fontset
];
764 XVECTOR (info
)->contents
[0] = make_number (fontsetp
->size
);
765 XVECTOR (info
)->contents
[1] = make_number (fontsetp
->height
);
767 for (i
= 0; i
<= MAX_CHARSET
; i
++)
768 if (fontsetp
->fontname
[i
])
770 int font_idx
= fontsetp
->font_indexes
[i
];
773 if (font_idx
== FONT_NOT_OPENED
)
775 else if (font_idx
== FONT_NOT_FOUND
)
779 = build_string ((*get_font_info_func
) (f
, font_idx
)->full_name
);
780 val
= Fcons (Fcons (CHARSET_SYMBOL (i
),
781 Fcons (build_string (fontsetp
->fontname
[i
]),
782 Fcons (loaded
, Qnil
))),
785 XVECTOR (info
)->contents
[2] = val
;
793 for (i
= 0; i
< 256; i
++)
794 my_strcasetbl
[i
] = (i
>= 'A' && i
<= 'Z') ? i
+ 'a' - 'A' : i
;
797 /* Window system initializer should have set proper functions. */
800 Qfontset
= intern ("fontset");
801 staticpro (&Qfontset
);
803 Vcached_fontset_data
= Qnil
;
804 staticpro (&Vcached_fontset_data
);
806 DEFVAR_LISP ("global-fontset-alist", &Vglobal_fontset_alist
,
807 "Internal data for fontset. Not for external use.\n\
808 This is an alist associating fontset names with the lists of fonts\n\
809 contained in them.\n\
810 Newly created frames make their own fontset database from here.");
811 Vglobal_fontset_alist
= Qnil
;
813 DEFVAR_LISP ("font-encoding-alist", &Vfont_encoding_alist
,
814 "Alist of fontname patterns vs corresponding encoding info.\n\
815 Each element looks like (REGEXP . ENCODING-INFO),\n\
816 where ENCODING-INFO is an alist of CHARSET vs ENCODING.\n\
817 ENCODING is one of the following integer values:\n\
818 0: code points 0x20..0x7F or 0x2020..0x7F7F are used,\n\
819 1: code points 0xA0..0xFF or 0xA0A0..0xFFFF are used,\n\
820 2: code points 0x20A0..0x7FFF are used,\n\
821 3: code points 0xA020..0xFF7F are used.");
822 Vfont_encoding_alist
= Qnil
;
824 DEFVAR_LISP ("use-default-ascent", &Vuse_default_ascent
,
825 "Char table of characters of which ascent values should be ignored.\n\
826 If an entry for a character is non-nil, the ascent value of the glyph\n\
827 is assumed to be what specified by _MULE_DEFAULT_ASCENT property of a font.");
828 Vuse_default_ascent
= Qnil
;
830 DEFVAR_LISP ("alternative-fontname-alist", &Valternative_fontname_alist
,
831 "Alist of fontname vs list of the alternative fontnames.
832 When no font can be opened by a fontname, the corresponding
833 alternative fontnames are tried.");
834 Valternative_fontname_alist
= Qnil
;
836 defsubr (&Squery_fontset
);
837 defsubr (&Snew_fontset
);
838 defsubr (&Sset_fontset_font
);
839 defsubr (&Sfont_info
);
840 defsubr (&Sfontset_info
);