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

Visual problem when part of a string containing '⧸' (U+29F8) is selected #1186

Closed
DrinkDregs opened this issue Nov 17, 2024 · 3 comments · Fixed by lxqt/qtermwidget#565
Closed

Comments

@DrinkDregs
Copy link

[The original report is now invisible to anyone other than me when I'm signed in.]

I've found some other characters that cause the problem:

ร ว ว เ ส ย ง

There must be many others.

@tsujan tsujan changed the title Difficulty handling Unicode slash character Visual problem when parts of a string containing '⧸' (U+29F8) is selected Nov 17, 2024
@tsujan
Copy link
Member

tsujan commented Nov 17, 2024

[The original report is now invisible to anyone other than me when I'm signed in.]

Thanks for adding it again.

I add your comment in the previous report that mysteriously vanished:

"When selecting a name that contains a '⧸', the whole string moves to the right and a space inserted to the right or left of the selection for every '⧸' selected."

I also add my comments in that report :

This may not be an issue in QTerminal, because characters like "U+29F8" contradict the monospace property (= fixed-width).

It happens in Konsole too, but in a worse way.

@tsujan tsujan changed the title Visual problem when parts of a string containing '⧸' (U+29F8) is selected Visual problem when part of a string containing '⧸' (U+29F8) is selected Nov 17, 2024
@tsujan
Copy link
Member

tsujan commented Nov 17, 2024

XTerm cheats but adding a margin after such characters to make them like fixed-width characters, while we use QPainter::drawText(), which draws the text as it is, and then the problem arises because the width is smaller than what it should be.

This screenshot shows xterm on the top and QTerminal below it:

xterm

QTerminal (actually, QPainter::drawText) draws the text correctly (it's aabb⧸aabb⧸aabb⧸aabb⧸aabb), but we don't want that in this case.

A workaround may be to use our own version of QPainter::drawText(), but that isn't easy, if possible at all.

EDIT: gnome-terminal cheats exactly in the same way.

@tsujan
Copy link
Member

tsujan commented Nov 18, 2024

Found a simple way of "cheating". It makes QTerminal exactly like XTerm and gnome-terminal in this regard:

qterminal

Will make a PR soon.

EDIT: The PR is made at lxqt/qtermwidget#565

tsujan added a commit to lxqt/qtermwidget that referenced this issue Nov 18, 2024
As Qt explains in https://doc.qt.io/qt-6/qfont.html#StyleStrategy-enum, "if the font selected for a certain writing system does not contain a character requested to draw, then Qt automatically chooses a similar looking font that contains the character."

This caused a problem for us because the width of the replacing character might be smaller than the monospace width, while the code expected the same width.

The patch fixes the issue by checking the width and adding simple conditions if it's smaller than expected.

To test it, you could use a string like `aabb⧸aabb⧸aabb⧸aabb⧸aabb` ('⧸' is *not* an ordinary slash). Previously, the characters were moved on making selections or moving the text cursor.

Fixes lxqt/qterminal#1186

NOTE: There is still a rare issue with another kind of character that isn't related to this PR. I might investigate it later.
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.

2 participants