加载和提取数据| C++
Contents
[
Hide
Show
]从光盘加载CFF字体
Aspose.Font 适用于C++ API允许从计算机上的光盘文件加载CFF字体。以下步骤可用于加载CFF字体文件:
- 创建一个新的fontdefinition类的对象
- 选择fonttype作为CFF,然后将FontfiledEfinition作为CFF选择
- 声明一个cfffont对象,然后从fontdefinition对象打开字体文件,
1For complete examples and data files, please go to https://github.com/aspose-font/Aspose.Font-for-C
2System::String fileName = dataDir + u"OpenSans-Regular.cff";
3//Font file name with full path
4
5System::SharedPtr<FontDefinition> fd = System::MakeObject<FontDefinition>(Aspose::Font::FontType::CFF, System::MakeObject<FontFileDefinition>(u"cff", System::MakeObject<FileSystemStreamSource>(fileName)));
6System::SharedPtr<CffFont> ttfFont = System::DynamicCast_noexcept<Aspose::Font::Cff::CffFont>(Aspose::Font::Font::Open(fd));
从字节数组加载CFF字体
CFF字体文件可以使用以下代码示例从流中加载。
1For complete examples and data files, please go to https://github.com/aspose-font/Aspose.Font-for-C
2System::ArrayPtr<uint8_t> fontMemoryData = System::IO::File::ReadAllBytes(dataDir + u"OpenSans-Regular.cff");
3System::SharedPtr<FontDefinition> fd = System::MakeObject<FontDefinition>(Aspose::Font::FontType::CFF, System::MakeObject<FontFileDefinition>(u"cff", System::MakeObject<ByteContentStreamSource>(fontMemoryData)));
4System::SharedPtr<CffFont> cffFont = System::DynamicCast_noexcept<Aspose::Font::Cff::CffFont>(Aspose::Font::Font::Open(fd));