HtmlSaveOptionsFontResourcesSubsettingSizeThreshold Property |
Namespace: Aspose.Words.Saving
ExportFontResources allows exporting fonts as subsidiary files or as parts of the output package. If the document uses many fonts, especially with large number of glyphs, then output size can grow significantly. Font subsetting reduces the size of the exported font resource by filtering out glyphs that are not used by the current document.
Font subsetting works as follows:
Important! When exporting font resources, font licensing issues should be considered. Authors who want to use specific fonts via a downloadable font mechanism must always carefully verify that their intended use is within the scope of the font license. Many commercial fonts presently do not allow web downloading of their fonts in any form. License agreements that cover some fonts specifically note that usage via @font-face rules in CSS style sheets is not allowed. Font subsetting can also violate license terms.
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Use a DocumentBuilder to insert text with several fonts builder.Font.Name = "Arial"; builder.Writeln("Hello world!"); builder.Font.Name = "Times New Roman"; builder.Writeln("Hello world!"); builder.Font.Name = "Courier New"; builder.Writeln("Hello world!"); // When saving to .html, font subsetting fully applies by default, meaning that when we export fonts with our file, // the symbols not used by our document are not represented by the exported fonts, which cuts down file size dramatically // Font files of a file size larger than FontResourcesSubsettingSizeThreshold get subsetted, so a value of 0 will apply default full subsetting // Setting the value to something large will fully suppress subsetting, saving some very large font files that cover every glyph HtmlSaveOptions options = new HtmlSaveOptions { ExportFontResources = true, FontResourcesSubsettingSizeThreshold = int.MaxValue }; doc.Save(ArtifactsDir + "HtmlSaveOptions.FontSubsetting.html", options);