Top Description Inners Fields Constructors Methods
org.apache.pdfbox.pdmodel.font

public final Class Standard14Fonts

extends Object
Class Inheritance
Static Imports
org.apache.pdfbox.pdmodel.font.UniUtil.getUniNameOfCodePoint

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.
Author
John Hewson

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Standard14Fonts.FontName

Enum for the names of the 14 standard fonts.

Field Summary

Modifier and TypeField and Description
private static final Map<String, Standard14Fonts.FontName>
ALIASES

Contains all base names and alias names for the known fonts.

private static final Map<Standard14Fonts.FontName, FontMetrics>
FONTS

Contains the font metrics for the standard 14 fonts.

private static final Map<Standard14Fonts.FontName, FontBoxFont>
GENERIC_FONTS

Contains the mapped fonts for the standard 14 fonts.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true if the name is one of the known names
containsName
(String
the name of font, either a base name or alias
fontName
)

Returns true if the given font name is one of the known names, including alias.

public static FontMetrics

Returns:

the font metrics or null if the name is not one of the known names
getAFM
(String
name of font; either a base name or alias
fontName
)

Returns the metrics for font specified by fontName.

private static GlyphList
public static GeneralPath

Returns:

the mapped font
getGlyphPath
(Standard14Fonts.FontName
name of the standard 14 font
baseName
,
String
name of glyph
glyphName
)

Returns the path for the character with the given name for the specified Standard 14 font.

private static FontBoxFont

Returns:

the mapped font
getMappedFont
(Standard14Fonts.FontName
name of the standard 14 font
baseName
)

Returns the mapped font for the specified Standard 14 font.

public static Standard14Fonts.FontName

Returns:

the base name or null if this is not one of the known names
getMappedFontName
(String
name of font, either a base name or an alias
fontName
)

Returns the base name of the font which the given font name maps to.

public static Set<String>

Returns:

the set of known font names
getNames
()

Returns the set of known font names, including aliases.

private static void
loadMetrics(Standard14Fonts.FontName
one of the standard 14 font names for which to load the metrics.
fontName
)

Loads the metrics for the base font specified by name.

private static void
mapName(Standard14Fonts.FontName
the font name of the Standard 14 font
baseName
)

Adds a standard font name to the map of known aliases, to simplify the logic of finding font metrics by name.

private static void
mapName(String
an alias for the font
alias
,
Standard14Fonts.FontName
the font name of the Standard 14 font
baseName
)

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).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALIASESback to summary
private static final Map<String, Standard14Fonts.FontName> 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 FontName. We want a single lookup in the map to find the font both by a base name or an alias.

FONTSback to summary
private static final Map<Standard14Fonts.FontName, FontMetrics> FONTS

Contains the font metrics for the standard 14 fonts. The key is the font name, value is a FontMetrics instance. Metrics are loaded into this map on demand, only if needed.

See Also
getAFM
GENERIC_FONTSback to summary
private static final Map<Standard14Fonts.FontName, FontBoxFont> GENERIC_FONTS

Contains the mapped fonts for the standard 14 fonts. The key is the font name, value is a FontBoxFont instance. FontBoxFont are loaded into this map on demand, only if needed.

Constructor Detail

Standard14Fontsback to summary
private Standard14Fonts()

Method Detail

containsNameback to summary
public static boolean containsName(String fontName)

Returns true if the given font name is one of the known names, including alias.

Parameters
fontName:String

the name of font, either a base name or alias

Returns:boolean

true if the name is one of the known names

getAFMback to summary
public static FontMetrics getAFM(String fontName)

Returns the metrics for font specified by fontName. Loads the font metrics if not already loaded.

Parameters
fontName:String

name of font; either a base name or alias

Returns:FontMetrics

the font metrics or null if the name is not one of the known names

Exceptions
IllegalArgumentException:
if no metrics exist for that font.
getGlyphListback to summary
private static GlyphList getGlyphList(Standard14Fonts.FontName baseName)
getGlyphPathback to summary
public static GeneralPath getGlyphPath(Standard14Fonts.FontName baseName, String glyphName) throws IOException

Returns the path for the character with the given name for the specified Standard 14 font. The mapped font is cached. The path may differ in different environments as it depends on the mapped font.

Parameters
baseName:Standard14Fonts.FontName

name of the standard 14 font

glyphName:String

name of glyph

Returns:GeneralPath

the mapped font

