Skip to content
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

No SVG tests #95

Open
Connum opened this issue Mar 22, 2024 · 7 comments
Open

No SVG tests #95

Connum opened this issue Mar 22, 2024 · 7 comments

Comments

@Connum
Copy link

Connum commented Mar 22, 2024

SVG fonts were added a while ago via #56, but there are actually no tests for SVG font rendering in the test suite.
Opentype.js may soon have parsing and writing support for them (opentypejs/opentype.js#672) and I'd like to try to implement the rendering, so it would be great to have tests for that.

@HinTak
Copy link

HinTak commented Mar 22, 2024

Recent version of skia-python can render them. (And colrv1 too). Don't know if you want to add that.

@Connum
Copy link
Author

Connum commented Mar 27, 2024

Is there at least a standardized structure of outputting SVG for color glyphs? I'd like to prevent implementing it one way and then having to refactor it once tests are added.

@behdad
Copy link
Contributor

behdad commented Mar 27, 2024

Not sure it answers your question, but nanoemoji can convert SVGs to various color-font formats:
https://github.com/googlefonts/nanoemoji

@Connum
Copy link
Author

Connum commented Mar 27, 2024

Not sure it answers your question, but nanoemoji can convert SVGs to various color-font formats: https://github.com/googlefonts/nanoemoji

Thanks! We actually need to look at the other way round, SVG from COLR/CPAL, but maybe there's something in there...

@HinTak
Copy link

HinTak commented Mar 28, 2024

Is there at least a standardized structure of outputting SVG for color glyphs? I'd like to prevent implementing it one way and then having to refactor it once tests are added.

See this example, up to about line 50:
https://github.com/rougier/freetype-py/blob/master/examples/ot-svg-draw-skia.py

It extracts the SVG data from a ot-svg glyph via freetype-py, then (from about line 50 onwards) draw it with skia. You can replace the drawing code with another svg drawing library. This is the earliest example that works with older skia-python. The other *ot-svg* examples are better (one uses skia python, the other use pycairo/rsvg - there are 3 examples in total which deals with ot-svg fonts), if you are not interested in ot-svg internals.

@Connum
Copy link
Author

Connum commented Mar 28, 2024

I think there's a misunderstanding. The text rendering tests expect an SVG structure to compare if a glyph is rendered correctly. As there are no tests for color fonts (neither SVG fonts, nor COLR/CPAL fonts), it's currently unknown what SVG structure is expected.

@HinTak
Copy link

HinTak commented Mar 28, 2024

The freetype-py code extracts the ot-svg data directly as a svg document. (Supposedly with a subset of svg functionality, since animations etc don't make sense as avg glyphs). Wouldn't that be just a direct comparison after some lint'ting?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants