DomException when loading SVG file - doubts about the correctness of parsing the font-face rule
Opened this issue · 1 comments
Hi,
I have the following problem related to this simple code, which has the task of loading a given SVG file as an object of type DrawingGroup. I care that the texts contained in the given SVG file are not geometries.
Mentioned fragment of code:
var settings = new WpfDrawingSettings
{
IncludeRuntime = true,
TextAsGeometry = false
};
var converter = new FileSvgReader(settings);
return converter.Read(svgFilePath);
During its execution for the example SVG file, I got such an exception:
[DomException]
Code: SyntaxErr
Message: Style declaration ending bracket missing
HelpLink: [null]
Source: SharpVectors.Css
----------------------------------------------------------------------------------------------------------------------------------
Stack trace:
at SharpVectors.Dom.Css.CssStyleDeclaration.ParseString(String cssText)
at SharpVectors.Dom.Css.CssFontFaceRule.Parse(String& css, Object parent, Boolean readOnly, IList`1 replacedStrings, CssStyleSheetType origin)
at SharpVectors.Dom.Css.CssRuleList.TryParse(String& css, Object parent, Boolean readOnly, IList`1 replacedStrings, CssStyleSheetType origin)
at SharpVectors.Dom.Css.CssRuleList.Parse(String& css, Object parent, Boolean readOnly, IList`1 replacedStrings, CssStyleSheetType origin)
at SharpVectors.Dom.Css.CssStyleSheet.get_CssRules()
at SharpVectors.Dom.Svg.SvgDocument.GetFontUrl(CssStyleSheet cssSheet, IList`1 fontUrls, IDictionary`2 styledFontIds)
at SharpVectors.Dom.Svg.SvgDocument.GetFontUrls()
at SharpVectors.Dom.Svg.SvgDocument.OnLoaded()
at SharpVectors.Dom.Css.CssXmlDocument.Load(XmlReader reader)
at SharpVectors.Dom.Svg.SvgDocument.Load(String filename)
at SharpVectors.Renderers.Utils.WpfSvgWindow.LoadDocument(Uri documentUri, WpfDrawingSettings drawingSettings)
at SharpVectors.Converters.FileSvgReader.LoadFile(String fileName)
It looks to me that we have a problem here with loading custom fonts defined with the css rule font-face. I found only one such case in my file. I have included the definition of this font below:
<style type="text/css">
<![CDATA[@font-face{font-family:"MicrosoftSansSerif";src:url("data:application/font-woff;charset=utf-8;base64,<stream of bytes, which I had to shorten because the post was too long>")}]]>
</style>
It seems to me that the given font-face rule is well defined (according to what I write here). For that, I have doubts about the parsing in the method CssStyleDeclaration.ParseString(String cssText)
. Can you please analyze the correctness of this method?