Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

font fallback for U+2387 is inconsistent with native macOS apps #5341

Open
amusingimpala75 opened this issue Apr 26, 2024 · 9 comments
Open
Labels
bug Something isn't working macOS Issue applies to Apple macOS

Comments

@amusingimpala75
Copy link

What Operating System(s) are you seeing this problem on?

macOS

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

wezterm 20240203-110809-5046fc22

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

The wrong font is selected for a given symbol, in this case ' ⎇ '. Alacritty, set to use the JetBrains Mono font, yields:
Screenshot 2024-04-26 at 12 50 37 AM
whereas Wezterm, set to use that font setup renders it as
Screenshot 2024-04-26 at 12 50 53 AM.
Asking wezterm to list the font applied for the symbol says that it is using the Apple Symbols font.

To Reproduce

No response

Configuration

font related parts of my wezterm config are below:

config.font = wezterm.font_with_fallback {
  { family = "JetBrainsMono Nerd Font", weight = "Medium" },
  -- ⎇ symbol is broken, but not on alacritty
  { family = "JetBrains Mono", weight = "Regular" },
  "DroidSansMono Nerd Font",
}

config.font_size = 16.0
config.bold_brightens_ansi_colors = true
config.dpi = 144.0
config.font_rules = {
  {
    intensity = "Bold",
    font = wezterm.font("JetBrainsMono Nerd Font", {weight = "ExtraBold"})
  },
  {
    italic = true,
    intensity = "Bold",
    font = wezterm.font("JetBrainsMono Nerd Font", {italic = true, weight = "ExtraBold"})
  },
  {
    italic = true,
    font = wezterm.font("JetBrainsMono Nerd Font", {italic = true, weight = "Medium"})
  },
}
config.harfbuzz_features = {"calt=1", "clig=1", "liga=1"}

Expected Behavior

Font behavior should be the same, and the JetBrains mono font should be used over the Apple symbols font.

Logs

No response

Anything else?

No response

@amusingimpala75 amusingimpala75 added the bug Something isn't working label Apr 26, 2024
@wez wez added the macOS Issue applies to Apple macOS label May 5, 2024
@zevelix

This comment was marked as off-topic.

@amusingimpala75

This comment was marked as off-topic.

@wez
Copy link
Owner

wez commented May 13, 2024

This isn't alacritty; what it shows is not relevant to me.
Please run through https://wezfurlong.org/wezterm/troubleshooting.html#debugging-font-display

@wez wez added the waiting-on-op Waiting for more information from the original poster label May 13, 2024
@zevelix

This comment was marked as off-topic.

@amusingimpala75
Copy link
Author

amusingimpala75 commented May 13, 2024

I already tried debugging it (hence knowing that it was being printed using the Apple Symbols font), but I'll provide the full printout here:

wezterm ls-fonts --text ⎇: ls_fonts_char.txt

LeftToRight
 0 ⎇    \u{2387}     x_adv=25.330141129032256 cells=1  glyph=uni2387,3455 wezterm.font("Apple Symbols", {weight="Regular", stretch="Normal", style="Normal"})
                                      /System/Library/Fonts/Apple Symbols.ttf, CoreText

wezterm ls-fonts --list-system: ls_fonts_system.txt
wezterm ls-fonts: ls_fonts.txt

@github-actions github-actions bot removed the waiting-on-op Waiting for more information from the original poster label May 13, 2024
@amusingimpala75
Copy link
Author

And for the record, yes the font should be printing the character the way I expected, I checked with gucharmap.

@wez
Copy link
Owner

wez commented May 14, 2024

What this tells me is that U+2387 is not present in JetBrainsMono Nerd Font, so wezterm asks macOS where to find it and macOS says that it is present in /System/Library/Fonts/Apple Symbols.ttf.

image

The Font Book app also shows that the Apple Symbols font is a reasonable choice. If you look at the symbol on the mac keyboard, the Apple Symbol font glyph is in the same orientation, so it "feels right".

However, the macOS Terminal app picks a different font from that!

Looking deeper:

$ WEZTERM_LOG=wezterm_font=trace,info wezterm --config-file /tmp/5341.lua ls-fonts --text ⎇
...
18:16:07.085  TRACE  wezterm_font                     > Fallback fonts that match \u{2387} before sorting are: [
    ParsedFont {
        names: Names {
            full_name: "Apple Symbols Regular",
            family: "Apple Symbols",
            sub_family: Some(
                "Regular",
            ),
            postscript_name: Some(
                "AppleSymbols",
            ),
            aliases: [],
        },
        weight: FontWeight(
            400,
        ),
        stretch: Normal,
        style: Normal,
        handle: FontDataHandle {
            source: OnDisk {
                path: "/System/Library/Fonts/Apple Symbols.ttf",
            },
            index: 0,
            variation: 0,
            origin: CoreText,
            coverage: None,
        },
        cap_height: Some(
            0.54638671875,
        ),
        synthesize_italic: false,
        synthesize_bold: false,
        synthesize_dim: false,
        assume_emoji_presentation: false,
        pixel_sizes: [],
        harfbuzz_features: None,
        freetype_load_target: None,
        freetype_render_target: None,
        freetype_load_flags: None,
        scale: None,
    },
    ParsedFont {
        names: Names {
            full_name: "STIX Two Math Regular",
            family: "STIX Two Math",
            sub_family: Some(
                "Regular",
            ),
            postscript_name: Some(
                "STIXTwoMath-Regular",
            ),
            aliases: [],
        },
        weight: FontWeight(
            400,
        ),
        stretch: Normal,
        style: Normal,
        handle: FontDataHandle {
            source: OnDisk {
                path: "/System/Library/Fonts/Supplemental/STIXTwoMath.otf",
            },
            index: 0,
            variation: 0,
            origin: CoreText,
            coverage: None,
        },
        cap_height: Some(
            0.657,
        ),
        synthesize_italic: false,
        synthesize_bold: false,
        synthesize_dim: false,
        assume_emoji_presentation: false,
        pixel_sizes: [],
        harfbuzz_features: None,
        freetype_load_target: None,
        freetype_render_target: None,
        freetype_load_flags: None,
        scale: None,
    },
]

that STIX Two Math font is returned as a candidate as well, but since the Apple Symbols font satisfies the query we don't try it.

If you explicitly select that font, you also get a glyph that is consistent with Apple Symbols and the Apple Keyboard.

If you add Lucida Grande to the fallback list, then you get a glyph with the same orientation as the one that Terminal.app selects.

So, I'm not sure what I can do here; we're using the font that macOS tells us to use, which is not the same as the font as its own internal font resolver would use.

What I'd suggest in the meantime is adding either Lucida Grande or Fira Code to your fallback list to get the style of glyph that you're looking for.

@wez wez changed the title Wrong font being selected font fallback for U+2387 is inconsistent with native macOS apps May 14, 2024
@amusingimpala75
Copy link
Author

Yeah using Fira Code solves the issues, thanks! Do you want me to leave this issue open or would you rather I closed it?

@wez
Copy link
Owner

wez commented May 14, 2024

We can keep it open; it does bother me that this inconsistency exists, and if you hit it, then someone else is likely to hit it in the future. I'm not sure if/when I'll be able to do anything about it, but this at least serves as documentation on what's happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working macOS Issue applies to Apple macOS
Projects
None yet
Development

No branches or pull requests

3 participants