SupportFontFaceRules

HtmlLoadOptions.SupportFontFaceRules property

获取或设置一个值,指示是否支持@font-face 规则以及是否加载声明的字体。 默认值为错误的.

public bool SupportFontFaceRules { get; set; }

评论

如果启用此选项,则会加载@font-face 规则中声明的字体并将其嵌入到结果文档的 字体定义中(请参阅FontInfos)。这使得加载的字体可用于渲染,但 不会在保存时自动启用字体嵌入。为了保存已加载字体的文档, EmbedTrueTypeFonts的财产FontInfos 集合应设置为真的.

支持的字体格式为 TTF、EOT 和 WOFF。

加载 SVG 图像时不支持 @font-face 规则。

例子

展示如何加载声明的“@font-face”规则。

HtmlLoadOptions loadOptions = new HtmlLoadOptions();
loadOptions.SupportFontFaceRules = true;
Document doc = new Document(MyDir + "Html with FontFace.html", loadOptions);

Assert.AreEqual("Squarish Sans CT Regular", doc.FontInfos[0].Name);

也可以看看