aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2008-05-30 02:34:46 +0000
committerKenichi Handa2008-05-30 02:34:46 +0000
commit72606e458007f845e104d7dfd9368b8c5b966b6e (patch)
treec417aeb50fc46f22499b47631b3f353304a202bd /src
parenta118b59bed88dee370dba64bfc09245fb78dbf8b (diff)
downloademacs-72606e458007f845e104d7dfd9368b8c5b966b6e.tar.gz
emacs-72606e458007f845e104d7dfd9368b8c5b966b6e.zip
(font_style_to_value, font_score): Delete casting of the
args to xstcasecmp. (register_font_driver): Increment num_font_drivers only when registering the driver globally. (Ffont_info): Moved from fontset.c. Handle a font object too. (syms_of_font): Defsubr Sfont_info.
Diffstat (limited to 'src')
-rw-r--r--src/font.c89
1 files changed, 80 insertions, 9 deletions
diff --git a/src/font.c b/src/font.c
index 3a18d98bf20..84fb5ccd265 100644
--- a/src/font.c
+++ b/src/font.c
@@ -296,7 +296,7 @@ font_style_to_value (prop, val, noerror)
296 296
297 if (SYMBOLP (val)) 297 if (SYMBOLP (val))
298 { 298 {
299 char *s; 299 unsigned char *s;
300 Lisp_Object args[2], elt; 300 Lisp_Object args[2], elt;
301 301
302 /* At first try exact match. */ 302 /* At first try exact match. */
@@ -306,12 +306,12 @@ font_style_to_value (prop, val, noerror)
306 return ((XINT (AREF (AREF (table, i), 0)) << 8) 306 return ((XINT (AREF (AREF (table, i), 0)) << 8)
307 | (i << 4) | (j - 1)); 307 | (i << 4) | (j - 1));
308 /* Try also with case-folding match. */ 308 /* Try also with case-folding match. */
309 s = (char *) SDATA (SYMBOL_NAME (val)); 309 s = SDATA (SYMBOL_NAME (val));
310 for (i = 0; i < len; i++) 310 for (i = 0; i < len; i++)
311 for (j = 1; j < ASIZE (AREF (table, i)); j++) 311 for (j = 1; j < ASIZE (AREF (table, i)); j++)
312 { 312 {
313 elt = AREF (AREF (table, i), j); 313 elt = AREF (AREF (table, i), j);
314 if (xstrcasecmp (s, (char *) SDATA (SYMBOL_NAME (elt))) == 0) 314 if (xstrcasecmp (s, SDATA (SYMBOL_NAME (elt))) == 0)
315 return ((XINT (AREF (AREF (table, i), 0)) << 8) 315 return ((XINT (AREF (AREF (table, i), 0)) << 8)
316 | (i << 4) | (j - 1)); 316 | (i << 4) | (j - 1));
317 } 317 }
@@ -1980,8 +1980,7 @@ font_score (entity, spec_prop, alternate_families)
1980 Lisp_Object entity_str = SYMBOL_NAME (AREF (entity, i)); 1980 Lisp_Object entity_str = SYMBOL_NAME (AREF (entity, i));
1981 Lisp_Object spec_str = SYMBOL_NAME (spec_prop[i]); 1981 Lisp_Object spec_str = SYMBOL_NAME (spec_prop[i]);
1982 1982
1983 if (xstrcasecmp ((char *) SDATA (spec_str), 1983 if (xstrcasecmp (SDATA (spec_str), SDATA (entity_str)))
1984 (char *) SDATA (entity_str)))
1985 { 1984 {
1986 if (i == FONT_FAMILY_INDEX && CONSP (alternate_families)) 1985 if (i == FONT_FAMILY_INDEX && CONSP (alternate_families))
1987 { 1986 {
@@ -1991,10 +1990,8 @@ font_score (entity, spec_prop, alternate_families)
1991 j++, alternate_families = XCDR (alternate_families)) 1990 j++, alternate_families = XCDR (alternate_families))
1992 { 1991 {
1993 spec_str = XCAR (alternate_families); 1992 spec_str = XCAR (alternate_families);
1994 if (xstrcasecmp ((char *) SDATA (spec_str), 1993 if (xstrcasecmp (SDATA (spec_str), SDATA (entity_str)) == 0)
1995 (char *) SDATA (entity_str)) == 0)
1996 break; 1994 break;
1997
1998 } 1995 }
1999 if (j > 3) 1996 if (j > 3)
2000 j = 3; 1997 j = 3;
@@ -3095,7 +3092,8 @@ register_font_driver (driver, f)
3095 f->font_driver_list = list; 3092 f->font_driver_list = list;
3096 else 3093 else
3097 font_driver_list = list; 3094 font_driver_list = list;
3098 num_font_drivers++; 3095 if (! f)
3096 num_font_drivers++;
3099} 3097}
3100 3098
3101 3099
@@ -4351,6 +4349,78 @@ Type C-l to recover what previously shown. */)
4351 4349
4352#endif /* FONT_DEBUG */ 4350#endif /* FONT_DEBUG */
4353 4351
4352DEFUN ("font-info", Ffont_info, Sfont_info, 1, 2, 0,
4353 doc: /* Return information about a font named NAME on frame FRAME.
4354If FRAME is omitted or nil, use the selected frame.
4355The returned value is a vector of OPENED-NAME, FULL-NAME, CHARSET, SIZE,
4356 HEIGHT, BASELINE-OFFSET, RELATIVE-COMPOSE, and DEFAULT-ASCENT,
4357where
4358 OPENED-NAME is the name used for opening the font,
4359 FULL-NAME is the full name of the font,
4360 SIZE is the maximum bound width of the font,
4361 HEIGHT is the height of the font,
4362 BASELINE-OFFSET is the upward offset pixels from ASCII baseline,
4363 RELATIVE-COMPOSE and DEFAULT-ASCENT are the numbers controlling
4364 how to compose characters.
4365If the named font is not yet loaded, return nil. */)
4366 (name, frame)
4367 Lisp_Object name, frame;
4368{
4369 FRAME_PTR f;
4370 struct font *font;
4371 Lisp_Object info;
4372 Lisp_Object font_object;
4373
4374 (*check_window_system_func) ();
4375
4376 if (! FONTP (name))
4377 CHECK_STRING (name);
4378 if (NILP (frame))
4379 frame = selected_frame;
4380 CHECK_LIVE_FRAME (frame);
4381 f = XFRAME (frame);
4382
4383 if (STRINGP (name))
4384 {
4385 int fontset = fs_query_fontset (name, 0);
4386
4387 if (fontset >= 0)
4388 name = fontset_ascii (fontset);
4389 font_object = font_open_by_name (f, (char *) SDATA (name));
4390 }
4391 else if (FONT_OBJECT_P (name))
4392 font_object = name;
4393 else if (FONT_ENTITY_P (name))
4394 font_object = font_open_entity (f, name, 0);
4395 else
4396 {
4397 struct face *face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
4398 Lisp_Object entity = font_matching_entity (f, face->lface, name);
4399
4400 font_object = ! NILP (entity) ? font_open_entity (f, entity, 0) : Qnil;
4401 }
4402 if (NILP (font_object))
4403 return Qnil;
4404 font = XFONT_OBJECT (font_object);
4405
4406 info = Fmake_vector (make_number (7), Qnil);
4407 XVECTOR (info)->contents[0] = AREF (font_object, FONT_NAME_INDEX);
4408 XVECTOR (info)->contents[1] = AREF (font_object, FONT_NAME_INDEX);
4409 XVECTOR (info)->contents[2] = make_number (font->pixel_size);
4410 XVECTOR (info)->contents[3] = make_number (font->height);
4411 XVECTOR (info)->contents[4] = make_number (font->baseline_offset);
4412 XVECTOR (info)->contents[5] = make_number (font->relative_compose);
4413 XVECTOR (info)->contents[6] = make_number (font->default_ascent);
4414
4415#if 0
4416 /* As font_object is still in FONT_OBJLIST of the entity, we can't
4417 close it now. Perhaps, we should manage font-objects
4418 by `reference-count'. */
4419 font_close_object (f, font_object);
4420#endif
4421 return info;
4422}
4423
4354 4424
4355#define BUILD_STYLE_TABLE(TBL) \ 4425#define BUILD_STYLE_TABLE(TBL) \
4356 build_style_table ((TBL), sizeof TBL / sizeof (struct table_entry)) 4426 build_style_table ((TBL), sizeof TBL / sizeof (struct table_entry))
@@ -4521,6 +4591,7 @@ syms_of_font ()
4521 defsubr (&Sdraw_string); 4591 defsubr (&Sdraw_string);
4522#endif 4592#endif
4523#endif /* FONT_DEBUG */ 4593#endif /* FONT_DEBUG */
4594 defsubr (&Sfont_info);
4524 4595
4525 DEFVAR_LISP ("font-encoding-alist", &Vfont_encoding_alist, 4596 DEFVAR_LISP ("font-encoding-alist", &Vfont_encoding_alist,
4526 doc: /* 4597 doc: /*