typedef SvgStyleGradient* (*GradientFactoryMethod)(SvgLoaderData* loader, const char* buf, unsigned bufLength);
-
-
static char* _skipSpace(const char* str, const char* end)
{
while (((end && str < end) || (!end && *str != '\0')) && isspace(*str)) {
return simpleXmlParseW3CAttribute(value, _parseStyleAttr, loader);
}
#ifdef THORVG_LOG_ENABLED
- else if (!strcmp(key, "xmlns") || !strcmp(key, "xmlns:xlink") || !strcmp(key, "xmlns:svg")) {
- //No action
+ else if (!strcmp(key, "x") || !strcmp(key, "y")) {
+ if (0.0f == _parseLength(value, &type)) printf("SVG: Unsupported attributes used [Elements type: Svg][Attribute: %s][Value: %s]\n", key, value);
}
#endif
else {
static SvgNode* _createMaskNode(SvgLoaderData* loader, SvgNode* parent, TVG_UNUSED const char* buf, TVG_UNUSED unsigned bufLength)
{
- loader->svgParse->node = _createNode(parent, SvgNodeType::Unknown);
+ loader->svgParse->node = _createNode(parent, SvgNodeType::Mask);
if (!loader->svgParse->node) return nullptr;
simpleXmlParseAttributes(buf, bufLength, _attrParseMaskNode, loader);
}
#ifdef THORVG_LOG_ENABLED
else {
- printf("SVG: Unsupported elements used [Elements: %s]\n", tagName);
+ if (!isIgnoreUnsupportedLogElements(tagName)) printf("SVG: Unsupported elements used [Elements: %s]\n", tagName);
}
#endif
}
string simpleXmlNodeTypeToString(SvgNodeType type)
{
switch (type) {
- case SvgNodeType::Doc: return "Doc";
+ case SvgNodeType::Doc: return "Svg";
case SvgNodeType::G: return "G";
case SvgNodeType::Defs: return "Defs";
case SvgNodeType::Animation: return "Animation";
case SvgNodeType::Use: return "Use";
case SvgNodeType::Video: return "Video";
case SvgNodeType::ClipPath: return "ClipPath";
+ case SvgNodeType::Mask: return "Mask";
default: return "Unknown";
}
return "Unknown";
}
+
+bool isIgnoreUnsupportedLogElements(const char* tagName)
+{
+ const auto elementsNum = 1;
+ const char* const elements[] = { "title" };
+
+ for (unsigned int i = 0; i < elementsNum; ++i) {
+ if (!strncmp(tagName, elements[i], strlen(tagName))) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool _isIgnoreUnsupportedLogAttributes(const char* tagAttribute, const char* tagValue)
+{
+ const auto attributesNum = 6;
+ const struct
+ {
+ const char* tag;
+ bool tagWildcard; //If true, it is assumed that a wildcard is used after the tag. (ex: tagName*)
+ const char* value;
+ } attributes[] = {
+ {"id", false, nullptr},
+ {"data-name", false, nullptr},
+ {"overflow", false, "visible"},
+ {"version", false, nullptr},
+ {"xmlns", true, nullptr},
+ {"xml:space", false, nullptr},
+ };
+
+ for (unsigned int i = 0; i < attributesNum; ++i) {
+ if (!strncmp(tagAttribute, attributes[i].tag, attributes[i].tagWildcard ? strlen(attributes[i].tag) : strlen(tagAttribute))) {
+ if (attributes[i].value && tagValue) {
+ if (!strncmp(tagValue, attributes[i].value, strlen(tagValue))) {
+ return true;
+ } else continue;
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
#endif
static const char* _simpleXmlFindWhiteSpace(const char* itr, const char* itrEnd)
tval[i] = '\0';
#ifdef THORVG_LOG_ENABLED
- if (!func((void*)data, tmpBuf, tval)) printf("SVG: Unsupported attributes used [Elements type: %s][Attribute: %s]\n", simpleXmlNodeTypeToString(((SvgLoaderData*)data)->svgParse->node->type).c_str(), tmpBuf);
+ if (!func((void*)data, tmpBuf, tval)) {
+ if (!_isIgnoreUnsupportedLogAttributes(tmpBuf, tval)) printf("SVG: Unsupported attributes used [Elements type: %s][Id : %s][Attribute: %s][Value: %s]\n", simpleXmlNodeTypeToString(((SvgLoaderData*)data)->svgParse->node->type).c_str(), ((SvgLoaderData*)data)->svgParse->node->id ? ((SvgLoaderData*)data)->svgParse->node->id->c_str() : "NO_ID", tmpBuf, tval ? tval : "NONE");
+ }
#else
func((void*)data, tmpBuf, tval);
#endif