intarsys PDF library API

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:
IFont, ICOSObjectListener, IAttributeSupport
Direct Known Subclasses:
CIDFont, PDFontAny, PDFontTrueType, PDFontType0, PDFontType1, PDFontType3

public abstract class PDFont
extends PDObject
implements IFont

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 compress()
           
 COSName getBaseFont()
           
 Encoding getEncoding()
          The encoding of the glyphs in the font
 int getFirstChar()
          The first codepoint defined in the font.
 PDFontDescriptor getFontDescriptor()
           
static String getFontFamilyName(String name)
           
static String getFontName(String name)
          extracts the "name" portion from the given font name string
static FontStyle getFontStyle(String name)
          extracts the "style" portion from the given font name
 int getGlyphWidth(int codePoint)
          return the glyph width of a codepoint in the receiver font
 int[] getGlyphWidths()
           
 int getLastChar()
           
 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  CID getNextCID(byte[] bytes, int offset)
           
 CMap getToUnicode()
           
abstract  float getUnderlinePosition()
           
abstract  int getUnderlineThickness()
           
 int getUnicode(int byteCode)
           
 boolean isCharUsed(int c)
           
 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 setCharUsed(int c)
           
 void setEncoding(Encoding newFontEncoding)
          set an encoding for the font
 void setFontDescriptor(PDFontDescriptor descriptor)
           
 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, invalidateCaches, removeAttribute, setAttribute, setFieldBoolean, setFieldFixed, setFieldInt, setFieldMLString, setFieldName, setFieldObject, setFieldString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.intarsys.font.IFont
getFontFamilyName, getFontName, getFontStyle
 

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_ToUnicode

public static final COSName DK_ToUnicode

DK_Widths

public static final COSName DK_Widths

DK_Name

public static final COSName DK_Name

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 FontStyle getFontStyle(String name)
extracts the "style" portion from the given font name

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

compress

public void compress()

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 codepoint defined in the font.

Returns:
The first codepoint defined in the font

getFontDescriptor

public PDFontDescriptor getFontDescriptor()
Returns:
the font descriptor object for this font

getGlyphWidth

public int getGlyphWidth(int codePoint)
return the glyph width of a codepoint in the receiver font

Parameters:
codePoint - the index of the glyph in the font
Returns:
the width of the glyph

getGlyphWidths

public int[] getGlyphWidths()
Returns:
the array of defined widths for the font

getLastChar

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

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

getNextCID

public abstract CID getNextCID(byte[] bytes,
                               int offset)

getToUnicode

public CMap getToUnicode()

getUnderlinePosition

public abstract float getUnderlinePosition()

getUnderlineThickness

public abstract int getUnderlineThickness()

getUnicode

public int getUnicode(int byteCode)

isCharUsed

public boolean isCharUsed(int c)

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)

setCharUsed

public void setCharUsed(int c)

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)

toString

public String toString()
Overrides:
toString in class PDObject

intarsys PDF library API

Copyright © 2006 intarsys consulting GmbH. All Rights Reserved.