2 Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN.
3 Licensed to the Free Software Foundation.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
25 #endif /* HAVE_ALLOCA_H */
32 Lisp_Object Vglobal_fontset_alist
;
33 Lisp_Object Vfont_encoding_alist
;
34 Lisp_Object Vuse_default_ascent
;
35 Lisp_Object Valternative_fontname_alist
;
36 Lisp_Object Vfontset_alias_alist
;
37 Lisp_Object Vhighlight_wrong_size_font
;
38 Lisp_Object Vclip_large_size_font
;
40 /* Used as a temporary in macro FS_LOAD_FONT. */
43 /* We had better have our own strcasecmp function because some system
45 static char my_strcasetbl
[256];
47 /* Compare two strings S0 and S1 while ignoring differences in case.
48 Return 1 if they differ, else return 0. */
50 my_strcasecmp (s0
, s1
)
51 unsigned char *s0
, *s1
;
54 if (my_strcasetbl
[*s0
++] != my_strcasetbl
[*s1
++]) return 1;
58 /* The following six are window system dependent functions. See
59 the comments in src/fontset.h for more detail. */
61 /* Return a pointer to struct font_info of font FONT_IDX of frame F. */
62 struct font_info
*(*get_font_info_func
) (/* FRAME_PTR f; int font_idx */);
64 /* Return a list of font names which matches PATTERN. See the document of
65 `x-list-fonts' for more detail. */
66 Lisp_Object (*list_fonts_func
) (/* Lisp_Object pattern, face, frame, width */);
68 /* Load a font named NAME for frame F and return a pointer to the
69 information of the loaded font. If loading is failed, return 0. */
70 struct font_info
*(*load_font_func
) (/* FRAME_PTR f; char *name */);
72 /* Return a pointer to struct font_info of a font named NAME for frame F. */
73 struct font_info
*(*query_font_func
) (/* FRAME_PTR f; char *name */);
75 /* Additional function for setting fontset or changing fontset
76 contents of frame F. */
77 void (*set_frame_fontset_func
) (/* FRAME_PTR f; Lisp_Object arg, oldval */);
79 /* Check if any window system is used now. */
80 void (*check_window_system_func
) ();
85 struct fontset_data
*fontset_data
86 = (struct fontset_data
*) xmalloc (sizeof (struct fontset_data
));
88 bzero (fontset_data
, sizeof (struct fontset_data
));
94 free_fontset_data (fontset_data
)
95 struct fontset_data
*fontset_data
;
99 for (i
= 0; i
< fontset_data
->n_fontsets
; i
++)
103 xfree (fontset_data
->fontset_table
[i
]->name
);
104 for (j
= 0; j
<= MAX_CHARSET
; j
++)
105 if (fontset_data
->fontset_table
[i
]->fontname
[j
])
106 xfree (fontset_data
->fontset_table
[i
]->fontname
[j
]);
107 xfree (fontset_data
->fontset_table
[i
]);
109 xfree (fontset_data
->fontset_table
);
111 xfree (fontset_data
);
114 /* Load a font named FONTNAME for displaying CHARSET on frame F.
115 All fonts for frame F is stored in a table pointed by FONT_TABLE.
116 Return a pointer to the struct font_info of the loaded font.
117 If loading fails, return 0;
118 If FONTNAME is NULL, the name is taken from the information of FONTSET.
119 If FONTSET is given, try to load a font whose size matches that of
120 FONTSET, and, the font index is stored in the table for FONTSET.
122 If you give FONTSET argument, don't call this function directry,
123 instead call macro FS_LOAD_FONT with the same argument. */
126 fs_load_font (f
, font_table
, charset
, fontname
, fontset
)
128 struct font_info
*font_table
;
129 int charset
, fontset
;
132 Lisp_Object font_list
;
133 Lisp_Object list
, elt
;
136 struct fontset_info
*fontsetp
= 0;
137 struct font_info
*fontp
;
139 if (fontset
>= 0 && fontset
< FRAME_FONTSET_DATA (f
)->n_fontsets
)
141 fontsetp
= FRAME_FONTSET_DATA (f
)->fontset_table
[fontset
];
142 font_idx
= fontsetp
->font_indexes
[charset
];
144 /* We have already loaded a font. */
145 return font_table
+ font_idx
;
146 else if (font_idx
== FONT_NOT_FOUND
)
147 /* We have already tried loading a font and failed. */
150 fontname
= fontsetp
->fontname
[charset
];
154 /* No way to get fontname. */
157 /* If CHARSET is not ASCII and FONTSET is specified, we must load a
158 font of appropriate size to be used with other fonts in this
160 if (charset
!= CHARSET_ASCII
&& fontsetp
)
162 /* If we have not yet loaded ASCII font of FONTSET, we must load
163 it now to decided the size and height of this fontset. */
164 if (fontsetp
->size
== 0)
166 fontp
= fs_load_font (f
, font_table
, CHARSET_ASCII
, 0, fontset
);
168 /* Any fontset should contain avairable ASCII. */
171 /* Now we have surely decided the size of this fontset. */
172 size
= fontsetp
->size
* CHARSET_WIDTH (charset
);
175 fontp
= (*load_font_func
) (f
, fontname
, size
);
180 fontsetp
->font_indexes
[charset
] = FONT_NOT_FOUND
;
184 /* Fill in fields (CHARSET, ENCODING, and FONT_ENCODER) which are
185 not set by (*load_font_func). */
186 fontp
->charset
= charset
;
188 if (fontp
->encoding
[1] != FONT_ENCODING_NOT_DECIDED
)
190 /* The font itself tells which code points to be used. Use this
191 encoding for all other charsets. */
194 fontp
->encoding
[0] = fontp
->encoding
[1];
195 for (i
= MIN_CHARSET_OFFICIAL_DIMENSION1
; i
<= MAX_CHARSET
; i
++)
196 fontp
->encoding
[i
] = fontp
->encoding
[1];
200 /* The font itself doesn't tell which code points to be used. */
203 /* At first, set 1 (means 0xA0..0xFF) as the default. */
204 fontp
->encoding
[0] = 1;
205 for (i
= MIN_CHARSET_OFFICIAL_DIMENSION1
; i
<= MAX_CHARSET
; i
++)
206 fontp
->encoding
[i
] = 1;
207 /* Then override them by a specification in Vfont_encoding_alist. */
208 for (list
= Vfont_encoding_alist
; CONSP (list
); list
= XCONS (list
)->cdr
)
210 elt
= XCONS (list
)->car
;
212 && STRINGP (XCONS (elt
)->car
) && CONSP (XCONS (elt
)->cdr
)
213 && (fast_c_string_match_ignore_case (XCONS (elt
)->car
, fontname
)
218 for (tmp
= XCONS (elt
)->cdr
; CONSP (tmp
); tmp
= XCONS (tmp
)->cdr
)
219 if (CONSP (XCONS (tmp
)->car
)
220 && ((i
= get_charset_id (XCONS (XCONS (tmp
)->car
)->car
))
222 && INTEGERP (XCONS (XCONS (tmp
)->car
)->cdr
)
223 && XFASTINT (XCONS (XCONS (tmp
)->car
)->cdr
) < 4)
225 = XFASTINT (XCONS (XCONS (tmp
)->car
)->cdr
);
230 fontp
->font_encoder
= (struct ccl_program
*) 0;
231 for (list
= Vfont_ccl_encoder_alist
; CONSP (list
); list
= XCONS (list
)->cdr
)
233 elt
= XCONS (list
)->car
;
235 && STRINGP (XCONS (elt
)->car
) && VECTORP (XCONS (elt
)->cdr
)
236 && fast_c_string_match_ignore_case (XCONS (elt
)->car
, fontname
) >= 0)
239 = (struct ccl_program
*) xmalloc (sizeof (struct ccl_program
));
240 setup_ccl_program (fontp
->font_encoder
, XCONS (elt
)->cdr
);
245 /* If FONTSET is specified, setup various fields of it. */
248 fontsetp
->font_indexes
[charset
] = fontp
->font_idx
;
249 if (charset
== CHARSET_ASCII
)
251 /* Decide or change the size and height of this fontset. */
252 if (fontsetp
->size
== 0)
254 fontsetp
->size
= fontp
->size
;
255 fontsetp
->height
= fontp
->height
;
257 else if (fontsetp
->size
!= fontp
->size
258 || fontsetp
->height
!= fontp
->height
)
260 /* When loading ASCII font of the different size from
261 the size of FONTSET, we have to update the size of
262 FONTSET. Since changing the size of FONTSET may make
263 some fonts already loaded inappropriate to be used in
264 FONTSET, we must delete the record of such fonts. In
265 that case, we also have to calculate the height of
266 FONTSET from the remaining fonts. */
269 fontsetp
->size
= fontp
->size
;
270 fontsetp
->height
= fontp
->height
;
271 for (i
= CHARSET_ASCII
+ 1; i
<= MAX_CHARSET
; i
++)
273 font_idx
= fontsetp
->font_indexes
[i
];
276 struct font_info
*fontp2
= font_table
+ font_idx
;
278 if (fontp2
->size
!= fontp
->size
* CHARSET_WIDTH (i
))
279 fontsetp
->font_indexes
[i
] = FONT_NOT_OPENED
;
280 /* The following code should be disabled until
281 Emacs supports variable height lines. */
283 else if (fontsetp
->height
< fontp
->height
)
284 fontsetp
->height
= fontp
->height
;
295 /* Return ID of the fontset named NAME on frame F. */
298 fs_query_fontset (f
, name
)
302 struct fontset_data
*fontset_data
= FRAME_FONTSET_DATA (f
);
305 for (i
= 0; i
< fontset_data
->n_fontsets
; i
++)
306 if (!my_strcasecmp(name
, fontset_data
->fontset_table
[i
]->name
))
311 /* Register a fontset specified by FONTSET_INFO for frame FRAME.
312 Return the fontset ID if successfully registered, else return -1.
313 FONTSET_INFO is a cons of name of the fontset and FONTLIST, where
314 FONTLIST is an alist of charsets vs fontnames. */
317 fs_register_fontset (f
, fontset_info
)
319 Lisp_Object fontset_info
;
321 struct fontset_data
*fontset_data
= FRAME_FONTSET_DATA (f
);
322 Lisp_Object name
, fontlist
;
324 struct fontset_info
*fontsetp
;
327 if (!CONSP (fontset_info
)
328 || !STRINGP (XCONS (fontset_info
)->car
)
329 || !CONSP (XCONS (fontset_info
)->cdr
))
330 /* Invalid data in FONTSET_INFO. */
333 name
= XCONS (fontset_info
)->car
;
334 if ((fontset
= fs_query_fontset (f
, XSTRING (name
)->data
)) >= 0)
335 /* This fontset already exists on frame F. */
338 fontsetp
= (struct fontset_info
*) xmalloc (sizeof (struct fontset_info
));
340 fontsetp
->name
= (char *) xmalloc (XSTRING (name
)->size
+ 1);
341 bcopy(XSTRING (name
)->data
, fontsetp
->name
, XSTRING (name
)->size
+ 1);
343 fontsetp
->size
= fontsetp
->height
= 0;
345 for (i
= 0; i
<= MAX_CHARSET
; i
++)
347 fontsetp
->fontname
[i
] = (char *) 0;
348 fontsetp
->font_indexes
[i
] = FONT_NOT_OPENED
;
351 for (fontlist
= XCONS (fontset_info
)->cdr
; CONSP (fontlist
);
352 fontlist
= XCONS (fontlist
)->cdr
)
354 Lisp_Object tem
= Fcar (fontlist
);
358 && (charset
= get_charset_id (XCONS (tem
)->car
)) >= 0
359 && STRINGP (XCONS (tem
)->cdr
))
361 fontsetp
->fontname
[charset
]
362 = (char *) xmalloc (XSTRING (XCONS (tem
)->cdr
)->size
+ 1);
363 bcopy (XSTRING (XCONS (tem
)->cdr
)->data
,
364 fontsetp
->fontname
[charset
],
365 XSTRING (XCONS (tem
)->cdr
)->size
+ 1);
368 /* Broken or invalid data structure. */
372 /* Do we need to create the table? */
373 if (fontset_data
->fontset_table_size
== 0)
375 fontset_data
->fontset_table_size
= 8;
376 fontset_data
->fontset_table
377 = (struct fontset_info
**) xmalloc (fontset_data
->fontset_table_size
378 * sizeof (struct fontset_info
*));
380 /* Do we need to grow the table? */
381 else if (fontset_data
->n_fontsets
>= fontset_data
->fontset_table_size
)
383 fontset_data
->fontset_table_size
+= 8;
384 fontset_data
->fontset_table
385 = (struct fontset_info
**) xrealloc (fontset_data
->fontset_table
,
386 fontset_data
->fontset_table_size
387 * sizeof (struct fontset_info
*));
389 fontset
= fontset_data
->n_fontsets
++;
390 fontset_data
->fontset_table
[fontset
] = fontsetp
;
395 /* Cache data used by fontset_pattern_regexp. The car part is a
396 pattern string containing at least one wild card, the cdr part is
397 the corresponding regular expression. */
398 static Lisp_Object Vcached_fontset_data
;
400 #define CACHED_FONTSET_NAME (XSTRING (XCONS (Vcached_fontset_data)->car)->data)
401 #define CACHED_FONTSET_REGEX (XCONS (Vcached_fontset_data)->cdr)
403 /* If fontset name PATTERN contains any wild card, return regular
404 expression corresponding to PATTERN. */
407 fontset_pattern_regexp (pattern
)
410 if (!index (XSTRING (pattern
)->data
, '*')
411 && !index (XSTRING (pattern
)->data
, '?'))
412 /* PATTERN does not contain any wild cards. */
415 if (!CONSP (Vcached_fontset_data
)
416 || strcmp (XSTRING (pattern
)->data
, CACHED_FONTSET_NAME
))
418 /* We must at first update the cached data. */
419 char *regex
= (char *) alloca (XSTRING (pattern
)->size
* 2);
420 char *p0
, *p1
= regex
;
422 /* Convert "*" to ".*", "?" to ".". */
424 for (p0
= (char *) XSTRING (pattern
)->data
; *p0
; p0
++)
439 Vcached_fontset_data
= Fcons (build_string (XSTRING (pattern
)->data
),
440 build_string (regex
));
443 return CACHED_FONTSET_REGEX
;
446 DEFUN ("query-fontset", Fquery_fontset
, Squery_fontset
, 1, 1, 0,
447 "Return a fontset name which matches PATTERN, nil if no matching fontset.\n\
448 PATTERN can contain `*' or `?' as a wild card\n\
449 just like X's font name matching algorithm allows.")
453 Lisp_Object regexp
, tem
;
455 (*check_window_system_func
) ();
457 CHECK_STRING (pattern
, 0);
459 if (XSTRING (pattern
)->size
== 0)
462 tem
= Frassoc (pattern
, Vfontset_alias_alist
);
466 regexp
= fontset_pattern_regexp (pattern
);
468 for (tem
= Vglobal_fontset_alist
; CONSP (tem
); tem
= XCONS (tem
)->cdr
)
470 Lisp_Object fontset_name
= XCONS (XCONS (tem
)->car
)->car
;
473 if (fast_c_string_match_ignore_case (regexp
,
474 XSTRING (fontset_name
)->data
)
480 if (!my_strcasecmp (XSTRING (pattern
)->data
,
481 XSTRING (fontset_name
)->data
))
489 Lisp_Object
Fframe_char_width ();
491 /* Return a list of names of available fontsets matching PATTERN on
492 frame F. If SIZE is not 0, it is the size (maximum bound width) of
493 fontsets to be listed. */
496 list_fontsets (f
, pattern
, size
)
502 Lisp_Object regexp
, val
;
504 regexp
= fontset_pattern_regexp (pattern
);
507 for (i
= 0; i
< FRAME_FONTSET_DATA (f
)->n_fontsets
; i
++)
509 struct fontset_info
*fontsetp
= FRAME_FONTSET_DATA (f
)->fontset_table
[i
];
510 int name_matched
= 0;
511 int size_matched
= 0;
515 if (fast_c_string_match_ignore_case (regexp
, fontsetp
->name
) >= 0)
520 if (!my_strcasecmp (XSTRING (pattern
)->data
, fontsetp
->name
))
526 if (!size
|| fontsetp
->size
== size
)
528 else if (fontsetp
->size
== 0)
530 /* No font of this fontset has loaded yet. Try loading
534 for (j
= 0; j
<= MAX_CHARSET
; j
++)
535 if (fontsetp
->fontname
[j
])
537 if ((*load_font_func
) (f
, fontsetp
->fontname
[j
], size
))
544 val
= Fcons (build_string (fontsetp
->name
), val
);
551 DEFUN ("new-fontset", Fnew_fontset
, Snew_fontset
, 2, 2, 0,
552 "Create a new fontset NAME which contains fonts in FONTLIST.\n\
553 FONTLIST is an alist of charsets vs corresponding font names.")
555 Lisp_Object name
, fontlist
;
557 Lisp_Object fullname
, fontset_info
;
560 (*check_window_system_func
) ();
562 CHECK_STRING (name
, 0);
563 CHECK_LIST (fontlist
, 1);
565 fullname
= Fquery_fontset (name
);
566 if (!NILP (fullname
))
567 error ("Fontset \"%s\" matches the existing fontset \"%s\"",
568 XSTRING (name
)->data
, XSTRING (fullname
)->data
);
570 /* Check the validity of FONTLIST. */
571 for (tail
= fontlist
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
573 Lisp_Object tem
= XCONS (tail
)->car
;
577 || (charset
= get_charset_id (XCONS (tem
)->car
)) < 0
578 || !STRINGP (XCONS (tem
)->cdr
))
579 error ("Elements of fontlist must be a cons of charset and font name");
582 fontset_info
= Fcons (name
, fontlist
);
583 Vglobal_fontset_alist
= Fcons (fontset_info
, Vglobal_fontset_alist
);
585 /* Register this fontset for all existing frames. */
587 Lisp_Object framelist
, frame
;
589 FOR_EACH_FRAME (framelist
, frame
)
590 if (!FRAME_TERMCAP_P (XFRAME (frame
)))
591 fs_register_fontset (XFRAME (frame
), fontset_info
);
597 extern Lisp_Object
Fframe_parameters ();
598 extern Lisp_Object Qfont
;
599 Lisp_Object Qfontset
;
601 DEFUN ("set-fontset-font", Fset_fontset_font
, Sset_fontset_font
, 3, 4, 0,
602 "Set FONTNAME for a font of CHARSET in fontset NAME on frame FRAME.\n\
603 If FRAME is omitted or nil, all frames are affected.")
604 (name
, charset_symbol
, fontname
, frame
)
605 Lisp_Object name
, charset_symbol
, fontname
, frame
;
608 Lisp_Object fullname
, fontlist
;
610 (*check_window_system_func
) ();
612 CHECK_STRING (name
, 0);
613 CHECK_SYMBOL (charset_symbol
, 1);
614 CHECK_STRING (fontname
, 2);
616 CHECK_LIVE_FRAME (frame
, 3);
618 if ((charset
= get_charset_id (charset_symbol
)) < 0)
619 error ("Invalid charset: %s", XSYMBOL (charset_symbol
)->name
->data
);
621 fullname
= Fquery_fontset (name
);
623 error ("Fontset \"%s\" does not exist", XSTRING (name
)->data
);
625 /* If FRAME is not specified, we must, at first, update contents of
626 `global-fontset-alist' for a frame created in the future. */
629 Lisp_Object fontset_info
= Fassoc (fullname
, Vglobal_fontset_alist
);
630 Lisp_Object tem
= Fassq (charset_symbol
, XCONS (fontset_info
)->cdr
);
633 XCONS (fontset_info
)->cdr
634 = Fcons (Fcons (charset_symbol
, fontname
),
635 XCONS (fontset_info
)->cdr
);
637 XCONS (tem
)->cdr
= fontname
;
640 /* Then, update information in the specified frame or all existing
643 Lisp_Object framelist
, tem
;
645 FOR_EACH_FRAME (framelist
, tem
)
646 if (!FRAME_TERMCAP_P (XFRAME (tem
))
647 && (NILP (frame
) || EQ (frame
, tem
)))
649 FRAME_PTR f
= XFRAME (tem
);
650 int fontset
= fs_query_fontset (f
, XSTRING (fullname
)->data
);
651 struct fontset_info
*fontsetp
652 = FRAME_FONTSET_DATA (f
)->fontset_table
[fontset
];
654 if (fontsetp
->fontname
[charset
])
655 xfree (fontsetp
->fontname
[charset
]);
656 fontsetp
->fontname
[charset
]
657 = (char *) xmalloc (XSTRING (fontname
)->size
+ 1);
658 bcopy (XSTRING (fontname
)->data
, fontsetp
->fontname
[charset
],
659 XSTRING (fontname
)->size
+ 1);
660 fontsetp
->font_indexes
[charset
] = FONT_NOT_OPENED
;
662 if (charset
== CHARSET_ASCII
)
664 Lisp_Object font_param
= Fassq (Qfont
, Fframe_parameters (tem
));
666 if (set_frame_fontset_func
667 && !NILP (font_param
)
668 && !strcmp (XSTRING (fullname
)->data
,
669 XSTRING (XCONS (font_param
)->cdr
)->data
))
670 /* This fontset is the default fontset on frame TEM.
671 We may have to resize this frame because of new
673 (*set_frame_fontset_func
) (f
, fullname
, Qnil
);
681 DEFUN ("font-info", Ffont_info
, Sfont_info
, 1, 2, 0,
682 "Return information about a font named NAME on frame FRAME.\n\
683 If FRAME is omitted or nil, use the selected frame.\n\
684 The returned value is a vector of OPENED-NAME, FULL-NAME, CHARSET, SIZE,\n\
685 HEIGHT, BASELINE-OFFSET, RELATIVE-COMPOSE, and DEFAULT-ASCENT,\n\
687 OPENED-NAME is the name used for opening the font,\n\
688 FULL-NAME is the full name of the font,\n\
689 CHARSET is the charset displayed by the font,\n\
690 SIZE is the minimum bound width of the font,\n\
691 HEIGHT is the height of the font,\n\
692 BASELINE-OFFSET is the upward offset pixels from ASCII baseline,\n\
693 RELATIVE-COMPOSE and DEFAULT-ASCENT are the numbers controlling\n\
694 how to compose characters.\n\
695 If the named font is not yet loaded, return nil.")
697 Lisp_Object name
, frame
;
700 struct font_info
*fontp
;
703 (*check_window_system_func
) ();
705 CHECK_STRING (name
, 0);
710 CHECK_LIVE_FRAME (frame
, 1);
714 if (!query_font_func
)
715 error ("Font query function is not supported");
717 fontp
= (*query_font_func
) (f
, XSTRING (name
)->data
);
721 info
= Fmake_vector (make_number (8), Qnil
);
723 XVECTOR (info
)->contents
[0] = build_string (fontp
->name
);
724 XVECTOR (info
)->contents
[1] = build_string (fontp
->full_name
);
725 XVECTOR (info
)->contents
[2] = CHARSET_SYMBOL (fontp
->charset
);
726 XVECTOR (info
)->contents
[3] = make_number (fontp
->size
);
727 XVECTOR (info
)->contents
[4] = make_number (fontp
->height
);
728 XVECTOR (info
)->contents
[5] = make_number (fontp
->baseline_offset
);
729 XVECTOR (info
)->contents
[6] = make_number (fontp
->relative_compose
);
730 XVECTOR (info
)->contents
[7] = make_number (fontp
->default_ascent
);
735 DEFUN ("fontset-info", Ffontset_info
, Sfontset_info
, 1, 2, 0,
736 "Return information about a fontset named NAME on frame FRAME.\n\
737 If FRAME is omitted or nil, use the selected frame.\n\
738 The returned value is a vector of SIZE, HEIGHT, and FONT-LIST,\n\
740 SIZE is the minimum bound width of ASCII font of the fontset,\n\
741 HEIGHT is the height of the tallest font in the fontset, and\n\
742 FONT-LIST is an alist of the format:\n\
743 (CHARSET REQUESTED-FONT-NAME LOADED-FONT-NAME).\n\
744 LOADED-FONT-NAME t means the font is not yet loaded, nil means the\n\
747 Lisp_Object name
, frame
;
751 struct fontset_info
*fontsetp
;
752 Lisp_Object info
, val
;
755 (*check_window_system_func
) ();
757 CHECK_STRING(name
, 0);
762 CHECK_LIVE_FRAME (frame
, 1);
766 fontset
= fs_query_fontset (f
, XSTRING (name
)->data
);
768 error ("Fontset \"%s\" does not exist", XSTRING (name
)->data
);
770 info
= Fmake_vector (make_number (3), Qnil
);
772 fontsetp
= FRAME_FONTSET_DATA (f
)->fontset_table
[fontset
];
774 XVECTOR (info
)->contents
[0] = make_number (fontsetp
->size
);
775 XVECTOR (info
)->contents
[1] = make_number (fontsetp
->height
);
777 for (i
= 0; i
<= MAX_CHARSET
; i
++)
778 if (fontsetp
->fontname
[i
])
780 int font_idx
= fontsetp
->font_indexes
[i
];
783 if (font_idx
== FONT_NOT_OPENED
)
785 else if (font_idx
== FONT_NOT_FOUND
)
789 = build_string ((*get_font_info_func
) (f
, font_idx
)->full_name
);
790 val
= Fcons (Fcons (CHARSET_SYMBOL (i
),
791 Fcons (build_string (fontsetp
->fontname
[i
]),
792 Fcons (loaded
, Qnil
))),
795 XVECTOR (info
)->contents
[2] = val
;
803 for (i
= 0; i
< 256; i
++)
804 my_strcasetbl
[i
] = (i
>= 'A' && i
<= 'Z') ? i
+ 'a' - 'A' : i
;
807 /* Window system initializer should have set proper functions. */
810 Qfontset
= intern ("fontset");
811 staticpro (&Qfontset
);
813 Vcached_fontset_data
= Qnil
;
814 staticpro (&Vcached_fontset_data
);
816 DEFVAR_LISP ("global-fontset-alist", &Vglobal_fontset_alist
,
817 "Internal data for fontset. Not for external use.\n\
818 This is an alist associating fontset names with the lists of fonts\n\
819 contained in them.\n\
820 Newly created frames make their own fontset database from here.");
821 Vglobal_fontset_alist
= Qnil
;
823 DEFVAR_LISP ("font-encoding-alist", &Vfont_encoding_alist
,
824 "Alist of fontname patterns vs corresponding encoding info.\n\
825 Each element looks like (REGEXP . ENCODING-INFO),\n\
826 where ENCODING-INFO is an alist of CHARSET vs ENCODING.\n\
827 ENCODING is one of the following integer values:\n\
828 0: code points 0x20..0x7F or 0x2020..0x7F7F are used,\n\
829 1: code points 0xA0..0xFF or 0xA0A0..0xFFFF are used,\n\
830 2: code points 0x20A0..0x7FFF are used,\n\
831 3: code points 0xA020..0xFF7F are used.");
832 Vfont_encoding_alist
= Qnil
;
834 DEFVAR_LISP ("use-default-ascent", &Vuse_default_ascent
,
835 "Char table of characters of which ascent values should be ignored.\n\
836 If an entry for a character is non-nil, the ascent value of the glyph\n\
837 is assumed to be what specified by _MULE_DEFAULT_ASCENT property of a font.");
838 Vuse_default_ascent
= Qnil
;
840 DEFVAR_LISP ("alternative-fontname-alist", &Valternative_fontname_alist
,
841 "Alist of fontname vs list of the alternative fontnames.\n\
842 When no font can be opened by a fontname, the corresponding\n\
843 alternative fontnames are tried.");
844 Valternative_fontname_alist
= Qnil
;
846 DEFVAR_LISP ("fontset-alias-alist", &Vfontset_alias_alist
,
847 "Alist of fontset names vs the aliases.");
848 Vfontset_alias_alist
= Qnil
;
850 DEFVAR_LISP ("highlight-wrong-size-font", &Vhighlight_wrong_size_font
,
851 "*Non-nil means highlight characters shown in wrong size fonts somehow.\n\
852 The way to highlight them depends on window system on which Emacs runs.\n\
853 On X window, a rectangle is shown around each such character.");
854 Vhighlight_wrong_size_font
= Qt
;
856 DEFVAR_LISP ("clip-large-size-font", &Vclip_large_size_font
,
857 "*Non-nil means characters shown in large size fonts are clipped.\n\
858 The height of clipping area is the same as that of an ASCII character.\n\
859 The width of the area is the same as that of an ASCII character or\n\
860 twice wider than that of an ASCII character depending on\n\
861 the width (i.e. column numbers occupied on screen) of the character set\n\
864 In the case that you only have too large size font for a specific\n\
865 charscter set, and clipping characters of the character set makes them\n\
866 almost unreadable, you can set this variable to t to see the\n\
867 characters in exchage for garbage dots left on your screen.");
868 Vclip_large_size_font
= Qt
;
870 defsubr (&Squery_fontset
);
871 defsubr (&Snew_fontset
);
872 defsubr (&Sset_fontset_font
);
873 defsubr (&Sfont_info
);
874 defsubr (&Sfontset_info
);