Mercurial > emacs
comparison src/font.c @ 95403:26df7325a6ff
(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.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 30 May 2008 02:34:46 +0000 |
parents | f6580a4c58da |
children | 3350c9ac1f37 |
comparison
equal
deleted
inserted
replaced
95402:6f0d3ea7dbbe | 95403:26df7325a6ff |
---|---|
294 int len = ASIZE (table); | 294 int len = ASIZE (table); |
295 int i, j; | 295 int i, j; |
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. */ |
303 for (i = 0; i < len; i++) | 303 for (i = 0; i < len; i++) |
304 for (j = 1; j < ASIZE (AREF (table, i)); j++) | 304 for (j = 1; j < ASIZE (AREF (table, i)); j++) |
305 if (EQ (val, AREF (AREF (table, i), j))) | 305 if (EQ (val, AREF (AREF (table, i), j))) |
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 } |
318 if (! noerror) | 318 if (! noerror) |
319 return -1; | 319 return -1; |
1978 && ! NILP (spec_prop[i]) && ! EQ (AREF (entity, i), spec_prop[i])) | 1978 && ! NILP (spec_prop[i]) && ! EQ (AREF (entity, i), spec_prop[i])) |
1979 { | 1979 { |
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 { |
1988 int j; | 1987 int j; |
1989 | 1988 |
1990 for (j = 1; CONSP (alternate_families); | 1989 for (j = 1; CONSP (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; |
2001 score |= j << sort_shift_bits[i]; | 1998 score |= j << sort_shift_bits[i]; |
2002 } | 1999 } |
3093 prev->next = list; | 3090 prev->next = list; |
3094 else if (f) | 3091 else if (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 |
3102 /* Free font-driver list on frame F. It doesn't free font-drivers | 3100 /* Free font-driver list on frame F. It doesn't free font-drivers |
3103 themselves. */ | 3101 themselves. */ |
4349 } | 4347 } |
4350 #endif | 4348 #endif |
4351 | 4349 |
4352 #endif /* FONT_DEBUG */ | 4350 #endif /* FONT_DEBUG */ |
4353 | 4351 |
4352 DEFUN ("font-info", Ffont_info, Sfont_info, 1, 2, 0, | |
4353 doc: /* Return information about a font named NAME on frame FRAME. | |
4354 If FRAME is omitted or nil, use the selected frame. | |
4355 The returned value is a vector of OPENED-NAME, FULL-NAME, CHARSET, SIZE, | |
4356 HEIGHT, BASELINE-OFFSET, RELATIVE-COMPOSE, and DEFAULT-ASCENT, | |
4357 where | |
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. | |
4365 If 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)) |
4357 | 4427 |
4358 static Lisp_Object | 4428 static Lisp_Object |
4519 defsubr (&Sfont_at); | 4589 defsubr (&Sfont_at); |
4520 #if 0 | 4590 #if 0 |
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: /* |
4527 Alist of fontname patterns vs the corresponding encoding and repertory info. | 4598 Alist of fontname patterns vs the corresponding encoding and repertory info. |
4528 Each element looks like (REGEXP . (ENCODING . REPERTORY)), | 4599 Each element looks like (REGEXP . (ENCODING . REPERTORY)), |