Fwd: Drawing vertical text glyphs

Luboš Luňák l.lunak at collabora.com
Wed Apr 28 17:19:55 UTC 2021


On Wednesday 28 of April 2021, Mark Hung wrote:
> Anyway, if you need someone to verify text layout results with vertical
> writing or
> , don't hesitate to ask.
>
> I can definitely help. I can also verify patches on Windows.
> There is also a telegram group of TDF members from the CJK area if you
> prefer.

 The Skia VCL backend code for text drawing is 
SkiaSalGraphicsImpl::drawGenericLayout(). For non-vertical glyphs, the code 
is easy, just iterate over all glyphs and pass them to Skia with their 
positions, possibly rotated. That approach doesn't work well for vertical 
glyphs, for the tdf#103785 document I get [1], with the glyphs being 
positioned too high. If I apply the attached patch that moves all vertical 
glyphs down based on the glyph height, then I get [2], which appears to be at 
least roughly acceptable, although it doesn't look to be completely correct.

 And I don't know how to make it correct. First of all, I don't know how to 
visually identify what is correct. At [3] I've uploaded screenshots of the 
document rendered by LO/Cairo, LO/GDI and Word2013. They are all different, 
both in X and Y positioning. Cairo draws them slightly to the left of the 
latin alphabet characters, GDI is roughly centered, Word draws them to the 
right. Vertically they also differ, I made sure to include cursor in all the 
screenshots and e.g. with the first glyph (中) the cursor doesn't touch the 
glyph with Word, it touches it with GDI and it overlaps the glyph with Cairo 
(the image may need zooming to see it clearly). Which of those are correct?

 Second, I would need to express the correct positioning in the code. Do you 
know how to do that? I copied the glyph-size change in the attached patch 
from Cairo, it also moves in X direction by the font descent, but I'd prefer 
not to do random modifications without understanding them.

[1] https://people.collabora.com/~llunak/skia/skia_current.png
[2] https://people.collabora.com/~llunak/skia/skia_vert1.png
[3] https://people.collabora.com/~llunak/skia/

-- 
 Luboš Luňák
 l.lunak at collabora.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdiimpl.cxx.patch
Type: text/x-diff
Size: 1073 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20210428/a76709e4/attachment.patch>


More information about the LibreOffice mailing list