diff options
| author | K. Handa | 2016-01-08 23:21:15 +0900 |
|---|---|---|
| committer | K. Handa | 2016-01-08 23:21:15 +0900 |
| commit | bc9a28ab424647209cc2f91ad21cdb41a7052812 (patch) | |
| tree | 2309427d860156e8ad04ea78476a23f80de190b1 /src | |
| parent | e94b1799d4f4c57266bdbc4801b26fe0121b7c7a (diff) | |
| download | emacs-bc9a28ab424647209cc2f91ad21cdb41a7052812.tar.gz emacs-bc9a28ab424647209cc2f91ad21cdb41a7052812.zip | |
Fix outdated comments.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fontset.c | 82 |
1 files changed, 59 insertions, 23 deletions
diff --git a/src/fontset.c b/src/fontset.c index 9429d79b6b9..0f89b71ff68 100644 --- a/src/fontset.c +++ b/src/fontset.c | |||
| @@ -63,17 +63,26 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 63 | An element of a base fontset is a vector of FONT-DEFs which themselves | 63 | An element of a base fontset is a vector of FONT-DEFs which themselves |
| 64 | are vectors of the form [ FONT-SPEC ENCODING REPERTORY ]. | 64 | are vectors of the form [ FONT-SPEC ENCODING REPERTORY ]. |
| 65 | 65 | ||
| 66 | An element of a realized fontset is nil, t, 0, or a vector of this | 66 | An element of a realized fontset is nil, t, 0, or a cons that has |
| 67 | form: | 67 | this from: |
| 68 | 68 | ||
| 69 | [ PREFERRED-RFONT-DEF RFONT-DEF0 RFONT-DEF1 ... ] | 69 | (CHARSET-ORDERED-LIST-TICK . FONT-GROUP) |
| 70 | |||
| 71 | CHARSET_ORDERED_LIST_TICK is the same as charset_ordered_list_tick or -1. | ||
| 72 | |||
| 73 | FONT-GROUP is a vector of elements that have this form: | ||
| 74 | |||
| 75 | [ RFONT-DEF0 RFONT-DEF1 ... ] | ||
| 70 | 76 | ||
| 71 | Each RFONT-DEFn (i.e. Realized FONT-DEF) has this form: | 77 | Each RFONT-DEFn (i.e. Realized FONT-DEF) has this form: |
| 72 | 78 | ||
| 73 | [ FACE-ID FONT-DEF FONT-OBJECT SORTING-SCORE ] | 79 | [ FACE-ID FONT-DEF FONT-OBJECT SORTING-SCORE ] |
| 74 | 80 | ||
| 75 | RFONT-DEFn are automatically reordered by the current charset | 81 | RFONT-DEFn are automatically reordered considering the current |
| 76 | priority list. | 82 | charset priority list, the current language environment, and |
| 83 | priorities determined by font-backends. | ||
| 84 | |||
| 85 | RFONT-DEFn may not be a vector in the following cases. | ||
| 77 | 86 | ||
| 78 | The value nil means that we have not yet generated the above vector | 87 | The value nil means that we have not yet generated the above vector |
| 79 | from the base of the fontset. | 88 | from the base of the fontset. |
| @@ -83,7 +92,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 83 | 92 | ||
| 84 | The value 0 means that no font is available for the corresponding | 93 | The value 0 means that no font is available for the corresponding |
| 85 | range of characters in this fontset, but may be available in the | 94 | range of characters in this fontset, but may be available in the |
| 86 | default fontset. | 95 | fallback font-group or in the default fontset. |
| 87 | 96 | ||
| 88 | A fontset has 8 extra slots. | 97 | A fontset has 8 extra slots. |
| 89 | 98 | ||
| @@ -407,6 +416,9 @@ reorder_font_vector (Lisp_Object font_group, struct font *font) | |||
| 407 | 416 | ||
| 408 | if (! NILP (encoding)) | 417 | if (! NILP (encoding)) |
| 409 | { | 418 | { |
| 419 | /* This spec specifies an encoding by a charset set | ||
| 420 | name. Reflect the preference order of that charset | ||
| 421 | in the upper bits of SCORE. */ | ||
| 410 | Lisp_Object tail; | 422 | Lisp_Object tail; |
| 411 | 423 | ||
| 412 | for (tail = Vcharset_ordered_list; | 424 | for (tail = Vcharset_ordered_list; |
| @@ -419,6 +431,10 @@ reorder_font_vector (Lisp_Object font_group, struct font *font) | |||
| 419 | } | 431 | } |
| 420 | else | 432 | else |
| 421 | { | 433 | { |
| 434 | /* This spec does not specify an encoding. If the spec | ||
| 435 | specifies a language, and the language is not for the | ||
| 436 | current language environment, make the score | ||
| 437 | larger. */ | ||
| 422 | Lisp_Object lang = Ffont_get (font_spec, QClang); | 438 | Lisp_Object lang = Ffont_get (font_spec, QClang); |
| 423 | 439 | ||
| 424 | if (! NILP (lang) | 440 | if (! NILP (lang) |
| @@ -442,11 +458,11 @@ reorder_font_vector (Lisp_Object font_group, struct font *font) | |||
| 442 | XSETCAR (font_group, make_number (low_tick_bits)); | 458 | XSETCAR (font_group, make_number (low_tick_bits)); |
| 443 | } | 459 | } |
| 444 | 460 | ||
| 445 | /* Return a font-group (actually a cons (-1 . FONT-GROUP-VECTOR)) for | 461 | /* Return a font-group (actually a cons (CHARSET_ORDERED_LIST_TICK |
| 446 | character C in FONTSET. If C is -1, return a fallback font-group. | 462 | . FONT-GROUP)) for character C or a fallback font-group in the |
| 447 | If C is not -1, the value may be Qt (FONTSET doesn't have a font | 463 | realized fontset FONTSET. The elements of FONT-GROUP are |
| 448 | for C even in the fallback group), or 0 (a font for C may be found | 464 | RFONT-DEFs. The value may not be a cons. See the comment at the |
| 449 | only in the fallback group). */ | 465 | head of this file for the detail of the return value. */ |
| 450 | 466 | ||
| 451 | static Lisp_Object | 467 | static Lisp_Object |
| 452 | fontset_get_font_group (Lisp_Object fontset, int c) | 468 | fontset_get_font_group (Lisp_Object fontset, int c) |
| @@ -461,23 +477,37 @@ fontset_get_font_group (Lisp_Object fontset, int c) | |||
| 461 | else | 477 | else |
| 462 | font_group = FONTSET_FALLBACK (fontset); | 478 | font_group = FONTSET_FALLBACK (fontset); |
| 463 | if (! NILP (font_group)) | 479 | if (! NILP (font_group)) |
| 480 | /* We have already realized FONT-DEFs of this font group for C or | ||
| 481 | for fallback (FONT_GROUP is a cons), or we have already found | ||
| 482 | that no appropriate font was found (FONT_GROUP is t or 0). */ | ||
| 464 | return font_group; | 483 | return font_group; |
| 465 | base_fontset = FONTSET_BASE (fontset); | 484 | base_fontset = FONTSET_BASE (fontset); |
| 466 | if (NILP (base_fontset)) | 485 | if (NILP (base_fontset)) |
| 486 | /* Actually we never come here because FONTSET is a realized one, | ||
| 487 | and thus it should have a base. */ | ||
| 467 | font_group = Qnil; | 488 | font_group = Qnil; |
| 468 | else if (c >= 0) | 489 | else if (c >= 0) |
| 469 | font_group = char_table_ref_and_range (base_fontset, c, &from, &to); | 490 | font_group = char_table_ref_and_range (base_fontset, c, &from, &to); |
| 470 | else | 491 | else |
| 471 | font_group = FONTSET_FALLBACK (base_fontset); | 492 | font_group = FONTSET_FALLBACK (base_fontset); |
| 493 | |||
| 494 | /* FONT_GROUP not being a vector means that no fonts are specified | ||
| 495 | for C, or the fontset does not have fallback fonts. */ | ||
| 472 | if (NILP (font_group)) | 496 | if (NILP (font_group)) |
| 473 | { | 497 | { |
| 474 | font_group = make_number (0); | 498 | font_group = make_number (0); |
| 475 | if (c >= 0) | 499 | if (c >= 0) |
| 500 | /* Record that FONTSET does not specify fonts for C. As | ||
| 501 | there's a possiblity that a font is found in a fallback | ||
| 502 | font group, we set 0 at the moment. */ | ||
| 476 | char_table_set_range (fontset, from, to, font_group); | 503 | char_table_set_range (fontset, from, to, font_group); |
| 477 | return font_group; | 504 | return font_group; |
| 478 | } | 505 | } |
| 479 | if (!VECTORP (font_group)) | 506 | if (!VECTORP (font_group)) |
| 480 | return font_group; | 507 | return font_group; |
| 508 | |||
| 509 | /* Now realize FONT-DEFs of this font group, and update the realized | ||
| 510 | fontset FONTSET. */ | ||
| 481 | font_group = Fcopy_sequence (font_group); | 511 | font_group = Fcopy_sequence (font_group); |
| 482 | for (i = 0; i < ASIZE (font_group); i++) | 512 | for (i = 0; i < ASIZE (font_group); i++) |
| 483 | if (! NILP (AREF (font_group, i))) | 513 | if (! NILP (AREF (font_group, i))) |
| @@ -498,21 +528,21 @@ fontset_get_font_group (Lisp_Object fontset, int c) | |||
| 498 | } | 528 | } |
| 499 | 529 | ||
| 500 | /* Return RFONT-DEF (vector) in the realized fontset FONTSET for the | 530 | /* Return RFONT-DEF (vector) in the realized fontset FONTSET for the |
| 501 | character C. If no font is found, return Qnil if there's a | 531 | character C. If no font is found, return Qnil or 0 if there's a |
| 502 | possibility that the default fontset or the fallback font groups | 532 | possibility that the default fontset or the fallback font groups |
| 503 | have a proper font, and return Qt if not. | 533 | have a proper font, and return Qt if not. |
| 504 | 534 | ||
| 505 | If a font is found but is not yet opened, open it (if FACE is not | 535 | If a font is found but is not yet opened, open it (if FACE is not |
| 506 | NULL) or return Qnil (if FACE is NULL). | 536 | NULL) or return Qnil (if FACE is NULL). |
| 507 | 537 | ||
| 508 | ID is a charset-id that must be preferred, or -1 meaning no | 538 | CHARSET_ID is a charset-id that must be preferred, or -1 meaning no |
| 509 | preference. | 539 | preference. |
| 510 | 540 | ||
| 511 | If FALLBACK, search only fallback fonts. */ | 541 | If FALLBACK, search only fallback fonts. */ |
| 512 | 542 | ||
| 513 | static Lisp_Object | 543 | static Lisp_Object |
| 514 | fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id, | 544 | fontset_find_font (Lisp_Object fontset, int c, struct face *face, |
| 515 | bool fallback) | 545 | int charset_id, bool fallback) |
| 516 | { | 546 | { |
| 517 | Lisp_Object vec, font_group; | 547 | Lisp_Object vec, font_group; |
| 518 | int i, charset_matched = 0, found_index; | 548 | int i, charset_matched = 0, found_index; |
| @@ -534,8 +564,8 @@ fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id, | |||
| 534 | /* We have just created the font-group, | 564 | /* We have just created the font-group, |
| 535 | or the charset priorities were changed. */ | 565 | or the charset priorities were changed. */ |
| 536 | reorder_font_vector (font_group, face->ascii_face->font); | 566 | reorder_font_vector (font_group, face->ascii_face->font); |
| 537 | if (id >= 0) | 567 | if (charset_id >= 0) |
| 538 | /* Find a spec matching with the charset ID to try at | 568 | /* Find a spec matching with CHARSET_ID to try it at |
| 539 | first. */ | 569 | first. */ |
| 540 | for (i = 0; i < ASIZE (vec); i++) | 570 | for (i = 0; i < ASIZE (vec); i++) |
| 541 | { | 571 | { |
| @@ -546,7 +576,7 @@ fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id, | |||
| 546 | break; | 576 | break; |
| 547 | repertory = FONT_DEF_REPERTORY (RFONT_DEF_FONT_DEF (rfont_def)); | 577 | repertory = FONT_DEF_REPERTORY (RFONT_DEF_FONT_DEF (rfont_def)); |
| 548 | 578 | ||
| 549 | if (XINT (repertory) == id) | 579 | if (XINT (repertory) == charset_id) |
| 550 | { | 580 | { |
| 551 | charset_matched = i; | 581 | charset_matched = i; |
| 552 | break; | 582 | break; |
| @@ -554,7 +584,9 @@ fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id, | |||
| 554 | } | 584 | } |
| 555 | } | 585 | } |
| 556 | 586 | ||
| 557 | /* Find the first available font in the vector of RFONT-DEF. */ | 587 | /* Find the first available font in the vector of RFONT-DEF. If |
| 588 | CHARSET_MATCHED > 0, try the correspoing RFONT-DEF first, then | ||
| 589 | try the rest. */ | ||
| 558 | for (i = 0; i < ASIZE (vec); i++) | 590 | for (i = 0; i < ASIZE (vec); i++) |
| 559 | { | 591 | { |
| 560 | Lisp_Object font_def; | 592 | Lisp_Object font_def; |
| @@ -565,13 +597,13 @@ fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id, | |||
| 565 | { | 597 | { |
| 566 | if (charset_matched > 0) | 598 | if (charset_matched > 0) |
| 567 | { | 599 | { |
| 568 | /* Try the element matching with the charset ID at first. */ | 600 | /* Try the element matching with CHARSET_ID at first. */ |
| 569 | found_index = charset_matched; | 601 | found_index = charset_matched; |
| 570 | /* Make this negative so that we don't come here in the | 602 | /* Make this negative so that we don't come here in the |
| 571 | next loop. */ | 603 | next loop. */ |
| 572 | charset_matched = - charset_matched; | 604 | charset_matched = - charset_matched; |
| 573 | /* We must try the first element in the next loop. */ | 605 | /* We must try the first element in the next loop. */ |
| 574 | i--; | 606 | i = -1; |
| 575 | } | 607 | } |
| 576 | } | 608 | } |
| 577 | else if (i == - charset_matched) | 609 | else if (i == - charset_matched) |
| @@ -630,10 +662,10 @@ fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id, | |||
| 630 | if (NILP (font_object)) | 662 | if (NILP (font_object)) |
| 631 | { | 663 | { |
| 632 | /* Something strange happened, perhaps because of a | 664 | /* Something strange happened, perhaps because of a |
| 633 | Font-backend problem. Too avoid crashing, record | 665 | Font-backend problem. To avoid crashing, record |
| 634 | that this spec is unusable. It may be better to find | 666 | that this spec is unusable. It may be better to find |
| 635 | another font of the same spec, but currently we don't | 667 | another font of the same spec, but currently we don't |
| 636 | have such an API. */ | 668 | have such an API in font-backend. */ |
| 637 | RFONT_DEF_SET_FACE (rfont_def, -1); | 669 | RFONT_DEF_SET_FACE (rfont_def, -1); |
| 638 | continue; | 670 | continue; |
| 639 | } | 671 | } |
| @@ -693,6 +725,7 @@ fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id, | |||
| 693 | i = found_index; | 725 | i = found_index; |
| 694 | } | 726 | } |
| 695 | 727 | ||
| 728 | /* Record that no font in this font group supports C. */ | ||
| 696 | FONTSET_SET (fontset, make_number (c), make_number (0)); | 729 | FONTSET_SET (fontset, make_number (c), make_number (0)); |
| 697 | return Qnil; | 730 | return Qnil; |
| 698 | 731 | ||
| @@ -711,6 +744,9 @@ fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id, | |||
| 711 | } | 744 | } |
| 712 | 745 | ||
| 713 | 746 | ||
| 747 | /* Return RFONT-DEF (vector) corresponding to the font for character | ||
| 748 | C. The value is not a vector if no font is found for C. */ | ||
| 749 | |||
| 714 | static Lisp_Object | 750 | static Lisp_Object |
| 715 | fontset_font (Lisp_Object fontset, int c, struct face *face, int id) | 751 | fontset_font (Lisp_Object fontset, int c, struct face *face, int id) |
| 716 | { | 752 | { |