Bug 404011 - Krita text appears to be drawn at incorrect point size
Summary: Krita text appears to be drawn at incorrect point size
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Tool/Text (show other bugs)
Version: unspecified
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords: release_blocker, triaged
: 402094 412070 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-02-06 15:27 UTC by john@ridgwaydesign.fsnet.co.uk
Modified: 2021-08-09 13:06 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Three samples of text. Krita, Photoshop, Painter in descending order. (179.58 KB, image/jpeg)
2019-02-06 15:27 UTC, john@ridgwaydesign.fsnet.co.uk
Details
Chilanka font, 18 points on 300 ppi canvas (93.87 KB, image/png)
2020-09-15 12:59 UTC, Tiar
Details
Gimp and Krita 72ppi vs 300ppi comparison (69.00 KB, image/png)
2020-09-16 13:36 UTC, Tiar
Details
Gimp, Krita and LibreOffice 72ppi vs 300ppi comparison (93.04 KB, image/png)
2020-09-16 13:42 UTC, Tiar
Details
Gimp and Krita 72ppi 20points comparison (22.05 KB, image/png)
2020-09-16 14:44 UTC, Tiar
Details
Krita font test.jpg (24.91 KB, image/jpeg)
2021-04-15 09:06 UTC, john@ridgwaydesign.fsnet.co.uk
Details
attachment-18245-0.html (4.11 KB, text/html)
2021-05-07 11:10 UTC, john@ridgwaydesign.fsnet.co.uk
Details

Note You need to log in before you can comment on or make changes to this bug.
Description john@ridgwaydesign.fsnet.co.uk 2019-02-06 15:27:37 UTC
Created attachment 117882 [details]
Three samples of text. Krita, Photoshop, Painter in descending order.

SUMMARY
Text appears at an incorrect point size.

STEPS TO REPRODUCE
1. Type in a note. Save as jpg file.
2. Open this file in Photoshop and type the same note. Save again.
3. Open file in Painter and type in the same note again.

Compare results. The text as produced in Photoshop and Painter are similar size (letter spacing and line spacing may be slightly different). The text as produced in Krita is substantially larger. Text used Arial regular. 9pt. Document at 300 dpi.

OBSERVED RESULT


EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: 
MacOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Tyson Tan 2019-04-08 15:10:31 UTC
Happens to me as well. I can confirm this in Photoshop CC. And I clearly remembered how small 9pt letters were when I was using PS back in the days.
Comment 2 wolthera 2019-04-08 15:15:39 UTC
setting to confirmed then.
Comment 3 Tyson Tan 2019-04-08 15:20:50 UTC
Take 9pt for example. Back in the days we actually matched 9pt with 12px for webpages. You can see how small 9pt really is in Microsoft Word and LibreOffice as well. I migrated from Photoshop, and 9pt was tiny in a PS document with similar settings.

9pt letters in Krita's default A4 template is substantially larger than what I observed in other applications.
Comment 4 wolthera 2019-04-08 18:41:05 UTC
I guess the problem is that officially, pt is 'points' that is 1/72th of an inch, and I am not sure if that is also the case in ps...
Comment 5 vanyossi 2019-05-13 14:08:35 UTC

*** This bug has been marked as a duplicate of bug 397616 ***
Comment 6 Tiar 2020-09-15 12:42:58 UTC
I'm unduplicating it from bug 397616 because it is about a bit different issue (read bug 397616 comment 6 for details). It's still present, so I'm reopening it as well.
Comment 7 Tiar 2020-09-15 12:59:31 UTC
Created attachment 131675 [details]
Chilanka font, 18 points on 300 ppi canvas

