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

Textured shapes get incorrectly set as PAINT_NONE fill #232

Open
mcclure opened this issue Nov 24, 2022 · 0 comments
Open

Textured shapes get incorrectly set as PAINT_NONE fill #232

mcclure opened this issue Nov 24, 2022 · 0 comments

Comments

@mcclure
Copy link

mcclure commented Nov 24, 2022

If a shape's "fill" property is an url(), then attr->hasFill gets set to 2, but then at this point NanoSVG when checking for hasFill 2 checks to see if there's a gradient and if there's no gradient it just sets the shape fill type to NSVG_PAINT_NONE. This is causing my app to misbehave because it handles PAINT_NONE in a particular way and even if it can't currently access the fill url() through nanoSVG currently, it's important to know it is filled.

I have locally patched this with:

diff --git a/src/nanosvg.h b/src/nanosvg.h
index 79a9878..0c55b8b 100644
--- a/src/nanosvg.h
+++ b/src/nanosvg.h
@@ -75,7 +75,8 @@ enum NSVGpaintType {
        NSVG_PAINT_NONE = 0,
        NSVG_PAINT_COLOR = 1,
        NSVG_PAINT_LINEAR_GRADIENT = 2,
-       NSVG_PAINT_RADIAL_GRADIENT = 3
+       NSVG_PAINT_RADIAL_GRADIENT = 3,
+       NSVG_PAINT_SPECIAL = 4
 };

 enum NSVGspreadType {
@@ -995,7 +996,7 @@ static void nsvg__addShape(NSVGparser* p)
                nsvg__getLocalBounds(localBounds, shape, inv);
                shape->fill.gradient = nsvg__createGradient(p, attr->fillGradient, localBounds, &shape->fill.type);
                if (shape->fill.gradient == NULL) {
-                       shape->fill.type = NSVG_PAINT_NONE;
+                       shape->fill.type = NSVG_PAINT_SPECIAL;
                }
        }

I could create a PR, but I don't know if this is how you want it done upstream because nanosvgrast won't know how to deal with the new NSVG_PAINT_SPECIAL type.

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

1 participant