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

Unicode rendering issue from version 0.14.1 #1713

Closed
kristijanhusak opened this issue Jun 14, 2019 · 34 comments
Closed

Unicode rendering issue from version 0.14.1 #1713

kristijanhusak opened this issue Jun 14, 2019 · 34 comments

Comments

@kristijanhusak
Copy link

kristijanhusak commented Jun 14, 2019

Today i updated my kitty from 0.14.0 to latest version.
When i restarted it, i noticed that some unicode characters are rendered differently.

Here's screenshot with 0.14.0:
before

And here's with 0.14.1:
after

Note the Lambda and checkmark.

I tried to find commit that introduced it, but no luck.

Here are some system and configuration information:

  • OS: Manjaro Linux i3
  • Kitty configuration related to font and line height:
font_family IBM Plex Mono Medium
bold_font IBM Plex Mono Bold
italic_font IBM Plex Mono Medium Italic
bold_italic_font IBM Plex Mono Bold Italic
font_size 10.5
adjust_line_height 8
@kovidgoyal
Copy link
Owner

There haven't been any changes to font rendering between those two versions. Most likely the fallback font being used for those symbols has changed because of changes on your system. Use --debug-font-fallback to see which font is used and symbol_map in kitty.conf to control it.

@kristijanhusak
Copy link
Author

I tried, and for lambda debug returns completely same info:

0.14.0:

U+3bb bold Face(family=DejaVu Sans Mono, style=Bold, ps_name=DejaVuSansMono-Bold, path=/usr/share/fonts/TTF/DejaVuSansMono-Bold.ttf, index=0, is_scalable=True, has_color=False, ascender=1901, descender=-483, height=2384, underline_position=-175, underline_thickness=90) (new face)

0.14.1

U+3bb bold Face(family=DejaVu Sans Mono, style=Bold, ps_name=DejaVuSansMono-Bold, path=/usr/share/fonts/TTF/DejaVuSansMono-Bold.ttf, index=0, is_scalable=True, has_color=False, ascender=1901, descender=-483, height=2384, underline_position=-175, underline_thickness=90) (new face)

When i define symbol_map u+3bb DejaVu Sans Mono Bold, it fixes it, which is strange, since debug tells it's same font used by default.

Is there a way to use different font for all unicode chars? symbol_map requires defining each separately, or a range.

@Luflosi
Copy link
Contributor

Luflosi commented Jun 14, 2019

Wasn't there a change that automatically adapted the line height if symbols are too high or something like that?

@kovidgoyal
Copy link
Owner

That would only affect line height not font selection/rendering.

@kovidgoyal
Copy link
Owner

If you want to use deja vu sans mono bold for all character set it in the font_family directive

@kovidgoyal
Copy link
Owner

Personally, I get best results for unicode symbols with symbola

@kristijanhusak
Copy link
Author

I would like to keep using font that i'm currently using now, and for all symbols to use something else. If i remember well iTerm has a similar feature where they allow choosing different font for those (regular and ascii).

@kovidgoyal
Copy link
Owner

So use the appropriate range in symbol_map

@kristijanhusak
Copy link
Author

@Luflosi is right, it is related to the line height.
When i set it to 0, it rendered properly.

screenshot

Up until value of 3 it looks relatively ok, but from 3 and above it is like on the initial screenshot.

@kovidgoyal
Copy link
Owner

well zero is the default value, so I think we are good here.

@Luflosi
Copy link
Contributor

Luflosi commented Jun 14, 2019

It's probably commit 1ae32b5.
I'm wondering how this change interacts with manual adjustments of adjust_line_height.

@kristijanhusak
Copy link
Author

yes, zero is default value, but that doesn't suit me.
Something is clearly changed between versions that causes this issue, since with 0.14.0 and line height of 8, everything looks fine.

@kovidgoyal
Copy link
Owner

well like I said, as far as I know, nothing has changed in font rendering, but you are welcome to bisect and find out what is causing it.

@kovidgoyal
Copy link
Owner

It's probably commit 1ae32b5.
I'm wondering how this change interacts with manual adjustments of adjust_line_height.

All that does is change the default calculated line height for a font that draws the underscore outside the cell. The adjustment option is applied afterwards.

@kristijanhusak
Copy link
Author

@kovidgoyal i did bisect and that 1ae32b5 causes the problem. Commit before it works fine 4e9dabf

I would fix it, but i never wrote C.

@kovidgoyal
Copy link
Owner

As I said before, all that patch does is change the default line height
calculation. You simply need to adjust the value you put in
adjust_line_height accordingly to compensate, put a simple printf() in
there to see what values are returned for cell height before and after
the patch and adjust the setting accordingly.

@kristijanhusak
Copy link
Author

Not sure i understand.
I need to change line height in my config?
Or you mean to do some changes in the c code to fix the calculation?

How can i compensate anything by changing adjust_line_height ?

@kovidgoyal
Copy link
Owner

That commit changes the value of cell_height. adjust_line_height also
changes that same value, so simply change adjust_line_height in your
kitty.conf to compensate.

@kristijanhusak
Copy link
Author

I tried all from 0 - 20, and only 0 - 3 renders it ok. Everything above that causes issue (more or less).
If this requires me to change my settings, which also didn't help, this is clearly a bug. with 0.13 and 0.14.0 i didn't had any issues.

Can this code be set up somehow to optionally include/exclude the new cell calculation, and use the old on instead?

