Package com.itextpdf.io.font
Class FontEncoding
java.lang.Object
com.itextpdf.io.font.FontEncoding
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringBase font encoding.protected int[]protected String[]Encoding names.static final Stringprotected booleantrueif the font must use its built in encoding.static final StringA not defined character in a custom PDF encoding.protected com.itextpdf.io.util.IntHashtableEncodings unicode differencesprotected com.itextpdf.io.util.IntHashtableMapping map from unicode to simple code according to the encoding. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddSymbol(int code, int unicode) booleancanDecode(int code) Check whether abytecode can be converted to unicode symbol according to the encoding.booleancanEncode(int unicode) Check whether a unicode symbol or font specific code can be converted tobyteaccording to the encoding.intconvertToByte(int unicode) Converts a unicode symbol or font specific code tobyteaccording to the encoding.byte[]convertToBytes(String text) Converts aStringto abytearray according to the encoding.static FontEncodingstatic FontEncodingcreateFontEncoding(String baseEncoding) static FontEncodingThis encoding will base on font encoding (FontSpecific encoding in Type 1 terminology)protected voidstatic voidfillFontEncoding(FontEncoding encoding) FillFontEncodingobject with default data.protected voidprotected voidgetDifference(int index) intgetUnicode(int index) Gets unicode value for corresponding font's char code.intgetUnicodeDifference(int index) booleanbooleanisBuiltWith(String encoding) Checks whether theFontEncodingwas built with corresponding encoding.booleanprotected static StringnormalizeEncoding(String enc) Normalize the encoding names.voidsetDifference(int index, String difference) Sets a new value in the differences array.
-
Field Details
-
FONT_SPECIFIC
- See Also:
-
NOTDEF
A not defined character in a custom PDF encoding.- See Also:
-
baseEncoding
Base font encoding. -
fontSpecific
protected boolean fontSpecifictrueif the font must use its built in encoding. In that case theencodingis only used to map a char to the position inside the font, not to the expected char name. -
unicodeToCode
protected com.itextpdf.io.util.IntHashtable unicodeToCodeMapping map from unicode to simple code according to the encoding. -
codeToUnicode
protected int[] codeToUnicode -
differences
Encoding names. -
unicodeDifferences
protected com.itextpdf.io.util.IntHashtable unicodeDifferencesEncodings unicode differences
-
-
Constructor Details
-
FontEncoding
protected FontEncoding()
-
-
Method Details
-
createFontEncoding
-
createEmptyFontEncoding
-
createFontSpecificEncoding
This encoding will base on font encoding (FontSpecific encoding in Type 1 terminology)- Returns:
- created font specific encoding
-
fillFontEncoding
FillFontEncodingobject with default data.- Parameters:
-
encoding-FontEncodingto fill.
-
getBaseEncoding
-
isFontSpecific
public boolean isFontSpecific() -
addSymbol
public boolean addSymbol(int code, int unicode) -
getUnicode
public int getUnicode(int index) Gets unicode value for corresponding font's char code.- Parameters:
-
index- font's char code - Returns:
- -1, if the char code unsupported or valid unicode.
-
getUnicodeDifference
public int getUnicodeDifference(int index) -
hasDifferences
public boolean hasDifferences() -
getDifference
-
setDifference
Sets a new value in the differences array. Seedifferences.- Parameters:
-
index- position to replace -
difference- new difference value
-
convertToBytes
Converts aStringto abytearray according to the encoding. String could contain a unicode symbols or font specific codes.- Parameters:
-
text- theStringto be converted. - Returns:
-
an array of
byterepresenting the conversion according to the encoding
-
convertToByte
public int convertToByte(int unicode) Converts a unicode symbol or font specific code tobyteaccording to the encoding.- Parameters:
-
unicode- a unicode symbol or FontSpecif code to be converted. - Returns:
-
a
byterepresenting the conversion according to the encoding
-
canEncode
public boolean canEncode(int unicode) Check whether a unicode symbol or font specific code can be converted tobyteaccording to the encoding.- Parameters:
-
unicode- a unicode symbol or font specific code to be checked. - Returns:
-
trueifchcould be encoded.
-
canDecode
public boolean canDecode(int code) Check whether abytecode can be converted to unicode symbol according to the encoding.- Parameters:
-
code- a byte code to be checked. - Returns:
-
trueifcodecould be decoded.
-
isBuiltWith
Checks whether theFontEncodingwas built with corresponding encoding.- Parameters:
-
encoding- an encoding - Returns:
- true, if the FontEncoding was built with the encoding. Otherwise false.
-
fillCustomEncoding
protected void fillCustomEncoding() -
fillNamedEncoding
protected void fillNamedEncoding() -
fillStandardEncoding
protected void fillStandardEncoding() -
normalizeEncoding
Normalize the encoding names. "winansi" is changed to "Cp1252" and "macroman" is changed to "MacRoman".- Parameters:
-
enc- the encoding to be normalized - Returns:
- the normalized encoding
-