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 /* We had better have our own strcasecmp function because some system
42 static char my_strcasetbl
[256];
44 /* Compare two strings S0 and S1 while ignoring differences in case.
45 Return 1 if they differ, else return 0. */
47 my_strcasecmp (s0
, s1
)
48 unsigned char *s0
, *s1
;
51 if (my_strcasetbl
[*s0
++] != my_strcasetbl
[*s1
++]) return 1;
55 /* The following six are window system dependent functions. See
56 the comments in src/fontset.h for more detail. */
58 /* Return a pointer to struct font_info of font FONT_IDX of frame F. */
59 struct font_info
*(*get_font_info_func
) (/* FRAME_PTR f; int font_idx */);
61 /* Return a list of font names which matches PATTERN. See the document of
62 `x-list-fonts' for more detail. */
63 Lisp_Object (*list_fonts_func
) (/* Lisp_Object pattern, face, frame, width */);
65 /* Load a font named NAME for frame F and return a pointer to the
66 information of the loaded font. If loading is failed, return 0. */
67 struct font_info
*(*load_font_func
) (/* FRAME_PTR f; char *name */);
69 /* Return a pointer to struct font_info of a font named NAME for frame F. */
70 struct font_info
*(*query_font_func
) (/* FRAME_PTR f; char *name */);
72 /* Additional function for setting fontset or changing fontset
73 contents of frame F. */
74 void (*set_frame_fontset_func
) (/* FRAME_PTR f; Lisp_Object arg, oldval */);
76 /* Check if any window system is used now. */
77 void (*check_window_system_func
) ();
82 struct fontset_data
*fontset_data
83 = (struct fontset_data
*) xmalloc (sizeof (struct fontset_data
));
85 bzero (fontset_data
, sizeof (struct fontset_data
));
91 free_fontset_data (fontset_data
)
92 struct fontset_data
*fontset_data
;
96 for (i
= 0; i
< fontset_data
->n_fontsets
; i
++)
100 xfree (fontset_data
->fontset_table
[i
]->name
);
101 for (j
= 0; j
<= MAX_CHARSET
; j
++)
102 if (fontset_data
->fontset_table
[i
]->fontname
[j
])
103 xfree (fontset_data
->fontset_table
[i
]->fontname
[j
]);
104 xfree (fontset_data
->fontset_table
[i
]);
106 xfree (fontset_data
->fontset_table
);
108 xfree (fontset_data
);
111 /* Load a font named FONTNAME for displaying CHARSET on frame F.
112 All fonts for frame F is stored in a table pointed by FONT_TABLE.
113 Return a pointer to the struct font_info of the loaded font.
114 If loading fails, return 0;
115 If FONTNAME is NULL, the name is taken from the information of FONTSET.
116 If FONTSET is given, try to load a font whose size matches that of
117 FONTSET, and, the font index is stored in the table for FONTSET. */
120 fs_load_font (f
, font_table
, charset
, fontname
, fontset
)
122 struct font_info
*font_table
;
123 int charset
, fontset
;
126 Lisp_Object font_list
;
127 Lisp_Object list
, elt
;
130 struct fontset_info
*fontsetp
= 0;
131 struct font_info
*fontp
;
133 if (fontset
>= 0 && fontset
< FRAME_FONTSET_DATA (f
)->n_fontsets
)
135 fontsetp
= FRAME_FONTSET_DATA (f
)->fontset_table
[fontset
];
136 font_idx
= fontsetp
->font_indexes
[charset
];
138 /* We have already loaded a font. */
139 return font_table
+ font_idx
;
140 else if (font_idx
== FONT_NOT_FOUND
)
141 /* We have already tried loading a font and failed. */
144 fontname
= fontsetp
->fontname
[charset
];
148 /* No way to get fontname. */
151 /* If CHARSET is not ASCII and FONTSET is specified, we must load a
152 font of appropriate size to be used with other fonts in this
154 if (charset
!= CHARSET_ASCII
&& fontsetp
)
156 /* If we have not yet loaded ASCII font of FONTSET, we must load
157 it now to decided the size and height of this fontset. */
158 if (fontsetp
->size
== 0)
160 fontp
= fs_load_font (f
, font_table
, CHARSET_ASCII
, 0, fontset
);
162 /* Any fontset should contain avairable ASCII. */
165 /* Now we have surely decided the size of this fontset. */
166 size
= fontsetp
->size
* CHARSET_WIDTH (charset
);
169 fontp
= (*load_font_func
) (f
, fontname
, size
);
174 fontsetp
->font_indexes
[charset
] = FONT_NOT_FOUND
;
178 /* Fill in fields (CHARSET, ENCODING, and FONT_ENCODER) which are
179 not set by (*load_font_func). */
180 fontp
->charset
= charset
;
182 if (fontp
->encoding
[1] != FONT_ENCODING_NOT_DECIDED
)
184 /* The font itself tells which code points to be used. Use this
185 encoding for all other charsets. */
188 fontp
->encoding
[0] = fontp
->encoding
[1];
189 for (i
= MIN_CHARSET_OFFICIAL_DIMENSION1
; i
<= MAX_CHARSET
; i
++)
190 fontp
->encoding
[i
] = fontp
->encoding
[1];
194 /* The font itself doesn't tell which code points to be used. */
197 /* At first, set 1 (means 0xA0..0xFF) as the default. */
198 fontp
->encoding
[0] = 1;
199 for (i
= MIN_CHARSET_OFFICIAL_DIMENSION1
; i
<= MAX_CHARSET
; i
++)
200 fontp
->encoding
[i
] = 1;
201 /* Then override them by a specification in Vfont_encoding_alist. */
202 for (list
= Vfont_encoding_alist
; CONSP (list
); list
= XCONS (list
)->cdr
)
204 elt
= XCONS (list
)->car
;
206 && STRINGP (XCONS (elt
)->car
) && CONSP (XCONS (elt
)->cdr
)
207 && (fast_c_string_match_ignore_case (XCONS (elt
)->car
, fontname
)
212 for (tmp
= XCONS (elt
)->cdr
; CONSP (tmp
); tmp
= XCONS (tmp
)->cdr
)
213 if (CONSP (XCONS (tmp
)->car
)
214 && ((i
= get_charset_id (XCONS (XCONS (tmp
)->car
)->car
))
216 && INTEGERP (XCONS (XCONS (tmp
)->car
)->cdr
)
217 && XFASTINT (XCONS (XCONS (tmp
)->car
)->cdr
) < 4)
219 = XFASTINT (XCONS (XCONS (tmp
)->car
)->cdr
);
224 fontp
->font_encoder
= (struct ccl_program
*) 0;
225 for (list
= Vfont_ccl_encoder_alist
; CONSP (list
); list
= XCONS (list
)->cdr
)
227 elt
= XCONS (list
)->car
;
229 && STRINGP (XCONS (elt
)->car
) && VECTORP (XCONS (elt
)->cdr
)
230 && fast_c_string_match_ignore_case (XCONS (elt
)->car
, fontname
) >= 0)
233 = (struct ccl_program
*) xmalloc (sizeof (struct ccl_program
));
234 setup_ccl_program (fontp
->font_encoder
, XCONS (elt
)->cdr
);
239 /* If FONTSET is specified, setup various fields of it. */
242 fontsetp
->font_indexes
[charset
] = fontp
->font_idx
;
243 if (charset
== CHARSET_ASCII
)
245 /* Decide or change the size and height of this fontset. */
246 if (fontsetp
->size
== 0)
248 fontsetp
->size
= fontp
->size
;
249 fontsetp
->height
= fontp
->height
;
251 else if (fontsetp
->size
!= fontp
->size
252 || fontsetp
->height
!= fontp
->height
)
254 /* When loading ASCII font of the different size from
255 the size of FONTSET, we have to update the size of
256 FONTSET. Since changing the size of FONTSET may make
257 some fonts already loaded inappropriate to be used in
258 FONTSET, we must delete the record of such fonts. In
259 that case, we also have to calculate the height of
260 FONTSET from the remaining fonts. */
263 fontsetp
->size
= fontp
->size
;
264 fontsetp
->height
= fontp
->height
;
265 for (i
= CHARSET_ASCII
+ 1; i
<= MAX_CHARSET
; i
++)
267 font_idx
= fontsetp
->font_indexes
[i
];
270 struct font_info
*fontp2
= font_table
+ font_idx
;
272 if (fontp2
->size
!= fontp
->size
* CHARSET_WIDTH (i
))
273 fontsetp
->font_indexes
[i
] = FONT_NOT_OPENED
;
274 /* The following code should be disabled until
275 Emacs supports variable height lines. */
277 else if (fontsetp
->height
< fontp
->height
)
278 fontsetp
->height
= fontp
->height
;
289 /* Return ID of the fontset named NAME on frame F. */
292 fs_query_fontset (f
, name
)
296 struct fontset_data
*fontset_data
= FRAME_FONTSET_DATA (f
);
299 for (i
= 0; i
< fontset_data
->n_fontsets
; i
++)
300 if (!my_strcasecmp(name
, fontset_data
->fontset_table
[i
]->name
))
305 /* Register a fontset specified by FONTSET_INFO for frame FRAME.
306 Return the fontset ID if successfully registered, else return -1.
307 FONTSET_INFO is a cons of name of the fontset and FONTLIST, where
308 FONTLIST is an alist of charsets vs fontnames. */
311 fs_register_fontset (f
, fontset_info
)
313 Lisp_Object fontset_info
;
315 struct fontset_data
*fontset_data
= FRAME_FONTSET_DATA (f
);
316 Lisp_Object name
, fontlist
;
318 struct fontset_info
*fontsetp
;
321 if (!CONSP (fontset_info
)
322 || !STRINGP (XCONS (fontset_info
)->car
)
323 || !CONSP (XCONS (fontset_info
)->cdr
))
324 /* Invalid data in FONTSET_INFO. */
327 name
= XCONS (fontset_info
)->car
;
328 if ((fontset
= fs_query_fontset (f
, XSTRING (name
)->data
)) >= 0)
329 /* This fontset already exists on frame F. */
332 fontsetp
= (struct fontset_info
*) xmalloc (sizeof (struct fontset_info
));
334 fontsetp
->name
= (char *) xmalloc (XSTRING (name
)->size
+ 1);
335 bcopy(XSTRING (name
)->data
, fontsetp
->name
, XSTRING (name
)->size
+ 1);
337 fontsetp
->size
= fontsetp
->height
= 0;
339 for (i
= 0; i
<= MAX_CHARSET
; i
++)
341 fontsetp
->fontname
[i
] = (char *) 0;
342 fontsetp
->font_indexes
[i
] = FONT_NOT_OPENED
;
345 for (fontlist
= XCONS (fontset_info
)->cdr
; CONSP (fontlist
);
346 fontlist
= XCONS (fontlist
)->cdr
)
348 Lisp_Object tem
= Fcar (fontlist
);
352 && (charset
= get_charset_id (XCONS (tem
)->car
)) >= 0
353 && STRINGP (XCONS (tem
)->cdr
))
355 fontsetp
->fontname
[charset
]
356 = (char *) xmalloc (XSTRING (XCONS (tem
)->cdr
)->size
+ 1);
357 bcopy (XSTRING (XCONS (tem
)->cdr
)->data
,
358 fontsetp
->fontname
[charset
],
359 XSTRING (XCONS (tem
)->cdr
)->size
+ 1);
362 /* Broken or invalid data structure. */
366 /* Do we need to create the table? */
367 if (fontset_data
->fontset_table_size
== 0)
369 fontset_data
->fontset_table_size
= 8;
370 fontset_data
->fontset_table
371 = (struct fontset_info
**) xmalloc (fontset_data
->fontset_table_size
372 * sizeof (struct fontset_info
*));
374 /* Do we need to grow the table? */
375 else if (fontset_data
->n_fontsets
>= fontset_data
->fontset_table_size
)
377 fontset_data
->fontset_table_size
+= 8;
378 fontset_data
->fontset_table
379 = (struct fontset_info
**) xrealloc (fontset_data
->fontset_table
,
380 fontset_data
->fontset_table_size
381 * sizeof (struct fontset_info
*));
383 fontset
= fontset_data
->n_fontsets
++;
384 fontset_data
->fontset_table
[fontset
] = fontsetp
;
389 /* Cache data used by fontset_pattern_regexp. The car part is a
390 pattern string containing at least one wild card, the cdr part is
391 the corresponding regular expression. */
392 static Lisp_Object Vcached_fontset_data
;
394 #define CACHED_FONTSET_NAME (XSTRING (XCONS (Vcached_fontset_data)->car)->data)
395 #define CACHED_FONTSET_REGEX (XCONS (Vcached_fontset_data)->cdr)
397 /* If fontset name PATTERN contains any wild card, return regular
398 expression corresponding to PATTERN. */
401 fontset_pattern_regexp (pattern
)
404 if (!index (XSTRING (pattern
)->data
, '*')
405 && !index (XSTRING (pattern
)->data
, '?'))
406 /* PATTERN does not contain any wild cards. */
409 if (!CONSP (Vcached_fontset_data
)
410 || strcmp (XSTRING (pattern
)->data
, CACHED_FONTSET_NAME
))
412 /* We must at first update the cached data. */
413 char *regex
= (char *) alloca (XSTRING (pattern
)->size
* 2);
414 char *p0
, *p1
= regex
;
416 /* Convert "*" to ".*", "?" to ".". */
418 for (p0
= (char *) 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 tem
= Frassoc (pattern
, Vfontset_alias_alist
);
460 regexp
= fontset_pattern_regexp (pattern
);
462 for (tem
= Vglobal_fontset_alist
; CONSP (tem
); tem
= XCONS (tem
)->cdr
)
464 Lisp_Object fontset_name
= XCONS (XCONS (tem
)->car
)->car
;
467 if (fast_c_string_match_ignore_case (regexp
,
468 XSTRING (fontset_name
)->data
)
474 if (!my_strcasecmp (XSTRING (pattern
)->data
,
475 XSTRING (fontset_name
)->data
))
483 Lisp_Object
Fframe_char_width ();
485 /* Return a list of names of available fontsets matching PATTERN on
486 frame F. If SIZE is not 0, it is the size (maximum bound width) of
487 fontsets to be listed. */
490 list_fontsets (f
, pattern
, size
)
496 Lisp_Object regexp
, val
;
498 regexp
= fontset_pattern_regexp (pattern
);
501 for (i
= 0; i
< FRAME_FONTSET_DATA (f
)->n_fontsets
; i
++)
503 struct fontset_info
*fontsetp
= FRAME_FONTSET_DATA (f
)->fontset_table
[i
];
504 int name_matched
= 0;
505 int size_matched
= 0;
509 if (fast_c_string_match_ignore_case (regexp
, fontsetp
->name
) >= 0)
514 if (!my_strcasecmp (XSTRING (pattern
)->data
, fontsetp
->name
))
520 if (!size
|| fontsetp
->size
== size
)
522 else if (fontsetp
->size
== 0)
524 /* No font of this fontset has loaded yet. Try loading
528 for (j
= 0; j
<= MAX_CHARSET
; j
++)
529 if (fontsetp
->fontname
[j
])
531 if ((*load_font_func
) (f
, fontsetp
->fontname
[j
], size
))
538 val
= Fcons (build_string (fontsetp
->name
), val
);
545 DEFUN ("new-fontset", Fnew_fontset
, Snew_fontset
, 2, 2, 0,
546 "Create a new fontset NAME which contains fonts in FONTLIST.\n\
547 FONTLIST is an alist of charsets vs corresponding font names.")
549 Lisp_Object name
, fontlist
;
551 Lisp_Object fullname
, fontset_info
;
554 (*check_window_system_func
) ();
556 CHECK_STRING (name
, 0);
557 CHECK_LIST (fontlist
, 1);
559 fullname
= Fquery_fontset (name
);
560 if (!NILP (fullname
))
561 error ("Fontset \"%s\" matches the existing fontset \"%s\"",
562 XSTRING (name
)->data
, XSTRING (fullname
)->data
);
564 /* Check the validity of FONTLIST. */
565 for (tail
= fontlist
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
567 Lisp_Object tem
= XCONS (tail
)->car
;
571 || (charset
= get_charset_id (XCONS (tem
)->car
)) < 0
572 || !STRINGP (XCONS (tem
)->cdr
))
573 error ("Elements of fontlist must be a cons of charset and font name");
576 fontset_info
= Fcons (name
, fontlist
);
577 Vglobal_fontset_alist
= Fcons (fontset_info
, Vglobal_fontset_alist
);
579 /* Register this fontset for all existing frames. */
581 Lisp_Object framelist
, frame
;
583 FOR_EACH_FRAME (framelist
, frame
)
584 if (!FRAME_TERMCAP_P (XFRAME (frame
)))
585 fs_register_fontset (XFRAME (frame
), fontset_info
);
591 extern Lisp_Object
Fframe_parameters ();
592 extern Lisp_Object Qfont
;
593 Lisp_Object Qfontset
;
595 DEFUN ("set-fontset-font", Fset_fontset_font
, Sset_fontset_font
, 3, 4, 0,
596 "Set FONTNAME for a font of CHARSET in fontset NAME on frame FRAME.\n\
597 If FRAME is omitted or nil, all frames are affected.")
598 (name
, charset_symbol
, fontname
, frame
)
599 Lisp_Object name
, charset_symbol
, fontname
, frame
;
602 Lisp_Object fullname
, fontlist
;
604 (*check_window_system_func
) ();
606 CHECK_STRING (name
, 0);
607 CHECK_SYMBOL (charset_symbol
, 1);
608 CHECK_STRING (fontname
, 2);
610 CHECK_LIVE_FRAME (frame
, 3);
612 if ((charset
= get_charset_id (charset_symbol
)) < 0)
613 error ("Invalid charset: %s", XSYMBOL (charset_symbol
)->name
->data
);
615 fullname
= Fquery_fontset (name
);
617 error ("Fontset \"%s\" does not exist", XSTRING (name
)->data
);
619 /* If FRAME is not specified, we must, at first, update contents of
620 `global-fontset-alist' for a frame created in the future. */
623 Lisp_Object fontset_info
= Fassoc (fullname
, Vglobal_fontset_alist
);
624 Lisp_Object tem
= Fassq (charset_symbol
, XCONS (fontset_info
)->cdr
);
627 XCONS (fontset_info
)->cdr
628 = Fcons (Fcons (charset_symbol
, fontname
),
629 XCONS (fontset_info
)->cdr
);
631 XCONS (tem
)->cdr
= fontname
;
634 /* Then, update information in the specified frame or all existing
637 Lisp_Object framelist
, tem
;
639 FOR_EACH_FRAME (framelist
, tem
)
640 if (!FRAME_TERMCAP_P (XFRAME (tem
))
641 && (NILP (frame
) || EQ (frame
, tem
)))
643 FRAME_PTR f
= XFRAME (tem
);
644 int fontset
= fs_query_fontset (f
, XSTRING (fullname
)->data
);
645 struct fontset_info
*fontsetp
646 = FRAME_FONTSET_DATA (f
)->fontset_table
[fontset
];
648 if (fontsetp
->fontname
[charset
])
649 xfree (fontsetp
->fontname
[charset
]);
650 fontsetp
->fontname
[charset
]
651 = (char *) xmalloc (XSTRING (fontname
)->size
+ 1);
652 bcopy (XSTRING (fontname
)->data
, fontsetp
->fontname
[charset
],
653 XSTRING (fontname
)->size
+ 1);
654 fontsetp
->font_indexes
[charset
] = FONT_NOT_OPENED
;
656 if (charset
== CHARSET_ASCII
)
658 Lisp_Object font_param
= Fassq (Qfont
, Fframe_parameters (tem
));
660 if (set_frame_fontset_func
661 && !NILP (font_param
)
662 && !strcmp (XSTRING (fullname
)->data
,
663 XSTRING (XCONS (font_param
)->cdr
)->data
))
664 /* This fontset is the default fontset on frame TEM.
665 We may have to resize this frame because of new
667 (*set_frame_fontset_func
) (f
, fullname
, Qnil
);
675 DEFUN ("font-info", Ffont_info
, Sfont_info
, 1, 2, 0,
676 "Return information about a font named NAME on frame FRAME.\n\
677 If FRAME is omitted or nil, use the selected frame.\n\
678 The returned value is a vector of OPENED-NAME, FULL-NAME, CHARSET, SIZE,\n\
679 HEIGHT, BASELINE-OFFSET, RELATIVE-COMPOSE, and DEFAULT-ASCENT,\n\
681 OPENED-NAME is the name used for opening the font,\n\
682 FULL-NAME is the full name of the font,\n\
683 CHARSET is the charset displayed by the font,\n\
684 SIZE is the minimum bound width of the font,\n\
685 HEIGHT is the height of the font,\n\
686 BASELINE-OFFSET is the upward offset pixels from ASCII baseline,\n\
687 RELATIVE-COMPOSE and DEFAULT-ASCENT are the numbers controlling\n\
688 how to compose characters.\n\
689 If the named font is not yet loaded, return nil.")
691 Lisp_Object name
, frame
;
694 struct font_info
*fontp
;
697 (*check_window_system_func
) ();
699 CHECK_STRING (name
, 0);
704 CHECK_LIVE_FRAME (frame
, 1);
708 if (!query_font_func
)
709 error ("Font query function is not supported");
711 fontp
= (*query_font_func
) (f
, XSTRING (name
)->data
);
715 info
= Fmake_vector (make_number (7), Qnil
);
717 XVECTOR (info
)->contents
[0] = build_string (fontp
->name
);
718 XVECTOR (info
)->contents
[1] = build_string (fontp
->full_name
);
719 XVECTOR (info
)->contents
[2] = CHARSET_SYMBOL (fontp
->charset
);
720 XVECTOR (info
)->contents
[3] = make_number (fontp
->size
);
721 XVECTOR (info
)->contents
[4] = make_number (fontp
->height
);
722 XVECTOR (info
)->contents
[5] = make_number (fontp
->baseline_offset
);
723 XVECTOR (info
)->contents
[6] = make_number (fontp
->relative_compose
);
724 XVECTOR (info
)->contents
[7] = make_number (fontp
->default_ascent
);
729 DEFUN ("fontset-info", Ffontset_info
, Sfontset_info
, 1, 2, 0,
730 "Return information about a fontset named NAME on frame FRAME.\n\
731 If FRAME is omitted or nil, use the selected frame.\n\
732 The returned value is a vector of SIZE, HEIGHT, and FONT-LIST,\n\
734 SIZE is the minimum bound width of ASCII font of the fontset,\n\
735 HEIGHT is the height of the tallest font in the fontset, and\n\
736 FONT-LIST is an alist of the format:\n\
737 (CHARSET REQUESTED-FONT-NAME LOADED-FONT-NAME).\n\
738 LOADED-FONT-NAME t means the font is not yet loaded, nil means the\n\
741 Lisp_Object name
, frame
;
745 struct fontset_info
*fontsetp
;
746 Lisp_Object info
, val
;
749 (*check_window_system_func
) ();
751 CHECK_STRING(name
, 0);
756 CHECK_LIVE_FRAME (frame
, 1);
760 fontset
= fs_query_fontset (f
, XSTRING (name
)->data
);
762 error ("Fontset \"%s\" does not exist", XSTRING (name
)->data
);
764 info
= Fmake_vector (make_number (3), Qnil
);
766 fontsetp
= FRAME_FONTSET_DATA (f
)->fontset_table
[fontset
];
768 XVECTOR (info
)->contents
[0] = make_number (fontsetp
->size
);
769 XVECTOR (info
)->contents
[1] = make_number (fontsetp
->height
);
771 for (i
= 0; i
<= MAX_CHARSET
; i
++)
772 if (fontsetp
->fontname
[i
])
774 int font_idx
= fontsetp
->font_indexes
[i
];
777 if (font_idx
== FONT_NOT_OPENED
)
779 else if (font_idx
== FONT_NOT_FOUND
)
783 = build_string ((*get_font_info_func
) (f
, font_idx
)->full_name
);
784 val
= Fcons (Fcons (CHARSET_SYMBOL (i
),
785 Fcons (build_string (fontsetp
->fontname
[i
]),
786 Fcons (loaded
, Qnil
))),
789 XVECTOR (info
)->contents
[2] = val
;
797 for (i
= 0; i
< 256; i
++)
798 my_strcasetbl
[i
] = (i
>= 'A' && i
<= 'Z') ? i
+ 'a' - 'A' : i
;
801 /* Window system initializer should have set proper functions. */
804 Qfontset
= intern ("fontset");
805 staticpro (&Qfontset
);
807 Vcached_fontset_data
= Qnil
;
808 staticpro (&Vcached_fontset_data
);
810 DEFVAR_LISP ("global-fontset-alist", &Vglobal_fontset_alist
,
811 "Internal data for fontset. Not for external use.\n\
812 This is an alist associating fontset names with the lists of fonts\n\
813 contained in them.\n\
814 Newly created frames make their own fontset database from here.");
815 Vglobal_fontset_alist
= Qnil
;
817 DEFVAR_LISP ("font-encoding-alist", &Vfont_encoding_alist
,
818 "Alist of fontname patterns vs corresponding encoding info.\n\
819 Each element looks like (REGEXP . ENCODING-INFO),\n\
820 where ENCODING-INFO is an alist of CHARSET vs ENCODING.\n\
821 ENCODING is one of the following integer values:\n\
822 0: code points 0x20..0x7F or 0x2020..0x7F7F are used,\n\
823 1: code points 0xA0..0xFF or 0xA0A0..0xFFFF are used,\n\
824 2: code points 0x20A0..0x7FFF are used,\n\
825 3: code points 0xA020..0xFF7F are used.");
826 Vfont_encoding_alist
= Qnil
;
828 DEFVAR_LISP ("use-default-ascent", &Vuse_default_ascent
,
829 "Char table of characters of which ascent values should be ignored.\n\
830 If an entry for a character is non-nil, the ascent value of the glyph\n\
831 is assumed to be what specified by _MULE_DEFAULT_ASCENT property of a font.");
832 Vuse_default_ascent
= Qnil
;
834 DEFVAR_LISP ("alternative-fontname-alist", &Valternative_fontname_alist
,
835 "Alist of fontname vs list of the alternative fontnames.\n\
836 When no font can be opened by a fontname, the corresponding\n\
837 alternative fontnames are tried.");
838 Valternative_fontname_alist
= Qnil
;
840 DEFVAR_LISP ("fontset-alias-alist", &Vfontset_alias_alist
,
841 "Alist of fontset names vs the aliases.");
842 Vfontset_alias_alist
= Qnil
;
844 DEFVAR_LISP ("highlight-wrong-size-font", &Vhighlight_wrong_size_font
,
845 "*Non-nil means highlight characters shown in wrong size fonts somehow.\n\
846 The way to highlight them depends on window system on which Emacs runs.\n\
847 On X window, a rectangle is shown around each such character.");
848 Vhighlight_wrong_size_font
= Qt
;
850 DEFVAR_LISP ("clip-large-size-font", &Vclip_large_size_font
,
851 "*Non-nil means characters shown in large size fonts are clipped.\n\
852 The height of clipping area is the same as that of an ASCII character.\n\
853 The width of the area is the same as that of an ASCII character or\n\
854 twice wider than that of an ASCII character depending on\n\
855 the width (i.e. column numbers occupied on screen) of the character set\n\
858 In the case that you only have too large size font for a specific\n\
859 charscter set, and clipping characters of the character set makes them\n\
860 almost unreadable, you can set this variable to t to see the\n\
861 characters in exchage for garbage dots left on your screen.");
862 Vclip_large_size_font
= Qt
;
864 defsubr (&Squery_fontset
);
865 defsubr (&Snew_fontset
);
866 defsubr (&Sset_fontset_font
);
867 defsubr (&Sfont_info
);
868 defsubr (&Sfontset_info
);