lxqt / qtermwidget

The terminal widget for QTerminal
https://lxqt.github.io
GNU General Public License v2.0
506 stars 255 forks source link

Fixed the problem with characters like '⧸' (U+29F8) #565

Closed tsujan closed 2 hours ago

tsujan commented 1 week ago

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 https://github.com/lxqt/qterminal/issues/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.