com.lowagie.text.pdf

Class Type3Font

public class Type3Font extends BaseFont

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

Field Detail

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

usedSlot

private boolean[] usedSlot

widths3

private IntHashtable widths3

writer

private PdfWriter writer

Constructor Detail

Type3Font

public Type3Font(PdfWriter writer, char[] chars, boolean colorized)
Creates a Type3 font.

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

Type3Font

public Type3Font(PdfWriter writer, 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, 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 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(int c)

convertToBytes

byte[] convertToBytes(String text)

convertToBytes

byte[] convertToBytes(int char1)

defineGlyph

public PdfContentByte defineGlyph(char c, float wx, float llx, float lly, float urx, float ury)
Defines a glyph. If the character was already defined it will return the same content

Parameters: c the character to match this glyph. 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

getAllNameEntries

public String[][] getAllNameEntries()

Since: 2.0.8

getCharBBox

public int[] getCharBBox(int c)

getFamilyFontName

public String[][] getFamilyFontName()

getFontDescriptor

public float getFontDescriptor(int key, float fontSize)

getFullFontName

public String[][] getFullFontName()

getFullFontStream

public PdfStream getFullFontStream()
Always returns null, because you can't get the FontStream of a Type3 font.

Returns: null

Since: 2.1.3

getKerning

public int getKerning(int char1, int char2)

getPostscriptFontName

public String getPostscriptFontName()

getRawCharBBox

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

getRawWidth

int getRawWidth(int c, String name)

getWidth

public int getWidth(int char1)

getWidth

public int getWidth(String text)

hasKernPairs

public boolean hasKernPairs()

setCharAdvance

public boolean setCharAdvance(int c, int advance)

setKerning

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

setPostscriptFontName

public void setPostscriptFontName(String name)

writeFont

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