Skip to content

Comments

Double width overflow support#135

Merged
kdj0c merged 3 commits intoAetf:mainfrom
michael-oberpriller:Double-Width
Sep 29, 2025
Merged

Double width overflow support#135
kdj0c merged 3 commits intoAetf:mainfrom
michael-oberpriller:Double-Width

Conversation

@michael-oberpriller
Copy link

This PR along with Aetf/libtsm#51 adds support for single cell characters overflowing to the next cell. This fixes #18. Changes for both PRs will be in this in this description.

Libtsm Changes

A new callback function, overflow_cb, is added to tsm_screen_draw. This function determines if the current character needs to overflow into the next and writes that to overflow_next. The overflow_next variable will cause the next call to tsm_screen_draw to be skipped if it is an empty cell, thus preventing the previous cell from being overwritten.

Kmscon Changes

The kmscon_font_pango_get_overflow function is added to implement the overflow_cb in libtsm. This detects if the logical width of a character is greater than the fonts attribute width. The txt->ops->draw functions are altered to add an overflow_next parameter to change the functionality of drawing. gltex_draw is altered to use the glyph's width if overflow_next is set. tp_draw is altered to always use glyph's buffer width to draw. bbulk_draw is altered to set the next cell's buffer to NULL if overflow_next is set.

This causes all render engines to not overwrite the right side of single cell double width characters.

@michael-oberpriller
Copy link
Author

The logic of double width overflow has been moved from libtsm to kmscon. This prevents the problem of breaking libtsm's ABI.

@kdj0c
Copy link
Collaborator

kdj0c commented Sep 23, 2025

That looks good overall, but I think there is a small flaw.

bool previous_overflow, this checks if the previous drawn character has overflown, but this assume the previous character is on the left, which might not be always the case.

two example:

  • if the wide char is the last of the current line, and the next line starts with an empty cell,
  • If only a small subregion is redrawn due to cursor move / or updating a "VT scrolling region"

I think it can be solved by also storing the position in txt->overflow_posx and txt->overflow_posy ?

Also if you can rebase on top of main (instead of merge), and squash "Double width overflow support" and "Move double width overflow logic into kmscon" together, to have a nice linear git history.

Thanks

@michael-oberpriller
Copy link
Author

* if the wide char is the last of the current line, and the next line starts with an empty cell,

I updated previous_overflow to not be used if posx is 0, so this should be fixed.

* If only a small subregion is redrawn due to cursor move / or updating a "VT scrolling region"

From my understanding libtsm and each render engine always redraws the entire screen from up to down left to right. If I am wrong about this, please show me in the code where this is wrong.

Also if you can rebase on top of main (instead of merge), and squash "Double width overflow support" and "Move double width overflow logic into kmscon" together, to have a nice linear git history.

Should be fixed now.

@kdj0c
Copy link
Collaborator

kdj0c commented Sep 23, 2025

Thanks a lot, just let me a few days to run some tests, and I will merge it.

@kdj0c
Copy link
Collaborator

kdj0c commented Sep 28, 2025

I've tested it, and that's indeed fixes the issue with Hack Nerd Fonts.
Thanks a lot @michael-oberpriller for doing this!

And indeed libtsm always redraw the whole screen, I really thought there was some optimizations there.

If no objection, I will merge it soon.

@kdj0c kdj0c mentioned this pull request Sep 28, 2025
@kdj0c kdj0c merged commit 77b9628 into Aetf:main Sep 29, 2025
1 check passed
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 this pull request may close these issues.

Font is not properly rendered yet

2 participants