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

Wide characters get truncated #223

Closed
Dreomite opened this issue Jun 11, 2020 · 2 comments · Fixed by #224
Closed

Wide characters get truncated #223

Dreomite opened this issue Jun 11, 2020 · 2 comments · Fixed by #224

Comments

@Dreomite
Copy link
Contributor

Dreomite commented Jun 11, 2020

The issue

ST divides rendered text to sequences of glyphs with same style and then sequentially draws them. This leads to a problem: if a wide glyph is followed by another glyph with different style (can be color, weight or anything), the excessive parts of the glyph will be overdrawn by the beginning of the next sequence.

Steps to reproduce

  1. If you have a double-width Nerd font installed, execute this in your terminal: echo '\uF03E\e[36mX \uF03EX '

You'll get the following picture:
image
Note how the first icon gets truncated due to style difference while the second one doesn't.

The reason

If you'll take a look at xdrawglyphfontspecs function, which is used for drawing sequences of glyphs with same style, you'll see that it calls 2 functions before drawing actual glyphs:

  • XftDrawRect - this one draws background of the current sequence basically overdrawing parts of previous sequence if they happen to cross current sequence boundary.
  • XftDrawSetClipRectangles - this one puts drawable glyphs in an invisible rectangle outside of which glyphs are not rendered. (Later followed by XftDrawSetClip to negate this.)

Proposed solution

  1. Use 2 passes for drawing lines: one for background, another one for foreground. So parts of wide glyphs do not get overdrawn.
  2. Git rid of rectangle clipping. It was introduced in this commit and is intended for removing overdrawing for some fonts. Was it worth introducing in the first place? I don't know. Such fonts are still going to look crippled and are not worth using in the first place.

I made a very dirty proof-of-concept fix here: Dreomite@e4355b5

With no fix:
image

With this fix:
image

Is this an acceptable solution?

@LukeSmithxyz
Copy link
Owner

Okay, you can open a PR if you'd like.

It'd be nice to have taken care of and I'll reverse it if it causes some unforeseen issues.

oibind added a commit to oibind/st that referenced this issue Aug 13, 2020
@Mattio-cmd
Copy link

still working?

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

Successfully merging a pull request may close this issue.

3 participants