Loading and Extracting Data | .NET
Contents
[
Hide
Show
]Load CFF Font from Disc
Aspose.Font for .NET API lets you read CFF Font types from files stored in your digital storage. CFF font files stored on disc can be loaded by using the following steps.
- Define a new object of FontDefinition class
- Specify FontType as CFF and FontFileDefinition as cff
- Create a CffFont object and open the font file from FontDefinition object defined in the earlier step
1// For complete examples and data files, please go to https://github.com/aspose-font/Aspose.Font-for-.NET
2string fileName = dataDir + "OpenSans-Regular.cff"; //Font file name with full path
3
4FontDefinition fd = new FontDefinition(FontType.CFF, new FontFileDefinition("cff", new FileSystemStreamSource(fileName)));
5CffFont ttfFont = Aspose.Font.Font.Open(fd) as CffFont;
Load CFF Font from Byte Array
You can also load CFF fonts from stream using the following code sample.
1// For complete examples and data files, please go to https://github.com/aspose-font/Aspose.Font-for-.NET
2byte[] fontMemoryData = File.ReadAllBytes(dataDir + "OpenSans-Regular.cff");
3FontDefinition fd = new FontDefinition(FontType.CFF, new FontFileDefinition("cff", new ByteContentStreamSource(fontMemoryData)));
4CffFont cffFont = Aspose.Font.Font.Open(fd) as CffFont;