jPod PDF library

de.intarsys.pdf.font
Class PDFont

java.lang.Object
  extended by de.intarsys.pdf.cos.COSBasedObject
      extended by de.intarsys.pdf.pd.PDObject
          extended by de.intarsys.pdf.font.PDFont
All Implemented Interfaces:
ICOSObjectListener, de.intarsys.tools.attribute.IAttributeSupport
Direct Known Subclasses:
CIDFont, PDFontType0, PDSingleByteFont

public abstract class PDFont
extends PDObject

A PDF font object.


Nested Class Summary
static class PDFont.MetaClass
          The meta class implementation
 
Field Summary
static COSName CN_Subtype_CIDFontType0
           
static COSName CN_Subtype_CIDFontType2
           
static COSName CN_Subtype_MMType1
           
static COSName CN_Subtype_TrueType
           
static COSName CN_Subtype_Type0
           
static COSName CN_Subtype_Type1
           
static COSName CN_Subtype_Type3
           
static COSName CN_Type_Font
           
static COSName DK_BaseFont
           
static COSName DK_Encoding
           
static COSName DK_FirstChar
           
static COSName DK_FontDescriptor
           
static COSName DK_LastChar
           
static COSName DK_Name
           
static COSName DK_ToUnicode
           
static COSName DK_Widths
           
static PDFont.MetaClass META
          The meta class instance
 
Fields inherited from class de.intarsys.pdf.pd.PDObject
DK_Subtype, DK_Type
 
Method Summary
 void dumpFontFile(File file)
           
 COSName getBaseFont()
           
 Encoding getEncoding()
          The encoding of the glyphs in the font
 int getFirstChar()
          The first (encoded) codepoint defined in the font.
 PDFontDescriptor getFontDescriptor()
          The PDFontDescriptor object for this font.
 String getFontFamilyName()
           
static String getFontFamilyName(String name)
           
 String getFontName()
           
static String getFontName(String name)
          extracts the "name" portion from the given font name string
 String getFontNameNormalized()
           
 PDFontStyle getFontStyle()
           
static PDFontStyle getFontStyle(String name)
          extracts the "style" portion from the given font name
abstract  String getFontType()
           
abstract  PDGlyphs getGlyphsEncoded(int codepoint)
          The PDGlyphs instance for the encoded codepoint.
abstract  int getGlyphWidthEncoded(int codepoint)
          The glyph width of an encoded codepoint in the font.
 int getLastChar()
           
 String getLookupFontFamilyName()
           
 String getLookupFontName()
           
 PDFontStyle getLookupFontStyle()
           
 int getMacintoshRomanCode(int codePoint)
          This is a special mapping that is used if we have a font on the physical device using a Macintosh Roman encoding character map.
 int getMissingWidth()
           
abstract  PDGlyphs getNextGlyphsEncoded(ByteArrayInputStream is)
          The PDGlyphs denoted by the next byte or bytes in the input stream.
 CMap getToUnicode()
           
 void invalidateCaches()
          Invalidate all local caches as the base object may have changed.
 boolean isEmbedded()
          Answer true if this font's program is embedded within the document.
 boolean isStandardFont()
          Answer true if this is one of the 14 standard fonts.
 boolean isSubset()
          Answer true if this font is partially embedded in the document.
 void setBaseFont(String name)
           
 void setEncoding(Encoding newFontEncoding)
          set an encoding for the font
 void setFontDescriptor(PDFontDescriptor descriptor)
           
 void setLookupFontFamilyName(String name)
           
 void setLookupFontName(String name)
           
 void setLookupFontStyle(PDFontStyle newStyle)
           
 void setToUnicode(CMap newToUnicode)
          set the to unicode mapping
 String toString()
           
 
Methods inherited from class de.intarsys.pdf.pd.PDObject
cosGetFieldDescendant, cosGetFieldInheritable, cosGetFieldInherited, cosGetSubtype, cosGetType, cosRemoveFieldInheritable, cosSetFieldInheritable, cosSetSubtype, cosSetType, getDoc, getGenericChildren, getGenericParent, setGenericParent
 
Methods inherited from class de.intarsys.pdf.cos.COSBasedObject
changed, cosGetArray, cosGetDict, cosGetDoc, cosGetField, cosGetObject, cosGetStream, cosHasField, cosRemoveField, cosSetField, getAttribute, getFieldBoolean, getFieldDate, getFieldFixed, getFieldFixedArray, getFieldInt, getFieldMLString, getFieldString, removeAttribute, setAttribute, setFieldBoolean, setFieldFixed, setFieldInt, setFieldMLString, setFieldName, setFieldObject, setFieldString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CN_Subtype_CIDFontType0

public static final COSName CN_Subtype_CIDFontType0

CN_Subtype_CIDFontType2

public static final COSName CN_Subtype_CIDFontType2

CN_Subtype_MMType1

public static final COSName CN_Subtype_MMType1

CN_Subtype_TrueType

public static final COSName CN_Subtype_TrueType

CN_Subtype_Type0

public static final COSName CN_Subtype_Type0

CN_Subtype_Type1

public static final COSName CN_Subtype_Type1

CN_Subtype_Type3

public static final COSName CN_Subtype_Type3

