feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -405,6 +405,27 @@ static char* _idFromUrl(const char* url)
|
|||
}
|
||||
|
||||
|
||||
static size_t _srcFromUrl(const char* url, char*& src)
|
||||
{
|
||||
src = (char*)strchr(url, '(');
|
||||
auto close = strchr(url, ')');
|
||||
if (!src || !close || src >= close) return 0;
|
||||
|
||||
src = strchr(src, '\'');
|
||||
if (!src || src >= close) return 0;
|
||||
++src;
|
||||
|
||||
close = strchr(src, '\'');
|
||||
if (!close || close == src) return 0;
|
||||
--close;
|
||||
|
||||
while (src < close && *src == ' ') ++src;
|
||||
while (src < close && *close == ' ') --close;
|
||||
|
||||
return close - src + 1;
|
||||
}
|
||||
|
||||
|
||||
static unsigned char _parseColor(const char* value, char** end)
|
||||
{
|
||||
float r;
|
||||
|
|
@ -2005,6 +2026,42 @@ static SvgNode* _createImageNode(SvgLoaderData* loader, SvgNode* parent, const c
|
|||
}
|
||||
|
||||
|
||||
static char* _unquote(const char* str)
|
||||
{
|
||||
auto len = str ? strlen(str) : 0;
|
||||
if (len >= 2 && str[0] == '\'' && str[len - 1] == '\'') return strDuplicate(str + 1, len - 2);
|
||||
return strdup(str);
|
||||
}
|
||||
|
||||
|
||||
static bool _attrParseFontFace(void* data, const char* key, const char* value)
|
||||
{
|
||||
if (!key || !value) return false;
|
||||
|
||||
key = _skipSpace(key, nullptr);
|
||||
value = _skipSpace(value, nullptr);
|
||||
|
||||
auto loader = (SvgLoaderData*)data;
|
||||
auto& font = loader->fonts.last();
|
||||
|
||||
if (!strcmp(key, "font-family")) {
|
||||
if (font.name) free(font.name);
|
||||
font.name = _unquote(value);
|
||||
} else if (!strcmp(key, "src")) {
|
||||
font.srcLen = _srcFromUrl(value, font.src);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void _createFontFace(SvgLoaderData* loader, const char* buf, unsigned bufLength, parseAttributes func)
|
||||
{
|
||||
loader->fonts.push(FontFace());
|
||||
func(buf, bufLength, _attrParseFontFace, loader);
|
||||
}
|
||||
|
||||
|
||||
static SvgNode* _getDefsNode(SvgNode* node)
|
||||
{
|
||||
if (!node) return nullptr;
|
||||
|
|
@ -3382,6 +3439,7 @@ static void _svgLoaderParserXmlOpen(SvgLoaderData* loader, const char* content,
|
|||
if (node->type != SvgNodeType::Defs || !empty) {
|
||||
loader->stack.push(node);
|
||||
}
|
||||
loader->latestGradient = nullptr;
|
||||
} else if ((method = _findGraphicsFactory(tagName))) {
|
||||
if (loader->stack.count > 0) parent = loader->stack.last();
|
||||
else parent = loader->doc;
|
||||
|
|
@ -3392,6 +3450,7 @@ static void _svgLoaderParserXmlOpen(SvgLoaderData* loader, const char* content,
|
|||
loader->stack.push(defs);
|
||||
loader->currentGraphicsNode = node;
|
||||
}
|
||||
loader->latestGradient = nullptr;
|
||||
} else if ((gradientMethod = _findGradientFactory(tagName))) {
|
||||
SvgStyleGradient* gradient;
|
||||
gradient = gradientMethod(loader, attrs, attrsLength);
|
||||
|
|
@ -3417,8 +3476,9 @@ static void _svgLoaderParserXmlOpen(SvgLoaderData* loader, const char* content,
|
|||
loader->svgParse->flags = SvgStopStyleFlags::StopDefault;
|
||||
simpleXmlParseAttributes(attrs, attrsLength, _attrParseStops, loader);
|
||||
loader->latestGradient->stops.push(loader->svgParse->gradStop);
|
||||
} else if (!isIgnoreUnsupportedLogElements(tagName)) {
|
||||
TVGLOG("SVG", "Unsupported elements used [Elements: %s]", tagName);
|
||||
} else {
|
||||
loader->latestGradient = nullptr;
|
||||
if (!isIgnoreUnsupportedLogElements(tagName)) TVGLOG("SVG", "Unsupported elements used [Elements: %s]", tagName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3452,6 +3512,8 @@ static void _svgLoaderParserXmlCssStyle(SvgLoaderData* loader, const char* conte
|
|||
TVGLOG("SVG", "Unsupported elements used in the internal CSS style sheets [Elements: %s]", tag);
|
||||
} else if (!strcmp(tag, "all")) {
|
||||
if ((node = _createCssStyleNode(loader, loader->cssStyle, attrs, attrsLength, simpleXmlParseW3CAttribute))) node->id = _copyId(name);
|
||||
} else if (!strcmp(tag, "@font-face")) { //css at-rule specifying font
|
||||
_createFontFace(loader, attrs, attrsLength, simpleXmlParseW3CAttribute);
|
||||
} else if (!isIgnoreUnsupportedLogElements(tag)) {
|
||||
TVGLOG("SVG", "Unsupported elements used in the internal CSS style sheets [Elements: %s]", tag);
|
||||
}
|
||||
|
|
@ -3826,7 +3888,7 @@ SvgLoader::SvgLoader() : ImageLoader(FileType::Svg)
|
|||
|
||||
SvgLoader::~SvgLoader()
|
||||
{
|
||||
this->done();
|
||||
done();
|
||||
clear();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue