Created attachment 160423 [details] Test svg The attached SVG uses Source Han Sans. The green text is SVG 1, the black text uses inline-size. For the text using `inline-size`, Krita appears to set the baseline to the right of the glyph. It looks like something font-specific, because I've tried a few other fonts but they don't show the same behaviour.
Created attachment 160424 [details] Screenshot
Hum, when I use "Source Han Sans HC" or "Noto Sans CJK HK" or "Noto Sans CJK JP" the difference is not as bad as the screenshot, which I suspect means there's been an improvement in the situation after all our bugfixes. What might be going on now is that the bounding box is calculated differently, lemme check.
Inkscape seems to be having a similar problem, which might be caused by inkscape aligning inline-size incorrectly when using transforms to begin with, so that's a dead end... bounding boxes seem to be exactly the same. Gonna check the ascent and descent now...
Git commit e5764c7ef5cb0429e6901d07f752f995226f99cf by Wolthera van Hövell tot Westerflier. Committed on 06/08/2023 at 17:56. Pushed by woltherav into branch 'master'. Fix incorrect baseline value by reinitializing the variable to 0. There's a bit of a problem still that it seems the baselineOffset was missing from the pre-formatted text while only applied to the inline-wrapped text, but that will be a bug for another day. M +10 -1 libs/flake/text/KoSvgTextShape.cpp https://invent.kde.org/graphics/krita/-/commit/e5764c7ef5cb0429e6901d07f752f995226f99cf
Git commit 1a500747693dc535bbe1d946671e3c25d628f94f by Wolthera van Hövell tot Westerflier. Committed on 06/08/2023 at 18:45. Pushed by woltherav into branch 'master'. Fix text-top and text-bottom alignment baselines. The calculation of the line was incorrect, we're now using the ascent and descent appropriately. This now also takes into account baseline-offsets set earlier in subnodes of the text-top or bottom aligned node. M +21 -17 libs/flake/text/KoSvgTextShape.cpp https://invent.kde.org/graphics/krita/-/commit/1a500747693dc535bbe1d946671e3c25d628f94f
ok, when using vertical-align/alignment-baseline as the css-spec expects me to (on a subchunk with different font(either by size or family)) everything works as expected. When using vertical-align:alphabetic on the root, it differs between inline-size and preformatted. Now, we shouldn't be able to set the alignment-baseline on the root, but at the same time it's weird that there would be a difference at all...
ok, the lines where we're losing our 'incorrect' vertical-align is at the resolution of the absolute X and Y post (step 6), particularly when trying to compensate for the relative dx and dy (step 4)... which would make this the cause of bug #426607 ... Guess I'll leave it at that for tonight.
Git commit efb32c8a841663113acf7c0b5e14b7862cec195a by Wolthera van Hövell, on behalf of Wolthera van Hövell tot Westerflier. Committed on 06/08/2023 at 20:48. Pushed by woltherav into branch 'krita/5.2'. Fix incorrect baseline value by reinitializing the variable to 0. There's a bit of a problem still that it seems the baselineOffset was missing from the pre-formatted text while only applied to the inline-wrapped text, but that will be a bug for another day. (cherry picked from commit e5764c7ef5cb0429e6901d07f752f995226f99cf) M +10 -1 libs/flake/text/KoSvgTextShape.cpp https://invent.kde.org/graphics/krita/-/commit/efb32c8a841663113acf7c0b5e14b7862cec195a
Git commit f0c0e7c45479a87f8996f0313acc427d74ef2ce9 by Wolthera van Hövell, on behalf of Wolthera van Hövell tot Westerflier. Committed on 06/08/2023 at 20:49. Pushed by woltherav into branch 'krita/5.2'. Fix text-top and text-bottom alignment baselines. The calculation of the line was incorrect, we're now using the ascent and descent appropriately. This now also takes into account baseline-offsets set earlier in subnodes of the text-top or bottom aligned node. (cherry picked from commit 1a500747693dc535bbe1d946671e3c25d628f94f) M +21 -17 libs/flake/text/KoSvgTextShape.cpp https://invent.kde.org/graphics/krita/-/commit/f0c0e7c45479a87f8996f0313acc427d74ef2ce9
The linked commits didn't fix the issue, did they? Here the text is still being rendered exactly the same as the screenshot.
(In reply to Alvin Wong from comment #10) > The linked commits didn't fix the issue, did they? Here the text is still > being rendered exactly the same as the screenshot. Uh, they fixed the offset I saw. If you could test locally whether commenting out step 6 fixes the issue, then we know the problem is baseline-adjustment related. I wonder if we should disable adjustment baseline for vertical, given that it's currently unsure what counts as the origin: https://github.com/MicrosoftDocs/typography-issues/issues/913
Created attachment 160789 [details] Test with step 6 disabled Disabling step 6 with base commit 5dce46d2f6 gives me this.
Ok, then the problem is caused by baseline-alignment issues... I think the fundamental issue here is that my Krita build seems to insist on system-harfbuzz instead of the locally build harfbuzz which it can obviously find, so what might be going on is that the 'with fallback' code for harfbuzz 4.0 offsets the central as if it were to the right of the font.
Created attachment 160791 [details] blind patch that may fix the issue Alvin, can you apply this diff and see if it helps? It's a bit of a blind implementation, but if I'm correct it should work?
Created attachment 160795 [details] Screenshot with patch attachment 160791 [details] applied (In reply to wolthera from comment #14) > Created attachment 160791 [details] > blind patch that may fix the issue > > Alvin, can you apply this diff and see if it helps? It's a bit of a blind > implementation, but if I'm correct it should work? Thanks, looks like it does the job.
Git commit 0e4119b18f32385def1c6db0608ea2e28225313d by Wolthera van Hövell tot Westerflier. Committed on 07/08/2023 at 15:54. Pushed by woltherav into branch 'master'. Subtract the origin from baseline value to get appropriate baseline offset. This alsdo simplifies the code a little and fixes the calculation of the central baseline for vertical, only hb above 4.0 has the central baseline tag. M +41 -32 libs/flake/text/KoSvgTextShape.cpp https://invent.kde.org/graphics/krita/-/commit/0e4119b18f32385def1c6db0608ea2e28225313d
Git commit d927917f2b592a46cdd8474b0f34b42d92e4b6a4 by Wolthera van Hövell, on behalf of Wolthera van Hövell tot Westerflier. Committed on 07/08/2023 at 16:06. Pushed by woltherav into branch 'krita/5.2'. Subtract the origin from baseline value to get appropriate baseline offset. This alsdo simplifies the code a little and fixes the calculation of the central baseline for vertical, only hb above 4.0 has the central baseline tag. (cherry picked from commit 0e4119b18f32385def1c6db0608ea2e28225313d) M +41 -32 libs/flake/text/KoSvgTextShape.cpp https://invent.kde.org/graphics/krita/-/commit/d927917f2b592a46cdd8474b0f34b42d92e4b6a4