Krita text:
- create a 1000x1000 canvas 300ppi
- make a text shape using a specific font (I used Chilanka) - set the size to 18 points
Gimp text:
- create a 1000x1000 canvas 300ppi
- make a text shape using the same font and the same size like in Krita
- export to png
- import to Krita
LibreOffice Writer:
- Write text using the same font and size
- Export to PDF (make sure it's 300 ppi!)
- import in Krita as image (make sure it's 300 ppi here as well!)
Scribus:
- create new project, make sure it's 300 ppi
- create a text shape, write text using the same font and size
- export to pdf
- import in Krita as image (make sure it's 300 ppi here as well!)

Even though there is lots of steps for all other programs, Scribus, Gimp and LibreOffice Writer give the same results while Krita's text is bigger.
Comment 8 Tiar 2020-09-16 13:36:49 UTC
Created attachment 131699 [details]
Gimp and Krita 72ppi vs 300ppi comparison
Comment 9 Tiar 2020-09-16 13:42:02 UTC
Created attachment 131700 [details]
Gimp, Krita and LibreOffice 72ppi vs 300ppi comparison

Note that LibreOffice couldn't be set to 72ppi, so it's 75ppi, but the size is still much more Gimp-like than Krita-like, so I believe that at 72ppi it would be just the same.
Comment 10 Tiar 2020-09-16 14:44:00 UTC
Created attachment 131702 [details]
Gimp and Krita 72ppi 20points comparison

It looks like Krita is counting the font size only using the middle and higher parts of the characters, dismissing the lower parts. So "Ch" (20 points) text in Krita is exactly 20 pixels high in 72ppi, while in Gimp it would be 14 pixels. "Chy" however in Krita has 28 pixels, while in Gimp it's 20 pixels.
Comment 11 Tiar 2020-10-05 12:28:37 UTC
*** Bug 412070 has been marked as a duplicate of this bug. ***
Comment 12 Tiar 2021-03-30 13:20:50 UTC
Assigning Dmitry, relevant MR: https://invent.kde.org/graphics/krita/-/merge_requests/716
Comment 13 Tiar 2021-04-14 02:50:29 UTC
I'm marking it as "release_blocker" because we really need to fix it before Krita 5, otherwise we'd have to wait until Krita 6 (because it will change the way text is rendered on the canvas) and this is a serious issue.
Comment 14 john@ridgwaydesign.fsnet.co.uk 2021-04-15 09:05:59 UTC
Created attachment 137625 [details]
Krita font test.jpg

Dear sirs,


Re:-

-- Comment #13 from Tiar <tamtamy.tymona@gmail.com> ---
I'm marking it as "release_blocker" because we really need to fix it before
Krita 5, otherwise we'd have to wait until Krita 6 (because it will change
the
way text is rendered on the canvas) and this is a serious issue.

Having reported the bug in text height I felt I must report a possibly
connected bug regarding the inclination of text in italic which I came
across yesterday when working on a picture I had originally lettered using
Photoshop. I noticed an omission in the original text and replaced it with
text using Krita. The original text was with an opening capital of 12 pts
and the remainder in 8 points with 8 point line spacing and font kerning of
+25%.


In checking that the Krita text matched the size of the original text, I
adjusted the font sizes, kerning and line spacing, but I was surprised to
find that the angle of the italic text did not match as can be seen in the
attached pic.. Below is svg code as generated by Krita.


I hope this helps.


Best regards,


John Ridgway


<text style="fill:#ffff7d; letter-spacing:0.25; word-spacing:0;
kerning:auto; font-family:Laffayette Comic Pro; font-size:6pt;
font-size-adjust:0.235294; font-weight:400; font-style:italic;
baseline-shift:baseline; stroke-width:0; font-stretch:0"><tspan
x="0"><tspan style="font-size:8pt; font-size-adjust:0.294118;
font-weight:700">A</tspan><tspan style="fill:#000000">nd from within the
splintered </tspan></tspan><tspan style="fill:#000000" x="0"
dy="7.8pt">remains of the dark tower, a demon </tspan><tspan
style="fill:#000000" x="0" dy="8.01pt">was released...</tspan></text>

On Wed, 14 Apr 2021 at 03:50, Tiar <bugzilla_noreply@kde.org> wrote:

> https://bugs.kde.org/show_bug.cgi?id=404011
>
> Tiar <tamtamy.tymona@gmail.com> changed:
>
>            What    |Removed                     |Added
>
> ----------------------------------------------------------------------------
>            Keywords|                            |release_blocker
>
> --- Comment #13 from Tiar <tamtamy.tymona@gmail.com> ---
> I'm marking it as "release_blocker" because we really need to fix it before
> Krita 5, otherwise we'd have to wait until Krita 6 (because it will change
> the
> way text is rendered on the canvas) and this is a serious issue.
>
> --
> You are receiving this mail because:
> You reported the bug.
Comment 15 Dmitry Kazakov 2021-04-28 09:10:22 UTC
Git commit cb06cfb2c037db6c51a0569ab59940e7e93a729a by Dmitry Kazakov.
Committed on 28/04/2021 at 09:05.
Pushed by dkazakov into branch 'master'.

Fix size of the rendered fonts in Krita

Qt has a bug. When requesting font from the font
database (in QFontDatabase::load()), Qt scales its size by the
current primary display DPI. The only official way to disable
that is to assign QTextDocument to QTextLayout, which is not
something we would like to do. So we do the hackish way, we
just prescale the font with inverted value.

This hack changes only the rendering process without touching
the way how the text is saved into .kra or .svg. That is nice,
but it means it also affects how old files are renderred. To
let the user open older files we provide a preference option
to enable this scaling again.

NOTE:  the hack is not needed for pixel-measured fonts, they
       seem to render correctly. Pity we don't use them in
       our SVG code (partially because they don't allow
       fractional-sized fonts).

M  +50   -1    libs/flake/text/KoSvgTextChunkShape.cpp
M  +26   -0    libs/ui/dialogs/kis_dlg_preferences.cc
M  +2    -0    libs/ui/dialogs/kis_dlg_preferences.h
M  +51   -17   libs/ui/forms/wdggeneralsettings.ui

https://invent.kde.org/graphics/krita/commit/cb06cfb2c037db6c51a0569ab59940e7e93a729a
Comment 16 Tyson Tan 2021-04-28 11:38:19 UTC
Thank you Dmitry! :D
Comment 17 Dmitry Kazakov 2021-05-03 14:43:53 UTC
Git commit 91625c4ae311e5293dbee54eb2e6a04a5a53d6dd by Dmitry Kazakov.
Committed on 03/05/2021 at 14:20.
Pushed by dkazakov into branch 'master'.

Fix font size in files created in Krita 4.4

Now when loading a file created in Krita 4.4 we convert its font
sizes using the DPI of the dispaly and bake this new value into
the file. The user can override this behavior by selecting
another DPI in Settings->General->Miscelaneous->Font DPI workaround.
Setting this value to 72 DPI will effectively disable any scaling.

M  +0    -2    libs/flake/svg/SvgGraphicContext.h
M  +0    -1    libs/flake/svg/SvgLoadingContext.cpp
M  +1    -1    libs/flake/svg/SvgLoadingContext.h
M  +14   -0    libs/flake/svg/SvgParser.cpp
M  +1    -0    libs/flake/svg/SvgParser.h
M  +2    -25   libs/flake/svg/SvgStyleParser.cpp
M  +3    -2    libs/flake/svg/SvgUtil.cpp
M  +29   -20   libs/flake/tests/TestSvgText.cpp
M  +65   -36   libs/flake/text/KoSvgTextChunkShape.cpp
M  +0    -2    libs/flake/text/KoSvgTextChunkShape_p.h
M  +63   -5    libs/flake/text/KoSvgTextProperties.cpp
M  +5    -1    libs/flake/text/KoSvgTextProperties.h
M  +15   -1    libs/ui/flake/kis_shape_layer.cc
M  +1    -0    libs/ui/flake/kis_shape_layer.h
M  +1    -0    libs/ui/flake/kis_shape_selection.cpp
M  +5    -1    libs/ui/forms/wdggeneralsettings.ui
M  +1    -0    plugins/impex/svg/kis_svg_import.cc

https://invent.kde.org/graphics/krita/commit/91625c4ae311e5293dbee54eb2e6a04a5a53d6dd
Comment 18 john@ridgwaydesign.fsnet.co.uk 2021-05-07 11:10:17 UTC
Created attachment 138214 [details]
attachment-18245-0.html

I notice that the text in the placeholder box types in at the correct size
for the setting. This has become apparent when creating multi-line text for
caption boxes in comics. Text has to be split into several lines to fit the
width of a picture. If I want the text in the picture to be 10 points, I
have to type it into the placeholder at 10 points to see where to make line
breaks so that the length of  text is going to fit the picture width. I
then have to reduce the font size by two points (to 8 points) and change
the spacing of the lines in svg mode. I can then  save the text to place it
in the dialog box. I don't understand why the placeholder box is correct
and the artwork is the wrong size. Is this due to the dpi of the
placeholder being at a different resolution?

Best regards,

John Ridgway

On Mon, 3 May 2021 at 15:43, Dmitry Kazakov <bugzilla_noreply@kde.org>
wrote:

> https://bugs.kde.org/show_bug.cgi?id=404011
>
> Dmitry Kazakov <dimula73@gmail.com> changed:
>
>            What    |Removed                     |Added
>
> ----------------------------------------------------------------------------
>       Latest Commit|https://invent.kde.org/grap |
> https://invent.kde.org/grap
>                    |hics/krita/commit/cb06cfb2c
> |hics/krita/commit/91625c4ae
>                    |037db6c51a0569ab59940e7e93a
> |311e5293dbee54eb2e6a04a5a53
>                    |729a                        |d6dd
>
> --- Comment #17 from Dmitry Kazakov <dimula73@gmail.com> ---
> Git commit 91625c4ae311e5293dbee54eb2e6a04a5a53d6dd by Dmitry Kazakov.
> Committed on 03/05/2021 at 14:20.
> Pushed by dkazakov into branch 'master'.
>
> Fix font size in files created in Krita 4.4
>
> Now when loading a file created in Krita 4.4 we convert its font
> sizes using the DPI of the dispaly and bake this new value into
> the file. The user can override this behavior by selecting
> another DPI in Settings->General->Miscelaneous->Font DPI workaround.
> Setting this value to 72 DPI will effectively disable any scaling.
>
> M  +0    -2    libs/flake/svg/SvgGraphicContext.h
> M  +0    -1    libs/flake/svg/SvgLoadingContext.cpp
> M  +1    -1    libs/flake/svg/SvgLoadingContext.h
> M  +14   -0    libs/flake/svg/SvgParser.cpp
> M  +1    -0    libs/flake/svg/SvgParser.h
> M  +2    -25   libs/flake/svg/SvgStyleParser.cpp
> M  +3    -2    libs/flake/svg/SvgUtil.cpp
> M  +29   -20   libs/flake/tests/TestSvgText.cpp
> M  +65   -36   libs/flake/text/KoSvgTextChunkShape.cpp
> M  +0    -2    libs/flake/text/KoSvgTextChunkShape_p.h
> M  +63   -5    libs/flake/text/KoSvgTextProperties.cpp
> M  +5    -1    libs/flake/text/KoSvgTextProperties.h
> M  +15   -1    libs/ui/flake/kis_shape_layer.cc
> M  +1    -0    libs/ui/flake/kis_shape_layer.h
> M  +1    -0    libs/ui/flake/kis_shape_selection.cpp
> M  +5    -1    libs/ui/forms/wdggeneralsettings.ui
> M  +1    -0    plugins/impex/svg/kis_svg_import.cc
>
>
> https://invent.kde.org/graphics/krita/commit/91625c4ae311e5293dbee54eb2e6a04a5a53d6dd
>
> --
> You are receiving this mail because:
> You reported the bug.
Comment 19 Tiar 2021-08-09 13:06:03 UTC
*** Bug 402094 has been marked as a duplicate of this bug. ***