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

Font width issue #2566

Open
DarthGandalf opened this issue Nov 20, 2023 · 16 comments · Fixed by #2573
Open

Font width issue #2566

DarthGandalf opened this issue Nov 20, 2023 · 16 comments · Fixed by #2573

Comments

@DarthGandalf
Copy link
Member

Gentoo Linux amd64, version 4a51c0e
Qt 5.15.11

When the last time I accidentally deleted my config by trying test version of kvirc (yes, I need better backups) something happened with calculation of font width. See the video: https://youtu.be/tvh8nV_K2vM

This actually makes it hard to select a substring, because when I click it the string visually moves, and I end up selecting a different substring than I intended.

@ctrlaltca
Copy link
Contributor

It seems in #2567 that this font can trick QFontDialog into thinking it's bold while it's not, and this could be also the cause of a miscalculation of the glyph width.
Does it happen with another font, too?

@DarthGandalf
Copy link
Member Author

I'll check.

Before the accident I was using the same font, and I have another kvirc setup with this font (different version though), which also works fine.

@ctrlaltca
Copy link
Contributor

It would be nice to check if the value of fontIrcView is the same in the different configs, and / or how the new version handles the old config

@DarthGandalf
Copy link
Member Author

Changing font didn't fix it, same for changing style

@DarthGandalf
Copy link
Member Author

This happens even on a brand new config, when running kvirc -f -n /tmp/kvircrc, without changing any fonts.

@DarthGandalf
Copy link
Member Author

I ran git bisect, and the regression happened in 2829217

Looks like @pragmaware tried to fix this in 148d8d9 but for me it made the effect even stronger

@ctrlaltca
Copy link
Contributor

I guess 2829217#diff-457dd4d023c2f347f0f23f4d9413c1d71ff648494e2d8cefdfd01bd007c88692L412 it what is causing the issue (similar changes apply to input and topic widgets aswell.

We used some tricks before to ensure correct font width calculation, disabling kerning and the QFont::ForceIntegerMetrics style, that doesn't exist anymore in Qt6.
Qt's advice is to use QFontMetrics to restore the old behavior (see https://doc.qt.io/qt-5/qfont.html#StyleStrategy-enum ).
So, in 2829217 i switched from QFontMetricsF (float) to QFontMetrics (int).
This probably caused some other problems (overlapping texts), so @pragmaware reverted this last change in 148d8d9

Right now I'm not able to reproduce this, but I'll try harder.

@DarthGandalf
Copy link
Member Author

I tried to replace horizontalAdvance with width, but it's still broken. Would need to debug further

@ctrlaltca
Copy link
Contributor

A possible fix is here: master...ctrlaltca:KVIrc:fix_surrogate
At least, it fixes emojis as reported by @Gizmokid2005 yesterday on IRC
Since the inputeditor needs a similar fix, i'll open a PR when that's ready as well

@ctrlaltca
Copy link
Contributor

ctrlaltca commented Nov 29, 2023

Can you please test these two different attempts at fixing the issue?

Attempt1: Attempt at fixing font width size by enable full font hinting, aka forcing glyphs to be aligned to pixels in order to disable subpixel positioning (source: https://www.mail-archive.com/development@qt-project.org/msg43330.html)
This mimics the old "ForceIntegerMetrics" style that got removed in Qt6
ctrlaltca@c9a84af

Attempt2: Attempt at fixing font width problem by making the selection code use floats, too
ctrlaltca@7c56944

@DarthGandalf
Copy link
Member Author

Attempt1 fixes it, Attempt2 does not.

@AbSoLuT-ZcC
Copy link

Hello,

DarthGandalf told me I should report this here, so here it it.
I seem to have a similar problem to the one this thread was about, on a mac, running KVIrc 5.2.6.

Here is a video: https://youtu.be/jm1rdqxJAjw

And some more info:

KVIrc 5.2.6 'Quasar'

Information du système:
Nom du système: macOS
Version du système: Darwin Kernel Version 24.1.0: Thu Oct 10 21:05:14 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T8103
Architecture: x86_64
Version de Qt: 6.6.2
Thème de Qt: macos

Information de compilation:
Date de la compilation: 2024-10-11 13:34:22 UTC
Date des sources: 20241011
Numéro de la révision: 5.2.6
Nom du processeur: x86_64
Commande de compilation: /usr/local/Cellar/cmake/3.30.4/bin/cmake
Options de compilation:
MANDIR=share/man
CMAKE_INSTALL_PREFIX=/Users/runner/work/KVIrc/KVIrc/build/KVIrc.app
Threads=POSIX
Nom du compilateur: /Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
Options du compilateur: N/A
Version de Qt: 6.6.2
Fonctionnalités: IRC, IPv6, Crypt, SSL, IfAddr, IPC, Transparency, Perl, Enchant, Qt5, Qt6, KVS
Version de OpenSSL: OpenSSL 3.3.2 3 Sep 2024
OpenSSL compiler flags: compiler: clang -fPIC -arch x86_64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -D_REENTRANT -DOPENSSL_BUILDING_OPENSSL -DNDEBUG
OpenSSL built on: Tue Sep 3 12:46:38 2024 UTC

@DarthGandalf DarthGandalf reopened this Nov 20, 2024
@ctrlaltca
Copy link
Contributor

I saw the video, is that cropped part of window from KVIrc? is that a channel, a webview or what? I can't make sense of its contents. Also, can I ask you what font is that window using? Thank you

@AbSoLuT-ZcC
Copy link

I saw the video, is that cropped part of window from KVIrc? is that a channel, a webview or what? I can't make sense of its contents. Also, can I ask you what font is that window using? Thank you

Hello ctrlaltca,

it's the "status" window, but the same thing happens in all windows (channel, query, partlyline). I can do another video with the whole screen if you want, but it's just the same. As for the font, it was verdana, but I've tried with like 6 or 7 of them and the same thing happens, even when I change their sizes.

Thanks

@ctrlaltca
Copy link
Contributor

So, I've tested both Linux and Windows with the verdana font but I'm not been able to reproduce the issue.
Unfortunately I don't have a mac to test on right now, so i may need some external help here.

@AbSoLuT-ZcC
Copy link

Hello ctrlaltca,
Thanks a lot for trying! And as I said, the same happens whatever the font.
And I'd be willing (of course) to "test" anything you'd ask on my mac, if it can help, although I'm no coder at all...
Again, thx!

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.

3 participants