[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master c154309976: Whitelist some incorrectly labeled "color" fonts unde
From: |
Po Lu |
Subject: |
master c154309976: Whitelist some incorrectly labeled "color" fonts under Xft |
Date: |
Thu, 19 May 2022 08:10:35 -0400 (EDT) |
branch: master
commit c15430997679fced7ef6adc23cbc59d0cfa3d625
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Whitelist some incorrectly labeled "color" fonts under Xft
* etc/PROBLEMS: Document problem with fonts incorrectly labeled
as color fonts under Xft.
* src/ftfont.c (xft_color_font_whitelisted_p): New function.
(ftfont_spec_pattern, ftfont_list): Respect whitelisting of
"color" fonts under Xft.
* src/xftfont.c (syms_of_xftfont): New variable
`xft-color-font-whitelist'.
---
etc/PROBLEMS | 16 ++++++++++++++++
src/ftfont.c | 30 +++++++++++++++++++++++++++++-
src/xftfont.c | 9 +++++++++
3 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/etc/PROBLEMS b/etc/PROBLEMS
index 3e0b73a4d5..4224171298 100644
--- a/etc/PROBLEMS
+++ b/etc/PROBLEMS
@@ -805,6 +805,22 @@ to take advantage of.
* Runtime problems related to font handling
+** Some fonts are detected but not usable under Xft.
+
+Some fonts might not be usable under Emacs even though they show up in
+the font family list when Emacs is built with Xft. This is because
+Emacs prevents fonts that have color glyphs (such as color Emoji) from
+being used, since they typically cause Xft crashes.
+
+On some GNU/Linux systems, fonts (such as Source Code Pro) that do not
+have color glyphs are reported as color fonts, causing them to be
+unavailable when using Xft. This is known to happen under Fedora
+GNU/Linux 36 or later, and possibly other distributions as well.
+
+If you encounter a such a font, you can enable it while ignoring other
+fonts that actually have color glyphs by adding its family name to the
+list `xft-color-font-whitelist'.
+
** Characters are displayed as empty boxes or with wrong font under X.
*** This may be due to your local fontconfig customization.
diff --git a/src/ftfont.c b/src/ftfont.c
index 5797300d23..301a145b7a 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -645,8 +645,29 @@ ftfont_get_open_type_spec (Lisp_Object otf_spec)
return spec;
}
+#if defined HAVE_XFT && defined FC_COLOR
+static bool
+xft_color_font_whitelisted_p (const char *family)
+{
+ Lisp_Object tem, name;
+
+ tem = Vxft_color_font_whitelist;
+
+ FOR_EACH_TAIL_SAFE (tem)
+ {
+ name = XCAR (tem);
+
+ if (STRINGP (name) && !strcmp (family, SSDATA (name)))
+ return true;
+ }
+
+ return false;
+}
+#endif
+
static FcPattern *
-ftfont_spec_pattern (Lisp_Object spec, char *otlayout, struct OpenTypeSpec
**otspec, const char **langname)
+ftfont_spec_pattern (Lisp_Object spec, char *otlayout,
+ struct OpenTypeSpec **otspec, const char **langname)
{
Lisp_Object tmp, extra;
FcPattern *pattern = NULL;
@@ -785,6 +806,8 @@ ftfont_spec_pattern (Lisp_Object spec, char *otlayout,
struct OpenTypeSpec **ots
/* We really don't like color fonts, they cause Xft crashes. See
Bug#30874. */
if (xft_ignore_color_fonts
+ && (NILP (AREF (spec, FONT_FAMILY_INDEX))
+ || NILP (Vxft_color_font_whitelist))
&& ! FcPatternAddBool (pattern, FC_COLOR, FcFalse))
goto err;
#endif
@@ -930,7 +953,12 @@ ftfont_list (struct frame *f, Lisp_Object spec)
returns them even when it shouldn't really do so, so we
need to manually skip them here (Bug#37786). */
FcBool b;
+ FcChar8 *str;
+
if (xft_ignore_color_fonts
+ && (FcPatternGetString (fontset->fonts[i], FC_FAMILY,
+ 0, &str) != FcResultMatch
+ || !xft_color_font_whitelisted_p ((char *) str))
&& FcPatternGetBool (fontset->fonts[i], FC_COLOR, 0, &b)
== FcResultMatch && b != FcFalse)
continue;
diff --git a/src/xftfont.c b/src/xftfont.c
index 31fb877c35..6043ef9f94 100644
--- a/src/xftfont.c
+++ b/src/xftfont.c
@@ -797,6 +797,15 @@ syms_of_xftfont (void)
This is needed with some fonts to correct vertical overlap of glyphs. */);
xft_font_ascent_descent_override = 0;
+ DEFVAR_LISP ("xft-color-font-whitelist", Vxft_color_font_whitelist,
+ doc: /* List of "color" font families that don't actually have color
glyphs.
+Some fonts (such as Source Code Pro) are reported as color fonts, but
+do not actually have glyphs with colors that can cause Xft crashes.
+
+The font families in this list will not be ignored when
+`xft-ignore-color-fonts' is non-nil. */);
+ Vxft_color_font_whitelist = list1 (build_pure_c_string ("Source Code Pro"));
+
pdumper_do_now_and_after_load (syms_of_xftfont_for_pdumper);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master c154309976: Whitelist some incorrectly labeled "color" fonts under Xft,
Po Lu <=