public class CMapAwareDocumentFont extends DocumentFont
BaseFont.StreamFont
Modifier and Type | Field and Description |
---|---|
private char[] |
cidbyte2uni
Mapping between CID code (single byte only for now) and unicode equivalent
as derived by the font's encoding.
|
private PdfDictionary |
fontDic
The font dictionary.
|
private int |
spaceWidth
the width of a space for this font, in normalized 1000 point units
|
private CMap |
toUnicodeCmap
The CMap constructed from the ToUnicode map from the font's dictionary, if present.
|
ASCENT, AWT_ASCENT, AWT_DESCENT, AWT_LEADING, AWT_MAXADVANCE, BBOXLLX, BBOXLLY, BBOXURX, BBOXURY, BuiltinFonts14, CACHED, CAPHEIGHT, CHAR_RANGE_ARABIC, CHAR_RANGE_CYRILLIC, CHAR_RANGE_HEBREW, CHAR_RANGE_LATIN, charBBoxes, CID_NEWLINE, compressionLevel, COURIER, COURIER_BOLD, COURIER_BOLDOBLIQUE, COURIER_OBLIQUE, CP1250, CP1252, CP1257, DESCENT, differences, directTextToByte, embedded, EMBEDDED, encoding, fastWinansi, FONT_TYPE_CJK, FONT_TYPE_DOCUMENT, FONT_TYPE_T1, FONT_TYPE_T3, FONT_TYPE_TT, FONT_TYPE_TTUNI, fontCache, fontSpecific, fontType, forceWidthsOutput, HELVETICA, HELVETICA_BOLD, HELVETICA_BOLDOBLIQUE, HELVETICA_OBLIQUE, IDENTITY_H, IDENTITY_V, ITALICANGLE, MACROMAN, NOT_CACHED, NOT_EMBEDDED, notdef, RESOURCE_PATH, specialMap, STRIKETHROUGH_POSITION, STRIKETHROUGH_THICKNESS, SUBSCRIPT_OFFSET, SUBSCRIPT_SIZE, subset, subsetRanges, SUPERSCRIPT_OFFSET, SUPERSCRIPT_SIZE, SYMBOL, TIMES_BOLD, TIMES_BOLDITALIC, TIMES_ITALIC, TIMES_ROMAN, UNDERLINE_POSITION, UNDERLINE_THICKNESS, unicodeDifferences, WEIGHT_CLASS, WIDTH_CLASS, widths, WINANSI, ZAPFDINGBATS
Constructor and Description |
---|
CMapAwareDocumentFont(PRIndirectReference refFont)
Creates an instance of a CMapAwareFont based on an indirect reference to a font.
|
Modifier and Type | Method and Description |
---|---|
private int |
computeAverageWidth()
For all widths of all glyphs, compute the average width in normalized 1000 point units.
|
String |
decode(byte[] cidbytes,
int offset,
int len)
Decodes a string of bytes (encoded in the font's encoding) into a unicode string
This will use the ToUnicode map of the font, if available, otherwise it uses
the font's encoding
|
private String |
decodeSingleCID(byte[] bytes,
int offset,
int len)
Decodes a single CID (represented by one or two bytes) to a unicode String.
|
String |
encode(byte[] bytes,
int offset,
int len)
Deprecated.
method name is not indicative of what it does. Use
decode instead. |
int |
getWidth(int char1)
Gets the width of a
char in normalized 1000 units. |
private void |
processToUnicode()
Parses the ToUnicode entry, if present, and constructs a CMap for it
|
private void |
processUni2Byte()
Inverts DocumentFont's uni2byte mapping to obtain a cid-to-unicode mapping based
on the font's encoding
|
charExists, convertToBytes, convertToBytes, getAllNameEntries, getCharBBox, getDiffmap, getFamilyFontName, getFontDescriptor, getFullFontName, getFullFontStream, getIndirectReference, getKerning, getPostscriptFontName, getRawCharBBox, getRawWidth, getUni2Byte, getWidth, hasKernPairs, setKerning, setPostscriptFontName, writeFont
addSubsetRange, correctArabicAdvance, createEncoding, createFont, createFont, createFont, createFont, createFont, createFont, createFont, createSubsetPrefix, enumerateTTCNames, enumerateTTCNames, getAllFontNames, getAllNameEntries, getAscent, getAscentPoint, getBaseName, getCidCode, getCodePagesSupported, getCompressionLevel, getDescent, getDescentPoint, getDifferences, getDocumentFonts, getDocumentFonts, getEncoding, getFontType, getFullFontName, getResourceStream, getResourceStream, getUnicodeDifferences, getUnicodeDifferences, getUnicodeEquivalent, getWidthPoint, getWidthPoint, getWidthPointKerned, getWidths, isDirectTextToByte, isEmbedded, isFontSpecific, isForceWidthsOutput, isSubset, normalizeEncoding, setCharAdvance, setCompressionLevel, setDirectTextToByte, setForceWidthsOutput, setSubset
private PdfDictionary fontDic
private int spaceWidth
private CMap toUnicodeCmap
private char[] cidbyte2uni
public CMapAwareDocumentFont(PRIndirectReference refFont)
refFont
- the indirect reference to a fontprivate void processToUnicode()
private void processUni2Byte()
private int computeAverageWidth()
public int getWidth(int char1)
DocumentFont
char
in normalized 1000 units.getWidth
in class DocumentFont
char1
- the unicode char
to get the width ofDocumentFont.getWidth(int)
private String decodeSingleCID(byte[] bytes, int offset, int len)
bytes
- the bytes making up the character code to convertoffset
- an offsetlen
- a lengthpublic String decode(byte[] cidbytes, int offset, int len)
cidbytes
- the bytes that need to be decodedpublic String encode(byte[] bytes, int offset, int len)
decode
instead.bytes
- the bytes from a streamoffset
- an offsetlen
- a lengthWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses