データの読み込みと抽出| .NET
Contents
[
Hide
Show
]ディスクからCFFフォントをロードします
.NET APIのAspose.Fontでは、デジタルストレージに保存されているファイルから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;