BlackFoundryCom / black-renderer

Apache License 2.0
33 stars 7 forks source link

Skia python m116 - and its built-in COLRv1 support #161

Closed HinTak closed 1 year ago

HinTak commented 1 year ago

Hi @justvanrossum : I have ported skia-python from m87 to m116 : https://github.com/kyamagu/skia-python/pull/196

It passes 90% of pytest (I think the tests are a bit too thorough and tested too many obscure corners - it is a great job to be so thorough, but also a pain when about 20% of Skia has changed between m87 and m116 - so that was about 20% broken, and I have fixed 1/2 of them...), and it runs blackrenderer okay, too.

The goal is to get at the built-in OT-SVG support at m103 and COLRv1 support in later skia than m98. (Google stuff still fiddling with COLRv1 on m116...).

Anyway, here is the patch that will go in, in the next RC(RC2):

https://github.com/HinTak/skia-building-fun/blob/main/patches/skia-m116-colrv1-freetype.diff

It basically exposes two routines for external use - one for bound calculations and another for actual rendering. I have already got a "enhanced"-ft2-demos which use those, and basically allow any freetype-dependent application to have COLRv1 ability via skia. Anyway - besides a "heads up", I wonder if I could ask you for two things:

At the moment it gets a freetype face handle with everything already set, and just either do a bound box, or draw a bitmap.

Detached mirror for issues/pulls at https://github.com/HinTak/skia-m1xx-python

Cc: @davelab6

justvanrossum commented 1 year ago

I'm not sure what you are asking of me.

The point of black-renderer is to provide an alternative COLRv1 implementation, so by definition it does not want to use Skia's native COLRv1 support.

It may be interesting for drawbot-skia, which currently uses blackrenderer to draw COLRv1. Sounds like it could drop that in favor of native Skia COLRv1 support once it lands in skia-python.

That said, I'm afraid I'm not enough into the details of building skia-python, on top of having no extra capacity to begin with, to help out updating skia-python.

HinTak commented 1 year ago

You already use skia-python for drawing in one backend (and that works just fine when i just switch to my 90% skia-python m116); I am thinking of having an additional backend, which also use skia-python but differently?

I don't know how long it will take to land properly at skia-python - it will take months if not year to catch up from m87 to m116 properly (and if we are talking about a year, that would be ~m130...), but for now I have a detached mirror of the pull https://github.com/HinTak/skia-m1xx-python - and take issues / merges :-).

justvanrossum commented 1 year ago

The blackrenderer backends just provide vector drawing primitives. The COLRv1 parsing/drawing is done in the front end (font.py), passing primitive instructions to the backend.

Blackrenderer is not set up to have an alternative COLRv1 engine, because its whole reason for existence is to be a COLRv1 engine.

Perhaps some of the shaping/drawing logic of render.py could be repurposed for a tool that renders COLRv1 directly with Skia, but this isn't really in scope for the project.

HinTak commented 1 year ago

Thanks for the explanation. You mentioned drawbot-skia earlier. I came across it recently ( mostly looking for interesting thing to test my m116 to see how broken/functional it is - I only have one thing in my hard disk which depends on skia-python, which is why I am here đŸ˜‰). I don't quite understand what it does from the README description. Care to explain?

justvanrossum commented 1 year ago

It is a partial port of DrawBot (https://drawbot.com/). It allows you to produce graphics with Python scripts. Tiny example:

fill(1, 0, 0)
rect(50, 50, 200, 100)
fill(0, 1, 0)
rect(100, 75, 200, 100)
HinTak commented 1 year ago

Thanks for the explanation!

HinTak commented 1 year ago

Skia-python 116.0b2 landed. With bult-in support for OT-SVG and COLRv1. You can install via the usual pip methods for pre-releases.

https://pypi.org/project/skia-python/#history https://github.com/kyamagu/skia-python/blob/main/README.m116.md

There is no documentation nor example for that part of new addition yet . The c version of the former has been out posted to freetype-devel, python version will go to freetype-py's example section eventually; the c version of the latter still sitting in my hard drive, though binaries are up at FontVal-extras/binary-archive. Closing.

@davelab6 @anthrotype