Package com.itextpdf.io.font
Class FontEncoding
java.lang.Object
com.itextpdf.io.font.FontEncoding
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
Base font encoding.protected int[]
protected String[]
Encoding names.static final String
protected boolean
true
if the font must use its built in encoding.static final String
A not defined character in a custom PDF encoding.protected com.itextpdf.io.util.IntHashtable
Encodings unicode differencesprotected com.itextpdf.io.util.IntHashtable
Mapping map from unicode to simple code according to the encoding. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addSymbol
(int code, int unicode) boolean
canDecode
(int code) Check whether abyte
code can be converted to unicode symbol according to the encoding.boolean
canEncode
(int unicode) Check whether a unicode symbol or font specific code can be converted tobyte
according to the encoding.int
convertToByte
(int unicode) Converts a unicode symbol or font specific code tobyte
according to the encoding.byte[]
convertToBytes
(String text) Converts aString
to abyte
array according to the encoding.static FontEncoding
static FontEncoding
createFontEncoding
(String baseEncoding) static FontEncoding
This encoding will base on font encoding (FontSpecific encoding in Type 1 terminology)protected void
protected void
protected void
getDifference
(int index) int
getUnicode
(int index) Gets unicode value for corresponding font's char code.int
getUnicodeDifference
(int index) boolean
boolean
isBuiltWith
(String encoding) Checks whether theFontEncoding
was built with corresponding encoding.boolean
protected static String
normalizeEncoding
(String enc) Normalize the encoding names.void
setDifference
(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 fontSpecifictrue
if the font must use its built in encoding. In that case theencoding
is 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
-
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 aString
to abyte
array according to the encoding. String could contain a unicode symbols or font specific codes.- Parameters:
-
text
- theString
to be converted. - Returns:
-
an array of
byte
representing the conversion according to the encoding
-
convertToByte
public int convertToByte(int unicode) Converts a unicode symbol or font specific code tobyte
according to the encoding.- Parameters:
-
unicode
- a unicode symbol or FontSpecif code to be converted. - Returns:
-
a
byte
representing the conversion according to the encoding
-
canEncode
public boolean canEncode(int unicode) Check whether a unicode symbol or font specific code can be converted tobyte
according to the encoding.- Parameters:
-
unicode
- a unicode symbol or font specific code to be checked. - Returns:
-
true
ifch
could be encoded.
-
canDecode
public boolean canDecode(int code) Check whether abyte
code can be converted to unicode symbol according to the encoding.- Parameters:
-
code
- a byte code to be checked. - Returns:
-
true
ifcode
could be decoded.
-
isBuiltWith
Checks whether theFontEncoding
was 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
-