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

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

Java APIのAspose.Fontでは、デジタルストレージに保存されているファイルからTrueTypeフォントタイプを読み取ることができます。ディスクに保存されているTrueTypeフォントファイルは、次の手順を使用してロードできます。

1// For complete examples and data files, please go to https://github.com/aspose-font/Aspose.Font-for-Java
2String fileName = Utils.getDataDir() + "Montserrat-Regular.ttf"; //Font file name with full path
3
4      FontDefinition fd = new FontDefinition(FontType.TTF, new FontFileDefinition("ttf", new FileSystemStreamSource(fileName)));
5      TtfFont font = (TtfFont) Font.open(fd);        

TTFフォントを保存します

TTFファイルをロードしたら、フォントファイルを使用して、パラメーターを更新し、ファイルをディスクに保存することができます。 JavaのAspose.Fontでは、次の手順を使用してTTFファイルをディスクに保存できます。

 1// For complete examples and data files, please go to https://github.com/aspose-font/Aspose.Font-for-Java
 2byte[] fontMemoryData = Utils.getInputFileBytes("Montserrat-Regular.ttf"); //Font file name with full path
 3
 4      FontDefinition fd = new FontDefinition(FontType.TTF, new FontFileDefinition("ttf", new ByteContentStreamSource(fontMemoryData)));
 5      TtfFont font = (TtfFont) Font.open(fd);
 6      
 7      //Work with data from just loaded TtfFont object
 8
 9      //Save TtfFont to disk
10      //Output Font file name with full path
11      String outputFile = Utils.getDataDir() + "Montserrat-Regular_out.ttf";
12
13      font.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.