com.lowagie.text.pdf

Class Type3Font

public class Type3Font extends BaseFont

A class to support Type3 fonts.
Field Summary
IntHashtablechar2byte
HashMapchar2glyph
booleancolorized
floatllx
floatlly
PageResourcespageResources
floaturx
floatury
IntHashtablewidths3
PdfWriterwriter
Constructor Summary
Type3Font(PdfWriter writer, char[] chars, boolean colorized)
Creates a Type3 font.
Method Summary
booleancharExists(char c)
byte[]convertToBytes(String text)
PdfContentBytedefineGlyph(char c, float wx, float llx, float lly, float urx, float ury)
Defines a glyph.
int[]getCharBBox(char c)
String[][]getFamilyFontName()
floatgetFontDescriptor(int key, float fontSize)
String[][]getFullFontName()
intgetKerning(char char1, char char2)
StringgetPostscriptFontName()
protected int[]getRawCharBBox(int c, String name)
intgetRawWidth(int c, String name)
intgetWidth(char char1)
intgetWidth(String text)
booleanhasKernPairs()
booleansetCharAdvance(char c, int advance)
booleansetKerning(char char1, char char2, int kern)
voidsetPostscriptFontName(String name)
voidwriteFont(PdfWriter writer, PdfIndirectReference ref, Object[] params)

Field Detail

char2byte

private IntHashtable char2byte

char2glyph

private HashMap char2glyph

colorized

private boolean colorized

llx

private float llx

lly

private float lly

pageResources

private PageResources pageResources

urx

private float urx

ury

private float ury

widths3

private IntHashtable widths3

writer

private PdfWriter writer

Constructor Detail

Type3Font

public Type3Font(PdfWriter writer, char[] chars, boolean colorized)
Creates a Type3 font. This implementation assumes that the /FontMatrix is [0.001 0 0 0.001 0 0] or a 1000-unit glyph coordinate system.

An example:

 Document document = new Document(PageSize.A4);
 PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("type3.pdf"));
 document.open();
 Type3Font t3 = new Type3Font(writer, new char[]{'a', 'b'}, false);
 PdfContentByte g = t3.defineGlyph('a', 1000, 0, 0, 750, 750);
 g.rectangle(0, 0, 750, 750);
 g.fill();
 g = t3.defineGlyph('b', 1000, 0, 0, 750, 750);
 g.moveTo(0, 0);
 g.lineTo(375, 750);
 g.lineTo(750, 0);
 g.fill();
 Font f = new Font(t3, 12);
 document.add(new Paragraph("ababab", f));
 document.close();
 

Parameters: writer the writer chars an array of chars corresponding to the glyphs used colorized if true the font may specify color, if false no color commands are allowed and only images as masks can be used

Method Detail

charExists

public boolean charExists(char c)

convertToBytes

byte[] convertToBytes(String text)

defineGlyph

public PdfContentByte defineGlyph(char c, float wx, float llx, float lly, float urx, float ury)
Defines a glyph.

Parameters: c the character to match this glyph. It must be one of those defined in the constructor wx the advance this character will have llx the X lower left corner of the glyph bounding box. If the colorize option is true the value is ignored lly the Y lower left corner of the glyph bounding box. If the colorize option is true the value is ignored urx the X upper right corner of the glyph bounding box. If the colorize option is true the value is ignored ury the Y upper right corner of the glyph bounding box. If the colorize option is true the value is ignored

Returns: a content where the glyph can be defined

getCharBBox

public int[] getCharBBox(char c)

getFamilyFontName

public String[][] getFamilyFontName()

getFontDescriptor

public float getFontDescriptor(int key, float fontSize)

getFullFontName

public String[][] getFullFontName()

getKerning

public int getKerning(char char1, char char2)

getPostscriptFontName

public String getPostscriptFontName()

getRawCharBBox

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

getRawWidth

int getRawWidth(int c, String name)

getWidth

public int getWidth(char char1)

getWidth

public int getWidth(String text)

hasKernPairs

public boolean hasKernPairs()

setCharAdvance

public boolean setCharAdvance(char c, int advance)

setKerning

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

setPostscriptFontName

public void setPostscriptFontName(String name)

writeFont

void writeFont(PdfWriter writer, PdfIndirectReference ref, Object[] params)