]> git.eshelyaron.com Git - emacs.git/commitdiff
Provide an option to disable font instruction code execution
authorPo Lu <luangruo@yahoo.com>
Mon, 11 Sep 2023 11:45:58 +0000 (19:45 +0800)
committerPo Lu <luangruo@yahoo.com>
Mon, 11 Sep 2023 11:45:58 +0000 (19:45 +0800)
* 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.

etc/PROBLEMS
src/sfntfont.c

index faeee2a303525441a1ea21d5104855ac84e9364b..11659c66e68dce731e5f99417316179e7d4ed9d3 100644 (file)
@@ -3526,6 +3526,18 @@ points the test font attempts to hide.
 Since this behavior does not influence the display of real fonts, no
 action will be taken to address this problem.
 
+** Some other font's instruction code produces undesirable results.
+
+Executing instruction code is not a strict requirement for producing
+correct display results from most current fonts.  If a font's
+instruction code produces results that are merely unpleasing, but not
+incorrect, then the font was presumably not designed for Emacs's
+scaler.  If its uninstructed glyphs are satisfactory (such as if your
+screen resolution is high to the extent that scaling artifacts prove
+invisible), disable instruction code execution by appending its family
+name to the variable 'sfnt-uninstructable-font-regexp', then
+restarting Emacs.
+
 ** CJK text does not display in Emacs, but does in other programs.
 
 When inserting CJK text into a buffer or visiting a file containing
index 64dbffad03f817cd1127b2a64cd5296c560891e2..12fecb32df5abbbcb73fdf15a629742bc3becd79 100644 (file)
@@ -2667,6 +2667,18 @@ sfntfont_setup_interpreter (struct sfnt_font_info *info,
   struct sfnt_interpreter *interpreter;
   const char *error;
   struct sfnt_graphics_state state;
+  Lisp_Object regexp;
+
+  /* If Vsfnt_uninstructable_family_regexp matches this font, then
+     return.  */
+
+  regexp = Vsfnt_uninstructable_family_regexp;
+
+  if (STRINGP (regexp)
+      && (fast_string_match_ignore_case (regexp,
+                                        desc->family)
+         >= 0))
+    return;
 
   /* Load the cvt, fpgm and prep already read.  */
 
@@ -3952,12 +3964,26 @@ syms_of_sfntfont (void)
      of the font backend.  */
   DEFVAR_LISP ("sfnt-default-family-alist", Vsfnt_default_family_alist,
     doc: /* Alist between "emulated" and actual font family names.
-
 Much Emacs code assumes that font families named "Monospace" and "Sans
 Serif" exist, and map to the default monospace and Sans Serif fonts on
 a system.  When the `sfnt' font driver is asked to look for a font
 with one of the families in this alist, it uses its value instead.  */);
   Vsfnt_default_family_alist = Qnil;
+
+  DEFVAR_LISP ("sfnt-uninstructable-family-regexp",
+              Vsfnt_uninstructable_family_regexp,
+    doc: /* Regexp matching font families whose glyphs must not be instructed.
+If nil, instruction code supplied by all fonts will be executed.  This
+variable takes effect when a font entity is opened, not after, and
+therefore won't affect the scaling of realized faces until their
+frames' font caches are cleared (see `clear-font-cache').
+
+TrueType fonts incorporate instruction code executed to fit each glyph
+to a pixel grid, so as to improve the visual fidelity of each glyph by
+eliminating artifacts and chance effects consequent upon the direct
+upscaling of glyph outline data.  Instruction code is occasionally
+incompatible with Emacs and must be disregarded.  */);
+  Vsfnt_uninstructable_family_regexp = Qnil;
 }
 
 void