Repository navigation
Fonts
How icepdf finds fonts: the fonts embedded in a document first, then system fonts that stand in for fonts a document names but doesn't embed.
On this page: Embedded fonts · Substituting missing fonts · The font cache · Fonts from the class path · Writing text into annotations and signatures
icepdf reads every kind of embedded font in the PDF specification through Apache FontBox: Type 1, TrueType, OpenType, CFF and Type 3. Since 7.0.0 font rendering is entirely open source.
When a document names a font without embedding it, icepdf picks the closest installed font, preferring ones whose glyph widths match so text keeps its layout. Installing a few free font families makes a visible difference:
- Liberation: metric-compatible with Arial, Times New Roman and Courier New.
- The Ghostscript (URW base 35) fonts: stand-ins for the 14 standard PDF fonts, including Symbol and ZapfDingbats.
After installing fonts, rescan them: in the viewers, from the preferences; in your own code, with
FontManager.getInstance().readSystemFonts(null).
icepdf scans the system fonts once and keeps the result in a cache, so later launches start quickly. Since 8.0
the cache is versioned: the first launch after upgrading rescans the fonts once, picking up TrueType and OpenType
collections (.ttc/.otc), which are now used for substitution, notably for CJK text. A cache that can't be read
rebuilds itself.
To ship fonts with your application instead of relying on what's installed, put them in a package on the class path and load them by name:
// get an instance to the singleton FontManager
FontManager fontManager = FontManager.getInstance();
// read four fonts from the package fonts
fontManager.readFontPackage("fonts", Arrays.asList(
new String[]{"CenturySchL-Bold.pfb",
"Dingbats.pfb",
"NimbusMonL-Bold.pfb",
"NimbusSanL-Bold.pfb"}));
When icepdf writes text into a document, in a free-text annotation, a form field or a visible signature, it embeds a
subset of the font it used. With icepdf-fonts on the class path it has a known set of fonts to choose from. You
only need it if your application writes such text; see Dependencies for the coordinates.
Project site · Javadoc · Releases · Discussions · Issues
Start
Use the library
Viewers
Configure and tune
Project