加载和提取数据| .NET
Contents
[
Hide
Show
]从光盘加载CFF字体
适用于 .NET 的 Aspose.Font API可让您从存储在数字存储中的文件中读取CFF字体类型。可以使用以下步骤加载存储在光盘上的CFF字体文件。
- 定义FontDefinition类的新对象
- 将fonttype指定为cff,而fontfiledefinition为cff
- 创建一个cfffont对象,然后从fontdefinition对象打开字体文件,在早期步骤中定义
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;
从字节数组加载CFF字体
您还可以使用以下代码示例从流中加载CFF字体。
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;