Exceptions
IOException:
if the data could not be read
getMappedFontback to summary
private static FontBoxFont getMappedFont(Standard14Fonts.FontName baseName)

Returns the mapped font for the specified Standard 14 font. The mapped font is cached.

Parameters
baseName:Standard14Fonts.FontName

name of the standard 14 font

Returns:FontBoxFont

the mapped font

getMappedFontNameback to summary
public static Standard14Fonts.FontName getMappedFontName(String fontName)

Returns the base name of the font which the given font name maps to.

Parameters
fontName:String

name of font, either a base name or an alias

Returns:Standard14Fonts.FontName

the base name or null if this is not one of the known names

getNamesback to summary
public static Set<String> getNames()

Returns the set of known font names, including aliases.

Returns:Set<String>

the set of known font names

loadMetricsback to summary
private static void loadMetrics(Standard14Fonts.FontName fontName) throws IOException

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:Standard14Fonts.FontName

one of the standard 14 font names for which to load the metrics.

Exceptions
IOException:
if no metrics exist for that font.
mapNameback to summary
private static void mapName(Standard14Fonts.FontName baseName)

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:Standard14Fonts.FontName

the font name of the Standard 14 font

See Also
getAFM
mapNameback to summary
private static void mapName(String alias, Standard14Fonts.FontName baseName)

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 tbaseNamehe map to find the font both by a base name or an alias.

Parameters
alias:String

an alias for the font

baseName:Standard14Fonts.FontName

the font name of the Standard 14 font

org.apache.pdfbox.pdmodel.font back to summary

public final Enum Standard14Fonts.FontName

extends Enum<Standard14Fonts.FontName>
Class Inheritance

Enum for the names of the 14 standard fonts.

Field Summary

Modifier and TypeField and Description
public static final Standard14Fonts.FontName
public static final Standard14Fonts.FontName
public static final Standard14Fonts.FontName
public static final Standard14Fonts.FontName
public static final Standard14Fonts.FontName
public static final Standard14Fonts.FontName
public static final Standard14Fonts.FontName
public static final Standard14Fonts.FontName
private final String
public static final Standard14Fonts.FontName
public static final Standard14Fonts.FontName
public static final Standard14Fonts.FontName
public static final Standard14Fonts.FontName
public static final Standard14Fonts.FontName
public static final Standard14Fonts.FontName

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public String
public String
toString()

Overrides java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration.

public static Standard14Fonts.FontName
public static Standard14Fonts.FontName[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinalvalueOf

Field Detail

COURIERback to summary
public static final Standard14Fonts.FontName COURIER
COURIER_BOLDback to summary
public static final Standard14Fonts.FontName COURIER_BOLD
COURIER_BOLD_OBLIQUEback to summary
public static final Standard14Fonts.FontName COURIER_BOLD_OBLIQUE
COURIER_OBLIQUEback to summary
public static final Standard14Fonts.FontName COURIER_OBLIQUE
HELVETICAback to summary
public static final Standard14Fonts.FontName HELVETICA
HELVETICA_BOLDback to summary
public static final Standard14Fonts.FontName HELVETICA_BOLD
HELVETICA_BOLD_OBLIQUEback to summary
public static final Standard14Fonts.FontName HELVETICA_BOLD_OBLIQUE
HELVETICA_OBLIQUEback to summary
public static final Standard14Fonts.FontName HELVETICA_OBLIQUE
nameback to summary
private final String name

Hides java.lang.Enum.name.

SYMBOLback to summary
public static final Standard14Fonts.FontName SYMBOL
TIMES_BOLDback to summary
public static final Standard14Fonts.FontName TIMES_BOLD
TIMES_BOLD_ITALICback to summary
public static final Standard14Fonts.FontName TIMES_BOLD_ITALIC
TIMES_ITALICback to summary
public static final Standard14Fonts.FontName TIMES_ITALIC
TIMES_ROMANback to summary
public static final Standard14Fonts.FontName TIMES_ROMAN
ZAPF_DINGBATSback to summary
public static final Standard14Fonts.FontName ZAPF_DINGBATS

Constructor Detail

FontNameback to summary
private FontName(String name)

Method Detail

getNameback to summary
public String getName()
toStringback to summary
public String toString()

Overrides java.lang.Enum.toString.

Doc from java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists.

Returns:String

the name of this enum constant

Annotations
@Override
valueOfback to summary
public static Standard14Fonts.FontName valueOf(String name)
valuesback to summary
public static Standard14Fonts.FontName[] values()