加载,提取数据并从TTF中保存| .NET

从光盘加载TrueType字体

适用于 .NET 的 Aspose.Font API可让您从数字存储中存储的文件中读取TRUETYPE字体类型。可以使用以下步骤加载存储在光盘上的TRUETYPE字体文件。

加载功能在称为 如何加载字体的单独段落中充分描述。

1// For complete examples and data files, please go to https://github.com/aspose-font/Aspose.Font-for-.NET
2string fileName= dataDir + "Montserrat-Regular.ttf"; //Font file name with full path
3
4FontDefinition fd = new FontDefinition(FontType.TTF, new FontFileDefinition("ttf", new FileSystemStreamSource(fileName)));
5TtfFont ttfFont = Aspose.Font.Font.Open(fd) as TtfFont;

保存TTF字体

加载TTF文件后,您可以使用字体文件,更新一些参数,并希望将文件保存到光盘。 适用于 .NET 的 Aspose.Font允许您使用以下步骤将TTF文件保存为光盘。

 1// For complete examples and data files, please go to https://github.com/aspose-font/Aspose.Font-for-.NET
 2//byte array to load Font from
 3string dataDir = RunExamples.GetDataDir_Data();
 4            
 5byte[] fontMemoryData = File.ReadAllBytes(dataDir + "Montserrat-Regular.ttf");
 6FontDefinition fd = new FontDefinition(FontType.TTF, new FontFileDefinition("ttf", new ByteContentStreamSource(fontMemoryData)));
 7TtfFont ttfFont = Aspose.Font.Font.Open(fd) as TtfFont;
 8
 9//Work with data from just loaded TtfFont object
10
11//Save TtfFont to disk
12//Output Font file name with full path
13string outputFile = RunExamples.GetDataDir_Data() + "Montserrat-Regular_out.ttf";
14
15ttfFont.Save(outputFile);

有关更多示例,请转到 net-examples *Aspose.font document.font documentationgithub存储库中的 net-examples文件夹中,请转到 aspose.font.examples.sln解决方案

另外,请检查我们的免费在线 FONT操纵应用程序,以了解如何在Web解决方案中实现功能。

Have any questions about Aspose.Font?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.