com.lowagie.text.pdf

Class CJKFont

class CJKFont extends BaseFont

Creates a CJK font compatible with the fonts in the Adobe Asian font Pack.

Author: Paulo Soares (psoares@consiste.pt)

Field Summary
static HashtableallCMaps
static HashtableallFonts
static intBRACKET
booleancidDirect
static PropertiescjkEncodings
static PropertiescjkFonts
static StringCJK_ENCODING
The encoding used in the PDF document for CJK fonts
StringCMap
The CMap name associated with this font
HashMapfontDesc
StringfontName
The font name
static intFIRST
IntHashtablehMetrics
static booleanpropertiesLoaded
Stringstyle
The style modifier
static intSERIAL
char[]translationMap
booleanvertical
IntHashtablevMetrics
static intV1Y
Constructor Summary
CJKFont(String fontName, String enc, boolean emb)
Creates a CJK font.
Method Summary
booleancharExists(char c)
Checks if a character exists in this font.
static StringconvertToHCIDMetrics(int[] keys, IntHashtable h)
static StringconvertToVCIDMetrics(int[] keys, IntHashtable v, IntHashtable h)
static IntHashtablecreateMetric(String s)
floatgetBBox(int idx)
int[]getCharBBox(char c)
chargetCidCode(char c)
PdfDictionarygetCIDFont(PdfIndirectReference fontDescriptor, IntHashtable cjkTag)
floatgetDescNumber(String name)
String[][]getFamilyFontName()
Gets the family name of the font.
PdfDictionarygetFontBaseType(PdfIndirectReference CIDFont)
PdfDictionarygetFontDescriptor()
floatgetFontDescriptor(int key, float fontSize)
Gets the font parameter identified by key.
String[][]getFullFontName()
Gets the full name of the font.
intgetKerning(char char1, char char2)
StringgetPostscriptFontName()
protected int[]getRawCharBBox(int c, String name)
intgetRawWidth(int c, String name)
chargetUnicodeEquivalent(char c)
intgetWidth(String text)
booleanhasKernPairs()
Checks if the font has any kerning pairs.
static booleanisCJKFont(String fontName, String enc)
Checks if its a valid CJK font.
static voidloadProperties()
static char[]readCMap(String name)
static HashMapreadFontProperties(String name)
booleansetCharAdvance(char c, int advance)
Sets the character advance.
booleansetKerning(char char1, char 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)

Field Detail

allCMaps

static Hashtable allCMaps

allFonts

static Hashtable allFonts

BRACKET

private static final int BRACKET

cidDirect

private boolean cidDirect

cjkEncodings

static Properties cjkEncodings

cjkFonts

static Properties cjkFonts

CJK_ENCODING

static final String CJK_ENCODING
The encoding used in the PDF document for CJK fonts

CMap

private String CMap
The CMap name associated with this font

fontDesc

private HashMap fontDesc

fontName

private String fontName
The font name

FIRST

private static final int FIRST

hMetrics

private IntHashtable hMetrics

propertiesLoaded

private static boolean propertiesLoaded

style

private String style
The style modifier

SERIAL

private static final int SERIAL

translationMap

private char[] translationMap

vertical

private boolean vertical

vMetrics

private IntHashtable vMetrics

V1Y

private static final int V1Y

Constructor Detail

CJKFont

CJKFont(String fontName, String enc, boolean emb)
Creates a CJK font.

Parameters: fontName the name of the font enc the encoding of the font emb always false. CJK font and not embedded

Throws: DocumentException on error

Method Detail

charExists

public boolean charExists(char c)
Checks if a character exists in this font.

Parameters: c the character to check

Returns: true if the character has a glyph, false otherwise

convertToHCIDMetrics

static String convertToHCIDMetrics(int[] keys, IntHashtable h)

convertToVCIDMetrics

static String convertToVCIDMetrics(int[] keys, IntHashtable v, IntHashtable h)

createMetric

static IntHashtable createMetric(String s)

getBBox

private float getBBox(int idx)

getCharBBox

public int[] getCharBBox(char c)

getCidCode

public char getCidCode(char c)

getCIDFont

private PdfDictionary getCIDFont(PdfIndirectReference fontDescriptor, IntHashtable cjkTag)

getDescNumber

private float getDescNumber(String name)

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

getFontBaseType

private PdfDictionary getFontBaseType(PdfIndirectReference CIDFont)

getFontDescriptor

private PdfDictionary getFontDescriptor()

getFontDescriptor

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

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

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)

getUnicodeEquivalent

public char getUnicodeEquivalent(char c)

getWidth

public int getWidth(String text)

hasKernPairs

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

Returns: always false

isCJKFont

public static boolean isCJKFont(String fontName, String enc)
Checks if its a valid CJK font.

Parameters: fontName the font name enc the encoding

Returns: true if it is CJK font

loadProperties

private static void loadProperties()

readCMap

static char[] readCMap(String name)

readFontProperties

static HashMap readFontProperties(String name)

setCharAdvance

public boolean setCharAdvance(char c, int advance)
Sets the character advance.

Parameters: c the character advance the character advance normalized to 1000 units

Returns: true if the advance was set, false otherwise. Will always return false

setKerning

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

setPostscriptFontName

public void setPostscriptFontName(String name)
Sets the font name that will appear in the pdf font dictionary. Use with care as it can easily make a font unreadable if not embedded.

Parameters: name the new font name

writeFont

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