Bug 443795 - [text tool] Line spacing percentage issue: too big on text editor and bigger on canvas
Summary: [text tool] Line spacing percentage issue: too big on text editor and bigger ...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Tool/Text (other bugs)
Version First Reported In: 5.0.0-beta2
Platform: Appimage Linux
: NOR normal
Target Milestone: ---
Assignee: sh_zam
URL:
Keywords: regression
: 441850 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-10-15 16:55 UTC by David REVOY
Modified: 2021-12-02 14:20 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
^ comparison of line spacing with canvas/text-editor and Inkscape (133.33 KB, image/png)
2021-10-15 16:55 UTC, David REVOY
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David REVOY 2021-10-15 16:55:48 UTC
Created attachment 142479 [details]
^ comparison of line spacing with canvas/text-editor and Inkscape

Hi,
Creating new text-boxes multiline in Krita5.0appimagebeta2 reveal a lot of line-spacing. (see attachement)


STEPS TO REPRODUCE
1. Create a text with multiple lines.

OBSERVED RESULT
2. The setting for 100% line-spacing has like 30% more as necessary to get a real 100%. It forces user to set 70% manually on all text boxes.

EXPECTED RESULT
Getting an accurate 100% Line spacing.


SOFTWARE/OS VERSIONS
Kubuntu 20.04LTS/Appimage5.0beta2
Comment 1 wolthera 2021-11-23 15:14:32 UTC
Honestly, I suspect what's going on is that the offset-calculation is still using the QFont dpi, and not the 'fixed DPI'.
Comment 2 wolthera 2021-11-23 20:39:24 UTC
Yes, I am 100% sure that the problem is caused by the QFont workaround: The problem is that the "line-height" is set inside KoSvgTextShapeMarkupConverter::convertDocumentToSvg, where the font-size is still 'Qt-like', but then in the text-chunk shapes the font-size changes as per the DPI workaround. The problem is that we cannot change these values randomly in the place where we know about the workaround, as then we cannot load outside SVG correctly.

I have no idea how we're supposed to fix this.
Comment 3 wolthera 2021-11-28 16:34:50 UTC
*** Bug 441850 has been marked as a duplicate of this bug. ***
Comment 4 Dmitry Kazakov 2021-12-02 14:11:05 UTC
Git commit f0f55bea8e06c74b3a1b499d6c4cd84a29576753 by Dmitry Kazakov.
Committed on 02/12/2021 at 14:02.
Pushed by dkazakov into branch 'master'.

Fix line height being too huge in Krita 5.0

All the internals of QTextDocument work with the primary screen's DPI.
That is, when we ask Qt about font metrics, it returns values scaled
to the pixels in the current screen, that is,
ptValue * qt_defaultDpi() / 72.0. We need to convert this value back
into points before writing as SVG. Therefore, all the metrics returned
by the document are scaled with `fixQtDpi()`.

Official Qt's way to workaround this problem is to set logicalDpiX/Y()
values on the paint device's associated with the document. But it seems
like in our version of Qt (5.12.12, which is rather old) it doesn't work
properly.

M  +28   -5    libs/flake/text/KoSvgTextShapeMarkupConverter.cpp

https://invent.kde.org/graphics/krita/commit/f0f55bea8e06c74b3a1b499d6c4cd84a29576753
Comment 5 Dmitry Kazakov 2021-12-02 14:20:26 UTC
Git commit b655bfe1463234178775d530311286bcc2ae7f0b by Dmitry Kazakov.
Committed on 02/12/2021 at 14:17.
Pushed by dkazakov into branch 'krita/5.0'.

Fix line height being too huge in Krita 5.0

All the internals of QTextDocument work with the primary screen's DPI.
That is, when we ask Qt about font metrics, it returns values scaled
to the pixels in the current screen, that is,
ptValue * qt_defaultDpi() / 72.0. We need to convert this value back
into points before writing as SVG. Therefore, all the metrics returned
by the document are scaled with `fixQtDpi()`.

Official Qt's way to workaround this problem is to set logicalDpiX/Y()
values on the paint device's associated with the document. But it seems
like in our version of Qt (5.12.12, which is rather old) it doesn't work
properly.

M  +28   -5    libs/flake/text/KoSvgTextShapeMarkupConverter.cpp

https://invent.kde.org/graphics/krita/commit/b655bfe1463234178775d530311286bcc2ae7f0b