aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDima Kogan2015-02-09 15:52:48 +0100
committerJan D2015-02-09 15:52:48 +0100
commit054dcbab2414e72d7c743214b7c56408fa4912dd (patch)
tree1f8d6fe8ad842b88ec618fd94a49c88ac3402046 /src
parent83e5a17c3492f6d0bc79457624e69a1655ccb238 (diff)
downloademacs-054dcbab2414e72d7c743214b7c56408fa4912dd.tar.gz
emacs-054dcbab2414e72d7c743214b7c56408fa4912dd.zip
Try non-scaled xld fonts first, and scaled if that failed.
Fixes: debbugs:19117 * xfaces.c (realize_basic_faces): Don't set Qscalable_fonts_allowed to t. * font.c (font_score): Try to find a font without scaling first, and only accept scalable fonts if we did not get a match.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/xfaces.c3
-rw-r--r--src/xfont.c183
3 files changed, 108 insertions, 85 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 93cd5f30f08..bc5d6101a5c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
12015-02-09 Dima Kogan <dima@secretsauce.net>
2
3 * xfaces.c (realize_basic_faces): Don't set Qscalable_fonts_allowed to
4 t.
5 * font.c (font_score): Try to find a font without scaling first,
6 and only accept scalable fonts if we did not get a match (Bug#19117).
7
12015-02-09 Stefan Monnier <monnier@iro.umontreal.ca> 82015-02-09 Stefan Monnier <monnier@iro.umontreal.ca>
2 9
3 * keyboard.c (syms_of_keyboard): Use non-nil default value. 10 * keyboard.c (syms_of_keyboard): Use non-nil default value.
diff --git a/src/xfaces.c b/src/xfaces.c
index 6e01ab08cef..d0fe8726cbb 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -5141,12 +5141,10 @@ static bool
5141realize_basic_faces (struct frame *f) 5141realize_basic_faces (struct frame *f)
5142{ 5142{
5143 bool success_p = false; 5143 bool success_p = false;
5144 ptrdiff_t count = SPECPDL_INDEX ();
5145 5144
5146 /* Block input here so that we won't be surprised by an X expose 5145 /* Block input here so that we won't be surprised by an X expose
5147 event, for instance, without having the faces set up. */ 5146 event, for instance, without having the faces set up. */
5148 block_input (); 5147 block_input ();
5149 specbind (Qscalable_fonts_allowed, Qt);
5150 5148
5151 if (realize_default_face (f)) 5149 if (realize_default_face (f))
5152 { 5150 {
@@ -5180,7 +5178,6 @@ realize_basic_faces (struct frame *f)
5180 success_p = true; 5178 success_p = true;
5181 } 5179 }
5182 5180
5183 unbind_to (count, Qnil);
5184 unblock_input (); 5181 unblock_input ();
5185 return success_p; 5182 return success_p;
5186} 5183}
diff --git a/src/xfont.c b/src/xfont.c
index 3a0f5e39b4e..5f1c61c77ff 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -388,94 +388,113 @@ xfont_list_pattern (Display *display, const char *pattern,
388 Lisp_Object *props = XVECTOR (xfont_scratch_props)->contents; 388 Lisp_Object *props = XVECTOR (xfont_scratch_props)->contents;
389 Lisp_Object scripts = Qnil, entity = Qnil; 389 Lisp_Object scripts = Qnil, entity = Qnil;
390 390
391 /* We take two passes over the font list. The second pass is
392 taken only if scalable-fonts-allowed is nil, and only
393 scalable fonts were found.
394 */
395 int i_pass;
396 bool skipped_some_scalable_fonts = false;
397
391 for (i = 0; i < ASIZE (xfont_scratch_props); i++) 398 for (i = 0; i < ASIZE (xfont_scratch_props); i++)
392 ASET (xfont_scratch_props, i, Qnil); 399 ASET (xfont_scratch_props, i, Qnil);
393 for (i = 0; i < num_fonts; i++) 400 for (i = 0; i < num_fonts; i++)
394 indices[i] = names[i]; 401 indices[i] = names[i];
395 qsort (indices, num_fonts, sizeof (char *), compare_font_names); 402 qsort (indices, num_fonts, sizeof (char *), compare_font_names);
396 403
397 for (i = 0; i < num_fonts; i++) 404 for (i_pass = 0; i_pass < 2; i_pass++)
398 { 405 {
399 ptrdiff_t len; 406 for (i = 0; i < num_fonts; i++)
400 407 {
401 if (i > 0 && xstrcasecmp (indices[i - 1], indices[i]) == 0) 408 ptrdiff_t len;
402 continue; 409
403 if (NILP (entity)) 410 if (i > 0 && xstrcasecmp (indices[i - 1], indices[i]) == 0)
404 entity = font_make_entity (); 411 continue;
405 len = xfont_decode_coding_xlfd (indices[i], -1, buf); 412 if (NILP (entity))
406 if (font_parse_xlfd (buf, len, entity) < 0) 413 entity = font_make_entity ();
407 continue; 414 len = xfont_decode_coding_xlfd (indices[i], -1, buf);
408 ASET (entity, FONT_TYPE_INDEX, Qx); 415 if (font_parse_xlfd (buf, len, entity) < 0)
409 /* Avoid auto-scaled fonts. */ 416 continue;
410 if (INTEGERP (AREF (entity, FONT_DPI_INDEX)) 417 ASET (entity, FONT_TYPE_INDEX, Qx);
411 && INTEGERP (AREF (entity, FONT_AVGWIDTH_INDEX)) 418 /* Avoid auto-scaled fonts. */
412 && XINT (AREF (entity, FONT_DPI_INDEX)) != 0 419 if (INTEGERP (AREF (entity, FONT_DPI_INDEX))
413 && XINT (AREF (entity, FONT_AVGWIDTH_INDEX)) == 0) 420 && INTEGERP (AREF (entity, FONT_AVGWIDTH_INDEX))
414 continue; 421 && XINT (AREF (entity, FONT_DPI_INDEX)) != 0
415 /* Avoid not-allowed scalable fonts. */ 422 && XINT (AREF (entity, FONT_AVGWIDTH_INDEX)) == 0)
416 if (NILP (Vscalable_fonts_allowed)) 423 continue;
417 { 424 /* Avoid not-allowed scalable fonts. */
418 int size = 0; 425 if (NILP (Vscalable_fonts_allowed))
419 426 {
420 if (INTEGERP (AREF (entity, FONT_SIZE_INDEX))) 427 int size = 0;
421 size = XINT (AREF (entity, FONT_SIZE_INDEX)); 428
422 else if (FLOATP (AREF (entity, FONT_SIZE_INDEX))) 429 if (INTEGERP (AREF (entity, FONT_SIZE_INDEX)))
423 size = XFLOAT_DATA (AREF (entity, FONT_SIZE_INDEX)); 430 size = XINT (AREF (entity, FONT_SIZE_INDEX));
424 if (size == 0) 431 else if (FLOATP (AREF (entity, FONT_SIZE_INDEX)))
425 continue; 432 size = XFLOAT_DATA (AREF (entity, FONT_SIZE_INDEX));
426 } 433 if (size == 0 && i_pass == 0)
427 else if (CONSP (Vscalable_fonts_allowed)) 434 {
428 { 435 skipped_some_scalable_fonts = true;
429 Lisp_Object tail, elt; 436 continue;
430 437 }
431 for (tail = Vscalable_fonts_allowed; CONSP (tail); 438 }
432 tail = XCDR (tail)) 439 else if (CONSP (Vscalable_fonts_allowed))
433 { 440 {
434 elt = XCAR (tail); 441 Lisp_Object tail, elt;
435 if (STRINGP (elt) 442
436 && fast_c_string_match_ignore_case (elt, indices[i], 443 for (tail = Vscalable_fonts_allowed; CONSP (tail);
437 len) >= 0) 444 tail = XCDR (tail))
438 break; 445 {
439 } 446 elt = XCAR (tail);
440 if (! CONSP (tail)) 447 if (STRINGP (elt)
441 continue; 448 && fast_c_string_match_ignore_case (elt, indices[i],
442 } 449 len) >= 0)
443 450 break;
444 /* Avoid fonts of invalid registry. */ 451 }
445 if (NILP (AREF (entity, FONT_REGISTRY_INDEX))) 452 if (! CONSP (tail))
446 continue; 453 continue;
447 454 }
448 /* Update encoding and repertory if necessary. */ 455
449 if (! EQ (registry, AREF (entity, FONT_REGISTRY_INDEX))) 456 /* Avoid fonts of invalid registry. */
450 { 457 if (NILP (AREF (entity, FONT_REGISTRY_INDEX)))
451 registry = AREF (entity, FONT_REGISTRY_INDEX); 458 continue;
452 if (font_registry_charsets (registry, &encoding, &repertory) < 0) 459
453 encoding = NULL; 460 /* Update encoding and repertory if necessary. */
454 } 461 if (! EQ (registry, AREF (entity, FONT_REGISTRY_INDEX)))
455 if (! encoding) 462 {
456 /* Unknown REGISTRY, not supported. */ 463 registry = AREF (entity, FONT_REGISTRY_INDEX);
457 continue; 464 if (font_registry_charsets (registry, &encoding, &repertory) < 0)
458 if (repertory) 465 encoding = NULL;
459 { 466 }
460 if (NILP (script) 467 if (! encoding)
461 || xfont_chars_supported (chars, NULL, encoding, repertory)) 468 /* Unknown REGISTRY, not supported. */
462 list = Fcons (entity, list), entity = Qnil; 469 continue;
463 continue; 470 if (repertory)
464 } 471 {
465 if (memcmp (props, aref_addr (entity, FONT_FOUNDRY_INDEX), 472 if (NILP (script)
466 word_size * 7) 473 || xfont_chars_supported (chars, NULL, encoding, repertory))
467 || ! EQ (AREF (entity, FONT_SPACING_INDEX), props[7])) 474 list = Fcons (entity, list), entity = Qnil;
468 { 475 continue;
469 vcopy (xfont_scratch_props, 0, 476 }
470 aref_addr (entity, FONT_FOUNDRY_INDEX), 7); 477 if (memcmp (props, aref_addr (entity, FONT_FOUNDRY_INDEX),
471 ASET (xfont_scratch_props, 7, AREF (entity, FONT_SPACING_INDEX)); 478 word_size * 7)
472 scripts = xfont_supported_scripts (display, indices[i], 479 || ! EQ (AREF (entity, FONT_SPACING_INDEX), props[7]))
473 xfont_scratch_props, encoding); 480 {
474 } 481 vcopy (xfont_scratch_props, 0,
475 if (NILP (script) 482 aref_addr (entity, FONT_FOUNDRY_INDEX), 7);
476 || ! NILP (Fmemq (script, scripts))) 483 ASET (xfont_scratch_props, 7, AREF (entity, FONT_SPACING_INDEX));
477 list = Fcons (entity, list), entity = Qnil; 484 scripts = xfont_supported_scripts (display, indices[i],
478 } 485 xfont_scratch_props, encoding);
486 }
487 if (NILP (script)
488 || ! NILP (Fmemq (script, scripts)))
489 list = Fcons (entity, list), entity = Qnil;
490 }
491
492 /* We skip the second pass unless we really need it. */
493 if (! /* Loop again if... */
494 (NILP (list) /* No fonts found on the first pass */
495 && skipped_some_scalable_fonts)) /* and we skipped some scalable ones. */
496 break;
497 }
479 XFreeFontNames (names); 498 XFreeFontNames (names);
480 } 499 }
481 500