ロード、抽出、TTF |から保存しますC ++

ディスクからTrueTypeフォントをロードします

TrueTypeフォントは、ファイルにディスクに保存できます。 C ++ APIのAspose.Fontは、このようなファイルをロードして、これらからフォント情報を読み取ることができます。次の手順を使用して、C ++アプリケーションでTrueTypeフォントファイルを読み取ることができます。

1For complete examples and data files, please go to https://github.com/aspose-font/Aspose.Font-for-C
2System::String fileName = dataDir + u"Montserrat-Regular.ttf";
3//Font file name with full path
4    
5System::SharedPtr<FontDefinition> fd = System::MakeObject<FontDefinition>(Aspose::Font::FontType::TTF, System::MakeObject<FontFileDefinition>(u"ttf", System::MakeObject<FileSystemStreamSource>(fileName)));
6System::SharedPtr<TtfFont> ttfFont = System::DynamicCast_noexcept<Aspose::Font::Ttf::TtfFont>(Aspose::Font::Font::Open(fd));

TTFフォントを保存します

C ++のAspose.Fontは、フォントファイルを編集し、ディスクへの変更を保存する機能を提供します。次のC ++コードサンプルは、更新されたTTFフォントファイルをディスクに保存する方法を示しています。

 1For complete examples and data files, please go to https://github.com/aspose-font/Aspose.Font-for-C
 2//byte array to load Font from
 3System::String dataDir = RunExamples::GetDataDir_Data();
 4    
 5System::ArrayPtr<uint8_t> fontMemoryData = System::IO::File::ReadAllBytes(dataDir + u"Montserrat-Regular.ttf");
 6System::SharedPtr<FontDefinition> fd = System::MakeObject<FontDefinition>(Aspose::Font::FontType::TTF, System::MakeObject<FontFileDefinition>(u"ttf", System::MakeObject<ByteContentStreamSource>(fontMemoryData)));
 7System::SharedPtr<TtfFont> ttfFont = System::DynamicCast_noexcept<Aspose::Font::Ttf::TtfFont>(Aspose::Font::Font::Open(fd));
 8    
 9//Work with data from just loaded TtfFont object
10    
11//Save CffFont to disk
12//Output Font file name with full path
13System::String outputFile = RunExamples::GetDataDir_Data() + u"Montserrat-Regular_out.ttf";
14    
15ttfFont->Save(outputFile);

その他の例については、 aspose.examples.sln solutionnet-examples aspose.font documentationgithubリポジトリの net-examplesフォルダーにご覧ください。

また、無料のオンライン フォント操作アプリケーションを確認して、Webソリューションで機能を実装する方法を確認することもできます。

Have any questions about Aspose.Font?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.