Package org.apache.pdfbox.pdmodel.font
Class Standard14Fonts
java.lang.Object
org.apache.pdfbox.pdmodel.font.Standard14Fonts
The "Standard 14" PDF fonts, also known as the "base 14" fonts.
There are 14 font files, but Acrobat uses additional names for compatibility, e.g. Arial.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
containsName
(String fontName) Returns true if the given font name is one of the known names, including alias.static FontMetrics
Returns the metrics for font specified by fontName.static String
getMappedFontName
(String fontName) Returns the base name of the font which the given font name maps to.getNames()
Returns the set of known font names, including aliases.private static void
loadMetrics
(String fontName) Loads the metrics for the base font specified by name.private static void
Adds a standard font name to the map of known aliases, to simplify the logic of finding font metrics by name.private static void
Adds an alias name for a standard font to the map of known aliases to the map of aliases (alias as key, standard name as value).
-
Field Details
-
ALIASES
Contains all base names and alias names for the known fonts. For base fonts both the key and the value will be the base name. For aliases, the key is an alias, and the value is a base name. We want a single lookup in the map to find the font both by a base name or an alias. -
FONTS
Contains the font metrics for the base fonts. The key is a base font name, value is a FontMetrics instance. Metrics are loaded into this map on demand, only if needed.- See Also:
-
-
Constructor Details
-
Standard14Fonts
private Standard14Fonts()
-
-
Method Details
-
loadMetrics
Loads the metrics for the base font specified by name. Metric file must exist in the pdfbox jar under /org/apache/pdfbox/resources/afm/- Parameters:
fontName
- one of the standard 14 font names for which to lod the metrics.- Throws:
IOException
- if no metrics exist for that font.
-
mapName
Adds a standard font name to the map of known aliases, to simplify the logic of finding font metrics by name. We want a single lookup in the map to find the font both by a base name or an alias.- Parameters:
baseName
- the base name of the font; must be one of the 14 standard fonts- See Also:
-
mapName
Adds an alias name for a standard font to the map of known aliases to the map of aliases (alias as key, standard name as value). We want a single lookup in the map to find the font both by a base name or an alias.- Parameters:
alias
- an alias for the fontbaseName
- the base name of the font; must be one of the 14 standard fonts
-
getAFM
Returns the metrics for font specified by fontName. Loads the font metrics if not already loaded.- Parameters:
fontName
- name of font; either a base name or alias- Returns:
- the font metrics or null if the name is not one of the known names
- Throws:
IllegalArgumentException
- if no metrics exist for that font.
-
containsName
Returns true if the given font name is one of the known names, including alias.- Parameters:
fontName
- the name of font, either a base name or alias- Returns:
- true if the name is one of the known names
-
getNames
Returns the set of known font names, including aliases. -
getMappedFontName
Returns the base name of the font which the given font name maps to.- Parameters:
fontName
- name of font, either a base name or an alias- Returns:
- the base name or null if this is not one of the known names
-