Skip to content

Fix cursor disappear and rendering issue with Chinese characters#608

Open
bommbo wants to merge 1 commit intolxqt:masterfrom
bommbo:fix-cursor-render
Open

Fix cursor disappear and rendering issue with Chinese characters#608
bommbo wants to merge 1 commit intolxqt:masterfrom
bommbo:fix-cursor-render

Conversation

@bommbo
Copy link
Copy Markdown

@bommbo bommbo commented Jan 7, 2026

When switching between Block and I-beam cursor shapes on wide characters (e.g. Chinese), the cursor area was too narrow due to using _fontWidth instead of the actual character pixel width. This caused visual artifacts
such as partial cursor remnants or incomplete redraw.

This change uses QFontMetrics::horizontalAdvance() to get the true width of the character under the cursor, while preserving the existing -1/+1 adjustment to maintain I-beam visibility under sub-pixel rendering.

When switching between Block and I-beam cursor shapes on wide characters
(e.g. Chinese), the cursor area was too narrow due to using _fontWidth
instead of the actual character pixel width. This caused visual
artifacts
such as partial cursor remnants or incomplete redraw.

This change uses QFontMetrics::horizontalAdvance() to get the true width
of the character under the cursor, while preserving the existing -1/+1
adjustment to maintain I-beam visibility under sub-pixel rendering.
@bommbo
Copy link
Copy Markdown
Author

bommbo commented Jan 7, 2026

qterminal

before
test1

after
test2

@tsujan
Copy link
Copy Markdown
Member

tsujan commented Feb 9, 2026

First, thanks for your contribution!

Chinese characters come under the "double-column" category. IMO, there's no issue to fix: the blinking cursor is easy to recognize, although its behavior is different with double-column characters.

Moreover:

  • I doubt that doing extra computations is a good idea in the case of double-column characters when it comes to blinking.
  • This patch may cause inconsistencies in the case of other characters that are NOT double-column. (U+29F8 — not an ordinary slash) is only one example.

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.

2 participants