aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2023-09-11 19:45:58 +0800
committerPo Lu2023-09-11 19:45:58 +0800
commit38e96bee1f902dc3d2ca55dd9c4c920c2b75bf2a (patch)
tree6ec85c806b45ce284aeefded50776ac705fbc861
parentf6568dabf2996a1310dad13a2d4cdc197fa2d304 (diff)
downloademacs-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/PROBLEMS12
-rw-r--r--src/sfntfont.c28
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.
3526Since this behavior does not influence the display of real fonts, no 3526Since this behavior does not influence the display of real fonts, no
3527action will be taken to address this problem. 3527action will be taken to address this problem.
3528 3528
3529** Some other font's instruction code produces undesirable results.
3530
3531Executing instruction code is not a strict requirement for producing
3532correct display results from most current fonts. If a font's
3533instruction code produces results that are merely unpleasing, but not
3534incorrect, then the font was presumably not designed for Emacs's
3535scaler. If its uninstructed glyphs are satisfactory (such as if your
3536screen resolution is high to the extent that scaling artifacts prove
3537invisible), disable instruction code execution by appending its family
3538name to the variable 'sfnt-uninstructable-font-regexp', then
3539restarting 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
3531When inserting CJK text into a buffer or visiting a file containing 3543When 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
3956Much Emacs code assumes that font families named "Monospace" and "Sans 3967Much Emacs code assumes that font families named "Monospace" and "Sans
3957Serif" exist, and map to the default monospace and Sans Serif fonts on 3968Serif" exist, and map to the default monospace and Sans Serif fonts on
3958a system. When the `sfnt' font driver is asked to look for a font 3969a system. When the `sfnt' font driver is asked to look for a font
3959with one of the families in this alist, it uses its value instead. */); 3970with 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.
3976If nil, instruction code supplied by all fonts will be executed. This
3977variable takes effect when a font entity is opened, not after, and
3978therefore won't affect the scaling of realized faces until their
3979frames' font caches are cleared (see `clear-font-cache').
3980
3981TrueType fonts incorporate instruction code executed to fit each glyph
3982to a pixel grid, so as to improve the visual fidelity of each glyph by
3983eliminating artifacts and chance effects consequent upon the direct
3984upscaling of glyph outline data. Instruction code is occasionally
3985incompatible with Emacs and must be disregarded. */);
3986 Vsfnt_uninstructable_family_regexp = Qnil;
3961} 3987}
3962 3988
3963void 3989void