Bug 472073 - Different line-height compared to Firefox/Inkscape
Summary: Different line-height compared to Firefox/Inkscape
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Tool/Text (show other bugs)
Version: git master (please specify the git hash!)
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-08 12:54 UTC by Alvin Wong
Modified: 2023-07-23 14:19 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
test svg (1.95 KB, image/svg+xml)
2023-07-08 12:54 UTC, Alvin Wong
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alvin Wong 2023-07-08 12:54:45 UTC
Created attachment 160196 [details]
test svg

SUMMARY


STEPS TO REPRODUCE
1. Test the attached SVG (uses "Noto Sans" font)

OBSERVED RESULT
Line height appears a bit taller than in Firefox or Inkscape.

EXPECTED RESULT
Line height should be similar.

SOFTWARE/OS VERSIONS
Windows 10
Krita at d9959dfda2cd0b753a56570056789014d0820f02

ADDITIONAL INFORMATION
Comment 1 wolthera 2023-07-11 11:34:00 UTC
Ok, I can confirm, but it took me a while to find the nature of the bug.

we're expected to use os/2 sTypo metrics for ascent and descent. https://www.w3.org/TR/css-inline-3/#ascent-descent 
However, for line-height we need to multiply by font-size (https://www.w3.org/TR/css-inline-3/#propdef-line-height) for percentage and number values.

This is a problem because Noto's em square is 1000 divided into 800 ascent and 200 descent, but its metrics are set to 1069 ascent and 293 descent, which is afaik because it tries to work around bugs with glyphs larger than the em-square. I'll need to puzzle out how to tackle this.
Comment 2 wolthera 2023-07-11 12:57:39 UTC
Git commit 4e0194fe73cfd5816d24aadad1e618fdbdb06cae by Wolthera van Hövell tot Westerflier.
Committed on 11/07/2023 at 12:54.
Pushed by woltherav into branch 'wolthera/text-fixes-july-11'.

Fix empty-lined hardbreaks not contributing their line-height.

Not 100% sure this is correct, but it would require some tests.

M  +1    -1    libs/flake/text/KoSvgTextShape.cpp

https://invent.kde.org/graphics/krita/-/commit/4e0194fe73cfd5816d24aadad1e618fdbdb06cae
Comment 3 Alvin Wong 2023-07-23 14:19:17 UTC
Git commit 6f4a855cfc177cb94a50d4029a46b5471776e4eb by Alvin Wong, on behalf of Wolthera van Hövell tot Westerflier.
Committed on 23/07/2023 at 16:17.
Pushed by alvinwong into branch 'master'.

Fix empty-lined hardbreaks not contributing their line-height.

Not 100% sure this is correct, but it would require some tests.

Closes !1850

M  +18   -0    libs/flake/text/KoSvgTextShape.cpp

https://invent.kde.org/graphics/krita/-/commit/6f4a855cfc177cb94a50d4029a46b5471776e4eb
Comment 4 Alvin Wong 2023-07-23 14:19:25 UTC
Git commit 09c836c6d7ccf9f76008500298796bb3321c31c5 by Alvin Wong, on behalf of Wolthera van Hövell tot Westerflier.
Committed on 23/07/2023 at 16:17.
Pushed by alvinwong into branch 'master'.

Fix BUG:472073, use font-size for line-height ratio calculation.

Sometimes ascent-descent is larger than the font-size. Percentage
also uses font-size but also has different parsing, and thus should
already have been covered.

Closes !1850

M  +1    -1    libs/flake/text/KoSvgTextShape.cpp

https://invent.kde.org/graphics/krita/-/commit/09c836c6d7ccf9f76008500298796bb3321c31c5