mirror of
https://github.com/zed-industries/zed.git
synced 2026-10-21 05:31:11 +00:00
gpui_wgpu: Fix fallback fonts disappearing from the font database on Linux (#65269)
Closes #61660 On Linux, `load_family` skips any font without an `m` glyph, since the editor uses the width of `m` for layout and would panic otherwise. That part's fine. The problem is it also deleted the font from the fontdb database, and has since the cosmic-text port (#7539). That hurts because fonts like Arabic, Hebrew, Devanagari, Noto Color Emoji and Symbols Nerd Font have no `m`, and they're exactly what cosmic-text falls back to for glyphs your main font doesn't have. So if one of them ever went through `load_family`, say because you put it in `buffer_font_fallbacks`, it was gone for the rest of the session and that script showed up as empty boxes. It also blocks #64199, where the font picker renders each row in its own font. On Linux that would call `load_family` on every installed font and wipe out all the non-Latin and emoji ones. Running the Linux text system against the fonts on my Mac, 334 of 806 faces got removed. This keeps the `m` check and drops the removal. You still can't use these as your buffer or UI font, but fallback works again. --- Tested on Ubuntu 24.04. By default, emoji render because cosmic-text finds Noto Color Emoji on its own: <img width="400" alt="control-no-fallbacks" src="https://github.com/user-attachments/assets/ac9b5aa1-fb06-4033-9ca1-1f4938b34839" /> Setting `"buffer_font_fallbacks": ["Noto Color Emoji"]` sends the font through `load_family`, which deleted it from the database since it has no `m`, so emoji turned into empty boxes: <img width="400" alt="before" src="https://github.com/user-attachments/assets/0af20580-f074-4522-a4b2-9c0a1312594f" /> With this PR the font stays in the database and emoji render again: <img width="400" alt="after" src="https://github.com/user-attachments/assets/a1fe9e91-dc8e-413d-a89f-d0968c410a6e" /> Release Notes: - Fixed emoji, symbol and non-Latin fonts rendering as empty boxes on Linux after being used as a font fallback. - [GPUI] Fixed fonts without an `m` glyph being removed from the font database on Linux (`gpui_wgpu`) when loaded by family name, which broke fallback for emoji, symbol and non-Latin text.
This commit is contained in:
parent
b0d4fd203d
commit
d6358b2d3c
1 changed files with 8 additions and 1 deletions
|
|
@ -418,10 +418,17 @@ impl CosmicTextSystemState {
|
|||
"Segoe Fluent Icons",
|
||||
];
|
||||
|
||||
// This only decides whether a face can be a primary font. The
|
||||
// editor measures layout with the width of 'm' and would panic
|
||||
// without it.
|
||||
//
|
||||
// Don't remove the face from the font database. Arabic, Devanagari
|
||||
// and emoji fonts often have no Latin glyphs, and they are exactly
|
||||
// what cosmic-text falls back to when the primary font lacks a
|
||||
// glyph.
|
||||
if font.as_swash().charmap().map('m') == 0
|
||||
&& !allowed_bad_font_names.contains(&postscript_name.as_str())
|
||||
{
|
||||
self.font_system.db_mut().remove_face(font.id());
|
||||
continue;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue