Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aspose-com-gists/c358209682a8dd652b18f5ecc83c0837 to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-gists/c358209682a8dd652b18f5ecc83c0837 to your computer and use it in GitHub Desktop.
Loading CFF fonts from disk and byte arrays and extracting font data.

CFF Fonts Examples

Load Compact Font Format (CFF) fonts from files and byte arrays with Aspose.Font for Java.

Examples

  • Open a CFF file using a file-system stream source.
  • Read a CFF file into a byte array and open it using a byte-content stream source.

The examples use 29645.cff. Adapt getDataDir() and the relative input path to your application. These loading examples do not write output font files.

Related Documentation

Related Resources

Requirements

  • JDK 8 or later.
  • Aspose.Font for Java library.
  • A readable CFF input file, or its bytes supplied by your application.
Aspose.Font for Java – CFF Fonts Examples
// Learn more: https://docs.aspose.com/font/java/loading-saving-cff-fonts/
byte[] fontMemoryData = Files.readAllBytes(
Paths.get(getDataDir(), "..", "CFF", "29645.cff").normalize());
FontDefinition fd = new FontDefinition(FontType.CFF,
new FontFileDefinition("cff", new ByteContentStreamSource(fontMemoryData)));
CffFont cffFont = (CffFont) Font.open(fd);
// Learn more: https://docs.aspose.com/font/java/loading-saving-cff-fonts/
String fileName = Paths.get(getDataDir(), "..", "CFF", "29645.cff").normalize().toString();
FontDefinition fd = new FontDefinition(FontType.CFF,
new FontFileDefinition("cff", new FileSystemStreamSource(fileName)));
CffFont cffFont = (CffFont) Font.open(fd);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment