1. Products
  2.   Font
  3.   Java
  4.   FontVerter
 
  

Java Library to Read & Convert Fonts

Open Source Java Library allows to Load, Read, Manipulate and Convert TrueType, OpenType, and Type1 font file formats.

Fonts always play an important role while working with digital content. Whether users need to work on a website, an application, or a document, the selection of font can significantly impact the overall user experience. However, using the right font isn't always straightforward and can be very time-consuming and costly. This is where FontVerter can rescue users by helping them to convert fonts between different formats with ease. FontVerter is an open-source Java Font processing library that allows software developers to convert fonts from one format to another without any external dependency.

FontVerter is a lightweight and easy-to-use Java library that provides a simple API to convert font formats inside Java applications. It is written in Java, and therefore, it can be used in any Java-based application. With FontVerter, Software developers can effortlessly convert TrueType fonts (TTF) to Web Open Font Format (WOFF) or Web Open Font Format 2 (WOFF2), and vice versa. This library can be used to convert fonts to different formats for use in web applications, desktop applications, and mobile applications.

The FontVerter library offers a straightforward API that abstracts away the complexity of font conversion. Software developers can quickly integrate FontVerter into their Java projects without wrestling with intricate font file parsing or conversion algorithms and with just a couple of lines of Java code, users can convert fonts. During the conversion process, the API ensures that the essential metadata of the font, such as font names, font styles, and glyph information, is preserved accurately. In conclusion, If you're working on a project that requires font conversion, FontVerter is an invaluable tool that will save you time, effort, and headaches.

Previous Next

Getting Started with FontVerter

The recommended way to use FontVerter is using Maven Dependency. Please use the following command to add the maven dependency in your project.

Maven Dependency for FontVerter

 <dependencies>
	<dependency>
	<groupId>net.mabboud.fontverter</groupId>
	<artifactId>FontVerter;/artifactId>
	<version>1.2.22</version>
    </dependency>
</dependencies>

You can also install it manually; download the latest release files directly from GitHub repository.

Converting a Font via Java API

The open source FontVerter library has included a very powerful set of features for loading and converting exiting fonts to other supported file formats. It just requires a couple of lines of code for a smooth font conversion. To convert a file first users need to provide the input font file that they want to convert. After a successful conversion users can save Font to a desired location and use it latter. The following Example shows how to convert the input font to the WOFF format using Java commands.

How to Convert font to a Desired Format via Java API?

import com.example.fontverter.FontConverter;

public class FontConversionExample {
    public static void main(String[] args) {
        // ...

        // Create an instance of the FontConverter
        FontConverter fontConverter = new FontConverter();
        
        // Convert the font to the desired format
        Font outputFont = fontConverter.convertFont(inputFont, FontFormat.WOFF);
        
   // specify the path to save the converted font file
   String outputFontPath = "/path/to/save/output/font.woff";
        
   // Save the converted font to the specified path
   FontSaver fontSaver = new FontSaver();
   fontSaver.saveFontToFile(outputFont, outputFontPath);

    }
}

Extract Fonts from PDF File via Java Library

The free FontVerter library PDF has provided complete functionality for loading and extracting fonts programmatically from an existing PDF file with ease. It can extract fonts from PDF file or directory containing PDF files. The PDF font extractor helps software developers to extract directly to a directory or extract to list of FVFonts for further manipulation. It allows to save the fonts as WOFF1, WOFF2, OTF and so on. The following example shows how to extract fonts and save it a directory on a machine.

How to Extract Fonts from PDF File using Java API?

File pdf = new File("test.pdf");
PdfFontExtractor extractor = new PdfFontExtractor();

// extract directly to a directory
extractor.extractFontsToDir(pdf, TestUtils.tempOutputPath);

// or extract to list of FVFonts for further manipulation
List fonts = extractor.extractToFVFonts(doc);