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

Fixing #116: PaintComposite with an unbounded source #118

Merged
merged 7 commits into from
Sep 22, 2022
Merged

Conversation

justvanrossum
Copy link
Collaborator

@justvanrossum justvanrossum commented Sep 21, 2022

This fixes #116.

Fix each backend

  • Skia
  • CoreGraphics
  • Cairo
  • SVG (Doesn't support composite mode at all at the moment, still shouldn't crash)

Note this should be generalized to the non-solid paint canvas methods.

Needs a test font + test glyph.

  • Add small subset of Noto-COLRv1 as test case

@justvanrossum justvanrossum marked this pull request as draft September 21, 2022 14:49
@justvanrossum justvanrossum changed the title This sortof fixes #116 for Skia Fixing #116: PaintComposite with an unbounded source Sep 21, 2022
@justvanrossum justvanrossum marked this pull request as ready for review September 21, 2022 19:46
@justvanrossum justvanrossum merged commit 76eed16 into main Sep 22, 2022
@justvanrossum justvanrossum deleted the issue116 branch September 22, 2022 05:23
if path is None:
self._warn(
"unbounded",
"SVG canvas currently does not support unbounded draw operations",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if you want to go that route, but in nanoemoji.colr_to_svg (where we translate from COLR => SVG) we special case a src-in PaintComposite with transparent black PaintSolid background to mean SVG's group-level opacity, since that pattern is so common:

https://github.com/googlefonts/nanoemoji/blob/2ffdd23faad153c5cec763b6e210befc9d704cd1/src/nanoemoji/colr_to_svg.py#L283-L305

Also, I wonder, since your SVGSurface already knows its viewBox, if you could just use that when you find an unbounded paint, as if the unbounded paint were implicitly bounded by a rectangle the size of the viewbox.. though I am not sure when/whether SVG renderers would clip shapes outside the viewbox rectangle, I think it depends on the overflow property but IIRC its default changes depending on whether it's applied on the root <svg> element of a standalone document or not..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bigger problem is that the SVG backend doesn't implement composition to begin with. Once that's there, your second suggestion may indeed help to overcome the problem.

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

Successfully merging this pull request may close these issues.

Bug when rendering 🎛, 🎟 or 🎫 glyphs from Noto-COLRv1.ttf
2 participants