bakkeby / st-flexipatch

An st build with preprocessor directives to decide which patches to include during build time
MIT License
348 stars 107 forks source link

Height changes weirdly for characters on current line #82

Open UtkarshVerma opened 2 years ago

UtkarshVerma commented 2 years ago

I am observing this weird behaviour with the following key config:

chscale: 1.1
font: Comic Code Ligatures
vertcenter enabled

https://user-images.githubusercontent.com/31820255/188307382-081a8567-48d8-48b1-84a6-f0e973f53035.mp4

You can quickly test this with my build of st: https://github.com/UtkarshVerma/st-flexipatch/tree/no-reflow

bakkeby commented 2 years ago

Looks to be just a side effect of using fallback fonts that are of a different size (larger) than the primary font - not all fonts are created alike or at the same display size compared to point / pixel size.

If you disable the WIDE_GLYPHS_PATCH then you won't have this issue as the characters will be cropped when they are drawn.

This shouldn't have anything specifically to do with chscale or the vertcenter patch.

UtkarshVerma commented 2 years ago

I investigated a bit and realised that it's not due to fallback. Some of the glyphs in Comic Code fonts are very large, especially the ones for box drawing. I increased chscale (=1.35) to match the glyph height and now it is fine.

However, that means I have to put additional line height unnecessarily. Is there some way I can specifically crop exceeding glyphs on in the vertical direction?

bakkeby commented 2 years ago

You are right, the box drawing glyphs are larger in this font. I can only assume that the technical reasons for this is that the font does not come with built-in vertical padding (empty space above and below the characters) which allows for the text to be very compact or dense. The boxdrawing glyphs being larger would then be to compensate for when spacing is added.

Is there some way I can specifically crop exceeding glyphs on in the vertical direction?

If you remove the WIDE_GLYPHS_PATCH then glyphs should be cropped in the vertical direction as it is in a stock st. That patch is a hack that just avoids larger glyphs from being cropped when drawing the background; it doesn't actually fix the underlying issue that the wide glyph is reported as taking up one column rather than two.

UtkarshVerma commented 1 year ago

How do I ensure that the glyphs take up two columns?

bakkeby commented 1 year ago

I don't know. In #56 veltza referred to the implementation in kitty that works out the number of columns for a character. I tried but wasn't successful in porting that to st.