Carica, estrai dati e salva da TTF | C++

Caricare il carattere truetype dal disco

I caratteri di TrueType possono essere archiviati per disco nei file. Aspose.Font per API C ++ può caricare tali file e leggere le informazioni sul carattere da questi. I seguenti passaggi possono essere utilizzati per leggere il file dei caratteri TrueType nelle applicazioni C ++.

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));

Salva il carattere TTF

Aspose.Font per C++ fornisce la capacità di modificare i file di carattere e salvare le modifiche al disco. Il seguente campione di codice C ++ mostra come salvare un file font TTF aggiornato al disco.

 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);

Per ulteriori esempi, vai su aspose.font.examples.sln Solution, nella cartella net-examples della documentazione Aspose.Font Github repository.

Puoi anche controllare le nostre applicazioni gratuite di manipolazione online FONT per vedere come la funzionalità può essere implementata in una soluzione Web.