aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2001-04-04 12:56:14 +0000
committerGerd Moellmann2001-04-04 12:56:14 +0000
commit702a1e8e62463a675282f3e04667bc3ab68ba337 (patch)
tree54a7f699013368b93e8e2ec596c49dd199befe41 /src
parent32df8b472ad3d7886f95d74bd499ae0aee24fe2b (diff)
downloademacs-702a1e8e62463a675282f3e04667bc3ab68ba337.tar.gz
emacs-702a1e8e62463a675282f3e04667bc3ab68ba337.zip
(best_matching_font): Remove unused parameter PATTERN.
(first_font_matching): Removed unused function. (x_face_list_fonts): Remove unused parameter SCALABLE_P. (may_use_scalable_font_p): Remove parameter FONT; rename parameter NAME to FONT. (x_face_list_fonts): Fix missing bounds check. (realizing_default_face_p): New variable. (realize_default_face): Set and clear that flag. (x_face_list_fonts): When called during the realization of the default face, and no matching fonts are found when ignoring scalable fonts and fonts matching a regexp from face-ignored-fonts, try without ignoring fonts.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog15
-rw-r--r--src/xfaces.c134
2 files changed, 82 insertions, 67 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 28515da69a9..a0225dd188c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,18 @@
12001-04-04 Gerd Moellmann <gerd@gnu.org>
2
3 * xfaces.c (best_matching_font): Remove unused parameter PATTERN.
4 (first_font_matching): Removed unused function.
5 (x_face_list_fonts): Remove unused parameter SCALABLE_P.
6 (may_use_scalable_font_p): Remove parameter FONT; rename
7 parameter NAME to FONT.
8 (x_face_list_fonts): Fix missing bounds check.
9 (realizing_default_face_p): New variable.
10 (realize_default_face): Set and clear that flag.
11 (x_face_list_fonts): When called during the realization of the
12 default face, and no matching fonts are found when ignoring
13 scalable fonts and fonts matching a regexp from
14 face-ignored-fonts, try without ignoring fonts.
15
12001-04-03 Gerd Moellmann <gerd@gnu.org> 162001-04-03 Gerd Moellmann <gerd@gnu.org>
2 17
3 * xfns.c (postprocess_image): New function. 18 * xfns.c (postprocess_image): New function.
diff --git a/src/xfaces.c b/src/xfaces.c
index d3c99b30016..caf69488145 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -487,6 +487,10 @@ int tty_suppress_bold_inverse_default_colors_p;
487 487
488static Lisp_Object Vparam_value_alist; 488static Lisp_Object Vparam_value_alist;
489 489
490/* Non-zero while realizing the default face. */
491
492static int realizing_default_face_p;
493
490/* The total number of colors currently allocated. */ 494/* The total number of colors currently allocated. */
491 495
492#if GLYPH_DEBUG 496#if GLYPH_DEBUG
@@ -505,14 +509,12 @@ struct table_entry;
505static void map_tty_color P_ ((struct frame *, struct face *, 509static void map_tty_color P_ ((struct frame *, struct face *,
506 enum lface_attribute_index, int *)); 510 enum lface_attribute_index, int *));
507static Lisp_Object resolve_face_name P_ ((Lisp_Object)); 511static Lisp_Object resolve_face_name P_ ((Lisp_Object));
508static int may_use_scalable_font_p P_ ((struct font_name *, char *)); 512static int may_use_scalable_font_p P_ ((char *));
509static void set_font_frame_param P_ ((Lisp_Object, Lisp_Object)); 513static void set_font_frame_param P_ ((Lisp_Object, Lisp_Object));
510static int better_font_p P_ ((int *, struct font_name *, struct font_name *, 514static int better_font_p P_ ((int *, struct font_name *, struct font_name *,
511 int, int)); 515 int, int));
512static int first_font_matching P_ ((struct frame *f, char *,
513 struct font_name *));
514static int x_face_list_fonts P_ ((struct frame *, char *, 516static int x_face_list_fonts P_ ((struct frame *, char *,
515 struct font_name *, int, int, int)); 517 struct font_name *, int, int));
516static int font_scalable_p P_ ((struct font_name *)); 518static int font_scalable_p P_ ((struct font_name *));
517static int get_lface_attributes P_ ((struct frame *, Lisp_Object, Lisp_Object *, int)); 519static int get_lface_attributes P_ ((struct frame *, Lisp_Object, Lisp_Object *, int));
518static int load_pixmap P_ ((struct frame *, Lisp_Object, unsigned *, unsigned *)); 520static int load_pixmap P_ ((struct frame *, Lisp_Object, unsigned *, unsigned *));
@@ -532,7 +534,7 @@ static int font_list_1 P_ ((struct frame *, Lisp_Object, Lisp_Object,
532 Lisp_Object, struct font_name **)); 534 Lisp_Object, struct font_name **));
533static int font_list P_ ((struct frame *, Lisp_Object, Lisp_Object, 535static int font_list P_ ((struct frame *, Lisp_Object, Lisp_Object,
534 Lisp_Object, struct font_name **)); 536 Lisp_Object, struct font_name **));
535static int try_font_list P_ ((struct frame *, Lisp_Object *, Lisp_Object, 537static int try_font_list P_ ((struct frame *, Lisp_Object *,
536 Lisp_Object, Lisp_Object, struct font_name **)); 538 Lisp_Object, Lisp_Object, struct font_name **));
537static int cmp_font_names P_ ((const void *, const void *)); 539static int cmp_font_names P_ ((const void *, const void *));
538static struct face *realize_face P_ ((struct face_cache *, Lisp_Object *, int, 540static struct face *realize_face P_ ((struct face_cache *, Lisp_Object *, int,
@@ -2287,23 +2289,20 @@ sort_fonts (f, fonts, nfonts, cmpfn)
2287 display in x_display_list. FONTS is a pointer to a vector of 2289 display in x_display_list. FONTS is a pointer to a vector of
2288 NFONTS font_name structures. TRY_ALTERNATIVES_P non-zero means try 2290 NFONTS font_name structures. TRY_ALTERNATIVES_P non-zero means try
2289 alternative patterns from Valternate_fontname_alist if no fonts are 2291 alternative patterns from Valternate_fontname_alist if no fonts are
2290 found matching PATTERN. SCALABLE_FONTS_P non-zero means include 2292 found matching PATTERN.
2291 scalable fonts.
2292 2293
2293 For all fonts found, set FONTS[i].name to the name of the font, 2294 For all fonts found, set FONTS[i].name to the name of the font,
2294 allocated via xmalloc, and split font names into fields. Ignore 2295 allocated via xmalloc, and split font names into fields. Ignore
2295 fonts that we can't parse. Value is the number of fonts found. */ 2296 fonts that we can't parse. Value is the number of fonts found. */
2296 2297
2297static int 2298static int
2298x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p, 2299x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p)
2299 scalable_fonts_p)
2300 struct frame *f; 2300 struct frame *f;
2301 char *pattern; 2301 char *pattern;
2302 struct font_name *fonts; 2302 struct font_name *fonts;
2303 int nfonts, try_alternatives_p; 2303 int nfonts, try_alternatives_p;
2304 int scalable_fonts_p;
2305{ 2304{
2306 int n; 2305 int n, nignored;
2307 2306
2308 /* NTEMACS_TODO : currently this uses w32_list_fonts, but it may be 2307 /* NTEMACS_TODO : currently this uses w32_list_fonts, but it may be
2309 better to do it the other way around. */ 2308 better to do it the other way around. */
@@ -2318,17 +2317,18 @@ x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p,
2318 lfonts = w32_list_fonts (f, lpattern, 0, nfonts); 2317 lfonts = w32_list_fonts (f, lpattern, 0, nfonts);
2319 UNBLOCK_INPUT; 2318 UNBLOCK_INPUT;
2320#else 2319#else
2321 lfonts = x_list_fonts (f, lpattern, scalable_fonts_p ? -1 : 0, nfonts); 2320 lfonts = x_list_fonts (f, lpattern, -1, nfonts);
2322#endif 2321#endif
2323 2322
2324 /* Make a copy of the font names we got from X, and 2323 /* Make a copy of the font names we got from X, and
2325 split them into fields. */ 2324 split them into fields. */
2326 n = 0; 2325 n = nignored = 0;
2327 for (tem = lfonts; CONSP (tem); tem = XCDR (tem)) 2326 for (tem = lfonts; CONSP (tem) && n < nfonts; tem = XCDR (tem))
2328 { 2327 {
2329 Lisp_Object elt, tail; 2328 Lisp_Object elt, tail;
2330 char *name = XSTRING (XCAR (tem))->data; 2329 char *name = XSTRING (XCAR (tem))->data;
2331 2330
2331 /* Ignore fonts matching a pattern from face-ignored-fonts. */
2332 for (tail = Vface_ignored_fonts; CONSP (tail); tail = XCDR (tail)) 2332 for (tail = Vface_ignored_fonts; CONSP (tail); tail = XCDR (tail))
2333 { 2333 {
2334 elt = XCAR (tail); 2334 elt = XCAR (tail);
@@ -2337,24 +2337,44 @@ x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p,
2337 break; 2337 break;
2338 } 2338 }
2339 if (!NILP (tail)) 2339 if (!NILP (tail))
2340 continue; 2340 {
2341 ++nignored;
2342 continue;
2343 }
2341 2344
2342 /* Make a copy of the font name. */ 2345 /* Make a copy of the font name. */
2343 fonts[n].name = xstrdup (name); 2346 fonts[n].name = xstrdup (name);
2344 2347
2345 /* Ignore fonts having a name that we can't parse. */ 2348 if (split_font_name (f, fonts + n, 1))
2346 if (!split_font_name (f, fonts + n, 1))
2347 xfree (fonts[n].name);
2348 else if (font_scalable_p (fonts + n))
2349 { 2349 {
2350 if (!scalable_fonts_p 2350 if (font_scalable_p (fonts + n)
2351 || !may_use_scalable_font_p (fonts + n, name)) 2351 && !may_use_scalable_font_p (name))
2352 xfree (fonts[n].name); 2352 {
2353 ++nignored;
2354 xfree (fonts[n].name);
2355 }
2353 else 2356 else
2354 ++n; 2357 ++n;
2355 } 2358 }
2356 else 2359 else
2357 ++n; 2360 xfree (fonts[n].name);
2361 }
2362
2363 /* If someone specified a default font that's scalable, try
2364 to do the right thing. */
2365 if (realizing_default_face_p
2366 && try_alternatives_p
2367 && n == 0
2368 && nignored > 0)
2369 {
2370 for (tem = lfonts; CONSP (tem) && n < nfonts; tem = XCDR (tem))
2371 {
2372 fonts[n].name = xstrdup (XSTRING (XCAR (tem))->data);
2373 if (split_font_name (f, fonts + n, 1))
2374 ++n;
2375 else
2376 xfree (fonts[n].name);
2377 }
2358 } 2378 }
2359 2379
2360 /* If no fonts found, try patterns from Valternate_fontname_alist. */ 2380 /* If no fonts found, try patterns from Valternate_fontname_alist. */
@@ -2385,8 +2405,7 @@ x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p,
2385 already with no success. */ 2405 already with no success. */
2386 && (strcmp (XSTRING (name)->data, pattern) == 0 2406 && (strcmp (XSTRING (name)->data, pattern) == 0
2387 || (n = x_face_list_fonts (f, XSTRING (name)->data, 2407 || (n = x_face_list_fonts (f, XSTRING (name)->data,
2388 fonts, nfonts, 0, 2408 fonts, nfonts, 0),
2389 scalable_fonts_p),
2390 n == 0))) 2409 n == 0)))
2391 patterns = XCDR (patterns); 2410 patterns = XCDR (patterns);
2392 } 2411 }
@@ -2396,34 +2415,6 @@ x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p,
2396} 2415}
2397 2416
2398 2417
2399/* Determine the first font matching PATTERN on frame F. Return in
2400 *FONT the matching font name, split into fields. Value is non-zero
2401 if a match was found. */
2402
2403static int
2404first_font_matching (f, pattern, font)
2405 struct frame *f;
2406 char *pattern;
2407 struct font_name *font;
2408{
2409 int nfonts = 100;
2410 struct font_name *fonts;
2411
2412 fonts = (struct font_name *) xmalloc (nfonts * sizeof *fonts);
2413 nfonts = x_face_list_fonts (f, pattern, fonts, nfonts, 1, 0);
2414
2415 if (nfonts > 0)
2416 {
2417 bcopy (&fonts[0], font, sizeof *font);
2418
2419 fonts[0].name = NULL;
2420 free_font_names (fonts, nfonts);
2421 }
2422
2423 return nfonts > 0;
2424}
2425
2426
2427/* Determine fonts matching PATTERN on frame F. Sort resulting fonts 2418/* Determine fonts matching PATTERN on frame F. Sort resulting fonts
2428 using comparison function CMPFN. Value is the number of fonts 2419 using comparison function CMPFN. Value is the number of fonts
2429 found. If value is non-zero, *FONTS is set to a vector of 2420 found. If value is non-zero, *FONTS is set to a vector of
@@ -2447,7 +2438,7 @@ sorted_font_list (f, pattern, cmpfn, fonts)
2447 nfonts = XFASTINT (Vfont_list_limit); 2438 nfonts = XFASTINT (Vfont_list_limit);
2448 2439
2449 *fonts = (struct font_name *) xmalloc (nfonts * sizeof **fonts); 2440 *fonts = (struct font_name *) xmalloc (nfonts * sizeof **fonts);
2450 nfonts = x_face_list_fonts (f, pattern, *fonts, nfonts, 1, 1); 2441 nfonts = x_face_list_fonts (f, pattern, *fonts, nfonts, 1);
2451 2442
2452 /* Sort the resulting array and return it in *FONTS. If no 2443 /* Sort the resulting array and return it in *FONTS. If no
2453 fonts were found, make sure to set *FONTS to null. */ 2444 fonts were found, make sure to set *FONTS to null. */
@@ -5677,9 +5668,8 @@ build_scalable_font_name (f, font, specified_pt)
5677 with input blocked. */ 5668 with input blocked. */
5678 5669
5679static int 5670static int
5680may_use_scalable_font_p (font, name) 5671may_use_scalable_font_p (font)
5681 struct font_name *font; 5672 char *font;
5682 char *name;
5683{ 5673{
5684 if (EQ (Vscalable_fonts_allowed, Qt)) 5674 if (EQ (Vscalable_fonts_allowed, Qt))
5685 return 1; 5675 return 1;
@@ -5691,7 +5681,7 @@ may_use_scalable_font_p (font, name)
5691 { 5681 {
5692 regexp = XCAR (tail); 5682 regexp = XCAR (tail);
5693 if (STRINGP (regexp) 5683 if (STRINGP (regexp)
5694 && fast_c_string_match_ignore_case (regexp, name) >= 0) 5684 && fast_c_string_match_ignore_case (regexp, font) >= 0)
5695 return 1; 5685 return 1;
5696 } 5686 }
5697 } 5687 }
@@ -5817,16 +5807,23 @@ best_matching_font (f, attrs, fonts, nfonts, width_ratio)
5817} 5807}
5818 5808
5819 5809
5820/* Try to get a list of fonts on frame F with font family FAMILY and 5810/* Get a list of matching fonts on frame F.
5821 registry/encoding REGISTRY. Return in *FONTS a pointer to a vector 5811
5822 of font_name structures for the fonts matched. Value is the number 5812 FAMILY, if a string, specifies a font family. If nil, use
5823 of fonts found. */ 5813 the family specified in Lisp face attributes ATTRS instead.
5814
5815 REGISTRY, if a string, specifies a font registry and encoding to
5816 match. A value of nil means include fonts of any registry and
5817 encoding.
5818
5819 Return in *FONTS a pointer to a vector of font_name structures for
5820 the fonts matched. Value is the number of fonts found. */
5824 5821
5825static int 5822static int
5826try_font_list (f, attrs, pattern, family, registry, fonts) 5823try_font_list (f, attrs, family, registry, fonts)
5827 struct frame *f; 5824 struct frame *f;
5828 Lisp_Object *attrs; 5825 Lisp_Object *attrs;
5829 Lisp_Object pattern, family, registry; 5826 Lisp_Object family, registry;
5830 struct font_name **fonts; 5827 struct font_name **fonts;
5831{ 5828{
5832 int nfonts; 5829 int nfonts;
@@ -5834,7 +5831,7 @@ try_font_list (f, attrs, pattern, family, registry, fonts)
5834 if (NILP (family) && STRINGP (attrs[LFACE_FAMILY_INDEX])) 5831 if (NILP (family) && STRINGP (attrs[LFACE_FAMILY_INDEX]))
5835 family = attrs[LFACE_FAMILY_INDEX]; 5832 family = attrs[LFACE_FAMILY_INDEX];
5836 5833
5837 nfonts = font_list (f, pattern, family, registry, fonts); 5834 nfonts = font_list (f, Qnil, family, registry, fonts);
5838 if (nfonts == 0 && !NILP (family)) 5835 if (nfonts == 0 && !NILP (family))
5839 { 5836 {
5840 Lisp_Object alter; 5837 Lisp_Object alter;
@@ -5928,8 +5925,7 @@ choose_face_font (f, attrs, fontset, c)
5928 5925
5929 /* Get a list of fonts matching that pattern and choose the 5926 /* Get a list of fonts matching that pattern and choose the
5930 best match for the specified face attributes from it. */ 5927 best match for the specified face attributes from it. */
5931 nfonts = try_font_list (f, attrs, Qnil, XCAR (pattern), XCDR (pattern), 5928 nfonts = try_font_list (f, attrs, XCAR (pattern), XCDR (pattern), &fonts);
5932 &fonts);
5933 width_ratio = (SINGLE_BYTE_CHAR_P (c) 5929 width_ratio = (SINGLE_BYTE_CHAR_P (c)
5934 ? 1 5930 ? 1
5935 : CHARSET_WIDTH (CHAR_CHARSET (c))); 5931 : CHARSET_WIDTH (CHAR_CHARSET (c)));
@@ -6085,7 +6081,11 @@ realize_default_face (f)
6085 xassert (lface_fully_specified_p (XVECTOR (lface)->contents)); 6081 xassert (lface_fully_specified_p (XVECTOR (lface)->contents));
6086 check_lface (lface); 6082 check_lface (lface);
6087 bcopy (XVECTOR (lface)->contents, attrs, sizeof attrs); 6083 bcopy (XVECTOR (lface)->contents, attrs, sizeof attrs);
6084
6085 realizing_default_face_p = 1;
6088 face = realize_face (c, attrs, 0, NULL, DEFAULT_FACE_ID); 6086 face = realize_face (c, attrs, 0, NULL, DEFAULT_FACE_ID);
6087 realizing_default_face_p = 0;
6088
6089 return 1; 6089 return 1;
6090} 6090}
6091 6091