@kovidgoyal
Copy link
Owner

Sorry I dont follow. The cell height calculation has changed, if you dont like the new calculation you can revert its effects by using adjust_line_height. That is not a bug. The new calculation compensates for broken fonts that dont have correct bounding boxes that would otherwise result in underscores and bottoms of characters being cut-off.

@kovidgoyal
Copy link
Owner

And I see no rendering issues with lambda and dejavu sans mono with adjust_line_height=20:

kitty --config NONE -o font_family=DejaVu\ Sans\ Mono -o adjust_line_height=20

Screenshot_20190617_093343

@kristijanhusak
Copy link
Author

kristijanhusak commented Jun 17, 2019

Yes, when whole font family is DejaVu Sans Mono, it also works fine for me.
Can you try this checkmark with Source Code Pro font?
And also, if possible, try both lambda and checkmark with this font https://github.com/IBM/plex/tree/master/IBM-Plex-Mono/fonts/complete/ttf ?

When i checked, font fallback for lambda was Dejavu Sans Mono.

@kovidgoyal
Copy link
Owner

If you use multiple fonts, then whether any given character will render correctly or not depends entirely on whether that character as designed in the secondary font, will fit in the cell size for the main font. There are no guarantees in that case. As I said earlier try using symbola, in my experience, that works best with a wide range of main fonts.

@kristijanhusak
Copy link
Author

Fair enough.
One thing still confuses me (sorry for being PITA).

When i start kitty with --debug-font-fallback, i get this for a checkmark:

U+2714 bold Face(family=DejaVu Sans Mono, style=Bold, ps_name=DejaVuSansMono-Bold, path=/usr/share/fonts/TTF/DejaVuSansMono-Bold.ttf, index=0, is_scalable=True, has_color=False, ascender=1901, descender=-483, height=2384, underline_position=-175, underline_thickness=90)

As i recall, this tells that DejaVu Sans Mono Bold font is used as fallback for the checkmark https://www.compart.com/en/unicode/U+2714

With this fallback, it renders like this:

screenshot

Now, when i add this to config:

symbol_map U+2714 DejaVuSansMono-Bold

It renders it fine:
screenshot

What's the difference?

@kovidgoyal
Copy link
Owner

Weird, there shouldn't be any difference -- what does --debug-gont-fallback print out aboutsymbol fonts in the latter case

@kristijanhusak
Copy link
Author

kristijanhusak commented Jun 17, 2019

In the latter there's no any output for U+2714, only for lambda and that branching char.

U+3bb bold Face(family=DejaVu Sans Mono, style=Bold, ps_name=DejaVuSansMono-Bold, path=/usr/share/fonts/TTF/DejaVuSansMono-Bold.ttf, index=0, is_scalable=True, has_color=False, ascender=1901, descender=-483, height=2384, underline_position=-175, underline_thickness=90) (new face)
U+e0a0 Face(family=Source Code Pro, style=Regular, ps_name=SourceCodePro-Regular, path=/usr/share/fonts/adobe-source-code-pro/SourceCodePro-Regular.otf, index=0, is_scalable=True, has_color=False, ascender=984, descender=-273, height=1257, underline_position=-100, underline_thickness=50) (new face)

@kovidgoyal
Copy link
Owner

But there will be some output about a symbol map font right at the
start.

@kristijanhusak
Copy link
Author

Oh yeah, sorry. Here's the whole output:

[168 12:12:26.572021] Preloaded font faces:
[168 12:12:26.572044] normal face: /home/kristijan/.fonts/IBMPlexMono-Medium.ttf:0
[168 12:12:26.572054] bold face: /home/kristijan/.fonts/IBMPlexMono-Bold.ttf:0
[168 12:12:26.572061] italic face: /home/kristijan/.fonts/IBMPlexMono-MediumItalic.ttf:0
[168 12:12:26.572068] bi face: /home/kristijan/.fonts/IBMPlexMono-BoldItalic.ttf:0
[168 12:12:26.572077] Symbol map faces:
[168 12:12:26.572084] /usr/share/fonts/TTF/DejaVuSansMono-Bold.ttf:0
U+3bb bold Face(family=DejaVu Sans Mono, style=Bold, ps_name=DejaVuSansMono-Bold, path=/usr/share/fonts/TTF/DejaVuSansMono-Bold.ttf, index=0, is_scalable=True, has_color=False, ascender=1901, descender=-483, height=2384, underline_position=-175, underline_thickness=90) (new face)
U+e0a0 Face(family=Source Code Pro, style=Regular, ps_name=SourceCodePro-Regular, path=/usr/share/fonts/adobe-source-code-pro/SourceCodePro-Regular.otf, index=0, is_scalable=True, has_color=False, ascender=984, descender=-273, height=1257, underline_position=-100, underline_thickness=50) (new face)

@kovidgoyal
Copy link
Owner

Hmm dont see anything there to explain it and I cant reproduce on my system with

kitty --config=NONE -o font_family=IBM\ Plex\ Mono --debug-font-fallback

@kristijanhusak
Copy link
Author

Try setting line height to 8.

@kristijanhusak
Copy link
Author

Any luck with the line height setting?

@kovidgoyal
Copy link
Owner

I will look atit when I have a moment, am rather swamped for now.

@kristijanhusak
Copy link
Author

You should probably reopen this so you can keep track of it.

@kristijanhusak
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants