public class FontEncoding extends Object
Modifier and Type | Field and Description |
---|---|
protected String |
baseEncoding
Base font encoding.
|
protected int[] |
codeToUnicode |
protected String[] |
differences
Encoding names.
|
static String |
FONT_SPECIFIC |
protected boolean |
fontSpecific
true if the font must use its built in encoding.
|
static String |
NOTDEF
A not defined character in a custom PDF encoding.
|
protected com.itextpdf.io.util.IntHashtable |
unicodeDifferences
Encodings unicode differences
|
protected com.itextpdf.io.util.IntHashtable |
unicodeToCode
Mapping map from unicode to simple code according to the encoding.
|
Modifier | Constructor and Description |
---|---|
protected |
FontEncoding() |
Modifier and Type | Method and Description |
---|---|
boolean |
addSymbol(int code, int unicode) |
boolean |
canDecode(int code)
Check whether a byte 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 to byte according to the encoding.
|
int |
convertToByte(int unicode)
Converts a unicode symbol or font specific code to byte according to the encoding.
|
byte[] |
convertToBytes(String text)
Converts a String to a byte array according to the encoding.
|
static FontEncoding |
createEmptyFontEncoding() |
static FontEncoding |
createFontEncoding(String baseEncoding) |
static FontEncoding |
createFontSpecificEncoding()
This encoding will base on font encoding (FontSpecific encoding in Type 1 terminology)
|
protected void |
fillCustomEncoding() |
protected void |
fillNamedEncoding() |
protected void |
fillStandardEncoding() |
String |
getBaseEncoding() |
String |
getDifference(int index) |
int |
getUnicode(int index)
Gets unicode value for corresponding font's char code.
|
int |
getUnicodeDifference(int index) |
boolean |
hasDifferences() |
boolean |
isBuiltWith(String encoding)
Checks whether the FontEncoding was built with corresponding encoding.
|
boolean |
isFontSpecific() |
protected static String |
normalizeEncoding(String enc)
Normalize the encoding names.
|
void |
setDifference(int index, String difference)
Sets a new value in the differences array.
|
public static final String FONT_SPECIFIC
public static final String NOTDEF
protected String baseEncoding
protected boolean fontSpecific
true
if the font must use its built in encoding. In that case the encoding
is only used to map a char to the position inside the font, not to the expected char name.
protected com.itextpdf.io.util.IntHashtable unicodeToCode
protected int[] codeToUnicode
protected String[] differences
protected com.itextpdf.io.util.IntHashtable unicodeDifferences
public static FontEncoding createFontEncoding(String baseEncoding)
public static FontEncoding createEmptyFontEncoding()
public static FontEncoding createFontSpecificEncoding()
public String getBaseEncoding()
public boolean isFontSpecific()
public boolean addSymbol(int code, int unicode)
public int getUnicode(int index)
index
- font's char code
public int getUnicodeDifference(int index)
public boolean hasDifferences()
public String getDifference(int index)
public void setDifference(int index, String difference)
differences
.
index
- position to replace
difference
- new difference value
public byte[] convertToBytes(String text)
String
to a byte
array according to the encoding. String could contain a unicode symbols or font specific codes.
text
- the String
to be converted.
byte
representing the conversion according to the encoding
public int convertToByte(int unicode)
byte
according to the encoding.
unicode
- a unicode symbol or FontSpecif code to be converted.
byte
representing the conversion according to the encoding
public boolean canEncode(int unicode)
byte
according to the encoding.
unicode
- a unicode symbol or font specific code to be checked.
true
if ch
could be encoded.
public boolean canDecode(int code)
byte
code can be converted to unicode symbol according to the encoding.
code
- a byte code to be checked.
true
if code
could be decoded.
public boolean isBuiltWith(String encoding)
FontEncoding
was built with corresponding encoding.
encoding
- an encoding
protected void fillCustomEncoding()
protected void fillNamedEncoding()
protected void fillStandardEncoding()
Copyright © 1998–2022 iText Group NV. All rights reserved.