-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Binding the skparagraph module #225
Comments
Hi @HinTak, Kind regards, |
@olebedev nothing has been done so far. As you see this issue is more one or two statements of what possible benefits skparagraph module brings. I just had a quick look at the upstream code, and it is a pretty large module. It is probably a good idea to identify a good usage example in c (or other language?) for it and start adding those as a small usable subset? You can use the svg module as an example to see what's done and how https://github.com/kyamagu/skia-python/blob/main/src/skia/SVGDOM.cpp . That's the only module we bind so far - we also provide a few (one, I think) methods in the TextBlob class which accesses the skshaper module: skia-python/src/skia/TextBlob.cpp Line 255 in 832cb4e
skia.shaper class but decided that wasn't needed) . So probably either approaches: exposing SkParagraph as a python skia.Paragraph class etc, or additional methods to some of the other existing classes.
If you have a business need you can always get in touch privately about funding/ commissioning the work... |
The most recent changes in the svg module binding was to make this example work : https://github.com/rougier/freetype-py/blob/da3c14961f2e672bf487264e1e77dcbdb2344816/examples/skia_ot_svg_module.py#L96 The c version of this python code is at https://github.com/HinTak/freetype2-demos-skia . Historically it exists before the python one, only as a patch to freetype2-demos, posted at https://github.com/HinTak/harfbuzz-python-demos/tree/master/skia-adventure . The repository to host the patch is created more recently. That's how I came to skia-python a year ago. |
AFAIC only three modules are non-experimental at the moment: svg, skottie, and skresources. SkShaper and SkUnicode are with a stable API. (Look for |
I see, thank you for the comprehensive explanation, @HinTak. Understood. I will have to try to resolve my multiline rendering with the existing API and if I see I get blocked without have SkParagraph in place I will try to bring it in and contribute upstream. And thanks for the guidance, btw! Best, |
@olebedev an appropriate example in c++ trying to port to python is https://github.com/google/skia/blob/main/example/external_client/src/shape_text.cpp , I think. That would come to 3x to 5x the size of https://github.com/kyamagu/skia-python/blob/main/src/skia/SVGDOM.cpp . |
@olebedev example python code based on the upstream c++ example, and the pull in #258 . You'll need to install the python wheels when CI finishes https://github.com/kyamagu/skia-python/actions/runs/10337416324 to try it out, of course. Consider making a donation with the link in my profile https://hintak.github.io/ , especially if you want this for a business need and / or want to go further either yourself or have questions. #258 will likely get merged in a about 2 months' time - we typically make a release N or N +1 (if updating skia-python N to N+1 is simple) when upstream N+1 comes out. Since we just did 128 a week after upstream 128, we'll be doing either 129 or 130 when upstream 130 comes out. Note this is subjected to how upstream responds to |
Hi @HinTak, this is awesome, thank you so much for the effort! I am not sure at the moment if we are going to use the |
@olebedev after spending a good part of the weekend with skparagraph, I think it is quite neat - the c++ example is quite comprehensive, and it gets better with the python port as one can add/change rendering options quickly to try out without recompile. Justified / left / right / centred multi-line text, with decorations (under/over/strikethrough lines, dash, wavy, colored etc). The python example is the main "documentation" at the moment. Upstream documentation is quite sparse, actually, but having the c++ example useful. At the moment the python code uses platform fonts (while the c++ original example is capable of loading specific font file) - I think using platform fonts is sufficient, but the specific font file capability is probably useful for pixel-accurate agreement across platforms. I think I can add that soon. Anyway, #258 will grow a bit and #256 get included when we move to release m129/130 in about 2 months. |
Added the single font loading code as well as updated the example and comments within. |
The example is called shaped_text, and is able to do multi-line paragraphs in Arabic correctly... |
Underline and strikeout were removed as SkPaint style some years ago, but seem to have been re-added in the skparagraph module as a settable text decoration style.
See #224 also
The text was updated successfully, but these errors were encountered: