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