diff options
| author | Po Lu | 2024-02-09 10:43:48 +0800 |
|---|---|---|
| committer | Po Lu | 2024-02-09 10:43:48 +0800 |
| commit | 5af4e346b0b078d6e8f3dd90bb66899d3ed99810 (patch) | |
| tree | f84b71b124cf343ac1de09c020673166d9e0483a /src | |
| parent | 8290a1bacb019f5026caa08334a7087802ebc6f9 (diff) | |
| download | emacs-5af4e346b0b078d6e8f3dd90bb66899d3ed99810.tar.gz emacs-5af4e346b0b078d6e8f3dd90bb66899d3ed99810.zip | |
Don't lose track of adstyles during face merging
* src/xfaces.c (merge_face_vectors): If an adstyle exists in
FROM, guarantee that a font spec will exist in TO with the same.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfaces.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/xfaces.c b/src/xfaces.c index b9a78328661..a558e7328c0 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -2245,20 +2245,20 @@ merge_face_heights (Lisp_Object from, Lisp_Object to, Lisp_Object invalid) | |||
| 2245 | 2245 | ||
| 2246 | /* Merge two Lisp face attribute vectors on frame F, FROM and TO, and | 2246 | /* Merge two Lisp face attribute vectors on frame F, FROM and TO, and |
| 2247 | store the resulting attributes in TO, which must be already be | 2247 | store the resulting attributes in TO, which must be already be |
| 2248 | completely specified and contain only absolute attributes. | 2248 | completely specified and contain only absolute attributes. Every |
| 2249 | Every specified attribute of FROM overrides the corresponding | 2249 | specified attribute of FROM overrides the corresponding attribute of |
| 2250 | attribute of TO; relative attributes in FROM are merged with the | 2250 | TO; merge relative attributes in FROM with the absolute value in TO, |
| 2251 | absolute value in TO and replace it. NAMED_MERGE_POINTS is used | 2251 | which attributes also replace it. Use NAMED_MERGE_POINTS internally |
| 2252 | internally to detect loops in face inheritance/remapping; it should | 2252 | to detect loops in face inheritance/remapping; it should be 0 when |
| 2253 | be 0 when called from other places. If window W is non-NULL, use W | 2253 | called from other places. If window W is non-NULL, use W to |
| 2254 | to interpret face specifications. */ | 2254 | interpret face specifications. */ |
| 2255 | static void | 2255 | static void |
| 2256 | merge_face_vectors (struct window *w, | 2256 | merge_face_vectors (struct window *w, |
| 2257 | struct frame *f, const Lisp_Object *from, Lisp_Object *to, | 2257 | struct frame *f, const Lisp_Object *from, Lisp_Object *to, |
| 2258 | struct named_merge_point *named_merge_points) | 2258 | struct named_merge_point *named_merge_points) |
| 2259 | { | 2259 | { |
| 2260 | int i; | 2260 | int i; |
| 2261 | Lisp_Object font = Qnil; | 2261 | Lisp_Object font = Qnil, tospec, adstyle; |
| 2262 | 2262 | ||
| 2263 | /* If FROM inherits from some other faces, merge their attributes into | 2263 | /* If FROM inherits from some other faces, merge their attributes into |
| 2264 | TO before merging FROM's direct attributes. Note that an :inherit | 2264 | TO before merging FROM's direct attributes. Note that an :inherit |
| @@ -2318,6 +2318,25 @@ merge_face_vectors (struct window *w, | |||
| 2318 | to[LFACE_SLANT_INDEX] = FONT_SLANT_FOR_FACE (font); | 2318 | to[LFACE_SLANT_INDEX] = FONT_SLANT_FOR_FACE (font); |
| 2319 | if (! NILP (AREF (font, FONT_WIDTH_INDEX))) | 2319 | if (! NILP (AREF (font, FONT_WIDTH_INDEX))) |
| 2320 | to[LFACE_SWIDTH_INDEX] = FONT_WIDTH_FOR_FACE (font); | 2320 | to[LFACE_SWIDTH_INDEX] = FONT_WIDTH_FOR_FACE (font); |
| 2321 | |||
| 2322 | if (!NILP (AREF (font, FONT_ADSTYLE_INDEX))) | ||
| 2323 | { | ||
| 2324 | /* If an adstyle is specified in FROM's font spec, create a | ||
| 2325 | font spec for TO if none exists, and transfer the adstyle | ||
| 2326 | there. */ | ||
| 2327 | |||
| 2328 | tospec = to[LFACE_FONT_INDEX]; | ||
| 2329 | adstyle = AREF (font, FONT_ADSTYLE_INDEX); | ||
| 2330 | |||
| 2331 | if (!NILP (tospec)) | ||
| 2332 | tospec = copy_font_spec (tospec); | ||
| 2333 | else | ||
| 2334 | tospec = Ffont_spec (0, NULL); | ||
| 2335 | |||
| 2336 | to[LFACE_FONT_INDEX] = tospec; | ||
| 2337 | ASET (tospec, FONT_ADSTYLE_INDEX, adstyle); | ||
| 2338 | } | ||
| 2339 | |||
| 2321 | ASET (font, FONT_SIZE_INDEX, Qnil); | 2340 | ASET (font, FONT_SIZE_INDEX, Qnil); |
| 2322 | } | 2341 | } |
| 2323 | 2342 | ||