Mercurial > emacs
comparison src/xfaces.c @ 47618:e620377a0596
(try_font_list): New arg PREFER_FACE_FAMILY. If it is
nonzero, try face's family at first. Otherwise try FAMILY at
first.
(choose_face_font): If C is a single byte char or latin-1, call
try_font_list with PREFER_FACE_FAMILY 1.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Thu, 26 Sep 2002 08:03:52 +0000 |
parents | 8ed65bf4ee3d |
children | a7c8409f5cad |
comparison
equal
deleted
inserted
replaced
47617:ccda37186e6e | 47618:e620377a0596 |
---|---|
508 static int font_list_1 P_ ((struct frame *, Lisp_Object, Lisp_Object, | 508 static int font_list_1 P_ ((struct frame *, Lisp_Object, Lisp_Object, |
509 Lisp_Object, struct font_name **)); | 509 Lisp_Object, struct font_name **)); |
510 static int font_list P_ ((struct frame *, Lisp_Object, Lisp_Object, | 510 static int font_list P_ ((struct frame *, Lisp_Object, Lisp_Object, |
511 Lisp_Object, struct font_name **)); | 511 Lisp_Object, struct font_name **)); |
512 static int try_font_list P_ ((struct frame *, Lisp_Object *, | 512 static int try_font_list P_ ((struct frame *, Lisp_Object *, |
513 Lisp_Object, Lisp_Object, struct font_name **)); | 513 Lisp_Object, Lisp_Object, struct font_name **, |
514 int)); | |
514 static int try_alternative_families P_ ((struct frame *f, Lisp_Object, | 515 static int try_alternative_families P_ ((struct frame *f, Lisp_Object, |
515 Lisp_Object, struct font_name **)); | 516 Lisp_Object, struct font_name **)); |
516 static int cmp_font_names P_ ((const void *, const void *)); | 517 static int cmp_font_names P_ ((const void *, const void *)); |
517 static struct face *realize_face P_ ((struct face_cache *, Lisp_Object *, int, | 518 static struct face *realize_face P_ ((struct face_cache *, Lisp_Object *, int, |
518 struct face *, int)); | 519 struct face *, int)); |
6322 | 6323 |
6323 REGISTRY, if a string, specifies a font registry and encoding to | 6324 REGISTRY, if a string, specifies a font registry and encoding to |
6324 match. A value of nil means include fonts of any registry and | 6325 match. A value of nil means include fonts of any registry and |
6325 encoding. | 6326 encoding. |
6326 | 6327 |
6328 If PREFER_FACE_FAMILY is nonzero, perfer face's family to FAMILY. | |
6329 Otherwise, prefer FAMILY. | |
6330 | |
6327 Return in *FONTS a pointer to a vector of font_name structures for | 6331 Return in *FONTS a pointer to a vector of font_name structures for |
6328 the fonts matched. Value is the number of fonts found. */ | 6332 the fonts matched. Value is the number of fonts found. */ |
6329 | 6333 |
6330 static int | 6334 static int |
6331 try_font_list (f, attrs, family, registry, fonts) | 6335 try_font_list (f, attrs, family, registry, fonts, prefer_face_family) |
6332 struct frame *f; | 6336 struct frame *f; |
6333 Lisp_Object *attrs; | 6337 Lisp_Object *attrs; |
6334 Lisp_Object family, registry; | 6338 Lisp_Object family, registry; |
6335 struct font_name **fonts; | 6339 struct font_name **fonts; |
6340 int prefer_face_family; | |
6336 { | 6341 { |
6337 int nfonts = 0; | 6342 int nfonts = 0; |
6338 Lisp_Object face_family = attrs[LFACE_FAMILY_INDEX]; | 6343 Lisp_Object face_family = attrs[LFACE_FAMILY_INDEX]; |
6339 | 6344 Lisp_Object try_family; |
6340 if (STRINGP (face_family)) | 6345 |
6341 nfonts = try_alternative_families (f, face_family, registry, fonts); | 6346 try_family = prefer_face_family ? face_family : family; |
6347 | |
6348 if (STRINGP (try_family)) | |
6349 nfonts = try_alternative_families (f, try_family, registry, fonts); | |
6342 | 6350 |
6343 #ifdef MAC_OS | 6351 #ifdef MAC_OS |
6344 /* When realizing the default face and a font spec does not matched | 6352 /* When realizing the default face and a font spec does not matched |
6345 exactly, Emacs looks for ones with the same registry as the | 6353 exactly, Emacs looks for ones with the same registry as the |
6346 default font. On the Mac, this is mac-roman, which does not work | 6354 default font. On the Mac, this is mac-roman, which does not work |
6347 if the family is -etl-fixed, e.g. The following widens the | 6355 if the family is -etl-fixed, e.g. The following widens the |
6348 choices and fixes that problem. */ | 6356 choices and fixes that problem. */ |
6349 if (nfonts == 0 && STRINGP (face_family) && STRINGP (registry) | 6357 if (nfonts == 0 && STRINGP (try_family) && STRINGP (registry) |
6350 && xstricmp (SDATA (registry), "mac-roman") == 0) | 6358 && xstricmp (SDATA (registry), "mac-roman") == 0) |
6351 nfonts = try_alternative_families (f, face_family, Qnil, fonts); | 6359 nfonts = try_alternative_families (f, try_family, Qnil, fonts); |
6352 #endif | 6360 #endif |
6353 | 6361 |
6354 if (nfonts == 0 && !NILP (family)) | 6362 if (! prefer_face_family) |
6363 family = face_family; | |
6364 | |
6365 if (nfonts == 0 && STRINGP (family)) | |
6355 nfonts = try_alternative_families (f, family, registry, fonts); | 6366 nfonts = try_alternative_families (f, family, registry, fonts); |
6356 | 6367 |
6357 /* Try font family of the default face or "fixed". */ | 6368 /* Try font family of the default face or "fixed". */ |
6358 if (nfonts == 0) | 6369 if (nfonts == 0) |
6359 { | 6370 { |
6423 if (STRINGP (pattern)) | 6434 if (STRINGP (pattern)) |
6424 return xstrdup (SDATA (pattern)); | 6435 return xstrdup (SDATA (pattern)); |
6425 | 6436 |
6426 /* Get a list of fonts matching that pattern and choose the | 6437 /* Get a list of fonts matching that pattern and choose the |
6427 best match for the specified face attributes from it. */ | 6438 best match for the specified face attributes from it. */ |
6428 nfonts = try_font_list (f, attrs, XCAR (pattern), XCDR (pattern), &fonts); | 6439 nfonts = try_font_list (f, attrs, XCAR (pattern), XCDR (pattern), &fonts, |
6440 (SINGLE_BYTE_CHAR_P (c) | |
6441 || CHAR_CHARSET (c) == charset_latin_iso8859_1)); | |
6429 width_ratio = (SINGLE_BYTE_CHAR_P (c) | 6442 width_ratio = (SINGLE_BYTE_CHAR_P (c) |
6430 ? 1 | 6443 ? 1 |
6431 : CHARSET_WIDTH (CHAR_CHARSET (c))); | 6444 : CHARSET_WIDTH (CHAR_CHARSET (c))); |
6432 font_name = best_matching_font (f, attrs, fonts, nfonts, width_ratio); | 6445 font_name = best_matching_font (f, attrs, fonts, nfonts, width_ratio); |
6433 return font_name; | 6446 return font_name; |