Re: Fwd: Drawing vertical text glyphs
Hi Lubos, Luboš Luňák 於 2021年5月6日 週四 上午12:05寫道: > > Is there a testcase for that > I think you can take sample file from tdf#106295. It contains the set of fullwidth punctuations that worth testing. Also I find it useful, drawing the glyph bounding box together with the glyph. Based on my tests, Skia and DWrite text renderer ( with my patches on gerrit ) render consistently inside the bounding box. BTW, I've reported glyph positioning of windows built-in Chinese font DFKai-SB issue to Harfbuzz - i.e either we rely on Harfbuzz to fix the ot font functions, or we have to use Freetype for font functions to fix the problem. https://github.com/harfbuzz/harfbuzz/issues/2974 -- Mark Hung ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: Fwd: Drawing vertical text glyphs
On Thursday 29 of April 2021, Mark Hung wrote: > To be honest, I can only verify from the point of view of a user who can > read Chinese. I can use any other document as the testcase if it helps, I used that one simply because it seemed suitable to me. E.g. qadevOOo/testdocs/vertical-testcase.odt mentioned by Caolan seems better (but it's also Chinese if I'm getting it right). > The cursor which overlaps the position doesn't seem right. It's not a big > problem > as long as it does not strike through the glyph in the middle. But the > inconsistence among > platforms might be a problem. > I would have tested fullwidth punctuations. > It went wrong in vertical writing before. Is there a testcase for that? On Monday 03 of May 2021, Mark Hung wrote: > ./hb-view -O png -o ~/output.png \ > --shapers=ot,fallback \ > --direction ttb \ > --font-funcs=ot \ > ~/下載/kaiu.ttf "「風調,雨順」" Thank you, this should be useful. > [2]https://gerrit.libreoffice.org/c/core/+/115014 > [3]https://gerrit.libreoffice.org/c/core/+/115018 > [4]https://gerrit.libreoffice.org/c/core/+/115016 > [5]https://gerrit.libreoffice.org/c/core/+/115017 I'm currently testing Skia with these and it seems these help a lot with the problems. tdf#137907 seems fixed, tdf#105650 seems to get fixed with your https://gerrit.libreoffice.org/c/core/+/115015, I have a Skia-specific fix for tdf#136081 and even qadevOOo/testdocs/vertical-testcase.odt works for me now locally. I'll try to create unittests for these problems, and then I'll verify this all works. > llunak Is Skia used for all the platofrm as default text renderer right now? No. Skia is the default on Windows. It can also be used on Linux with the 'gen' VCL backend. -- Luboš Luňák l.lu...@collabora.com ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: Fwd: Drawing vertical text glyphs
Hi Lubos, I investigate a little bit more in last few days. Since Libreoffice unified all the text layout to use Harfbuzz, it would be best to achieve the result consistent with output generated from Harfbuzz utilities. Binaries can be downloaded from [1]. Here are some examples I use to verify: ./hb-view -O png -o ~/output.png \ --shapers=ot,fallback \ --direction ttb \ --font-funcs=ot \ ~/下載/kaiu.ttf "「風調,雨順」" ./hb-shape -O text \ --shapers=ot,fallback \ --direction ttb \ --font-funcs=ot \ ~/下載/kaiu.ttf "「風調,雨順」" You can check if it is a text renderer's problem this way when something goes wrong. Note that LibreOffice use default font function implementation from Harfbuzz (opentype, --font-funcs=ot ), while the utility use Freetype library ( --font-funcs=ft ) by default. I find that an important Windows built-in font (Kaiu.ttf) doesn't work well with Harfbuzz ot font functions. Skia text renderer works with [2], but it means that other text renderers are broken. Since Harfbuzz utilities also use Cairo, I believe we must be able to achieve consistent results at least with Cairo. My fix there seems to work[3]. For Windows, I think it's not possible to make old ExTextOutW API correct for vertical writing. It is possible to use DWriteTextRenderer for vertical writing[4][5]. There are still some clipping issues, though. I don't have a Mac so someone needs to fix that if it's broken. [1]https://github.com/harfbuzz/harfbuzz/releases [2]https://gerrit.libreoffice.org/c/core/+/115014 [3]https://gerrit.libreoffice.org/c/core/+/115018 [4]https://gerrit.libreoffice.org/c/core/+/115016 [5]https://gerrit.libreoffice.org/c/core/+/115017 -- Mark Hung ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: Fwd: Drawing vertical text glyphs
Hi Lubos, Luboš Luňák 於 2021年4月29日 週四 上午1:19寫道: > 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? > > To be honest, I can only verify from the point of view of a user who can read Chinese. The cursor which overlaps the position doesn't seem right. It's not a big problem as long as it does not strike through the glyph in the middle. But the inconsistence among platforms might be a problem. I would have tested fullwidth punctuations. It went wrong in vertical writing before. > 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. > > I tried to make a patch to highlight the relative positions, and find out something that I added to fix the issue - of course it can not complete fix the problem, but it may make more sense. https://gerrit.libreoffice.org/c/core/+/114887 ( the image of the test of the patch is also attached. ) Vertical positioning there is more correct to me. It also doesn't overlap with the cursor. It introduce horizontal offset issue unfortunately. Hope that helps. > [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.lu...@collabora.com > -- Mark Hung ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: Fwd: Drawing vertical text glyphs
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.lu...@collabora.com diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index 003c761542ff..9fb51868baf5 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -2084,9 +2084,19 @@ void SkiaSalGraphicsImpl::drawGenericLayout(const GenericSalLayout& layout, Colo { angle = layout.GetOrientation(); if (pGlyph->IsVertical()) -angle += 900_deg10; // 90 degree +//angle += 900_deg10; // 90 degree +angle = 0_deg10; } -SkRSXform form = SkRSXform::Make(toCos(angle), toSin(angle), aPos.X(), aPos.Y()); +SkRSXform form; +if(pGlyph->IsVertical()) +{ +tools::Rectangle rect; +bool b = pGlyph->GetGlyphBoundRect(rect); +assert(b); +form = SkRSXform::Make(toCos(angle), toSin(angle), aPos.X(), aPos.Y() + rect.GetHeight()); +} +else +form = SkRSXform::Make(toCos(angle), toSin(angle), aPos.X(), aPos.Y()); glyphForms.emplace_back(std::move(form)); } if (glyphIds.empty()) ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice