com.lowagie.text.pdf

Class DocumentFont

public class DocumentFont extends BaseFont

Author: psoares

Field Summary
floatAscender
static String[]cjkEncs
static String[]cjkEncs2
BaseFontcjkMirror
static String[]cjkNames
static String[]cjkNames2
floatCapHeight
IntHashtablediffmap
floatDescender
PdfDictionaryfont
StringfontName
booleanisType0
floatItalicAngle
floatllx
floatlly
HashMapmetrics
PRIndirectReferencerefFont
static int[]stdEnc
IntHashtableuni2byte
floaturx
floatury
Constructor Summary
DocumentFont(PRIndirectReference refFont)
Creates a new instance of DocumentFont
Method Summary
booleancharExists(int c)
byte[]convertToBytes(String text)
byte[]convertToBytes(int char1)
StringdecodeString(PdfString ps)
voiddoType1TT()
voidfillEncoding(PdfName encoding)
voidfillFontDesc(PdfDictionary fontDesc)
voidfillMetrics(byte[] touni, IntHashtable widths, int dw)
String[][]getAllNameEntries()
Gets all the entries of the names-table.
int[]getCharBBox(int c)
String[][]getFamilyFontName()
Gets the family name of the font.
floatgetFontDescriptor(int key, float fontSize)
Gets the font parameter identified by key.
String[][]getFullFontName()
Gets the full name of the font.
PdfStreamgetFullFontStream()
Always returns null.
PdfIndirectReferencegetIndirectReference()
intgetKerning(int char1, int char2)
Gets the kerning between two Unicode chars.
StringgetPostscriptFontName()
Gets the postscript font name.
protected int[]getRawCharBBox(int c, String name)
intgetRawWidth(int c, String name)
Gets the width from the font according to the Unicode char c or the name.
intgetWidth(int char1)
Gets the width of a char in normalized 1000 units.
intgetWidth(String text)
booleanhasKernPairs()
Checks if the font has any kerning pairs.
voidprocessType0(PdfDictionary font)
IntHashtablereadWidths(PdfArray ws)
booleansetKerning(int char1, int char2, int kern)
voidsetPostscriptFontName(String name)
Sets the font name that will appear in the pdf font dictionary.
voidwriteFont(PdfWriter writer, PdfIndirectReference ref, Object[] params)
Outputs to the writer the font dictionaries and streams.

Field Detail

Ascender

private float Ascender

cjkEncs

private static String[] cjkEncs

cjkEncs2

private static String[] cjkEncs2

cjkMirror

private BaseFont cjkMirror

cjkNames

private static String[] cjkNames

cjkNames2

private static String[] cjkNames2

CapHeight

private float CapHeight

diffmap

private IntHashtable diffmap

Descender

private float Descender

font

private PdfDictionary font

fontName

private String fontName

isType0

private boolean isType0

ItalicAngle

private float ItalicAngle

llx

private float llx

lly

private float lly

metrics

private HashMap metrics

refFont

private PRIndirectReference refFont

stdEnc

private static final int[] stdEnc

uni2byte

private IntHashtable uni2byte

urx

private float urx

ury

private float ury

Constructor Detail

DocumentFont

DocumentFont(PRIndirectReference refFont)
Creates a new instance of DocumentFont

Method Detail

charExists

public boolean charExists(int c)

convertToBytes

byte[] convertToBytes(String text)

convertToBytes

byte[] convertToBytes(int char1)

decodeString

private String decodeString(PdfString ps)

doType1TT

private void doType1TT()

fillEncoding

private void fillEncoding(PdfName encoding)

fillFontDesc

private void fillFontDesc(PdfDictionary fontDesc)

fillMetrics

private void fillMetrics(byte[] touni, IntHashtable widths, int dw)

getAllNameEntries

public String[][] getAllNameEntries()
Gets all the entries of the names-table. If it is a True Type font each array element will have {Name ID, Platform ID, Platform Encoding ID, Language ID, font name}. The interpretation of this values can be found in the Open Type specification, chapter 2, in the 'name' table.
For the other fonts the array has a single element with {"4", "", "", "", font name}.

Returns: the full name of the font

Since: 2.0.8

getCharBBox

public int[] getCharBBox(int c)

getFamilyFontName

public String[][] getFamilyFontName()
Gets the family name of the font. If it is a True Type font each array element will have {Platform ID, Platform Encoding ID, Language ID, font name}. The interpretation of this values can be found in the Open Type specification, chapter 2, in the 'name' table.
For the other fonts the array has a single element with {"", "", "", font name}.

Returns: the family name of the font

getFontDescriptor

public float getFontDescriptor(int key, float fontSize)
Gets the font parameter identified by key. Valid values for key are ASCENT, CAPHEIGHT, DESCENT, ITALICANGLE, BBOXLLX, BBOXLLY, BBOXURX and BBOXURY.

Parameters: key the parameter to be extracted fontSize the font size in points

Returns: the parameter in points

getFullFontName

public String[][] getFullFontName()
Gets the full name of the font. If it is a True Type font each array element will have {Platform ID, Platform Encoding ID, Language ID, font name}. The interpretation of this values can be found in the Open Type specification, chapter 2, in the 'name' table.
For the other fonts the array has a single element with {"", "", "", font name}.

Returns: the full name of the font

getFullFontStream

public PdfStream getFullFontStream()
Always returns null.

Returns: null

Since: 2.1.3

getIndirectReference

PdfIndirectReference getIndirectReference()

getKerning

public int getKerning(int char1, int char2)
Gets the kerning between two Unicode chars.

Parameters: char1 the first char char2 the second char

Returns: the kerning to be applied

getPostscriptFontName

public String getPostscriptFontName()
Gets the postscript font name.

Returns: the postscript font name

getRawCharBBox

protected int[] getRawCharBBox(int c, String name)

getRawWidth

int getRawWidth(int c, String name)
Gets the width from the font according to the Unicode char c or the name. If the name is null it's a symbolic font.

Parameters: c the unicode char name the glyph name

Returns: the width of the char

getWidth

public int getWidth(int char1)
Gets the width of a char in normalized 1000 units.

Parameters: char1 the unicode char to get the width of

Returns: the width in normalized 1000 units

getWidth

public int getWidth(String text)

hasKernPairs

public boolean hasKernPairs()
Checks if the font has any kerning pairs.

Returns: true if the font has any kerning pairs

processType0

private void processType0(PdfDictionary font)

readWidths

private IntHashtable readWidths(PdfArray ws)

setKerning

public boolean setKerning(int char1, int char2, int kern)

setPostscriptFontName

public void setPostscriptFontName(String name)
Sets the font name that will appear in the pdf font dictionary. It does nothing in this case as the font is already in the document.

Parameters: name the new font name

writeFont

void writeFont(PdfWriter writer, PdfIndirectReference ref, Object[] params)
Outputs to the writer the font dictionaries and streams.

Parameters: writer the writer for this document ref the font indirect reference params several parameters that depend on the font type

Throws: IOException on error DocumentException error in generating the object