Comments (4)
Currently, we track <svg>
tag and determine if it is broken based on whether there is the doc node or not.
Can you explain a bit more about the invalid svg file you talked about?
from thorvg.
Result Picture::load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false);
the input data without the tag, SvgLoader::header() returns true.
from thorvg.
Result Picture::load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false);
I tested Svg2.cpp by modifying the svg data and it works.
Could you please share a svg file of the case you are having trouble with?
~/dev/os/thorvg (main) 14:40:29 $ ./build/src/examples/Svg2
tvg engine: software
No SVG File. There is no <svg/>, return false
No SVG File. There is no <svg/>, return false
Svg Load Fail
diff --git a/src/examples/Svg2.cpp b/src/examples/Svg2.cpp
index 812f899e..fc6d8115 100644
--- a/src/examples/Svg2.cpp
+++ b/src/examples/Svg2.cpp
@@ -26,7 +26,7 @@
/* Drawing Commands */
/************************************************************************/
-static const char* svg = "<svg height=\"1000\" viewBox=\"0 0 1000 1000\" width=\"1000\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M.10681413.09784845 1000.0527.01592069V1000.0851L.06005738 999.9983Z\" fill=\"#ffffff\" stroke-width=\"3.910218\"/><g fill=\"#252f35\"><g stroke-width=\"3.864492\"><path d=\"M256.61221 100.51736H752.8963V386.99554H256.61221Z\"/><path d=\"M201.875 100.51736H238.366478V386.99554H201.875Z\"/><path d=\"M771.14203 100.51736H807.633508V386.99554H771.14203Z\"/></g><path d=\"M420.82388 380H588.68467V422.805317H420.82388Z\" stroke-width=\"3.227\"/><path d=\"m420.82403 440.7101v63.94623l167.86079 25.5782V440.7101Z\"/><path d=\"M420.82403 523.07258V673.47362L588.68482 612.59701V548.13942Z\"/></g><g fill=\"#222f35\"><path d=\"M420.82403 691.37851 588.68482 630.5019 589 834H421Z\"/><path d=\"m420.82403 852.52249h167.86079v28.64782H420.82403v-28.64782 0 0\"/><path d=\"m439.06977 879.17031c0 0-14.90282 8.49429-18.24574 15.8161-4.3792 9.59153 0 31.63185 0 31.63185h167.86079c0 0 4.3792-22.04032 0-31.63185-3.34292-7.32181-18.24574-15.8161-18.24574-15.8161z\"/></g><g fill=\"#ffffff\"><path d=\"m280 140h15v55l8 10 8-10v-55h15v60l-23 25-23-25z\"/><path d=\"m335 140v80h45v-50h-25v10h10v30h-15v-57h18v-13z\"/></g></svg>";
+static const char* svg = "<path d=\"M.10681413.09784845 1000.0527.01592069V1000.0851L.06005738 999.9983Z\" fill=\"#ffffff\" stroke-width=\"3.910218\"/><g fill=\"#252f35\"><g stroke-width=\"3.864492\"><path d=\"M256.61221 100.51736H752.8963V386.99554H256.61221Z\"/><path d=\"M201.875 100.51736H238.366478V386.99554H201.875Z\"/><path d=\"M771.14203 100.51736H807.633508V386.99554H771.14203Z\"/></g><path d=\"M420.82388 380H588.68467V422.805317H420.82388Z\" stroke-width=\"3.227\"/><path d=\"m420.82403 440.7101v63.94623l167.86079 25.5782V440.7101Z\"/><path d=\"M420.82403 523.07258V673.47362L588.68482 612.59701V548.13942Z\"/></g><g fill=\"#222f35\"><path d=\"M420.82403 691.37851 588.68482 630.5019 589 834H421Z\"/><path d=\"m420.82403 852.52249h167.86079v28.64782H420.82403v-28.64782 0 0\"/><path d=\"m439.06977 879.17031c0 0-14.90282 8.49429-18.24574 15.8161-4.3792 9.59153 0 31.63185 0 31.63185h167.86079c0 0 4.3792-22.04032 0-31.63185-3.34292-7.32181-18.24574-15.8161-18.24574-15.8161z\"/></g><g fill=\"#ffffff\"><path d=\"m280 140h15v55l8 10 8-10v-55h15v60l-23 25-23-25z\"/><path d=\"m335 140v80h45v-50h-25v10h10v30h-15v-57h18v-13z\"/></g></svg>";
void tvgDrawCmds(tvg::Canvas* canvas)
@@ -41,7 +41,10 @@ void tvgDrawCmds(tvg::Canvas* canvas)
if (canvas->push(std::move(shape)) != tvg::Result::Success) return;
auto picture = tvg::Picture::gen();
- if (picture->load(svg, strlen(svg), "svg", false) != tvg::Result::Success) return;
+ if (picture->load(svg, strlen(svg), "svg", false) != tvg::Result::Success) {
+ printf("Svg Load Fail\n");
+ return;
+ }
picture->size(WIDTH, HEIGHT);
diff --git a/src/examples/images/dst.svg b/src/examples/images/dst.svg
index bce75d84..2a64b9fd 100644
--- a/src/examples/images/dst.svg
+++ b/src/examples/images/dst.svg
@@ -1,4 +1,3 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" >
<g transform="translate(50,50)">
<path d="M38,-1h12v2h-12zM-38-1h-12v2h12z"/>
<path d="M40,-1h8v2h-8zM-40-1h-8v2h8z" transform="rotate(30)"/>
@@ -12,4 +11,3 @@
<path d="M25-12A28,28 0,0,1 28-2m-0.3,0l-1-2h2z" stroke-width="1" stroke-linejoin="round" stroke="#F00" fill="#F00"/>
<circle r="2"/>
</g>
-</svg>
diff --git a/src/loaders/svg/tvgSvgLoader.cpp b/src/loaders/svg/tvgSvgLoader.cpp
index 66b257bb..714a049b 100644
--- a/src/loaders/svg/tvgSvgLoader.cpp
+++ b/src/loaders/svg/tvgSvgLoader.cpp
@@ -3522,7 +3522,10 @@ bool SvgLoader::header()
//If the <svg> tag is found, the loaded file is valid and stores viewbox information.
//After that, the remaining content data is parsed in order with async.
loaderData.svgParse = (SvgParser*)malloc(sizeof(SvgParser));
- if (!loaderData.svgParse) return false;
+ if (!loaderData.svgParse) {
+ printf("parser is null\n");
+ return false;
+ }
loaderData.svgParse->flags = SvgStopStyleFlags::StopDefault;
viewFlag = SvgViewFlag::None;
@@ -3592,10 +3595,11 @@ bool SvgLoader::header()
h = loaderData.doc->node.doc.h;
}
+ printf("return true\n");
return true;
}
- TVGLOG("SVG", "No SVG File. There is no <svg/>");
+ printf("No SVG File. There is no <svg/>, return false\n");
return false;
}
from thorvg.
@JSUYA thanks for your cooperation, Let's see if the issue comes up in the next time.
from thorvg.
Related Issues (20)
- Support Focal property in Radial Gradient HOT 7
- Enhance Lottie feature
- Scene clipping - doesn't work properly
- Windows build error due to strip option HOT 6
- vcpkg-tool-meson tool is too old. HOT 1
- Improve Code quality HOT 2
- support stroke dash offset function HOT 5
- simple svg renders incorrectly HOT 2
- Introduce TVG Window port HOT 5
- Masking chaining bug
- Support dash offset in TVG binary
- cross compile on mcu HOT 1
- thread safety issue HOT 6
- Thread issues (Godot) HOT 1
- Support Merging-Path property in Lottie
- Support Expression in Lottie
- Lottie stacking order issue
- Lottie Trimpath+Dash+Offset doesn work.
- Incorrect blending issue at InvLumaMasking
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thorvg.