CN_Type_Font

public static final COSName CN_Type_Font

DK_BaseFont

public static final COSName DK_BaseFont

DK_Encoding

public static final COSName DK_Encoding

DK_FirstChar

public static final COSName DK_FirstChar

DK_FontDescriptor

public static final COSName DK_FontDescriptor

DK_LastChar

public static final COSName DK_LastChar

DK_Name

public static final COSName DK_Name

DK_ToUnicode

public static final COSName DK_ToUnicode

DK_Widths

public static final COSName DK_Widths

META

public static final PDFont.MetaClass META
The meta class instance

Method Detail

getFontFamilyName

public static String getFontFamilyName(String name)

getFontName

public static String getFontName(String name)
extracts the "name" portion from the given font name string

Parameters:
name - a font name
Returns:
font name's "name" portion

getFontStyle

public static PDFontStyle getFontStyle(String name)
extracts the "style" portion from the given font name

Parameters:
name - a font name
Returns:
font name's "style" portion

dumpFontFile

public void dumpFontFile(File file)

getBaseFont

public COSName getBaseFont()
Returns:
the base font for this font dictionary

getEncoding

public Encoding getEncoding()
The encoding of the glyphs in the font

Returns:
The encoding of the glyphs in the font

getFirstChar

public int getFirstChar()
The first (encoded) codepoint defined in the font.

Returns:
The first (encoded) codepoint defined in the font

getFontDescriptor

public PDFontDescriptor getFontDescriptor()
The PDFontDescriptor object for this font.

Returns:
The PDFontDescriptor object for this font

getFontFamilyName

public String getFontFamilyName()

getFontName

public String getFontName()

getFontNameNormalized

public String getFontNameNormalized()

getFontStyle

public PDFontStyle getFontStyle()

getFontType

public abstract String getFontType()

getGlyphsEncoded

public abstract PDGlyphs getGlyphsEncoded(int codepoint)
The PDGlyphs instance for the encoded codepoint.

Parameters:
codepoint -
Returns:
The PDGlyphs instance for the encoded codepoint.

getGlyphWidthEncoded

public abstract int getGlyphWidthEncoded(int codepoint)
The glyph width of an encoded codepoint in the font.

In the standard case for single byte encoded fonts, the codepoint is the index in the /Widths array, holding the glyph width.

For multibyte fonts, see PDFontType0.

Parameters:
codepoint - The codepoint
Returns:
The glyph width of an encoded codepoint in the font

getLastChar

public int getLastChar()
Returns:
the last (encoded) codepoint defined in the font

getLookupFontFamilyName

public String getLookupFontFamilyName()

getLookupFontName

public String getLookupFontName()

getLookupFontStyle

public PDFontStyle getLookupFontStyle()

getMacintoshRomanCode

public int getMacintoshRomanCode(int codePoint)
This is a special mapping that is used if we have a font on the physical device using a Macintosh Roman encoding character map.

See PDF docs, "Encodings for True Type fonts".

Parameters:
codePoint -
Returns:
The unicode value for codePoint

getMissingWidth

public int getMissingWidth()
Returns:
the width we should use for a missing/undefined glyph width

getNextGlyphsEncoded

public abstract PDGlyphs getNextGlyphsEncoded(ByteArrayInputStream is)
                                       throws IOException
The PDGlyphs denoted by the next byte or bytes in the input stream.

For single byte encoded fonts a single byte is read and the associated PDGlyphs is returned. For CID fonts, the appropriate number of bytes is read form the input stream to select the PDGlyphs.

Parameters:
is - The input stream on the COSString bytes
Returns:
The next PDGlyphs referenced by the input stream.
Throws:
IOException

getToUnicode

public CMap getToUnicode()

invalidateCaches

public void invalidateCaches()
Description copied from class: COSBasedObject
Invalidate all local caches as the base object may have changed.

Overrides:
invalidateCaches in class COSBasedObject

isEmbedded

public boolean isEmbedded()
Answer true if this font's program is embedded within the document.

Returns:
Answer true if this font's program is embedded within the document.

isStandardFont

public boolean isStandardFont()
Answer true if this is one of the 14 standard fonts. TODO 2 implement

Returns:
Answer true if this is one of the 14 standard fonts.

isSubset

public boolean isSubset()
Answer true if this font is partially embedded in the document.

Returns:
Answer true if this font is partially embedded in the document.

setBaseFont

public void setBaseFont(String name)

setEncoding

public void setEncoding(Encoding newFontEncoding)
set an encoding for the font

Parameters:
newFontEncoding - the new encoding to use

setFontDescriptor

public void setFontDescriptor(PDFontDescriptor descriptor)

setLookupFontFamilyName

public void setLookupFontFamilyName(String name)

setLookupFontName

public void setLookupFontName(String name)

setLookupFontStyle

public void setLookupFontStyle(PDFontStyle newStyle)

setToUnicode

public void setToUnicode(CMap newToUnicode)
set the to unicode mapping

Parameters:
newToUnicode - the new to unicode to use

toString

public String toString()
Overrides:
toString in class PDObject

jPod PDF library

Copyright © 2008 intarsys consulting GmbH. All Rights Reserved.