Closed snaggen closed 10 months ago
Note the first grean triangle-arrow is my prompt, the line starts with the read emoji. Tested both on a 200% zoom 4k screen and a screen with 100% zoom, and it renders the color emoji small on both screens. So it is not hdpi/zoom related.
Also, tried to enter it by ctrl-shit-u and unicode code (1f600) but that doesn't work at all, that just prints the digits and letters.
This could be connected to the braile issue (same underlying cause).
If you run with RUST_LOG=cosmic_text=trace
, do you see "Adjusted glyph font size" messages?
Yes I get [2024-01-18T20:00:38Z TRACE cosmic_text::shape] Adjusted glyph font size (20 => 9.637648)
@MoSal normalization of width should take into account the unicode width of the glyph, since that is what terminal programs will use to determine how many columns were used (https://docs.rs/unicode-width/latest/unicode_width/)
Yes, that is pretty strange. Noto color emoji should be preferred so I'm not sure why it is falling back to another font.
I would like to see what happens with pop-os/cosmic-text#215 applied first.
@MoSal normalization of width should take into account the unicode width of the glyph, since that is what terminal programs will use to determine how many columns were used (https://docs.rs/unicode-width/latest/unicode_width/)
But font resize uses the width of ' ' to avoid this!
There was no difference using the fallback_codepoints branch
When I look at the debug output I see that
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] failed to find family 'Noto Sans'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] failed to find family 'DejaVu Sans'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] failed to find family 'FreeSans'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] failed to find family 'Noto Sans Mono'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] failed to find family 'DejaVu Sans Mono'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] failed to find family 'FreeMono'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] failed to find family 'Noto Sans Symbols'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] failed to find family 'Noto Sans Symbols2'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] failed to find family 'Noto Color Emoji'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] Failed to find preset fallback for [] locale 'sv-SE', used 'DejaVu Sans': '😀'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] failed to find family 'Noto Sans'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] failed to find family 'FreeSans'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] failed to find family 'Noto Sans Mono'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] failed to find family 'DejaVu Sans Mono'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] failed to find family 'FreeMono'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] failed to find family 'Noto Sans Symbols'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] failed to find family 'Noto Sans Symbols2'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] failed to find family 'Noto Color Emoji'
[2024-01-18T20:53:59Z DEBUG cosmic_text::font::fallback] Failed to find preset fallback for [] locale 'sv-SE', used 'Noto Color Emoji': '😀'
It uses DejaVu Sans for the first substitution and then Noto Color Emoji.
Also, I realize it looks extra weird, since the zsh auto suggestion is suggesting previous emoji tests... but without that it still is like in the screenshot that it first fallbacks to the ugly emoji for the first char in the line, and after that it uses the correct emoji.
Deleted the screencast since that just got confusing due to zsh autosuggestions...
Since DejaVu Sans and Noto Color Emoji are not monospace fonts, whatever got resized probably wasn't an emoji!
@snaggen If you could test with the set_monospace_width()
lines in src/terminal.rs
commented, that should remove all doubt about this not being related to font resize.
Wait, Noto Color Emoji
is a Monospace font!
Emoji fonts, probably some CJK fonts too, are monospace.
Nevermind, not CJK fonts.
Actually, there are monospace CJK fonts. This means there are monospace full width characters other than emojis.
Actually, there are monospace CJK fonts. This means there are monospace full width characters other than emojis.
So, some characters would be a multiple of the Monospace width?
Yes, and unicode-width is the way to know.
But then again, I made font resizing depend on the width of a space:
A space in "Noto Color Emoji" has a horizontal_advance/units_per_em of 2550/2048. Compare that to 600/1000 for Fira Mono.
If, for the sake of keeping monospatiality, we pretend that an Emoji monospace font has half the width it really has, would that be too hackish?
Basically, pretending that it's not monospace so it doesn't get resized
vs. pretending it's half width so it gets double the resized font size
I'm not sure it is as easy as special handle emoji fonts.... we have other fonts with symbols, like Nerd Fonts (which may be merged in to various fonts, which can be found on the Nerd Font home page https://www.nerdfonts.com ).
The screenshot below shows how some nerd font symbol is rendred in Cosmic Term and Wezterm. I included the letter A for reference.
The rust logo is the Nerd Font character with unicode f1617
Also, I created https://github.com/pop-os/cosmic-term/pull/70 to make it easier to use various special unicode characters, that should make it easier to test this since you then just can enter the unicode code for the different characters.
Good point. This is not Emoji-specific.
Another idea to keep monospatiality is to add a rounded factor to resizing:
1/(font_width/default_width) * (font_width/default_width).round() * font_size
I have some old emoji font installed, not sure which font it belongs to, but then I also have NotoColorEmoji.ttf and that is the emojis I normally see. Now when I paste U+1F600 to a new line in the terminal, it renders it using the old emoji font, but the next time I paste it I get the color emoji (however, rendered very small).
To reproduce
This is how it looks