aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2008-05-20 06:33:10 +0000
committerKenichi Handa2008-05-20 06:33:10 +0000
commit819e81df0224fa777a721ecb2bf27412f0bdb2cb (patch)
tree7df6bc52aca7ca262402f3433b2af339635b018c /src
parente6aca9f35e3aef4d3ded65782a5a1dd29e35d082 (diff)
downloademacs-819e81df0224fa777a721ecb2bf27412f0bdb2cb.tar.gz
emacs-819e81df0224fa777a721ecb2bf27412f0bdb2cb.zip
(Vfont_encoding_alist, find_font_encoding): Moved from
fontset.c. (font_pixel_size)[! HAVE_WINDOW_SYSTEM]: Return 1. (font_open_entity): Update FRAME_X_DISPLAY_INFO (f)->n_fonts, FRAME_SMALLEST_CHAR_WIDTH (f), and FRAME_SMALLEST_FONT_HEIGHT (f) only when HAVE_WINDOW_SYSTEM is defined. (font_close_object): Update FRAME_X_DISPLAY_INFO (f)->n_fonts only when HAVE_WINDOW_SYSTEM is defined.
Diffstat (limited to 'src')
-rw-r--r--src/font.c65
1 files changed, 63 insertions, 2 deletions
diff --git a/src/font.c b/src/font.c
index 4f75615d8ed..d6c0305ffb1 100644
--- a/src/font.c
+++ b/src/font.c
@@ -93,6 +93,8 @@ Lisp_Object QCantialias, QCfont_entity, QCfc_unknown_spec;
93/* Symbols representing values of font spacing property. */ 93/* Symbols representing values of font spacing property. */
94Lisp_Object Qc, Qm, Qp, Qd; 94Lisp_Object Qc, Qm, Qp, Qd;
95 95
96Lisp_Object Vfont_encoding_alist;
97
96/* Alist of font registry symbol and the corresponding charsets 98/* Alist of font registry symbol and the corresponding charsets
97 information. The information is retrieved from 99 information. The information is retrieved from
98 Vfont_encoding_alist on demand. 100 Vfont_encoding_alist on demand.
@@ -209,6 +211,7 @@ font_pixel_size (f, spec)
209 FRAME_PTR f; 211 FRAME_PTR f;
210 Lisp_Object spec; 212 Lisp_Object spec;
211{ 213{
214#ifdef HAVE_WINDOW_SYSTEM
212 Lisp_Object size = AREF (spec, FONT_SIZE_INDEX); 215 Lisp_Object size = AREF (spec, FONT_SIZE_INDEX);
213 double point_size; 216 double point_size;
214 int dpi, pixel_size; 217 int dpi, pixel_size;
@@ -217,7 +220,8 @@ font_pixel_size (f, spec)
217 if (INTEGERP (size)) 220 if (INTEGERP (size))
218 return XINT (size); 221 return XINT (size);
219 if (NILP (size)) 222 if (NILP (size))
220 return 0; xassert (FLOATP (size)); 223 return 0;
224 xassert (FLOATP (size));
221 point_size = XFLOAT_DATA (size); 225 point_size = XFLOAT_DATA (size);
222 val = AREF (spec, FONT_DPI_INDEX); 226 val = AREF (spec, FONT_DPI_INDEX);
223 if (INTEGERP (val)) 227 if (INTEGERP (val))
@@ -226,6 +230,9 @@ font_pixel_size (f, spec)
226 dpi = f->resy; 230 dpi = f->resy;
227 pixel_size = POINT_TO_PIXEL (point_size, dpi); 231 pixel_size = POINT_TO_PIXEL (point_size, dpi);
228 return pixel_size; 232 return pixel_size;
233#else
234 return 1;
235#endif
229} 236}
230 237
231 238
@@ -328,6 +335,31 @@ extern Lisp_Object Vface_alternative_font_family_alist;
328extern Lisp_Object find_font_encoding P_ ((Lisp_Object)); 335extern Lisp_Object find_font_encoding P_ ((Lisp_Object));
329 336
330 337
338/* Return ENCODING or a cons of ENCODING and REPERTORY of the font
339 FONTNAME. ENCODING is a charset symbol that specifies the encoding
340 of the font. REPERTORY is a charset symbol or nil. */
341
342Lisp_Object
343find_font_encoding (fontname)
344 Lisp_Object fontname;
345{
346 Lisp_Object tail, elt;
347
348 for (tail = Vfont_encoding_alist; CONSP (tail); tail = XCDR (tail))
349 {
350 elt = XCAR (tail);
351 if (CONSP (elt)
352 && STRINGP (XCAR (elt))
353 && fast_string_match_ignore_case (XCAR (elt), fontname) >= 0
354 && (SYMBOLP (XCDR (elt))
355 ? CHARSETP (XCDR (elt))
356 : CONSP (XCDR (elt)) && CHARSETP (XCAR (XCDR (elt)))))
357 return (XCDR (elt));
358 }
359 /* We don't know the encoding of this font. Let's assume `ascii'. */
360 return Qascii;
361}
362
331/* Return encoding charset and repertory charset for REGISTRY in 363/* Return encoding charset and repertory charset for REGISTRY in
332 ENCODING and REPERTORY correspondingly. If correct information for 364 ENCODING and REPERTORY correspondingly. If correct information for
333 REGISTRY is available, return 0. Otherwise return -1. */ 365 REGISTRY is available, return 0. Otherwise return -1. */
@@ -2141,6 +2173,7 @@ font_check_object (font)
2141} 2173}
2142 2174
2143 2175
2176
2144/* Font cache 2177/* Font cache
2145 2178
2146 Each font backend has the callback function get_cache, and it 2179 Each font backend has the callback function get_cache, and it
@@ -2496,6 +2529,7 @@ font_open_entity (f, entity, pixel_size)
2496 : font->average_width ? font->average_width 2529 : font->average_width ? font->average_width
2497 : font->space_width ? font->space_width 2530 : font->space_width ? font->space_width
2498 : 1); 2531 : 1);
2532#ifdef HAVE_WINDOW_SYSTEM
2499 FRAME_X_DISPLAY_INFO (f)->n_fonts++; 2533 FRAME_X_DISPLAY_INFO (f)->n_fonts++;
2500 if (FRAME_X_DISPLAY_INFO (f)->n_fonts == 1) 2534 if (FRAME_X_DISPLAY_INFO (f)->n_fonts == 1)
2501 { 2535 {
@@ -2510,6 +2544,7 @@ font_open_entity (f, entity, pixel_size)
2510 if (FRAME_SMALLEST_FONT_HEIGHT (f) > font->height) 2544 if (FRAME_SMALLEST_FONT_HEIGHT (f) > font->height)
2511 FRAME_SMALLEST_FONT_HEIGHT (f) = font->height, fonts_changed_p = 1; 2545 FRAME_SMALLEST_FONT_HEIGHT (f) = font->height, fonts_changed_p = 1;
2512 } 2546 }
2547#endif
2513 2548
2514 return font_object; 2549 return font_object;
2515} 2550}
@@ -2531,9 +2566,11 @@ font_close_object (f, font_object)
2531 prev = tail, tail = XCDR (tail)) 2566 prev = tail, tail = XCDR (tail))
2532 if (EQ (font_object, XCAR (tail))) 2567 if (EQ (font_object, XCAR (tail)))
2533 { 2568 {
2534 xassert (FRAME_X_DISPLAY_INFO (f)->n_fonts);
2535 font->driver->close (f, font); 2569 font->driver->close (f, font);
2570#ifdef HAVE_WINDOW_SYSTEM
2571 xassert (FRAME_X_DISPLAY_INFO (f)->n_fonts);
2536 FRAME_X_DISPLAY_INFO (f)->n_fonts--; 2572 FRAME_X_DISPLAY_INFO (f)->n_fonts--;
2573#endif
2537 if (NILP (prev)) 2574 if (NILP (prev))
2538 ASET (font_object, FONT_OBJLIST_INDEX, XCDR (objlist)); 2575 ASET (font_object, FONT_OBJLIST_INDEX, XCDR (objlist));
2539 else 2576 else
@@ -4409,6 +4446,29 @@ syms_of_font ()
4409#endif 4446#endif
4410#endif /* FONT_DEBUG */ 4447#endif /* FONT_DEBUG */
4411 4448
4449 DEFVAR_LISP ("font-encoding-alist", &Vfont_encoding_alist,
4450 doc: /*
4451Alist of fontname patterns vs the corresponding encoding and repertory info.
4452Each element looks like (REGEXP . (ENCODING . REPERTORY)),
4453where ENCODING is a charset or a char-table,
4454and REPERTORY is a charset, a char-table, or nil.
4455
4456If ENCDING and REPERTORY are the same, the element can have the form
4457\(REGEXP . ENCODING).
4458
4459ENCODING is for converting a character to a glyph code of the font.
4460If ENCODING is a charset, encoding a character by the charset gives
4461the corresponding glyph code. If ENCODING is a char-table, looking up
4462the table by a character gives the corresponding glyph code.
4463
4464REPERTORY specifies a repertory of characters supported by the font.
4465If REPERTORY is a charset, all characters beloging to the charset are
4466supported. If REPERTORY is a char-table, all characters who have a
4467non-nil value in the table are supported. It REPERTORY is nil, Emacs
4468gets the repertory information by an opened font and ENCODING. */);
4469 Vfont_encoding_alist = Qnil;
4470
4471#ifdef HAVE_WINDOW_SYSTEM
4412#ifdef HAVE_FREETYPE 4472#ifdef HAVE_FREETYPE
4413 syms_of_ftfont (); 4473 syms_of_ftfont ();
4414#ifdef HAVE_X_WINDOWS 4474#ifdef HAVE_X_WINDOWS
@@ -4432,6 +4492,7 @@ syms_of_font ()
4432#ifdef MAC_OS 4492#ifdef MAC_OS
4433 syms_of_atmfont (); 4493 syms_of_atmfont ();
4434#endif /* MAC_OS */ 4494#endif /* MAC_OS */
4495#endif /* HAVE_WINDOW_SYSTEM */
4435} 4496}
4436 4497
4437/* arch-tag: 74c9475d-5976-4c93-a327-942ae3072846 4498/* arch-tag: 74c9475d-5976-4c93-a327-942ae3072846