diff options
| author | Po Lu | 2023-09-11 19:45:58 +0800 |
|---|---|---|
| committer | Po Lu | 2023-09-11 19:45:58 +0800 |
| commit | 38e96bee1f902dc3d2ca55dd9c4c920c2b75bf2a (patch) | |
| tree | 6ec85c806b45ce284aeefded50776ac705fbc861 | |
| parent | f6568dabf2996a1310dad13a2d4cdc197fa2d304 (diff) | |
| download | emacs-38e96bee1f902dc3d2ca55dd9c4c920c2b75bf2a.tar.gz emacs-38e96bee1f902dc3d2ca55dd9c4c920c2b75bf2a.zip | |
Provide an option to disable font instruction code execution
* etc/PROBLEMS: Mention instruction code woes and illustrate how
to circumvent them.
* src/sfntfont.c (sfntfont_setup_interpreter): Respect
Vsfnt_uninstructable_family_regexp.
(syms_of_sfntfont) <Vsfnt_uninstructable_family_regexp>: New
option.
| -rw-r--r-- | etc/PROBLEMS | 12 | ||||
| -rw-r--r-- | src/sfntfont.c | 28 |
2 files changed, 39 insertions, 1 deletions
diff --git a/etc/PROBLEMS b/etc/PROBLEMS index faeee2a3035..11659c66e68 100644 --- a/etc/PROBLEMS +++ b/etc/PROBLEMS | |||
| @@ -3526,6 +3526,18 @@ points the test font attempts to hide. | |||
| 3526 | Since this behavior does not influence the display of real fonts, no | 3526 | Since this behavior does not influence the display of real fonts, no |
| 3527 | action will be taken to address this problem. | 3527 | action will be taken to address this problem. |
| 3528 | 3528 | ||
| 3529 | ** Some other font's instruction code produces undesirable results. | ||
| 3530 | |||
| 3531 | Executing instruction code is not a strict requirement for producing | ||
| 3532 | correct display results from most current fonts. If a font's | ||
| 3533 | instruction code produces results that are merely unpleasing, but not | ||
| 3534 | incorrect, then the font was presumably not designed for Emacs's | ||
| 3535 | scaler. If its uninstructed glyphs are satisfactory (such as if your | ||
| 3536 | screen resolution is high to the extent that scaling artifacts prove | ||
| 3537 | invisible), disable instruction code execution by appending its family | ||
| 3538 | name to the variable 'sfnt-uninstructable-font-regexp', then | ||
| 3539 | restarting Emacs. | ||
| 3540 | |||
| 3529 | ** CJK text does not display in Emacs, but does in other programs. | 3541 | ** CJK text does not display in Emacs, but does in other programs. |
| 3530 | 3542 | ||
| 3531 | When inserting CJK text into a buffer or visiting a file containing | 3543 | When inserting CJK text into a buffer or visiting a file containing |
diff --git a/src/sfntfont.c b/src/sfntfont.c index 64dbffad03f..12fecb32df5 100644 --- a/src/sfntfont.c +++ b/src/sfntfont.c | |||
| @@ -2667,6 +2667,18 @@ sfntfont_setup_interpreter (struct sfnt_font_info *info, | |||
| 2667 | struct sfnt_interpreter *interpreter; | 2667 | struct sfnt_interpreter *interpreter; |
| 2668 | const char *error; | 2668 | const char *error; |
| 2669 | struct sfnt_graphics_state state; | 2669 | struct sfnt_graphics_state state; |
| 2670 | Lisp_Object regexp; | ||
| 2671 | |||
| 2672 | /* If Vsfnt_uninstructable_family_regexp matches this font, then | ||
| 2673 | return. */ | ||
| 2674 | |||
| 2675 | regexp = Vsfnt_uninstructable_family_regexp; | ||
| 2676 | |||
| 2677 | if (STRINGP (regexp) | ||
| 2678 | && (fast_string_match_ignore_case (regexp, | ||
| 2679 | desc->family) | ||
| 2680 | >= 0)) | ||
| 2681 | return; | ||
| 2670 | 2682 | ||
| 2671 | /* Load the cvt, fpgm and prep already read. */ | 2683 | /* Load the cvt, fpgm and prep already read. */ |
| 2672 | 2684 | ||
| @@ -3952,12 +3964,26 @@ syms_of_sfntfont (void) | |||
| 3952 | of the font backend. */ | 3964 | of the font backend. */ |
| 3953 | DEFVAR_LISP ("sfnt-default-family-alist", Vsfnt_default_family_alist, | 3965 | DEFVAR_LISP ("sfnt-default-family-alist", Vsfnt_default_family_alist, |
| 3954 | doc: /* Alist between "emulated" and actual font family names. | 3966 | doc: /* Alist between "emulated" and actual font family names. |
| 3955 | |||
| 3956 | Much Emacs code assumes that font families named "Monospace" and "Sans | 3967 | Much Emacs code assumes that font families named "Monospace" and "Sans |
| 3957 | Serif" exist, and map to the default monospace and Sans Serif fonts on | 3968 | Serif" exist, and map to the default monospace and Sans Serif fonts on |
| 3958 | a system. When the `sfnt' font driver is asked to look for a font | 3969 | a system. When the `sfnt' font driver is asked to look for a font |
| 3959 | with one of the families in this alist, it uses its value instead. */); | 3970 | with one of the families in this alist, it uses its value instead. */); |
| 3960 | Vsfnt_default_family_alist = Qnil; | 3971 | Vsfnt_default_family_alist = Qnil; |
| 3972 | |||
| 3973 | DEFVAR_LISP ("sfnt-uninstructable-family-regexp", | ||
| 3974 | Vsfnt_uninstructable_family_regexp, | ||
| 3975 | doc: /* Regexp matching font families whose glyphs must not be instructed. | ||
| 3976 | If nil, instruction code supplied by all fonts will be executed. This | ||
| 3977 | variable takes effect when a font entity is opened, not after, and | ||
| 3978 | therefore won't affect the scaling of realized faces until their | ||
| 3979 | frames' font caches are cleared (see `clear-font-cache'). | ||
| 3980 | |||
| 3981 | TrueType fonts incorporate instruction code executed to fit each glyph | ||
| 3982 | to a pixel grid, so as to improve the visual fidelity of each glyph by | ||
| 3983 | eliminating artifacts and chance effects consequent upon the direct | ||
| 3984 | upscaling of glyph outline data. Instruction code is occasionally | ||
| 3985 | incompatible with Emacs and must be disregarded. */); | ||
| 3986 | Vsfnt_uninstructable_family_regexp = Qnil; | ||
| 3961 | } | 3987 | } |
| 3962 | 3988 | ||
| 3963 | void | 3989 | void |