Draw Arabic text with draw text on path

Skip to first unread message

Heidi Kurz

Apr 30, 2021, 8:52:32 AMApr 30
to skia-discuss
Hi Together, 

I have to use Shaper to render arabic text.
Here is an excerpt from the code:

        SkTextBlobBuilderRunHandler runHandler(arabtext, { 0, 0 });
        m_fShaper->shape(wtext.c_str(), letterNumber, fontIterator, *bidi, script, *languageIter, width, &runHandler);
        canvas->drawTextBlob(runHandler.makeBlob(), x, y, skPaint);

But I have also to render this text along a street.
To do this I use MakeFromRSXform(..) like this:
canvas.drawTextBlob(SkTextBlob::MakeFromRSXform(glyphs.get(), count * sizeof(SkGlyphID),
            &xform[0], font, SkTextEncoding::kGlyphID),
            0, 0, paint);

How can I solve this problem?

Ben Wagner

Apr 30, 2021, 11:41:28 AMApr 30
to skia-d...@googlegroups.com
Drawing a connected script along a path cannot really be done in a
good way with just RSXform as the connections between the glyphs will
look bad if they aren't all on the same line. For something like this
one would need to distort the outlines of the glyphs along the path to
some degree. I think you would want something like the
SkDrawTextOnPath which was removed in
https://skia-review.googlesource.com/c/skia/+/158224 (though note that
this will not handle non-path fonts).

Even though that code has been removed, it may still be possible to
get the path of each glyph and use SkPath1DPathEffect with
kMorph_Style to get the same effect (though of course with more work
on your end). There is an example of this with nonglyphs in
samplecode/SamplePathEffects.cpp. If a glyph does not have a path it
may be possible to draw the glyph to an offscreen, run a rectangle of
its bounds through the path effect, and then use the resulting points
to call SkCanvas::drawVertices to distort the image to fit. (Of
course, if you know you'll always have paths you can skip this rather
convoluted step which I doubt anyone has ever actually implemented.)
> --
> You received this message because you are subscribed to the Google Groups "skia-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/b372cf7a-88cd-432f-ad7b-30749d24bc2an%40googlegroups.com.
Reply all
Reply to author
0 new messages