org.icepdf.core.pobjects.fonts
Class Font

java.lang.Object
  extended by org.icepdf.core.pobjects.Dictionary
      extended by org.icepdf.core.pobjects.fonts.Font
Direct Known Subclasses:
Font

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.

Simple Fonts

There are several types of simple font; all of which have the following properties:

Composite Fonts

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.

Since:
1.0

Field Summary
protected  java.lang.String basefont
           
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
           
protected  int firstchar
           
protected  FontFile font
           
protected  FontDescriptor fontDescriptor
           
protected  boolean inited
           
protected  boolean isAFMFont
           
protected  boolean isFontSubstitution
           
protected  boolean isVerticalWriting
           
protected  java.lang.String name
           
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  java.lang.String subtype
           
protected  int subTypeFormat
           
protected static java.lang.String[][] TO_UNICODE
          Map named CMap to Unicode mapping.
protected static java.lang.String[][] TYPE1_FONT_NAME
           
 
Fields inherited from class org.icepdf.core.pobjects.Dictionary
entries, isDeleted, isNew, library, SUBTYPE_KEY, TYPE_KEY
 
Constructor Summary
Font(Library library, java.util.Hashtable entries)
          Creates a new instance of a PDF Font.
 
Method Summary
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.
 java.lang.String getName()
          Gets the font name.
 java.lang.String 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
 java.lang.String toString()
          String representation of the Font object.
 
Methods inherited from class org.icepdf.core.pobjects.Dictionary
getEntries, getFloat, getInt, getLibrary, getNumber, getObject, getObject, getPObjectReference, isDeleted, isNew, setDeleted, setNew, setPObjectReference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

basefont

protected java.lang.String basefont

subtype

protected java.lang.String subtype

SIMPLE_FORMAT

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.

See Also:
Constant Field Values

CID_FORMAT

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.

See Also:
Constant Field Values

subTypeFormat

protected int subTypeFormat

font

protected FontFile font

firstchar

protected int firstchar

fontDescriptor

protected FontDescriptor fontDescriptor

inited

protected boolean inited

isAFMFont

protected boolean isAFMFont

isVerticalWriting

protected boolean isVerticalWriting

isFontSubstitution

protected boolean isFontSubstitution

TO_UNICODE

protected static final java.lang.String[][] TO_UNICODE
Map named CMap to Unicode mapping.


CORE14

protected static final java.lang.String[] CORE14

TYPE1_FONT_NAME

protected static final java.lang.String[][] TYPE1_FONT_NAME
Constructor Detail

Font

public Font(Library library,
            java.util.Hashtable entries)
Creates a new instance of a PDF Font.

Parameters:
library - Libaray of all objects in PDF
entries - hash of parsed font attributes
Method Detail

init

public abstract void init()
Initiate the font. Retrieve any needed attributes, basically set up the font so it can be used by the content parser.

Overrides:
init in class Dictionary

getCanonicalName

protected java.lang.String getCanonicalName(java.lang.String name)
Gets the base name of the core 14 fonts, null if it does not match

Parameters:
name - name of font to search for canonical name

getName

public java.lang.String getName()
Gets the font name.

Returns:
string representing the font name

getSubType

public java.lang.String getSubType()
Gets the font subtype value.

Returns:
string representing the font subtype

getSubTypeFormat

public int getSubTypeFormat()
Gets the font subtype format

Returns:
SIMPLE_FORMAT or CID_FORMAT.

getFont

public FontFile getFont()

Returns a font which can be used to paint the glyphs in the character set.

Returns:
value of embedded font.

isVerticalWriting

public boolean isVerticalWriting()

Returns true if the writing mode is vertical; false, otherwise

Returns:
true if the writing mode is vertical; false, otherwise.

isAFMFont

public boolean isAFMFont()

Indicates that this font is an Adobe Core 14 font.

Returns:
true, if font is a core 14 font; false otherwise.

isFontSubstitution

public boolean isFontSubstitution()

isCore14

public boolean isCore14(java.lang.String fontName)

Returns true if the font name is one of the core 14 fonts specified by Adobe.

Parameters:
fontName - name to test if a core 14 font.
Returns:
true, if font name is a core 14 font; false, otherwise.

toString

public java.lang.String toString()
String representation of the Font object.

Overrides:
toString in class Dictionary
Returns:
string representing Font object attributes.