Загрузка и извлечение данных | Java

Загрузить шрифт CFF с диска

API Aspose.Font for Java позволяет открывать файлы шрифтов CFF в ваших Java-приложениях. Файлы шрифтов CFF, хранящиеся на диске, можно загрузить, выполнив следующие действия.

1// For complete examples and data files, please go to https://github.com/aspose-font/Aspose.Font-for-Java
2String fileName = Utils.getDataDir() + "OpenSans-Regular.cff"; //Font file name with full path
3
4      FontDefinition fd = new FontDefinition(FontType.CFF, new FontFileDefinition("cff", new FileSystemStreamSource(fileName)));
5      CffFont ttfFont = (CffFont) Font.open(fd);
6      
7      System.out.println("Font has been loaded");

Загрузите шрифт CFF из байтового массива

Вы также можете загрузить шрифты CFF из потока, используя следующий пример кода.

1// For complete examples and data files, please go to https://github.com/aspose-font/Aspose.Font-for-Java
2byte [] fontMemoryData = Utils.getInputFileBytes("OpenSans-Regular.cff");
3
4      FontDefinition fd = new FontDefinition(FontType.CFF, new FontFileDefinition("cff", new ByteContentStreamSource(fontMemoryData)));
5      CffFont ttfFont = (CffFont) Font.open(fd);
6      
7      System.out.println("Font has been loaded");
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.