Substitute fonts
How to substitute fonts
Issue: How to substitute fonts.
Tips: To do this, you can specify the path to fonts that are not installed in the system..
Note: If you need to use fonts that are not installed on the system, you can specify the path to them. Below is an example of specifying the path to the necessary fonts. Attached are the result of exporting without using the necessary fonts (ExampleCustomFontNotSet.png) and the result of exporting with using them (ExampleCustomFontSet.png), the source file (ExampleCustomFont.dwg) and the necessary font (RomanS.ttf).
Example:
string fileName = "ExampleCustomFont"; | |
string file = string.Format("{0}.dwg", fileName); | |
string outFile = string.Format("{0}.png", fileName); | |
LoadOptions loadOptions = new LoadOptions(); | |
loadOptions.CustomFontFolders = new[] { "FolderWithCustomFonts" }; | |
using FileStream inStream = new FileStream(file, FileMode.Open); | |
using CadImage image = (CadImage)Image.Load(inStream, loadOptions); | |
using FileStream stream = new FileStream(outFile, FileMode.Create); | |
{ | |
ImageOptionsBase options = new PngOptions(); | |
options.VectorRasterizationOptions = new CadRasterizationOptions { UnitType = UnitType.Millimeter }; | |
image.Save(stream, options); | |
} |