public abstract class Font extends Dictionary
This class represents a PDF object which has a subtype value equal to "Font". The class does the necessary encoding and Cmap manipulation to allow the proper display of text that uses this font object.
This class is generally only used by the ContentParser for laying out text for display and for text extraction. There are two categories of PDF fonts: Simple and Composite.
There are several types of simple font; all of which have the following properties:
A composite font, also called Type0 font, is one whose glyphs are obtained from a font like object called a CIDFont. A composite font is represented by a font dictionary whose Subtype value is Type0. The Type 0 font is known as the root font, and its associated CID Font is called its descendant.
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
basefont |
static Name |
BASEFONT_KEY |
static int |
CID_FORMAT
Indicates that the font used to render this String object is in the
Composite Font family and thus each glyph is represented by at least
one byte.
|
protected static java.lang.String[] |
CORE14 |
static Name |
ENCODING_KEY |
static Name |
FIRST_CHAR_KEY |
protected int |
firstchar |
protected FontFile |
font |
static int |
FONT_FLAG_ALL_CAP
Font contains no lowercase letters; typically used for display purposes,
such as for titles or headlines.
|
static int |
FONT_FLAG_FIXED_PITCH
All glyphs have the same width (as opposed to proportional or
variable-pitch fonts, which have different widths).
|
static int |
FONT_FLAG_FORCE_BOLD
Font contains no lowercase letters; typically used for display purposes,
such as for titles or headlines.
|
static int |
FONT_FLAG_ITALIC
Glyphs have dominant vertical strokes that are slanted.
|
static int |
FONT_FLAG_NON_SYMBOLIC
Font uses the Adobe standard Latin character set or a subset of it.
|
static int |
FONT_FLAG_SCRIPT
Glyphs resemble cursive handwriting.
|
static int |
FONT_FLAG_SERIF
Glyphs have serifs, which are short strokes drawn at an angle on the top
and bottom of glyph stems.
|
static int |
FONT_FLAG_SMALL_CAP
Glyphs have dominant vertical strokes that are slanted.
|
static int |
FONT_FLAG_SYMBOLIC
Font contains glyphs outside the Adobe standard Latin character set.
|
protected FontDescriptor |
fontDescriptor |
protected boolean |
inited |
protected boolean |
isAFMFont |
protected boolean |
isFontSubstitution |
protected boolean |
isVerticalWriting |
static Name |
LAST_CHAR_KEY |
protected int |
lastchar |
protected Name |
name |
static Name |
NAME_KEY |
protected Resources |
parentResource |
static int |
SIMPLE_FORMAT
Indicates that the font used to render this String object is in the
Simple Font family and thus each glyph is represented by one byte.
|
protected Name |
subtype |
protected int |
subTypeFormat |
protected static java.lang.String[][] |
TO_UNICODE
Map named CMap to Unicode mapping.
|
static Name |
TYPE |
protected static java.lang.String[][] |
TYPE1_FONT_NAME |
entries, FORM_TYPE_KEY, isDeleted, isNew, LENGTH_KEY, library, SUBTYPE_KEY, TYPE_KEY| Constructor and Description |
|---|
Font(Library library,
java.util.HashMap entries)
Creates a new instance of a PDF Font.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getBaseFont()
Gets the fonts base name.
|
protected java.lang.String |
getCanonicalName(java.lang.String name)
Gets the base name of the core 14 fonts, null if it does not match
|
FontFile |
getFont()
Returns a font which can be used to paint the glyphs in the character
set.
|
Name |
getName()
Gets the font name.
|
Resources |
getParentResource() |
Name |
getSubType()
Gets the font subtype value.
|
int |
getSubTypeFormat()
Gets the font subtype format
|
abstract void |
init()
Initiate the font.
|
boolean |
isAFMFont()
Indicates that this font is an Adobe Core 14 font.
|
boolean |
isCore14(java.lang.String fontName)
Returns true if the font name is one of the core 14 fonts specified by
Adobe.
|
boolean |
isFontSubstitution() |
boolean |
isVerticalWriting()
Returns true if the writing mode is vertical; false, otherwise
|
void |
setParentResource(Resources parentResource) |
java.lang.String |
toString()
String representation of the Font object.
|
getEntries, getFloat, getInt, getLibrary, getNumber, getObject, getPObjectReference, isDeleted, isNew, setDeleted, setNew, setPObjectReferencepublic static final Name TYPE
public static final Name NAME_KEY
public static final Name BASEFONT_KEY
public static final Name ENCODING_KEY
public static final Name FIRST_CHAR_KEY
public static final Name LAST_CHAR_KEY
public static final int FONT_FLAG_FIXED_PITCH
public static final int FONT_FLAG_SERIF
public static final int FONT_FLAG_SYMBOLIC
public static final int FONT_FLAG_SCRIPT
public static final int FONT_FLAG_NON_SYMBOLIC
public static final int FONT_FLAG_ITALIC
public static final int FONT_FLAG_ALL_CAP
public static final int FONT_FLAG_SMALL_CAP
public static final int FONT_FLAG_FORCE_BOLD
protected Name name
protected java.lang.String basefont
protected Name subtype
public static final int SIMPLE_FORMAT
Indicates that the font used to render this String object is in the Simple Font family and thus each glyph is represented by one byte.
public static final int CID_FORMAT
Indicates that the font used to render this String object is in the Composite Font family and thus each glyph is represented by at least one byte.
protected int subTypeFormat
protected FontFile font
protected int firstchar
protected int lastchar
protected FontDescriptor fontDescriptor
protected boolean inited
protected boolean isAFMFont
protected boolean isVerticalWriting
protected boolean isFontSubstitution
protected Resources parentResource
protected static final java.lang.String[][] TO_UNICODE
protected static final java.lang.String[] CORE14
protected static final java.lang.String[][] TYPE1_FONT_NAME
public Font(Library library, java.util.HashMap entries)
library - Libaray of all objects in PDFentries - hash of parsed font attributespublic abstract void init()
init in class Dictionaryprotected java.lang.String getCanonicalName(java.lang.String name)
name - name of font to search for canonical namepublic java.lang.String getBaseFont()
public Name getName()
public Name getSubType()
public int getSubTypeFormat()
public FontFile getFont()
Returns a font which can be used to paint the glyphs in the character set.
public boolean isVerticalWriting()
Returns true if the writing mode is vertical; false, otherwise
public boolean isAFMFont()
Indicates that this font is an Adobe Core 14 font.
public boolean isFontSubstitution()
public boolean isCore14(java.lang.String fontName)
Returns true if the font name is one of the core 14 fonts specified by Adobe.
fontName - name to test if a core 14 font.public java.lang.String toString()
toString in class Dictionarypublic Resources getParentResource()
public void setParentResource(Resources parentResource)