Re: Fwd: Drawing vertical text glyphs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx
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@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/libreoffice

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux