原創(chuàng)|行業(yè)資訊|編輯:李顯亮|2020-09-18 11:21:54.397|閱讀 1088 次
概述:Aspose提供了專用的API——Aspose.Font,用于處理和渲染包括TrueType,CFF,OpenType和Type1在內(nèi)的流行字體類型。Aspose.Font重磅上線,慧都網(wǎng)提供試用下載和基礎(chǔ)教程等資源,歡迎下載體驗。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
在數(shù)字排版中,字體定義了用于字符外觀的特定樣式。通常,在文檔和網(wǎng)頁中使用字體來樣式化文本。每種字體都在一個文件中進行了描述,該文件包含有關(guān)字符的大小,粗細,樣式和編碼的信息。
對于此類情況,Aspose提供了專用的API——Aspose.Font,用于處理和渲染包括TrueType,CFF,OpenType和Type1在內(nèi)的流行字體類型。
Aspose.Font是一個本地API,可讓您在.NET應(yīng)用程序中使用C#來實現(xiàn)字體管理功能。除了從字體中加載,保存和提取信息外,API還允許您根據(jù)需要呈現(xiàn)字形或文本。
Aspose.Font for .NET的概述
Aspose.Font for .NET支持以下圖像格式
Aspose.Drawing for .NET支持任何從2.0開始的.NET框架
可以從數(shù)字存儲設(shè)備上存儲的文件中加載字體,以檢索字體信息。.NET的Aspose.Font公開了單獨的類來處理特定類型的字體,例如CFF,TrueType等。以下是加載和保存字體的步驟。
下面的代碼示例演示如何使用C#加載和保存CFF字體。
//byte array to load Font from string dataDir = RunExamples.GetDataDir_Data(); byte[] fontMemoryData = File.ReadAllBytes(dataDir + "OpenSans-Regular.cff"); FontDefinition fd = new FontDefinition(FontType.CFF, new FontFileDefinition("cff", new ByteContentStreamSource(fontMemoryData))); CffFont cffFont = Aspose.Font.Font.Open(fd) as CffFont; //Work with data from just loaded CffFont object //Save CffFont to disk //Output Font file name with full path string outputFile = RunExamples.GetDataDir_Data() + "OpenSans-Regular_out.cff"; cffFont.Save(outputFile);
下面的代碼示例演示如何使用C#加載和保存TrueType字體。
//byte array to load Font from string dataDir = RunExamples.GetDataDir_Data(); byte[] fontMemoryData = File.ReadAllBytes(dataDir + "Montserrat-Regular.ttf"); FontDefinition fd = new FontDefinition(FontType.TTF, new FontFileDefinition("ttf", new ByteContentStreamSource(fontMemoryData))); TtfFont ttfFont = Aspose.Font.Font.Open(fd) as TtfFont; //Work with data from just loaded TtfFont object //Save TtfFont to disk //Output Font file name with full path string outputFile = RunExamples.GetDataDir_Data() + "Montserrat-Regular_out.ttf"; ttfFont.Save(outputFile);
下面的代碼示例演示如何使用C#加載和保存Type1字體。
string fileName = dataDir + "courier.pfb"; //Font file name with full path FontDefinition fd = new FontDefinition(FontType.Type1, new FontFileDefinition("pfb", new FileSystemStreamSource(fileName))); Type1Font font = Aspose.Font.Font.Open(fd) as Type1Font;
還想要更多嗎?您可以點擊閱讀【2020 · Aspose最新資源整合】,查找需要的教程資源。可聯(lián)系快速了解!
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn