aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGregory Heytings2022-12-12 02:12:09 +0100
committerGregory Heytings2022-12-12 02:12:09 +0100
commitb8d2ec920f37f5d77d32440eefc97dd5e8c2c7dc (patch)
tree16f2c0bf864526cdac8ef4f1aab4110ccd9856f5 /src
parent24c8c28ae617df018ee2c8b2f9df93608467d392 (diff)
downloademacs-b8d2ec920f37f5d77d32440eefc97dd5e8c2c7dc.tar.gz
emacs-b8d2ec920f37f5d77d32440eefc97dd5e8c2c7dc.zip
Revert "Improve last change to xfaces.c" (05ece1eb8b)
* src/xfaces.c: Revert 05ece1eb8b. See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59347#331.
Diffstat (limited to 'src')
-rw-r--r--src/xfaces.c111
1 files changed, 52 insertions, 59 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index 7dbcacb35ac..643f4365896 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -6014,21 +6014,6 @@ realize_non_ascii_face (struct frame *f, Lisp_Object font_object,
6014} 6014}
6015#endif /* HAVE_WINDOW_SYSTEM */ 6015#endif /* HAVE_WINDOW_SYSTEM */
6016 6016
6017/* Remove the attribute at INDEX from the font object if SYMBOL
6018 appears in `font-fallback-ignored-attributes'. */
6019
6020static void
6021font_maybe_unset_attribute (Lisp_Object font_object,
6022 enum font_property_index index, Lisp_Object symbol)
6023{
6024 Lisp_Object tail = Vface_font_lax_matched_attributes;
6025
6026 FOR_EACH_TAIL_SAFE (tail)
6027 {
6028 if (EQ (XCAR (tail), symbol))
6029 ASET (font_object, index, Qnil);
6030 }
6031}
6032 6017
6033/* Realize the fully-specified face with attributes ATTRS in face 6018/* Realize the fully-specified face with attributes ATTRS in face
6034 cache CACHE for ASCII characters. Do it for GUI frame CACHE->f. 6019 cache CACHE for ASCII characters. Do it for GUI frame CACHE->f.
@@ -6088,33 +6073,38 @@ realize_gui_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE]
6088 if (! FONT_OBJECT_P (attrs[LFACE_FONT_INDEX])) 6073 if (! FONT_OBJECT_P (attrs[LFACE_FONT_INDEX]))
6089 { 6074 {
6090 Lisp_Object spec = copy_font_spec (attrs[LFACE_FONT_INDEX]); 6075 Lisp_Object spec = copy_font_spec (attrs[LFACE_FONT_INDEX]);
6091 6076#define MAYBE_UNSET_ATTRIBUTE(ATTR) \
6092 /* Maybe unset several values in SPEC, usually the width, 6077 if (realize_gui_face_ignored_spec_attributes \
6093 slant, and weight. The best possible values for these 6078 & (1 << FONT_##ATTR##_INDEX)) \
6094 attributes are determined in font_find_for_lface, called 6079 ASET (spec, FONT_##ATTR##_INDEX, Qnil);
6095 by font_load_for_lface, when the list of candidate fonts 6080 /* The default value of
6096 returned by font_list_entities is sorted by font_select_entity 6081 realize_gui_face_ignored_spec_attributes unsets the
6097 (which calls font_sort_entities, which calls font_score). 6082 weight, slant and width in spec. The best possible
6098 If these attributes are not unset here, the candidate 6083 values for these attributes is determined in
6099 font list returned by font_list_entities only contains 6084 font_find_for_lface, called by font_load_for_lface, when
6100 fonts that are exact matches for these weight, slant, and 6085 the candidate list returned by font_list_entities is
6101 width attributes, which could lead to suboptimal or wrong 6086 sorted by font_select_entity (which calls
6102 font selection. (bug#5934) */ 6087 font_sort_entities, which calls font_score). If these
6103 font_maybe_unset_attribute (spec, FONT_WEIGHT_INDEX, QCweight); 6088 attributes are not unset here, the candidate font list
6104 font_maybe_unset_attribute (spec, FONT_SLANT_INDEX, QCslant); 6089 returned by font_list_entities only contains fonts that
6105 font_maybe_unset_attribute (spec, FONT_WIDTH_INDEX, QCwidth); 6090 are exact matches for these weight, slant and width
6091 attributes, which leads to suboptimal or wrong font
6092 choices. See bug#59347. */
6093 MAYBE_UNSET_ATTRIBUTE (WEIGHT);
6094 MAYBE_UNSET_ATTRIBUTE (SLANT);
6095 MAYBE_UNSET_ATTRIBUTE (WIDTH);
6106 /* Also allow unsetting other attributes for debugging 6096 /* Also allow unsetting other attributes for debugging
6107 purposes. But not FONT_EXTRA_INDEX; that is not safe to 6097 purposes. */
6108 touch, at least in the Haiku font backend. */ 6098 MAYBE_UNSET_ATTRIBUTE (FAMILY);
6109 font_maybe_unset_attribute (spec, FONT_FAMILY_INDEX, QCfamily); 6099 MAYBE_UNSET_ATTRIBUTE (FOUNDRY);
6110 font_maybe_unset_attribute (spec, FONT_FOUNDRY_INDEX, QCfoundry); 6100 MAYBE_UNSET_ATTRIBUTE (REGISTRY);
6111 font_maybe_unset_attribute (spec, FONT_REGISTRY_INDEX, QCregistry); 6101 MAYBE_UNSET_ATTRIBUTE (ADSTYLE);
6112 font_maybe_unset_attribute (spec, FONT_ADSTYLE_INDEX, QCadstyle); 6102 MAYBE_UNSET_ATTRIBUTE (SIZE);
6113 font_maybe_unset_attribute (spec, FONT_SIZE_INDEX, QCsize); 6103 MAYBE_UNSET_ATTRIBUTE (DPI);
6114 font_maybe_unset_attribute (spec, FONT_DPI_INDEX, QCdpi); 6104 MAYBE_UNSET_ATTRIBUTE (SPACING);
6115 font_maybe_unset_attribute (spec, FONT_SPACING_INDEX, QCspacing); 6105 MAYBE_UNSET_ATTRIBUTE (AVGWIDTH);
6116 font_maybe_unset_attribute (spec, FONT_AVGWIDTH_INDEX, QCavgwidth); 6106 MAYBE_UNSET_ATTRIBUTE (EXTRA);
6117 6107#undef MAYBE_UNSET_ATTRIBUTE
6118 attrs[LFACE_FONT_INDEX] = font_load_for_lface (f, attrs, spec); 6108 attrs[LFACE_FONT_INDEX] = font_load_for_lface (f, attrs, spec);
6119 } 6109 }
6120 if (FONT_OBJECT_P (attrs[LFACE_FONT_INDEX])) 6110 if (FONT_OBJECT_P (attrs[LFACE_FONT_INDEX]))
@@ -7404,24 +7394,27 @@ Lisp programs that change the value of this variable should also
7404clear the face cache, see `clear-face-cache'. */); 7394clear the face cache, see `clear-face-cache'. */);
7405 face_near_same_color_threshold = 30000; 7395 face_near_same_color_threshold = 30000;
7406 7396
7407 DEFVAR_LISP ("face-font-lax-matched-attributes", 7397 DEFVAR_INT ("realize-gui-face-ignored-spec-attributes",
7408 Vface_font_lax_matched_attributes, 7398 realize_gui_face_ignored_spec_attributes,
7409 doc: /* Font-related face attributes to match in lax manner when realizing faces. 7399 doc: /* Ignored font-spec attributes in realize_gui_face.
7410 7400
7411The value should be a list of font-related face attribute symbols; 7401The value is an integer number and represents a bit mask.
7412see `set-face-attribute' for the full list of attributes. The 7402The attribute corresponding to each bit that is set is cleared in
7413corresponding face attributes will be treated as "soft" constraints 7403realize_gui_face. The bits are: 1 = :foundry, 2 = :family,
7414when looking for suitable fonts: if an exact match is not possible, 74043 = :adstyle, 4 = :registry, 5 = :weight, 6 = :slant, 7 = :width,
7415a font can be selected that is a close, but not an exact, match. For 74058 = :size, 9 = :dpi, 10 = :spacing, 11 = :avgwidth, 12 = extra
7416example, looking for a semi-bold font might select a bold or a medium 7406attributes (:name, :script, :lang and :otf).
7417font if no semi-bold font matching other attributes is found. Emacs 7407
7418still tries to find a font that is the closest possible match; in 7408Bits 5 to 7 are set in the default value. When these bits are not
7419particular, if a font is available that matches the face attributes 7409set, and when the font chosen for the default face has a weight, slant
7420exactly, it will be selected. 7410or width that is not supported by other available fonts on the system,
7421 7411such as 'medium', Emacs may select suboptimal fonts for other faces.
7422Note that if the `:extra' attribute is present in the value, it 7412
7423will be ignored. */); 7413There is no reason to change that value except for debugging purposes. */);
7424 Vface_font_lax_matched_attributes = list3 (QCweight, QCslant, QCwidth); 7414 realize_gui_face_ignored_spec_attributes =
7415 (1 << FONT_WEIGHT_INDEX) |
7416 (1 << FONT_SLANT_INDEX) |
7417 (1 << FONT_WIDTH_INDEX);
7425 7418
7426#ifdef HAVE_WINDOW_SYSTEM 7419#ifdef HAVE_WINDOW_SYSTEM
7427 defsubr (&Sbitmap_spec_p); 7420 defsubr (&Sbitmap_spec_p);