Mercurial > emacs
comparison src/xfont.c @ 91142:4bcf0716ddf4
* xfont.c (x_font_charset_alist): Moved to font.c and renamed.
(xfont_registry_charsets): Likewise. Caller changed.
(syms_of_xfont): Don't handle x_font_charset_alist.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Sat, 01 Dec 2007 02:41:41 +0000 |
parents | a31984e21969 |
children | ca4dcecf8f88 |
comparison
equal
deleted
inserted
replaced
91141:833744ce7f09 | 91142:4bcf0716ddf4 |
---|---|
37 | 37 |
38 | 38 |
39 /* X core font driver. */ | 39 /* X core font driver. */ |
40 | 40 |
41 Lisp_Object Qx; | 41 Lisp_Object Qx; |
42 | |
43 /* Alist of font registry symbol and the corresponding charsets | |
44 information. The information is retrieved from | |
45 Vfont_encoding_alist on demand. | |
46 | |
47 Eash element has the form: | |
48 (REGISTRY . (ENCODING-CHARSET-ID . REPERTORY-CHARSET-ID)) | |
49 or | |
50 (REGISTRY . nil) | |
51 | |
52 In the former form, ENCODING-CHARSET-ID is an ID of a charset that | |
53 encodes a character code to a glyph code of a font, and | |
54 REPERTORY-CHARSET-ID is an ID of a charset that tells if a | |
55 character is supported by a font. | |
56 | |
57 The latter form means that the information for REGISTRY couldn't be | |
58 retrieved. */ | |
59 static Lisp_Object x_font_charset_alist; | |
60 | 42 |
61 /* Prototypes of support functions. */ | 43 /* Prototypes of support functions. */ |
62 extern void x_clear_errors P_ ((Display *)); | 44 extern void x_clear_errors P_ ((Display *)); |
63 | 45 |
64 static char *xfont_query_font P_ ((Display *, char *, Lisp_Object)); | 46 static char *xfont_query_font P_ ((Display *, char *, Lisp_Object)); |
170 } | 152 } |
171 | 153 |
172 return ((pcm == NULL | 154 return ((pcm == NULL |
173 || (pcm->width == 0 && (pcm->rbearing - pcm->lbearing) == 0)) | 155 || (pcm->width == 0 && (pcm->rbearing - pcm->lbearing) == 0)) |
174 ? NULL : pcm); | 156 ? NULL : pcm); |
175 } | |
176 | |
177 extern Lisp_Object find_font_encoding P_ ((Lisp_Object)); | |
178 | |
179 /* Return encoding charset and repertory charset for REGISTRY in | |
180 ENCODING and REPERTORY correspondingly. If correct information for | |
181 REGISTRY is available, return 0. Otherwise return -1. */ | |
182 | |
183 static int | |
184 xfont_registry_charsets (registry, encoding, repertory) | |
185 Lisp_Object registry; | |
186 struct charset **encoding, **repertory; | |
187 { | |
188 Lisp_Object val; | |
189 int encoding_id, repertory_id; | |
190 | |
191 val = assq_no_quit (registry, x_font_charset_alist); | |
192 if (! NILP (val)) | |
193 { | |
194 val = XCDR (val); | |
195 if (NILP (val)) | |
196 return -1; | |
197 encoding_id = XINT (XCAR (val)); | |
198 repertory_id = XINT (XCDR (val)); | |
199 } | |
200 else | |
201 { | |
202 val = find_font_encoding (SYMBOL_NAME (registry)); | |
203 if (SYMBOLP (val) && CHARSETP (val)) | |
204 { | |
205 encoding_id = repertory_id = XINT (CHARSET_SYMBOL_ID (val)); | |
206 } | |
207 else if (CONSP (val)) | |
208 { | |
209 if (! CHARSETP (XCAR (val))) | |
210 goto invalid_entry; | |
211 encoding_id = XINT (CHARSET_SYMBOL_ID (XCAR (val))); | |
212 if (NILP (XCDR (val))) | |
213 repertory_id = -1; | |
214 else | |
215 { | |
216 if (! CHARSETP (XCDR (val))) | |
217 goto invalid_entry; | |
218 repertory_id = XINT (CHARSET_SYMBOL_ID (XCDR (val))); | |
219 } | |
220 } | |
221 else | |
222 goto invalid_entry; | |
223 val = Fcons (make_number (encoding_id), make_number (repertory_id)); | |
224 x_font_charset_alist | |
225 = nconc2 (x_font_charset_alist, Fcons (Fcons (registry, val), Qnil)); | |
226 } | |
227 | |
228 if (encoding) | |
229 *encoding = CHARSET_FROM_ID (encoding_id); | |
230 if (repertory) | |
231 *repertory = repertory_id >= 0 ? CHARSET_FROM_ID (repertory_id) : NULL; | |
232 return 0; | |
233 | |
234 invalid_entry: | |
235 x_font_charset_alist | |
236 = nconc2 (x_font_charset_alist, Fcons (Fcons (registry, Qnil), Qnil)); | |
237 return -1; | |
238 } | 157 } |
239 | 158 |
240 static Lisp_Object xfont_get_cache P_ ((Lisp_Object)); | 159 static Lisp_Object xfont_get_cache P_ ((Lisp_Object)); |
241 static Lisp_Object xfont_list P_ ((Lisp_Object, Lisp_Object)); | 160 static Lisp_Object xfont_list P_ ((Lisp_Object, Lisp_Object)); |
242 static Lisp_Object xfont_match P_ ((Lisp_Object, Lisp_Object)); | 161 static Lisp_Object xfont_match P_ ((Lisp_Object, Lisp_Object)); |
565 XFontStruct *xfont; | 484 XFontStruct *xfont; |
566 | 485 |
567 /* At first, check if we know how to encode characters for this | 486 /* At first, check if we know how to encode characters for this |
568 font. */ | 487 font. */ |
569 registry = AREF (entity, FONT_REGISTRY_INDEX); | 488 registry = AREF (entity, FONT_REGISTRY_INDEX); |
570 if (xfont_registry_charsets (registry, &encoding, &repertory) < 0) | 489 if (font_registry_charsets (registry, &encoding, &repertory) < 0) |
571 return NULL; | 490 return NULL; |
572 | 491 |
573 if (XINT (AREF (entity, FONT_SIZE_INDEX)) != 0) | 492 if (XINT (AREF (entity, FONT_SIZE_INDEX)) != 0) |
574 pixel_size = XINT (AREF (entity, FONT_SIZE_INDEX)); | 493 pixel_size = XINT (AREF (entity, FONT_SIZE_INDEX)); |
575 len = font_unparse_xlfd (entity, pixel_size, name, 256); | 494 len = font_unparse_xlfd (entity, pixel_size, name, 256); |
779 int c; | 698 int c; |
780 { | 699 { |
781 Lisp_Object registry = AREF (entity, FONT_REGISTRY_INDEX); | 700 Lisp_Object registry = AREF (entity, FONT_REGISTRY_INDEX); |
782 struct charset *repertory; | 701 struct charset *repertory; |
783 | 702 |
784 if (xfont_registry_charsets (registry, NULL, &repertory) < 0) | 703 if (font_registry_charsets (registry, NULL, &repertory) < 0) |
785 return -1; | 704 return -1; |
786 if (! repertory) | 705 if (! repertory) |
787 return -1; | 706 return -1; |
788 return (ENCODE_CHAR (repertory, c) != CHARSET_INVALID_CODE (repertory)); | 707 return (ENCODE_CHAR (repertory, c) != CHARSET_INVALID_CODE (repertory)); |
789 } | 708 } |
901 | 820 |
902 | 821 |
903 void | 822 void |
904 syms_of_xfont () | 823 syms_of_xfont () |
905 { | 824 { |
906 staticpro (&x_font_charset_alist); | |
907 x_font_charset_alist = Qnil; | |
908 | |
909 DEFSYM (Qx, "x"); | 825 DEFSYM (Qx, "x"); |
910 xfont_driver.type = Qx; | 826 xfont_driver.type = Qx; |
911 register_font_driver (&xfont_driver, NULL); | 827 register_font_driver (&xfont_driver, NULL); |
912 } | 828 } |
913 | 829 |