aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2015-02-09 11:01:36 -0800
committerPaul Eggert2015-02-09 11:08:58 -0800
commitb7028f6736132d8e29fc656e700a17163499d49b (patch)
treec0c700346407d26cb594dd1d0b03d7d49688ea39 /src
parent44d42562c3d1c8fb2f2b41e3b90d355dc9e7f9fe (diff)
downloademacs-b7028f6736132d8e29fc656e700a17163499d49b.tar.gz
emacs-b7028f6736132d8e29fc656e700a17163499d49b.zip
* xfont.c: Minor style fixes
(xfont_list_pattern): Reindent to 80 cols and use Emacs-style comments. Redo loop so that less indentation is needed.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/xfont.c196
2 files changed, 101 insertions, 101 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 4afcdcf0711..c5931b635e8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
12015-02-09 Paul Eggert <eggert@cs.ucla.edu>
2
3 * xfont.c: Minor style fixes
4 (xfont_list_pattern): Reindent to 80 cols and use Emacs-style comments.
5 Redo loop so that less indentation is needed.
6
12015-02-09 Eli Zaretskii <eliz@gnu.org> 72015-02-09 Eli Zaretskii <eliz@gnu.org>
2 8
3 * indent.c (Fvertical_motion): Accept an additional argument 9 * indent.c (Fvertical_motion): Accept an additional argument
diff --git a/src/xfont.c b/src/xfont.c
index 5f1c61c77ff..d5a7d64e697 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -388,113 +388,107 @@ 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
398 for (i = 0; i < ASIZE (xfont_scratch_props); i++) 391 for (i = 0; i < ASIZE (xfont_scratch_props); i++)
399 ASET (xfont_scratch_props, i, Qnil); 392 ASET (xfont_scratch_props, i, Qnil);
400 for (i = 0; i < num_fonts; i++) 393 for (i = 0; i < num_fonts; i++)
401 indices[i] = names[i]; 394 indices[i] = names[i];
402 qsort (indices, num_fonts, sizeof (char *), compare_font_names); 395 qsort (indices, num_fonts, sizeof (char *), compare_font_names);
403 396
404 for (i_pass = 0; i_pass < 2; i_pass++) 397 /* Take one or two passes over the font list. Do the second
405 { 398 pass only if we really need it, i.e., only if the first pass
406 for (i = 0; i < num_fonts; i++) 399 found no fonts and skipped some scalable fonts. */
407 { 400 bool skipped_some_scalable_fonts = false;
408 ptrdiff_t len; 401 for (int i_pass = 0;
409 402 (i_pass == 0
410 if (i > 0 && xstrcasecmp (indices[i - 1], indices[i]) == 0) 403 || (i_pass == 1 && NILP (list) && skipped_some_scalable_fonts));
411 continue; 404 i_pass++)
412 if (NILP (entity)) 405 for (i = 0; i < num_fonts; i++)
413 entity = font_make_entity (); 406 {
414 len = xfont_decode_coding_xlfd (indices[i], -1, buf); 407 ptrdiff_t len;
415 if (font_parse_xlfd (buf, len, entity) < 0) 408
416 continue; 409 if (i > 0 && xstrcasecmp (indices[i - 1], indices[i]) == 0)
417 ASET (entity, FONT_TYPE_INDEX, Qx); 410 continue;
418 /* Avoid auto-scaled fonts. */ 411 if (NILP (entity))
419 if (INTEGERP (AREF (entity, FONT_DPI_INDEX)) 412 entity = font_make_entity ();
420 && INTEGERP (AREF (entity, FONT_AVGWIDTH_INDEX)) 413 len = xfont_decode_coding_xlfd (indices[i], -1, buf);
421 && XINT (AREF (entity, FONT_DPI_INDEX)) != 0 414 if (font_parse_xlfd (buf, len, entity) < 0)
422 && XINT (AREF (entity, FONT_AVGWIDTH_INDEX)) == 0) 415 continue;
423 continue; 416 ASET (entity, FONT_TYPE_INDEX, Qx);
424 /* Avoid not-allowed scalable fonts. */ 417 /* Avoid auto-scaled fonts. */
425 if (NILP (Vscalable_fonts_allowed)) 418 if (INTEGERP (AREF (entity, FONT_DPI_INDEX))
426 { 419 && INTEGERP (AREF (entity, FONT_AVGWIDTH_INDEX))
427 int size = 0; 420 && XINT (AREF (entity, FONT_DPI_INDEX)) != 0
428 421 && XINT (AREF (entity, FONT_AVGWIDTH_INDEX)) == 0)
429 if (INTEGERP (AREF (entity, FONT_SIZE_INDEX))) 422 continue;
430 size = XINT (AREF (entity, FONT_SIZE_INDEX)); 423 /* Avoid not-allowed scalable fonts. */
431 else if (FLOATP (AREF (entity, FONT_SIZE_INDEX))) 424 if (NILP (Vscalable_fonts_allowed))
432 size = XFLOAT_DATA (AREF (entity, FONT_SIZE_INDEX)); 425 {
433 if (size == 0 && i_pass == 0) 426 int size = 0;
434 { 427
435 skipped_some_scalable_fonts = true; 428 if (INTEGERP (AREF (entity, FONT_SIZE_INDEX)))
436 continue; 429 size = XINT (AREF (entity, FONT_SIZE_INDEX));
437 } 430 else if (FLOATP (AREF (entity, FONT_SIZE_INDEX)))
438 } 431 size = XFLOAT_DATA (AREF (entity, FONT_SIZE_INDEX));
439 else if (CONSP (Vscalable_fonts_allowed)) 432 if (size == 0 && i_pass == 0)
440 { 433 {
441 Lisp_Object tail, elt; 434 skipped_some_scalable_fonts = true;
442 435 continue;
443 for (tail = Vscalable_fonts_allowed; CONSP (tail); 436 }
444 tail = XCDR (tail)) 437 }
445 { 438 else if (CONSP (Vscalable_fonts_allowed))
446 elt = XCAR (tail); 439 {
447 if (STRINGP (elt) 440 Lisp_Object tail;
448 && fast_c_string_match_ignore_case (elt, indices[i], 441
449 len) >= 0) 442 for (tail = Vscalable_fonts_allowed; CONSP (tail);
450 break; 443 tail = XCDR (tail))
451 } 444 {
452 if (! CONSP (tail)) 445 Lisp_Object elt = XCAR (tail);
453 continue; 446 if (STRINGP (elt)
454 } 447 && (fast_c_string_match_ignore_case (elt, indices[i],
455 448 len)
456 /* Avoid fonts of invalid registry. */ 449 >= 0))
457 if (NILP (AREF (entity, FONT_REGISTRY_INDEX))) 450 break;
458 continue; 451 }
459 452 if (! CONSP (tail))
460 /* Update encoding and repertory if necessary. */ 453 continue;
461 if (! EQ (registry, AREF (entity, FONT_REGISTRY_INDEX))) 454 }
462 { 455
463 registry = AREF (entity, FONT_REGISTRY_INDEX); 456 /* Avoid fonts of invalid registry. */
464 if (font_registry_charsets (registry, &encoding, &repertory) < 0) 457 if (NILP (AREF (entity, FONT_REGISTRY_INDEX)))
465 encoding = NULL; 458 continue;
466 } 459
467 if (! encoding) 460 /* Update encoding and repertory if necessary. */
468 /* Unknown REGISTRY, not supported. */ 461 if (! EQ (registry, AREF (entity, FONT_REGISTRY_INDEX)))
469 continue; 462 {
470 if (repertory) 463 registry = AREF (entity, FONT_REGISTRY_INDEX);
471 { 464 if (font_registry_charsets (registry, &encoding, &repertory) < 0)
472 if (NILP (script) 465 encoding = NULL;
473 || xfont_chars_supported (chars, NULL, encoding, repertory)) 466 }
474 list = Fcons (entity, list), entity = Qnil; 467 if (! encoding)
475 continue; 468 /* Unknown REGISTRY, not supported. */
476 } 469 continue;
477 if (memcmp (props, aref_addr (entity, FONT_FOUNDRY_INDEX), 470 if (repertory)
478 word_size * 7) 471 {
479 || ! EQ (AREF (entity, FONT_SPACING_INDEX), props[7])) 472 if (NILP (script)
480 { 473 || xfont_chars_supported (chars, NULL, encoding, repertory))
481 vcopy (xfont_scratch_props, 0, 474 list = Fcons (entity, list), entity = Qnil;
482 aref_addr (entity, FONT_FOUNDRY_INDEX), 7); 475 continue;
483 ASET (xfont_scratch_props, 7, AREF (entity, FONT_SPACING_INDEX)); 476 }
484 scripts = xfont_supported_scripts (display, indices[i], 477 if (memcmp (props, aref_addr (entity, FONT_FOUNDRY_INDEX),
485 xfont_scratch_props, encoding); 478 word_size * 7)
486 } 479 || ! EQ (AREF (entity, FONT_SPACING_INDEX), props[7]))
487 if (NILP (script) 480 {
488 || ! NILP (Fmemq (script, scripts))) 481 vcopy (xfont_scratch_props, 0,
489 list = Fcons (entity, list), entity = Qnil; 482 aref_addr (entity, FONT_FOUNDRY_INDEX), 7);
490 } 483 ASET (xfont_scratch_props, 7, AREF (entity, FONT_SPACING_INDEX));
491 484 scripts = xfont_supported_scripts (display, indices[i],
492 /* We skip the second pass unless we really need it. */ 485 xfont_scratch_props,
493 if (! /* Loop again if... */ 486 encoding);
494 (NILP (list) /* No fonts found on the first pass */ 487 }
495 && skipped_some_scalable_fonts)) /* and we skipped some scalable ones. */ 488 if (NILP (script)
496 break; 489 || ! NILP (Fmemq (script, scripts)))
497 } 490 list = Fcons (entity, list), entity = Qnil;
491 }
498 XFreeFontNames (names); 492 XFreeFontNames (names);
499 } 493 }
500 494