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
;
37 Lisp_Object Vfontset_alias_alist
;
38 Lisp_Object Vhighlight_wrong_size_font
;
39 Lisp_Object Vclip_large_size_font
;
41 /* We had better have our own strcasecmp function because some system
43 static char my_strcasetbl
[256];
45 /* Compare two strings S0 and S1 while ignoring differences in case.
46 Return 1 if they differ, else return 0. */
48 my_strcasecmp (s0
, s1
)
49 unsigned char *s0
, *s1
;
52 if (my_strcasetbl
[*s0
++] != my_strcasetbl
[*s1
++]) return 1;
56 /* The following six are window system dependent functions. See
57 the comments in src/fontset.h for more detail. */
59 /* Return a pointer to struct font_info of font FONT_IDX of frame F. */
60 struct font_info
*(*get_font_info_func
) (/* FRAME_PTR f; int font_idx */);
62 /* Return a list of font names which matches PATTERN. See the document of
63 `x-list-fonts' for more detail. */
64 Lisp_Object (*list_fonts_func
) (/* Lisp_Object pattern, face, frame, width */);
66 /* Load a font named NAME for frame F and return a pointer to the
67 information of the loaded font. If loading is failed, return 0. */
68 struct font_info
*(*load_font_func
) (/* FRAME_PTR f; char *name */);
70 /* Return a pointer to struct font_info of a font named NAME for frame F. */
71 struct font_info
*(*query_font_func
) (/* FRAME_PTR f; char *name */);
73 /* Additional function for setting fontset or changing fontset
74 contents of frame F. */
75 void (*set_frame_fontset_func
) (/* FRAME_PTR f; Lisp_Object arg, oldval */);
77 /* Check if any window system is used now. */
78 void (*check_window_system_func
) ();
83 struct fontset_data
*fontset_data
84 = (struct fontset_data
*) xmalloc (sizeof (struct fontset_data
));
86 bzero (fontset_data
, sizeof (struct fontset_data
));
92 free_fontset_data (fontset_data
)
93 struct fontset_data
*fontset_data
;
97 for (i
= 0; i
< fontset_data
->n_fontsets
; i
++)
101 xfree (fontset_data
->fontset_table
[i
]->name
);
102 for (j
= 0; j
<= MAX_CHARSET
; j
++)
103 if (fontset_data
->fontset_table
[i
]->fontname
[j
])
104 xfree (fontset_data
->fontset_table
[i
]->fontname
[j
]);
105 xfree (fontset_data
->fontset_table
[i
]);
107 xfree (fontset_data
->fontset_table
);
109 xfree (fontset_data
);
112 /* Load a font named FONTNAME for displaying CHARSET on frame F.
113 All fonts for frame F is stored in a table pointed by FONT_TABLE.
114 Return a pointer to the struct font_info of the loaded font.
115 If loading fails, return 0;
116 If FONTNAME is NULL, the name is taken from the information of FONTSET.
117 If FONTSET is given, try to load a font whose size matches that of
118 FONTSET, and, the font index is stored in the table for FONTSET. */
121 fs_load_font (f
, font_table
, charset
, fontname
, fontset
)
123 struct font_info
*font_table
;
124 int charset
, fontset
;
127 Lisp_Object font_list
;
128 Lisp_Object list
, elt
;
131 struct fontset_info
*fontsetp
= 0;
132 struct font_info
*fontp
;
134 if (fontset
>= 0 && fontset
< FRAME_FONTSET_DATA (f
)->n_fontsets
)
136 fontsetp
= FRAME_FONTSET_DATA (f
)->fontset_table
[fontset
];
137 font_idx
= fontsetp
->font_indexes
[charset
];
139 /* We have already loaded a font. */
140 return font_table
+ font_idx
;
141 else if (font_idx
== FONT_NOT_FOUND
)
142 /* We have already tried loading a font and failed. */
145 fontname
= fontsetp
->fontname
[charset
];
149 /* No way to get fontname. */
152 /* If CHARSET is not ASCII and FONTSET is specified, we must load a
153 font of appropriate size to be used with other fonts in this
155 if (charset
!= CHARSET_ASCII
&& fontsetp
)
157 /* If we have not yet loaded ASCII font of FONTSET, we must load
158 it now to decided the size and height of this fontset. */
159 if (fontsetp
->size
== 0)
161 fontp
= fs_load_font (f
, font_table
, CHARSET_ASCII
, 0, fontset
);
163 /* Any fontset should contain avairable ASCII. */
166 /* Now we have surely decided the size of this fontset. */
167 size
= fontsetp
->size
* CHARSET_WIDTH (charset
);
170 fontp
= (*load_font_func
) (f
, fontname
, size
);
175 fontsetp
->font_indexes
[charset
] = FONT_NOT_FOUND
;
179 /* Fill in fields (CHARSET, ENCODING, and FONT_ENCODER) which are
180 not set by (*load_font_func). */
181 fontp
->charset
= charset
;
183 if (fontp
->encoding
[1] != FONT_ENCODING_NOT_DECIDED
)
185 /* The font itself tells which code points to be used. Use this
186 encoding for all other charsets. */
189 fontp
->encoding
[0] = fontp
->encoding
[1];
190 for (i
= MIN_CHARSET_OFFICIAL_DIMENSION1
; i
<= MAX_CHARSET
; i
++)
191 fontp
->encoding
[i
] = fontp
->encoding
[1];
195 /* The font itself doesn't tell which code points to be used. */
198 /* At first, set 1 (means 0xA0..0xFF) as the default. */
199 fontp
->encoding
[0] = 1;
200 for (i
= MIN_CHARSET_OFFICIAL_DIMENSION1
; i
<= MAX_CHARSET
; i
++)
201 fontp
->encoding
[i
] = 1;
202 /* Then override them by a specification in Vfont_encoding_alist. */
203 for (list
= Vfont_encoding_alist
; CONSP (list
); list
= XCONS (list
)->cdr
)
205 elt
= XCONS (list
)->car
;
207 && STRINGP (XCONS (elt
)->car
) && CONSP (XCONS (elt
)->cdr
)
208 && (fast_c_string_match_ignore_case (XCONS (elt
)->car
, fontname
)
213 for (tmp
= XCONS (elt
)->cdr
; CONSP (tmp
); tmp
= XCONS (tmp
)->cdr
)
214 if (CONSP (XCONS (tmp
)->car
)
215 && ((i
= get_charset_id (XCONS (XCONS (tmp
)->car
)->car
))
217 && INTEGERP (XCONS (XCONS (tmp
)->car
)->cdr
)
218 && XFASTINT (XCONS (XCONS (tmp
)->car
)->cdr
) < 4)
220 = XFASTINT (XCONS (XCONS (tmp
)->car
)->cdr
);
225 fontp
->font_encoder
= (struct ccl_program
*) 0;
226 for (list
= Vfont_ccl_encoder_alist
; CONSP (list
); list
= XCONS (list
)->cdr
)
228 elt
= XCONS (list
)->car
;
230 && STRINGP (XCONS (elt
)->car
) && VECTORP (XCONS (elt
)->cdr
)
231 && fast_c_string_match_ignore_case (XCONS (elt
)->car
, fontname
) >= 0)
234 = (struct ccl_program
*) xmalloc (sizeof (struct ccl_program
));
235 setup_ccl_program (fontp
->font_encoder
, XCONS (elt
)->cdr
);
240 /* If FONTSET is specified, setup various fields of it. */
243 fontsetp
->font_indexes
[charset
] = fontp
->font_idx
;
244 if (charset
== CHARSET_ASCII
)
246 /* Decide or change the size and height of this fontset. */
247 if (fontsetp
->size
== 0)
249 fontsetp
->size
= fontp
->size
;
250 fontsetp
->height
= fontp
->height
;
252 else if (fontsetp
->size
!= fontp
->size
253 || fontsetp
->height
!= fontp
->height
)
255 /* When loading ASCII font of the different size from
256 the size of FONTSET, we have to update the size of
257 FONTSET. Since changing the size of FONTSET may make
258 some fonts already loaded inappropriate to be used in
259 FONTSET, we must delete the record of such fonts. In
260 that case, we also have to calculate the height of
261 FONTSET from the remaining fonts. */
264 fontsetp
->size
= fontp
->size
;
265 fontsetp
->height
= fontp
->height
;
266 for (i
= CHARSET_ASCII
+ 1; i
<= MAX_CHARSET
; i
++)
268 font_idx
= fontsetp
->font_indexes
[i
];
271 struct font_info
*fontp2
= font_table
+ font_idx
;
273 if (fontp2
->size
!= fontp
->size
* CHARSET_WIDTH (i
))
274 fontsetp
->font_indexes
[i
] = FONT_NOT_OPENED
;
275 /* The following code should be disabled until
276 Emacs supports variable height lines. */
278 else if (fontsetp
->height
< fontp
->height
)
279 fontsetp
->height
= fontp
->height
;
290 /* Return ID of the fontset named NAME on frame F. */
293 fs_query_fontset (f
, name
)
297 struct fontset_data
*fontset_data
= FRAME_FONTSET_DATA (f
);
300 for (i
= 0; i
< fontset_data
->n_fontsets
; i
++)
301 if (!my_strcasecmp(name
, fontset_data
->fontset_table
[i
]->name
))
306 /* Register a fontset specified by FONTSET_INFO for frame FRAME.
307 Return the fontset ID if successfully registered, else return -1.
308 FONTSET_INFO is a cons of name of the fontset and FONTLIST, where
309 FONTLIST is an alist of charsets vs fontnames. */
312 fs_register_fontset (f
, fontset_info
)
314 Lisp_Object fontset_info
;
316 struct fontset_data
*fontset_data
= FRAME_FONTSET_DATA (f
);
317 Lisp_Object name
, fontlist
;
319 struct fontset_info
*fontsetp
;
322 if (!CONSP (fontset_info
)
323 || !STRINGP (XCONS (fontset_info
)->car
)
324 || !CONSP (XCONS (fontset_info
)->cdr
))
325 /* Invalid data in FONTSET_INFO. */
328 name
= XCONS (fontset_info
)->car
;
329 if ((fontset
= fs_query_fontset (f
, XSTRING (name
)->data
)) >= 0)
330 /* This fontset already exists on frame F. */
333 fontsetp
= (struct fontset_info
*) xmalloc (sizeof (struct fontset_info
));
335 fontsetp
->name
= (char *) xmalloc (XSTRING (name
)->size
+ 1);
336 bcopy(XSTRING (name
)->data
, fontsetp
->name
, XSTRING (name
)->size
+ 1);
338 fontsetp
->size
= fontsetp
->height
= 0;
340 for (i
= 0; i
<= MAX_CHARSET
; i
++)
342 fontsetp
->fontname
[i
] = (char *) 0;
343 fontsetp
->font_indexes
[i
] = FONT_NOT_OPENED
;
346 for (fontlist
= XCONS (fontset_info
)->cdr
; CONSP (fontlist
);
347 fontlist
= XCONS (fontlist
)->cdr
)
349 Lisp_Object tem
= Fcar (fontlist
);
353 && (charset
= get_charset_id (XCONS (tem
)->car
)) >= 0
354 && STRINGP (XCONS (tem
)->cdr
))
356 fontsetp
->fontname
[charset
]
357 = (char *) xmalloc (XSTRING (XCONS (tem
)->cdr
)->size
+ 1);
358 bcopy (XSTRING (XCONS (tem
)->cdr
)->data
,
359 fontsetp
->fontname
[charset
],
360 XSTRING (XCONS (tem
)->cdr
)->size
+ 1);
363 /* Broken or invalid data structure. */
367 /* Do we need to create the table? */
368 if (fontset_data
->fontset_table_size
== 0)
370 fontset_data
->fontset_table_size
= 8;
371 fontset_data
->fontset_table
372 = (struct fontset_info
**) xmalloc (fontset_data
->fontset_table_size
373 * sizeof (struct fontset_info
*));
375 /* Do we need to grow the table? */
376 else if (fontset_data
->n_fontsets
>= fontset_data
->fontset_table_size
)
378 fontset_data
->fontset_table_size
+= 8;
379 fontset_data
->fontset_table
380 = (struct fontset_info
**) xrealloc (fontset_data
->fontset_table
,
381 fontset_data
->fontset_table_size
382 * sizeof (struct fontset_info
*));
384 fontset
= fontset_data
->n_fontsets
++;
385 fontset_data
->fontset_table
[fontset
] = fontsetp
;
390 /* Cache data used by fontset_pattern_regexp. The car part is a
391 pattern string containing at least one wild card, the cdr part is
392 the corresponding regular expression. */
393 static Lisp_Object Vcached_fontset_data
;
395 #define CACHED_FONTSET_NAME (XSTRING (XCONS (Vcached_fontset_data)->car)->data)
396 #define CACHED_FONTSET_REGEX (XCONS (Vcached_fontset_data)->cdr)
398 /* If fontset name PATTERN contains any wild card, return regular
399 expression corresponding to PATTERN. */
402 fontset_pattern_regexp (pattern
)
405 if (!index (XSTRING (pattern
)->data
, '*')
406 && !index (XSTRING (pattern
)->data
, '?'))
407 /* PATTERN does not contain any wild cards. */
410 if (!CONSP (Vcached_fontset_data
)
411 || strcmp (XSTRING (pattern
)->data
, CACHED_FONTSET_NAME
))
413 /* We must at first update the cached data. */
414 char *regex
= (char *) alloca (XSTRING (pattern
)->size
* 2);
415 char *p0
, *p1
= regex
;
417 /* Convert "*" to ".*", "?" to ".". */
419 for (p0
= (char *) XSTRING (pattern
)->data
; *p0
; p0
++)
434 Vcached_fontset_data
= Fcons (build_string (XSTRING (pattern
)->data
),
435 build_string (regex
));
438 return CACHED_FONTSET_REGEX
;
441 DEFUN ("query-fontset", Fquery_fontset
, Squery_fontset
, 1, 1, 0,
442 "Return a fontset name which matches PATTERN, nil if no matching fontset.\n\
443 PATTERN can contain `*' or `?' as a wild card\n\
444 just like X's font name matching algorithm allows.")
448 Lisp_Object regexp
, tem
;
450 (*check_window_system_func
) ();
452 CHECK_STRING (pattern
, 0);
454 if (XSTRING (pattern
)->size
== 0)
457 tem
= Frassoc (pattern
, Vfontset_alias_alist
);
461 regexp
= fontset_pattern_regexp (pattern
);
463 for (tem
= Vglobal_fontset_alist
; CONSP (tem
); tem
= XCONS (tem
)->cdr
)
465 Lisp_Object fontset_name
= XCONS (XCONS (tem
)->car
)->car
;
468 if (fast_c_string_match_ignore_case (regexp
,
469 XSTRING (fontset_name
)->data
)
475 if (!my_strcasecmp (XSTRING (pattern
)->data
,
476 XSTRING (fontset_name
)->data
))
484 Lisp_Object
Fframe_char_width ();
486 /* Return a list of names of available fontsets matching PATTERN on
487 frame F. If SIZE is not 0, it is the size (maximum bound width) of
488 fontsets to be listed. */
491 list_fontsets (f
, pattern
, size
)
497 Lisp_Object regexp
, val
;
499 regexp
= fontset_pattern_regexp (pattern
);
502 for (i
= 0; i
< FRAME_FONTSET_DATA (f
)->n_fontsets
; i
++)
504 struct fontset_info
*fontsetp
= FRAME_FONTSET_DATA (f
)->fontset_table
[i
];
505 int name_matched
= 0;
506 int size_matched
= 0;
510 if (fast_c_string_match_ignore_case (regexp
, fontsetp
->name
) >= 0)
515 if (!my_strcasecmp (XSTRING (pattern
)->data
, fontsetp
->name
))
521 if (!size
|| fontsetp
->size
== size
)
523 else if (fontsetp
->size
== 0)
525 /* No font of this fontset has loaded yet. Try loading
529 for (j
= 0; j
<= MAX_CHARSET
; j
++)
530 if (fontsetp
->fontname
[j
])
532 if ((*load_font_func
) (f
, fontsetp
->fontname
[j
], size
))
539 val
= Fcons (build_string (fontsetp
->name
), val
);
546 DEFUN ("new-fontset", Fnew_fontset
, Snew_fontset
, 2, 2, 0,
547 "Create a new fontset NAME which contains fonts in FONTLIST.\n\
548 FONTLIST is an alist of charsets vs corresponding font names.")
550 Lisp_Object name
, fontlist
;
552 Lisp_Object fullname
, fontset_info
;
555 (*check_window_system_func
) ();
557 CHECK_STRING (name
, 0);
558 CHECK_LIST (fontlist
, 1);
560 fullname
= Fquery_fontset (name
);
561 if (!NILP (fullname
))
562 error ("Fontset \"%s\" matches the existing fontset \"%s\"",
563 XSTRING (name
)->data
, XSTRING (fullname
)->data
);
565 /* Check the validity of FONTLIST. */
566 for (tail
= fontlist
; CONSP (tail
); tail
= XCONS (tail
)->cdr
)
568 Lisp_Object tem
= XCONS (tail
)->car
;
572 || (charset
= get_charset_id (XCONS (tem
)->car
)) < 0
573 || !STRINGP (XCONS (tem
)->cdr
))
574 error ("Elements of fontlist must be a cons of charset and font name");
577 fontset_info
= Fcons (name
, fontlist
);
578 Vglobal_fontset_alist
= Fcons (fontset_info
, Vglobal_fontset_alist
);
580 /* Register this fontset for all existing frames. */
582 Lisp_Object framelist
, frame
;
584 FOR_EACH_FRAME (framelist
, frame
)
585 if (!FRAME_TERMCAP_P (XFRAME (frame
)))
586 fs_register_fontset (XFRAME (frame
), fontset_info
);
592 extern Lisp_Object
Fframe_parameters ();
593 extern Lisp_Object Qfont
;
594 Lisp_Object Qfontset
;
596 DEFUN ("set-fontset-font", Fset_fontset_font
, Sset_fontset_font
, 3, 4, 0,
597 "Set FONTNAME for a font of CHARSET in fontset NAME on frame FRAME.\n\
598 If FRAME is omitted or nil, all frames are affected.")
599 (name
, charset_symbol
, fontname
, frame
)
600 Lisp_Object name
, charset_symbol
, fontname
, frame
;
603 Lisp_Object fullname
, fontlist
;
605 (*check_window_system_func
) ();
607 CHECK_STRING (name
, 0);
608 CHECK_SYMBOL (charset_symbol
, 1);
609 CHECK_STRING (fontname
, 2);
611 CHECK_LIVE_FRAME (frame
, 3);
613 if ((charset
= get_charset_id (charset_symbol
)) < 0)
614 error ("Invalid charset: %s", XSYMBOL (charset_symbol
)->name
->data
);
616 fullname
= Fquery_fontset (name
);
618 error ("Fontset \"%s\" does not exist", XSTRING (name
)->data
);
620 /* If FRAME is not specified, we must, at first, update contents of
621 `global-fontset-alist' for a frame created in the future. */
624 Lisp_Object fontset_info
= Fassoc (fullname
, Vglobal_fontset_alist
);
625 Lisp_Object tem
= Fassq (charset_symbol
, XCONS (fontset_info
)->cdr
);
628 XCONS (fontset_info
)->cdr
629 = Fcons (Fcons (charset_symbol
, fontname
),
630 XCONS (fontset_info
)->cdr
);
632 XCONS (tem
)->cdr
= fontname
;
635 /* Then, update information in the specified frame or all existing
638 Lisp_Object framelist
, tem
;
640 FOR_EACH_FRAME (framelist
, tem
)
641 if (!FRAME_TERMCAP_P (XFRAME (tem
))
642 && (NILP (frame
) || EQ (frame
, tem
)))
644 FRAME_PTR f
= XFRAME (tem
);
645 int fontset
= fs_query_fontset (f
, XSTRING (fullname
)->data
);
646 struct fontset_info
*fontsetp
647 = FRAME_FONTSET_DATA (f
)->fontset_table
[fontset
];
649 if (fontsetp
->fontname
[charset
])
650 xfree (fontsetp
->fontname
[charset
]);
651 fontsetp
->fontname
[charset
]
652 = (char *) xmalloc (XSTRING (fontname
)->size
+ 1);
653 bcopy (XSTRING (fontname
)->data
, fontsetp
->fontname
[charset
],
654 XSTRING (fontname
)->size
+ 1);
655 fontsetp
->font_indexes
[charset
] = FONT_NOT_OPENED
;
657 if (charset
== CHARSET_ASCII
)
659 Lisp_Object font_param
= Fassq (Qfont
, Fframe_parameters (tem
));
661 if (set_frame_fontset_func
662 && !NILP (font_param
)
663 && !strcmp (XSTRING (fullname
)->data
,
664 XSTRING (XCONS (font_param
)->cdr
)->data
))
665 /* This fontset is the default fontset on frame TEM.
666 We may have to resize this frame because of new
668 (*set_frame_fontset_func
) (f
, fullname
, Qnil
);
676 DEFUN ("font-info", Ffont_info
, Sfont_info
, 1, 2, 0,
677 "Return information about a font named NAME on frame FRAME.\n\
678 If FRAME is omitted or nil, use the selected frame.\n\
679 The returned value is a vector of OPENED-NAME, FULL-NAME, CHARSET, SIZE,\n\
680 HEIGHT, BASELINE-OFFSET, RELATIVE-COMPOSE, and DEFAULT-ASCENT,\n\
682 OPENED-NAME is the name used for opening the font,\n\
683 FULL-NAME is the full name of the font,\n\
684 CHARSET is the charset displayed by the font,\n\
685 SIZE is the minimum bound width of the font,\n\
686 HEIGHT is the height of the font,\n\
687 BASELINE-OFFSET is the upward offset pixels from ASCII baseline,\n\
688 RELATIVE-COMPOSE and DEFAULT-ASCENT are the numbers controlling\n\
689 how to compose characters.\n\
690 If the named font is not yet loaded, return nil.")
692 Lisp_Object name
, frame
;
695 struct font_info
*fontp
;
698 (*check_window_system_func
) ();
700 CHECK_STRING (name
, 0);
705 CHECK_LIVE_FRAME (frame
, 1);
709 if (!query_font_func
)
710 error ("Font query function is not supported");
712 fontp
= (*query_font_func
) (f
, XSTRING (name
)->data
);
716 info
= Fmake_vector (make_number (7), Qnil
);
718 XVECTOR (info
)->contents
[0] = build_string (fontp
->name
);
719 XVECTOR (info
)->contents
[1] = build_string (fontp
->full_name
);
720 XVECTOR (info
)->contents
[2] = CHARSET_SYMBOL (fontp
->charset
);
721 XVECTOR (info
)->contents
[3] = make_number (fontp
->size
);
722 XVECTOR (info
)->contents
[4] = make_number (fontp
->height
);
723 XVECTOR (info
)->contents
[5] = make_number (fontp
->baseline_offset
);
724 XVECTOR (info
)->contents
[6] = make_number (fontp
->relative_compose
);
725 XVECTOR (info
)->contents
[7] = make_number (fontp
->default_ascent
);
730 DEFUN ("fontset-info", Ffontset_info
, Sfontset_info
, 1, 2, 0,
731 "Return information about a fontset named NAME on frame FRAME.\n\
732 If FRAME is omitted or nil, use the selected frame.\n\
733 The returned value is a vector of SIZE, HEIGHT, and FONT-LIST,\n\
735 SIZE is the minimum bound width of ASCII font of the fontset,\n\
736 HEIGHT is the height of the tallest font in the fontset, and\n\
737 FONT-LIST is an alist of the format:\n\
738 (CHARSET REQUESTED-FONT-NAME LOADED-FONT-NAME).\n\
739 LOADED-FONT-NAME t means the font is not yet loaded, nil means the\n\
742 Lisp_Object name
, frame
;
746 struct fontset_info
*fontsetp
;
747 Lisp_Object info
, val
;
750 (*check_window_system_func
) ();
752 CHECK_STRING(name
, 0);
757 CHECK_LIVE_FRAME (frame
, 1);
761 fontset
= fs_query_fontset (f
, XSTRING (name
)->data
);
763 error ("Fontset \"%s\" does not exist", XSTRING (name
)->data
);
765 info
= Fmake_vector (make_number (3), Qnil
);
767 fontsetp
= FRAME_FONTSET_DATA (f
)->fontset_table
[fontset
];
769 XVECTOR (info
)->contents
[0] = make_number (fontsetp
->size
);
770 XVECTOR (info
)->contents
[1] = make_number (fontsetp
->height
);
772 for (i
= 0; i
<= MAX_CHARSET
; i
++)
773 if (fontsetp
->fontname
[i
])
775 int font_idx
= fontsetp
->font_indexes
[i
];
778 if (font_idx
== FONT_NOT_OPENED
)
780 else if (font_idx
== FONT_NOT_FOUND
)
784 = build_string ((*get_font_info_func
) (f
, font_idx
)->full_name
);
785 val
= Fcons (Fcons (CHARSET_SYMBOL (i
),
786 Fcons (build_string (fontsetp
->fontname
[i
]),
787 Fcons (loaded
, Qnil
))),
790 XVECTOR (info
)->contents
[2] = val
;
798 for (i
= 0; i
< 256; i
++)
799 my_strcasetbl
[i
] = (i
>= 'A' && i
<= 'Z') ? i
+ 'a' - 'A' : i
;
802 /* Window system initializer should have set proper functions. */
805 Qfontset
= intern ("fontset");
806 staticpro (&Qfontset
);
808 Vcached_fontset_data
= Qnil
;
809 staticpro (&Vcached_fontset_data
);
811 DEFVAR_LISP ("global-fontset-alist", &Vglobal_fontset_alist
,
812 "Internal data for fontset. Not for external use.\n\
813 This is an alist associating fontset names with the lists of fonts\n\
814 contained in them.\n\
815 Newly created frames make their own fontset database from here.");
816 Vglobal_fontset_alist
= Qnil
;
818 DEFVAR_LISP ("font-encoding-alist", &Vfont_encoding_alist
,
819 "Alist of fontname patterns vs corresponding encoding info.\n\
820 Each element looks like (REGEXP . ENCODING-INFO),\n\
821 where ENCODING-INFO is an alist of CHARSET vs ENCODING.\n\
822 ENCODING is one of the following integer values:\n\
823 0: code points 0x20..0x7F or 0x2020..0x7F7F are used,\n\
824 1: code points 0xA0..0xFF or 0xA0A0..0xFFFF are used,\n\
825 2: code points 0x20A0..0x7FFF are used,\n\
826 3: code points 0xA020..0xFF7F are used.");
827 Vfont_encoding_alist
= Qnil
;
829 DEFVAR_LISP ("use-default-ascent", &Vuse_default_ascent
,
830 "Char table of characters of which ascent values should be ignored.\n\
831 If an entry for a character is non-nil, the ascent value of the glyph\n\
832 is assumed to be what specified by _MULE_DEFAULT_ASCENT property of a font.");
833 Vuse_default_ascent
= Qnil
;
835 DEFVAR_LISP ("alternative-fontname-alist", &Valternative_fontname_alist
,
836 "Alist of fontname vs list of the alternative fontnames.\n\
837 When no font can be opened by a fontname, the corresponding\n\
838 alternative fontnames are tried.");
839 Valternative_fontname_alist
= Qnil
;
841 DEFVAR_LISP ("fontset-alias-alist", &Vfontset_alias_alist
,
842 "Alist of fontset names vs the aliases.");
843 Vfontset_alias_alist
= Qnil
;
845 DEFVAR_LISP ("highlight-wrong-size-font", &Vhighlight_wrong_size_font
,
846 "*Non-nil means highlight characters shown in wrong size fonts somehow.\n\
847 The way to highlight them depends on window system on which Emacs runs.\n\
848 On X window, a rectangle is shown around each such character.");
849 Vhighlight_wrong_size_font
= Qt
;
851 DEFVAR_LISP ("clip-large-size-font", &Vclip_large_size_font
,
852 "*Non-nil means characters shown in large size fonts are clipped.\n\
853 The height of clipping area is the same as that of an ASCII character.\n\
854 The width of the area is the same as that of an ASCII character or\n\
855 twice wider than that of an ASCII character depending on\n\
856 the width (i.e. column numbers occupied on screen) of the character set\n\
859 In the case that you only have too large size font for a specific\n\
860 charscter set, and clipping characters of the character set makes them\n\
861 almost unreadable, you can set this variable to t to see the\n\
862 characters in exchage for garbage dots left on your screen.");
863 Vclip_large_size_font
= Qt
;
865 defsubr (&Squery_fontset
);
866 defsubr (&Snew_fontset
);
867 defsubr (&Sset_fontset_font
);
868 defsubr (&Sfont_info
);
869 defsubr (&Sfontset_info
);