Class BaseFont
java.lang.Object
com.gitlab.pdftk_java.com.lowagie.text.pdf.BaseFont
- Direct Known Subclasses:
CJKFont, DocumentFont, TrueTypeFont, Type1Font
Base class for the several font types supported
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classGenerates the PDF stream with the Type1 and Truetype fonts returning a PdfStream. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe maximum height above the baseline reached by glyphs in this font, excluding the height of glyphs for accented characters.static final intjava.awt.Font propertystatic final intjava.awt.Font propertystatic final intjava.awt.Font propertystatic final intjava.awt.Font propertystatic final intThe lower left x glyph coordinate.static final intThe lower left y glyph coordinate.static final intThe upper right x glyph coordinate.static final intThe upper right y glyph coordinate.protected static final HashMaplist of the 14 built in fonts.static final booleanif the font has to be cachedstatic final intThe y coordinate of the top of flat capital letters, measured from the baseline.protected int[][]static final charThe fake CID code that represents a newline.static final StringThis is a possible value of a base 14 type 1 fontstatic final StringThis is a possible value of a base 14 type 1 fontstatic final StringThis is a possible value of a base 14 type 1 fontstatic final StringThis is a possible value of a base 14 type 1 fontstatic final StringA possible encoding.static final StringA possible encoding.static final StringA possible encoding.static final intThe maximum depth below the baseline reached by glyphs in this font.protected String[]encoding namesprotected booleanConvertschardirectly tobyteby casting.protected booleantrue if the font is to be embedded in the PDFstatic final booleanif the font has to be embeddedprotected Stringencoding used with this fontprotected booleanstatic final intThe font is CJK.static final intA font already inside the document.static final intThe font is Type 1.static final intA Type3 font.static final intThe font is True Type with a standard encoding.static final intThe font is True Type with a Unicode encoding.protected static HashMapcache for the fonts already used.protected booleantrue if the font must use it's built in encoding.(package private) intThe font type.protected booleanForces the output of the width array.static final StringThis is a possible value of a base 14 type 1 fontstatic final StringThis is a possible value of a base 14 type 1 fontstatic final StringThis is a possible value of a base 14 type 1 fontstatic final StringThis is a possible value of a base 14 type 1 fontstatic final StringThe Unicode encoding with horizontal writing.static final StringThe Unicode encoding with vertical writing.static final intThe angle, expressed in degrees counterclockwise from the vertical, of the dominant vertical strokes of the font.static final StringA possible encoding.static final booleanif the font doesn't have to be cachedstatic final booleanif the font doesn't have to be embeddedstatic final Stringa not defined character in a custom PDF encodingstatic final StringThe path to the font resources.protected booleanIndicates if all the glyphs and widths for that particular encoding should be included in the document.static final StringThis is a possible value of a base 14 type 1 fontstatic final StringThis is a possible value of a base 14 type 1 fontstatic final StringThis is a possible value of a base 14 type 1 fontstatic final StringThis is a possible value of a base 14 type 1 fontstatic final StringThis is a possible value of a base 14 type 1 fontprotected char[]same as differences but with the unicode codesprotected int[]table of characters widths for this encodingstatic final StringA possible encoding.static final StringThis is a possible value of a base 14 type 1 font -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddFont(PRIndirectReference fontRef, IntHashtable hits, ArrayList fonts) booleancharExists(char c) Checks if a character exists in this font.(package private) byte[]convertToBytes(String text) Converts aStringto a byte array according to the font's encoding.voidiText expects Arabic Diactrics (tashkeel) to have zero advance but some fonts, most notably those that come with Windows, like times.ttf, have non-zero advance for those characters.protected voidCreates thewidthsand thedifferencesarraysstatic BaseFontcreateFont(PRIndirectReference fontRef) Creates a font based on an existing document font.static BaseFontcreateFont(String name, String encoding, boolean embedded) Creates a new font.static BaseFontcreateFont(String name, String encoding, boolean embedded, boolean cached, byte[] ttfAfm, byte[] pfb) Creates a new font.static StringCreates a unique subset prefix to be added to the font name when the font is embedded and subset.static String[]enumerateTTCNames(byte[] ttcArray) Enumerates the postscript font names present inside a True Type Collection.static String[]enumerateTTCNames(String ttcFile) Enumerates the postscript font names present inside a True Type Collection.static Object[]getAllFontNames(String name, String encoding, byte[] ttfAfm) Gets all the names from the font.intGets the ascent of aStringin normalized 1000 units.floatgetAscentPoint(String text, float fontSize) Gets the ascent of aStringin points.protected static StringgetBaseName(String name) Gets the name without the modifiers Bold, Italic or BoldItalic.int[]getCharBBox(char c) Gets the smallest box enclosing the character contours.chargetCidCode(char c) Gets the CID code given an Unicode.String[]Gets the code pages supported by the font.intgetDescent(String text) Gets the descent of aStringin normalized 1000 units.floatgetDescentPoint(String text, float fontSize) Gets the descent of aStringin points.String[]Gets the array with the names of the characters.static ArrayListgetDocumentFonts(PdfReader reader) Gets a list of all document fonts.static ArrayListgetDocumentFonts(PdfReader reader, int page) Gets a list of the document fonts in a particular page.Gets the encoding used to convertStringintobyte[].abstract String[][]Gets the family name of the font.abstract floatgetFontDescriptor(int key, float fontSize) Gets the font parameter identified bykey.intGets the font type.abstract String[][]Gets the full name of the font.static String[][]getFullFontName(String name, String encoding, byte[] ttfAfm) Gets the full name of the font.abstract intgetKerning(char char1, char char2) Gets the kerning between two Unicode chars.abstract StringGets the postscript font name.protected abstract int[]getRawCharBBox(int c, String name) (package private) abstract intgetRawWidth(int c, String name) Gets the width from the font according to the Unicode charcor thename.static InputStreamgetResourceStream(String key) Gets the font resources.static InputStreamgetResourceStream(String key, ClassLoader loader) Gets the font resources.char[]Gets the array with the unicode characters.(package private) chargetUnicodeDifferences(int index) Gets the Unicode character corresponding to the byte output to the pdf stream.chargetUnicodeEquivalent(char c) Gets the Unicode equivalent to a CID.intgetWidth(char char1) Gets the width of acharin normalized 1000 units.intGets the width of aStringin normalized 1000 units.floatgetWidthPoint(char char1, float fontSize) Gets the width of acharin points.floatgetWidthPoint(String text, float fontSize) Gets the width of aStringin points.floatgetWidthPointKerned(String text, float fontSize) Gets the width of aStringin points taking kerning into account.int[]Gets the font width array.abstract booleanChecks if the font has any kerning pairs.booleanGets the direct conversion ofchartobyte.booleanGets the embedded flag.booleanGets the symbolic flag of the font.booleanGets the state of the property.booleanisSubset()Indicates if all the glyphs and widths for that particular encoding should be included in the document.protected static StringnormalizeEncoding(String enc) Normalize the encoding names.private static voidrecourseFonts(PdfDictionary page, IntHashtable hits, ArrayList fonts, int level) booleansetCharAdvance(char c, int advance) Sets the character advance.voidsetDirectTextToByte(boolean directTextToByte) Sets the conversion ofchardirectly tobyteby casting.voidsetForceWidthsOutput(boolean forceWidthsOutput) Set totrueto force the generation of the widths array.abstract booleansetKerning(char char1, char char2, int kern) Sets the kerning between two Unicode chars.abstract voidsetPostscriptFontName(String name) Sets the font name that will appear in the pdf font dictionary.voidsetSubset(boolean subset) Indicates if all the glyphs and widths for that particular encoding should be included in the document.(package private) abstract voidwriteFont(PdfWriter writer, PdfIndirectReference ref, Object[] params) Outputs to the writer the font dictionaries and streams.
-
Field Details
-
COURIER
-
COURIER_BOLD
-
COURIER_OBLIQUE
This is a possible value of a base 14 type 1 font- See Also:
-
COURIER_BOLDOBLIQUE
This is a possible value of a base 14 type 1 font- See Also:
-
HELVETICA
-
HELVETICA_BOLD
This is a possible value of a base 14 type 1 font- See Also:
-
HELVETICA_OBLIQUE
This is a possible value of a base 14 type 1 font- See Also:
-
HELVETICA_BOLDOBLIQUE
This is a possible value of a base 14 type 1 font- See Also:
-
SYMBOL
-
TIMES_ROMAN
-
TIMES_BOLD
-
TIMES_ITALIC
-
TIMES_BOLDITALIC
This is a possible value of a base 14 type 1 font- See Also:
-
ZAPFDINGBATS
-
ASCENT
public static final int ASCENTThe maximum height above the baseline reached by glyphs in this font, excluding the height of glyphs for accented characters.- See Also:
-
CAPHEIGHT
public static final int CAPHEIGHTThe y coordinate of the top of flat capital letters, measured from the baseline.- See Also:
-
DESCENT
public static final int DESCENTThe maximum depth below the baseline reached by glyphs in this font. The value is a negative number.- See Also:
-
ITALICANGLE
public static final int ITALICANGLEThe angle, expressed in degrees counterclockwise from the vertical, of the dominant vertical strokes of the font. The value is negative for fonts that slope to the right, as almost all italic fonts do.- See Also:
-
BBOXLLX
public static final int BBOXLLXThe lower left x glyph coordinate.- See Also:
-
BBOXLLY
public static final int BBOXLLYThe lower left y glyph coordinate.- See Also:
-
BBOXURX
public static final int BBOXURXThe upper right x glyph coordinate.- See Also:
-
BBOXURY
public static final int BBOXURYThe upper right y glyph coordinate.- See Also:
-
AWT_ASCENT
public static final int AWT_ASCENTjava.awt.Font property- See Also:
-
AWT_DESCENT
public static final int AWT_DESCENTjava.awt.Font property- See Also:
-
AWT_LEADING
public static final int AWT_LEADINGjava.awt.Font property- See Also:
-
AWT_MAXADVANCE
public static final int AWT_MAXADVANCEjava.awt.Font property- See Also:
-
FONT_TYPE_T1
public static final int FONT_TYPE_T1The font is Type 1.- See Also:
-
FONT_TYPE_TT
public static final int FONT_TYPE_TTThe font is True Type with a standard encoding.- See Also:
-
FONT_TYPE_CJK
public static final int FONT_TYPE_CJKThe font is CJK.- See Also:
-
FONT_TYPE_TTUNI
public static final int FONT_TYPE_TTUNIThe font is True Type with a Unicode encoding.- See Also:
-
FONT_TYPE_DOCUMENT
public static final int FONT_TYPE_DOCUMENTA font already inside the document.- See Also:
-
FONT_TYPE_T3
public static final int FONT_TYPE_T3A Type3 font.- See Also:
-
IDENTITY_H
-
IDENTITY_V
-
CP1250
-
CP1252
-
CP1257
-
WINANSI
-
MACROMAN
-
EMBEDDED
public static final boolean EMBEDDEDif the font has to be embedded- See Also:
-
NOT_EMBEDDED
public static final boolean NOT_EMBEDDEDif the font doesn't have to be embedded- See Also:
-
CACHED
public static final boolean CACHEDif the font has to be cached- See Also:
-
NOT_CACHED
public static final boolean NOT_CACHEDif the font doesn't have to be cached- See Also:
-
RESOURCE_PATH
-
CID_NEWLINE
public static final char CID_NEWLINEThe fake CID code that represents a newline.- See Also:
-
fontType
int fontTypeThe font type. -
notdef
-
widths
protected int[] widthstable of characters widths for this encoding -
differences
encoding names -
unicodeDifferences
protected char[] unicodeDifferencessame as differences but with the unicode codes -
charBBoxes
protected int[][] charBBoxes -
encoding
encoding used with this font -
embedded
protected boolean embeddedtrue if the font is to be embedded in the PDF -
fontSpecific
protected boolean fontSpecifictrue if the font must use it's 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. -
fontCache
cache for the fonts already used. -
BuiltinFonts14
list of the 14 built in fonts. -
forceWidthsOutput
protected boolean forceWidthsOutputForces the output of the width array. Only matters for the 14 built-in fonts. -
directTextToByte
protected boolean directTextToByteConvertschardirectly tobyteby casting. -
subset
protected boolean subsetIndicates if all the glyphs and widths for that particular encoding should be included in the document. -
fastWinansi
protected boolean fastWinansi
-
-
Constructor Details
-
BaseFont
protected BaseFont()Creates new BaseFont
-
-
Method Details
-
createFont
public static BaseFont createFont(String name, String encoding, boolean embedded) throws DocumentException, IOException Creates a new font. This font can be one of the 14 built in types, a Type1 font referred by an AFM file, a TrueType font (simple or collection) or a CJK font from the Adobe Asian Font Pack. TrueType fonts and CJK fonts can have an optional style modifier appended to the name. These modifiers are: Bold, Italic and BoldItalic. An example would be "STSong-Light,Bold". Note that this modifiers do not work if the font is embedded. Fonts in TrueType collections are addressed by index such as "msgothic.ttc,1". This would get the second font (indexes start at 0), in this case "MS PGothic".The fonts are cached and if they already exist they are extracted from the cache, not parsed again.
This method calls:
createFont(name, encoding, embedded, true, null, null);
- Parameters:
name- the name of the font or it's location on fileencoding- the encoding to be applied to this fontembedded- true if the font is to be embedded in the PDF- Returns:
- returns a new font. This font may come from the cache
- Throws:
DocumentException- the font is invalidIOException- the font file could not be read
-
createFont
public static BaseFont createFont(String name, String encoding, boolean embedded, boolean cached, byte[] ttfAfm, byte[] pfb) throws DocumentException, IOException Creates a new font. This font can be one of the 14 built in types, a Type1 font referred by an AFM file, a TrueType font (simple or collection) or a CJK font from the Adobe Asian Font Pack. TrueType fonts and CJK fonts can have an optional style modifier appended to the name. These modifiers are: Bold, Italic and BoldItalic. An example would be "STSong-Light,Bold". Note that this modifiers do not work if the font is embedded. Fonts in TrueType collections are addressed by index such as "msgothic.ttc,1". This would get the second font (indexes start at 0), in this case "MS PGothic".The fonts may or may not be cached depending on the flag
cached. If thebytearrays are present the font will be read from them instead of the name. The name is still required to identify the font type.- Parameters:
name- the name of the font or it's location on fileencoding- the encoding to be applied to this fontembedded- true if the font is to be embedded in the PDFcached- true if the font comes from the cache or is added to the cache if new, false if the font is always created newttfAfm- the true type font or the afm in a byte arraypfb- the pfb in a byte array- Returns:
- returns a new font. This font may come from the cache but only if cached is true, otherwise it will always be created new
- Throws:
DocumentException- the font is invalidIOException- the font file could not be read
-
createFont
Creates a font based on an existing document font. The created font font may not behave as expected, depending on the encoding or subset.- Parameters:
fontRef- the reference to the document font- Returns:
- the font
-
getBaseName
-
normalizeEncoding
-
createEncoding
protected void createEncoding()Creates thewidthsand thedifferencesarrays -
getRawWidth
Gets the width from the font according to the Unicode charcor thename. If thenameis null it's a symbolic font.- Parameters:
c- the unicode charname- the glyph name- Returns:
- the width of the char
-
getKerning
public abstract int getKerning(char char1, char char2) Gets the kerning between two Unicode chars.- Parameters:
char1- the first charchar2- the second char- Returns:
- the kerning to be applied in normalized 1000 units
-
setKerning
public abstract boolean setKerning(char char1, char char2, int kern) Sets the kerning between two Unicode chars.- Parameters:
char1- the first charchar2- the second charkern- the kerning to apply in normalized 1000 units- Returns:
trueif the kerning was applied,falseotherwise
-
getWidth
public int getWidth(char char1) Gets the width of acharin normalized 1000 units.- Parameters:
char1- the unicodecharto get the width of- Returns:
- the width in normalized 1000 units
-
getWidth
Gets the width of aStringin normalized 1000 units.- Parameters:
text- theStringto get the witdth of- Returns:
- the width in normalized 1000 units
-
getDescent
Gets the descent of aStringin normalized 1000 units. The descent will always be less than or equal to zero even if all the characters have an higher descent.- Parameters:
text- theStringto get the descent of- Returns:
- the dexcent in normalized 1000 units
-
getAscent
Gets the ascent of aStringin normalized 1000 units. The ascent will always be greater than or equal to zero even if all the characters have a lower ascent.- Parameters:
text- theStringto get the ascent of- Returns:
- the ascent in normalized 1000 units
-
getDescentPoint
Gets the descent of aStringin points. The descent will always be less than or equal to zero even if all the characters have an higher descent.- Parameters:
text- theStringto get the descent offontSize- the size of the font- Returns:
- the dexcent in points
-
getAscentPoint
Gets the ascent of aStringin points. The ascent will always be greater than or equal to zero even if all the characters have a lower ascent.- Parameters:
text- theStringto get the ascent offontSize- the size of the font- Returns:
- the ascent in points
-
getWidthPointKerned
Gets the width of aStringin points taking kerning into account.- Parameters:
text- theStringto get the witdth offontSize- the font size- Returns:
- the width in points
-
getWidthPoint
Gets the width of aStringin points.- Parameters:
text- theStringto get the witdth offontSize- the font size- Returns:
- the width in points
-
getWidthPoint
public float getWidthPoint(char char1, float fontSize) Gets the width of acharin points.- Parameters:
char1- thecharto get the witdth offontSize- the font size- Returns:
- the width in points
-
convertToBytes
Converts aStringto a byte array according to the font's encoding.- Parameters:
text- theStringto be converted- Returns:
- an array of
byterepresenting the conversion according to the font's encoding
-
writeFont
abstract void writeFont(PdfWriter writer, PdfIndirectReference ref, Object[] params) throws DocumentException, IOException Outputs to the writer the font dictionaries and streams.- Parameters:
writer- the writer for this documentref- the font indirect referenceparams- several parameters that depend on the font type- Throws:
IOException- on errorDocumentException- error in generating the object
-
getEncoding
Gets the encoding used to convertStringintobyte[].- Returns:
- the encoding name
-
getFontDescriptor
public abstract float getFontDescriptor(int key, float fontSize) Gets the font parameter identified bykey. Valid values forkeyareASCENT,AWT_ASCENT,CAPHEIGHT,DESCENT,AWT_DESCENT,ITALICANGLE,BBOXLLX,BBOXLLY,BBOXURXandBBOXURY.- Parameters:
key- the parameter to be extractedfontSize- the font size in points- Returns:
- the parameter in points
-
getFontType
public int getFontType()Gets the font type. The font types can be: FONT_TYPE_T1, FONT_TYPE_TT, FONT_TYPE_CJK and FONT_TYPE_TTUNI.- Returns:
- the font type
-
isEmbedded
public boolean isEmbedded()Gets the embedded flag.- Returns:
trueif the font is embedded.
-
isFontSpecific
public boolean isFontSpecific()Gets the symbolic flag of the font.- Returns:
trueif the font is symbolic
-
createSubsetPrefix
Creates a unique subset prefix to be added to the font name when the font is embedded and subset.- Returns:
- the subset prefix
-
getUnicodeDifferences
char getUnicodeDifferences(int index) Gets the Unicode character corresponding to the byte output to the pdf stream.- Parameters:
index- the byte index- Returns:
- the Unicode character
-
getPostscriptFontName
Gets the postscript font name.- Returns:
- the postscript font name
-
setPostscriptFontName
Sets the font name that will appear in the pdf font dictionary. Use with care as it can easily make a font unreadable if not embedded.- Parameters:
name- the new font name
-
getFullFontName
Gets the full name of the font. If it is a True Type font each array element will have {Platform ID, Platform Encoding ID, Language ID, font name}. The interpretation of this values can be found in the Open Type specification, chapter 2, in the 'name' table.
For the other fonts the array has a single element with {"", "", "", font name}.- Returns:
- the full name of the font
-
getFullFontName
public static String[][] getFullFontName(String name, String encoding, byte[] ttfAfm) throws DocumentException, IOException Gets the full name of the font. If it is a True Type font each array element will have {Platform ID, Platform Encoding ID, Language ID, font name}. The interpretation of this values can be found in the Open Type specification, chapter 2, in the 'name' table.
For the other fonts the array has a single element with {"", "", "", font name}.- Parameters:
name- the name of the fontencoding- the encoding of the fontttfAfm- the true type font or the afm in a byte array- Returns:
- the full name of the font
- Throws:
DocumentException- on errorIOException- on error
-
getAllFontNames
public static Object[] getAllFontNames(String name, String encoding, byte[] ttfAfm) throws DocumentException, IOException Gets all the names from the font. Only the required tables are read.- Parameters:
name- the name of the fontencoding- the encoding of the fontttfAfm- the true type font or the afm in a byte array- Returns:
- an array of Object[] built with {getPostscriptFontName(), getFamilyFontName(), getFullFontName()}
- Throws:
DocumentException- on errorIOException- on error
-
getFamilyFontName
Gets the family name of the font. If it is a True Type font each array element will have {Platform ID, Platform Encoding ID, Language ID, font name}. The interpretation of this values can be found in the Open Type specification, chapter 2, in the 'name' table.
For the other fonts the array has a single element with {"", "", "", font name}.- Returns:
- the family name of the font
-
getCodePagesSupported
Gets the code pages supported by the font. This has only meaning with True Type fonts.- Returns:
- the code pages supported by the font
-
enumerateTTCNames
Enumerates the postscript font names present inside a True Type Collection.- Parameters:
ttcFile- the file name of the font- Returns:
- the postscript font names
- Throws:
DocumentException- on errorIOException- on error
-
enumerateTTCNames
Enumerates the postscript font names present inside a True Type Collection.- Parameters:
ttcArray- the font as abytearray- Returns:
- the postscript font names
- Throws:
DocumentException- on errorIOException- on error
-
getWidths
public int[] getWidths()Gets the font width array.- Returns:
- the font width array
-
getDifferences
Gets the array with the names of the characters.- Returns:
- the array with the names of the characters
-
getUnicodeDifferences
public char[] getUnicodeDifferences()Gets the array with the unicode characters.- Returns:
- the array with the unicode characters
-
isForceWidthsOutput
public boolean isForceWidthsOutput()Gets the state of the property.- Returns:
- value of property forceWidthsOutput
-
setForceWidthsOutput
public void setForceWidthsOutput(boolean forceWidthsOutput) Set totrueto force the generation of the widths array.- Parameters:
forceWidthsOutput-trueto force the generation of the widths array
-
isDirectTextToByte
public boolean isDirectTextToByte()Gets the direct conversion ofchartobyte.- Returns:
- value of property directTextToByte.
- See Also:
-
setDirectTextToByte
public void setDirectTextToByte(boolean directTextToByte) Sets the conversion ofchardirectly tobyteby casting. This is a low level feature to put the bytes directly in the content stream without passing through String.getBytes().- Parameters:
directTextToByte- New value of property directTextToByte.
-
isSubset
public boolean isSubset()Indicates if all the glyphs and widths for that particular encoding should be included in the document.- Returns:
falseto include all the glyphs and widths.
-
setSubset
public void setSubset(boolean subset) Indicates if all the glyphs and widths for that particular encoding should be included in the document. Set tofalseto include all.- Parameters:
subset- new value of property subset
-
getResourceStream
Gets the font resources.- Parameters:
key- the full name of the resource- Returns:
- the
InputStreamto get the resource ornullif not found
-
getResourceStream
Gets the font resources.- Parameters:
key- the full name of the resourceloader- the ClassLoader to load the resource or null to try the ones available- Returns:
- the
InputStreamto get the resource ornullif not found
-
getUnicodeEquivalent
public char getUnicodeEquivalent(char c) Gets the Unicode equivalent to a CID. The (inexistent) CIDis translated as '\n'. It has only meaning with CJK fonts with Identity encoding. - Parameters:
c- the CID code- Returns:
- the Unicode equivalent
-
getCidCode
public char getCidCode(char c) Gets the CID code given an Unicode. It has only meaning with CJK fonts.- Parameters:
c- the Unicode- Returns:
- the CID equivalent
-
hasKernPairs
public abstract boolean hasKernPairs()Checks if the font has any kerning pairs.- Returns:
trueif the font has any kerning pairs
-
charExists
public boolean charExists(char c) Checks if a character exists in this font.- Parameters:
c- the character to check- Returns:
trueif the character has a glyph,falseotherwise
-
setCharAdvance
public boolean setCharAdvance(char c, int advance) Sets the character advance.- Parameters:
c- the characteradvance- the character advance normalized to 1000 units- Returns:
trueif the advance was set,falseotherwise
-
addFont
-
recourseFonts
private static void recourseFonts(PdfDictionary page, IntHashtable hits, ArrayList fonts, int level) -
getDocumentFonts
Gets a list of all document fonts. Each element of theArrayListcontains aObject[]{String,PRIndirectReference}with the font name and the indirect reference to it.- Parameters:
reader- the document where the fonts are to be listed from- Returns:
- the list of fonts and references
-
getDocumentFonts
Gets a list of the document fonts in a particular page. Each element of theArrayListcontains aObject[]{String,PRIndirectReference}with the font name and the indirect reference to it.- Parameters:
reader- the document where the fonts are to be listed frompage- the page to list the fonts from- Returns:
- the list of fonts and references
-
getCharBBox
public int[] getCharBBox(char c) Gets the smallest box enclosing the character contours. It will returnnullif 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].- Parameters:
c- the character to get the contour bounding box from- Returns:
- an array of four floats with the bounding box in the format [llx,lly,urx,ury] or
null
-
getRawCharBBox
-
correctArabicAdvance
public void correctArabicAdvance()iText expects Arabic Diactrics (tashkeel) to have zero advance but some fonts, most notably those that come with Windows, like times.ttf, have non-zero advance for those characters. This method makes those character to have zero width advance and work correctly in the iText Arabic shaping and reordering context.
-