diff options
| author | Eli Zaretskii | 2015-06-09 17:56:39 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2015-06-09 17:56:39 +0300 |
| commit | e0707282d214ff17b20a9f07ca2f4055610d30ea (patch) | |
| tree | d0960fdc88c52d8d558d9995d5f7cc92b4d51f44 /src | |
| parent | 68273707ecbca6ff6d34071c04c2b395384c41e5 (diff) | |
| download | emacs-e0707282d214ff17b20a9f07ca2f4055610d30ea.tar.gz emacs-e0707282d214ff17b20a9f07ca2f4055610d30ea.zip | |
Improve font selection for punctuation and other symbols
* src/fontset.c (face_for_char): If the character's script is
'symbol', and the font used for ASCII face has a glyph for it, use
the font for the ASCII face instead of searching the fontsets.
This comes instead of NS-specific code that used the current
face's font instead, which is now disabled due to undesirable
consequences. (Bug#20727)
Diffstat (limited to 'src')
| -rw-r--r-- | src/fontset.c | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/src/fontset.c b/src/fontset.c index e957c38eb60..97bdbcef5bf 100644 --- a/src/fontset.c +++ b/src/fontset.c | |||
| @@ -892,18 +892,46 @@ face_for_char (struct frame *f, struct face *face, int c, | |||
| 892 | if (ASCII_CHAR_P (c) || CHAR_BYTE8_P (c)) | 892 | if (ASCII_CHAR_P (c) || CHAR_BYTE8_P (c)) |
| 893 | return face->ascii_face->id; | 893 | return face->ascii_face->id; |
| 894 | 894 | ||
| 895 | #ifdef HAVE_NS | 895 | if (c > 0 && EQ (CHAR_TABLE_REF (Vchar_script_table, c), Qsymbol)) |
| 896 | if (face->font) | ||
| 897 | { | 896 | { |
| 898 | /* Fonts often have characters in other scripts, like symbol, even if they | 897 | /* Fonts often have characters for punctuation and other |
| 899 | don't match script: symbol. So check if the character is present | 898 | symbols, even if they don't match the 'symbol' script. So |
| 900 | in the current face first. Only enable for NS for now, but should | 899 | check if the character is present in the current ASCII face |
| 901 | perhaps be general? */ | 900 | first, and if so, use the same font as used by that face. |
| 901 | This avoids unnecessarily switching to another font when the | ||
| 902 | frame's default font will do. We only do this for symbols so | ||
| 903 | that users could still setup fontsets to force Emacs to use | ||
| 904 | specific fonts for characters from other scripts, because | ||
| 905 | choice of fonts is frequently affected by cultural | ||
| 906 | preferences and font features, not by font coverage. | ||
| 907 | However, these considerations are unlikely to be relevant to | ||
| 908 | punctuation and other symbols, since the latter generally | ||
| 909 | aren't specific to any culture, and don't require | ||
| 910 | sophisticated OTF features. */ | ||
| 902 | Lisp_Object font_object; | 911 | Lisp_Object font_object; |
| 903 | XSETFONT (font_object, face->font); | 912 | |
| 904 | if (font_has_char (f, font_object, c)) return face->id; | 913 | if (face->ascii_face->font) |
| 905 | } | 914 | { |
| 915 | XSETFONT (font_object, face->ascii_face->font); | ||
| 916 | if (font_has_char (f, font_object, c)) | ||
| 917 | return face->ascii_face->id; | ||
| 918 | } | ||
| 919 | |||
| 920 | #if 0 | ||
| 921 | /* Try the current face. Disabled because it can cause | ||
| 922 | counter-intuitive results, whereby the font used for some | ||
| 923 | character depends on the characters that precede it on | ||
| 924 | display. See the discussion of bug #15138. Note that the | ||
| 925 | original bug reported in #15138 was in a situation where face | ||
| 926 | == face->ascii_face, so the above code solves that situation | ||
| 927 | without risking the undesirable consequences. */ | ||
| 928 | if (face->font) | ||
| 929 | { | ||
| 930 | XSETFONT (font_object, face->font); | ||
| 931 | if (font_has_char (f, font_object, c)) return face->id; | ||
| 932 | } | ||
| 906 | #endif | 933 | #endif |
| 934 | } | ||
| 907 | 935 | ||
| 908 | fontset = FONTSET_FROM_ID (face->fontset); | 936 | fontset = FONTSET_FROM_ID (face->fontset); |
| 909 | eassert (!BASE_FONTSET_P (fontset)); | 937 | eassert (!BASE_FONTSET_P (fontset)); |