class TrueTypeFontUnicode extends TrueTypeFont implements java.util.Comparator
TrueTypeFont.FontHeader, TrueTypeFont.HorizontalHeader, TrueTypeFont.WindowsMetricsBaseFont.StreamFont| Modifier and Type | Field and Description |
|---|---|
(package private) java.util.HashMap |
inverseCmap |
private static byte[] |
rotbits |
(package private) boolean |
vertical
true if the encoding is vertical. |
allNameEntries, bboxes, cff, cffLength, cffOffset, cmap10, cmap31, cmapExt, codePages, directoryOffset, familyName, fileName, fontName, fullName, GlyphWidths, head, hhea, isFixedPitch, italicAngle, justNames, kerning, os_2, rf, style, tables, ttcIndex, underlinePosition, underlineThicknessASCENT, 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, widths, WINANSI, ZAPFDINGBATS| Constructor and Description |
|---|
TrueTypeFontUnicode(java.lang.String ttFile,
java.lang.String enc,
boolean emb,
byte[] ttfAfm,
boolean forceRead)
Creates a new TrueType font addressed by Unicode characters.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
charExists(int c)
Checks if a character exists in this font.
|
int |
compare(java.lang.Object o1,
java.lang.Object o2)
The method used to sort the metrics array.
|
(package private) byte[] |
convertToBytes(int char1)
Converts a
char to a byte array according
to the font's encoding. |
(package private) byte[] |
convertToBytes(java.lang.String text)
A forbidden operation.
|
private java.lang.Object[] |
filterCmapMetrics(java.lang.Object[] metrics) |
protected java.lang.Integer |
getCharacterCode(int code) |
int[] |
getCharBBox(int c)
Gets the smallest box enclosing the character contours.
|
private PdfDictionary |
getCIDFontType2(PdfIndirectReference fontDescriptor,
java.lang.String subsetPrefix,
java.lang.Object[] metrics)
Generates the CIDFontTyte2 dictionary.
|
private PdfDictionary |
getFontBaseType(PdfIndirectReference descendant,
java.lang.String subsetPrefix,
PdfIndirectReference toUnicode)
Generates the font dictionary.
|
PdfStream |
getFullFontStream()
Returns a PdfStream object with the full font program.
|
int[] |
getMetricsTT(int c)
Gets the glyph index and metrics for a character.
|
private PdfStream |
getToUnicode(java.lang.Object[] metrics)
Creates a ToUnicode CMap to allow copy and paste from Acrobat.
|
int |
getWidth(int char1)
Gets the width of a
char in normalized 1000 units. |
int |
getWidth(java.lang.String text)
Gets the width of a
String in normalized 1000 units. |
(package private) void |
readCMaps()
Reads the several maps from the table 'cmap'.
|
boolean |
setCharAdvance(int c,
int advance)
Sets the character advance.
|
(package private) static java.lang.String |
toHex(int n)
Gets an hex string in the format "<HHHH>".
|
private static java.lang.String |
toHex4(int n) |
(package private) void |
writeFont(PdfWriter writer,
PdfIndirectReference ref,
java.lang.Object[] params)
Outputs to the writer the font dictionaries and streams.
|
addRangeUni, checkCff, compactRanges, fillTables, getAllNameEntries, getAllNames, getBaseFont, getCodePagesSupported, getFamilyFontName, getFontBaseType, getFontDescriptor, getFontDescriptor, getFullFont, getFullFontName, getGlyphWidth, getKerning, getNames, getPostscriptFontName, getRawCharBBox, getRawWidth, getTTCName, hasKernPairs, process, readCffFont, readFormat0, readFormat12, readFormat4, readFormat6, readGlyphWidths, readKerning, readStandardString, readUnicodeString, setKerning, setPostscriptFontNameaddSubsetRange, correctArabicAdvance, createEncoding, createFont, createFont, createFont, createFont, createFont, createFont, createFont, createSubsetPrefix, enumerateTTCNames, enumerateTTCNames, getAllFontNames, getAllNameEntries, getAscent, getAscentPoint, getBaseName, getCidCode, getCompressionLevel, getDescent, getDescentPoint, getDifferences, getDocumentFonts, getDocumentFonts, getEncoding, getFontType, getFullFontName, getResourceStream, getResourceStream, getUnicodeDifferences, getUnicodeDifferences, getUnicodeEquivalent, getWidthPoint, getWidthPoint, getWidthPointKerned, getWidths, isDirectTextToByte, isEmbedded, isFontSpecific, isForceWidthsOutput, isSubset, normalizeEncoding, setCompressionLevel, setDirectTextToByte, setForceWidthsOutput, setSubsetboolean vertical
true if the encoding is vertical.java.util.HashMap inverseCmap
private static final byte[] rotbits
TrueTypeFontUnicode(java.lang.String ttFile,
java.lang.String enc,
boolean emb,
byte[] ttfAfm,
boolean forceRead)
throws DocumentException,
java.io.IOException
ttFile - the location of the font on file. The file must end in '.ttf'.
The modifiers after the name are ignored.enc - the encoding to be applied to this fontemb - true if the font is to be embedded in the PDFttfAfm - the font as a byte arrayDocumentException - the font is invalidjava.io.IOException - the font file could not be readvoid readCMaps()
throws DocumentException,
java.io.IOException
TrueTypeFontreadCMaps in class TrueTypeFontDocumentException - the font is invalidjava.io.IOException - the font file could not be readprotected java.lang.Integer getCharacterCode(int code)
public int getWidth(int char1)
char in normalized 1000 units.public int getWidth(java.lang.String text)
String in normalized 1000 units.private PdfStream getToUnicode(java.lang.Object[] metrics)
metrics - metrics[0] contains the glyph index and metrics[2]
contains the Unicode codenullprivate java.lang.Object[] filterCmapMetrics(java.lang.Object[] metrics)
private static java.lang.String toHex4(int n)
static java.lang.String toHex(int n)
n - the numberprivate PdfDictionary getCIDFontType2(PdfIndirectReference fontDescriptor, java.lang.String subsetPrefix, java.lang.Object[] metrics)
fontDescriptor - the indirect reference to the font descriptorsubsetPrefix - the subset prefixmetrics - the horizontal width metricsprivate PdfDictionary getFontBaseType(PdfIndirectReference descendant, java.lang.String subsetPrefix, PdfIndirectReference toUnicode)
descendant - the descendant dictionarysubsetPrefix - the subset prefixtoUnicode - the ToUnicode streampublic int compare(java.lang.Object o1,
java.lang.Object o2)
compare in interface java.util.Comparatoro1 - the first elemento2 - the second elementvoid writeFont(PdfWriter writer, PdfIndirectReference ref, java.lang.Object[] params) throws DocumentException, java.io.IOException
writeFont in class TrueTypeFontwriter - the writer for this documentref - the font indirect referenceparams - several parameters that depend on the font typejava.io.IOException - on errorDocumentException - error in generating the objectpublic PdfStream getFullFontStream() throws java.io.IOException, DocumentException
getFullFontStream in class TrueTypeFontjava.io.IOExceptionDocumentExceptionbyte[] convertToBytes(java.lang.String text)
convertToBytes in class BaseFonttext - the textnullbyte[] convertToBytes(int char1)
BaseFontchar to a byte array according
to the font's encoding.convertToBytes in class BaseFontchar1 - the char to be convertedbyte representing the conversion according to the font's encodingpublic int[] getMetricsTT(int c)
getMetricsTT in class TrueTypeFontc - the characterint array with {glyph index, width}public boolean charExists(int c)
charExists in class BaseFontc - the character to checktrue if the character has a glyph,
false otherwisepublic boolean setCharAdvance(int c,
int advance)
setCharAdvance in class BaseFontc - the characteradvance - the character advance normalized to 1000 unitstrue if the advance was set,
false otherwisepublic int[] getCharBBox(int c)
BaseFontnull if the font has not the information or the character has no
contours, as in the case of the space, for example. Characters with no contours may
also return [0,0,0,0].getCharBBox in class BaseFontc - the character to get the contour bounding box fromnull