public abstract class BaseFont extends Object
Modifier and Type | Field and Description |
---|---|
static int |
ASCENT
The maximum height above the baseline reached by glyphs in this font, excluding the height of glyphs for accented characters.
|
static int |
AWT_ASCENT
AWT Font property
|
static int |
AWT_DESCENT
AWT Font property
|
static int |
AWT_LEADING
AWT Font property
|
static int |
AWT_MAXADVANCE
AWT Font property
|
static int |
BBOXLLX
The lower left x glyph coordinate.
|
static int |
BBOXLLY
The lower left y glyph coordinate.
|
static int |
BBOXURX
The upper right x glyph coordinate.
|
static int |
BBOXURY
The upper right y glyph coordinate.
|
protected static HashMap<String,PdfName> |
BuiltinFonts14
list of the 14 built in fonts.
|
static boolean |
CACHED
if the font has to be cached
|
static int |
CAPHEIGHT
The y coordinate of the top of flat capital letters, measured from the baseline.
|
static int[] |
CHAR_RANGE_ARABIC |
static int[] |
CHAR_RANGE_CYRILLIC |
static int[] |
CHAR_RANGE_HEBREW |
static int[] |
CHAR_RANGE_LATIN |
protected int[][] |
charBBoxes |
static char |
CID_NEWLINE
The fake CID code that represents a newline.
|
protected int |
compressionLevel
The compression level for the font stream.
|
static String |
COURIER
This is a possible value of a base 14 type 1 font
|
static String |
COURIER_BOLD
This is a possible value of a base 14 type 1 font
|
static String |
COURIER_BOLDOBLIQUE
This is a possible value of a base 14 type 1 font
|
static String |
COURIER_OBLIQUE
This is a possible value of a base 14 type 1 font
|
static String |
CP1250
A possible encoding.
|
static String |
CP1252
A possible encoding.
|
static String |
CP1257
A possible encoding.
|
static double[] |
DEFAULT_FONT_MATRIX
default array of six numbers specifying the font matrix, mapping glyph space to text space
|
static int |
DESCENT
The maximum depth below the baseline reached by glyphs in this font.
|
protected String[] |
differences
encoding names
|
protected boolean |
directTextToByte
Converts char directly to byte by casting.
|
protected boolean |
embedded
true if the font is to be embedded in the PDF
|
static boolean |
EMBEDDED
if the font has to be embedded
|
protected String |
encoding
encoding used with this font
|
protected boolean |
fastWinansi |
static int |
FONT_TYPE_CJK
The font is CJK.
|
static int |
FONT_TYPE_DOCUMENT
A font already inside the document.
|
static int |
FONT_TYPE_T1
The font is Type 1.
|
static int |
FONT_TYPE_T3
A Type3 font.
|
static int |
FONT_TYPE_TT
The font is True Type with a standard encoding.
|
static int |
FONT_TYPE_TTUNI
The font is True Type with a Unicode encoding.
|
static int |
FONT_WEIGHT
The entry of PDF FontDescriptor dictionary.
|
protected static ConcurrentHashMap<String,BaseFont> |
fontCache
cache for the fonts already used.
|
protected boolean |
fontSpecific
true if the font must use its built in encoding.
|
protected boolean |
forceWidthsOutput
Forces the output of the width array.
|
static String |
HELVETICA
This is a possible value of a base 14 type 1 font
|
static String |
HELVETICA_BOLD
This is a possible value of a base 14 type 1 font
|
static String |
HELVETICA_BOLDOBLIQUE
This is a possible value of a base 14 type 1 font
|
static String |
HELVETICA_OBLIQUE
This is a possible value of a base 14 type 1 font
|
static String |
IDENTITY_H
The Unicode encoding with horizontal writing.
|
static String |
IDENTITY_V
The Unicode encoding with vertical writing.
|
static int |
ITALICANGLE
The angle, expressed in degrees counterclockwise from the vertical, of the dominant vertical strokes of the font.
|
static String |
MACROMAN
A possible encoding.
|
static boolean |
NOT_CACHED
if the font doesn't have to be cached
|
static boolean |
NOT_EMBEDDED
if the font doesn't have to be embedded
|
static String |
notdef
a not defined character in a custom PDF encoding
|
static char |
PARAGRAPH_SEPARATOR
Unicode Character 'PARAGRAPH SEPARATOR' (U+2029) Treated as a line feed character in XFA rich and plain text.
|
static String |
RESOURCE_PATH
The path to the font resources.
|
protected IntHashtable |
specialMap
Custom encodings use this map to key the Unicode character to the single byte code.
|
static int |
STRIKETHROUGH_POSITION
The strikethrough position.
|
static int |
STRIKETHROUGH_THICKNESS
The strikethrough thickness.
|
static int |
SUBSCRIPT_OFFSET
The recommended vertical offset from the baseline for subscripts for this font.
|
static int |
SUBSCRIPT_SIZE
The recommended vertical size for subscripts for this font.
|
protected boolean |
subset
Indicates if all the glyphs and widths for that particular encoding should be included in the document.
|
protected ArrayList |
subsetRanges |
static int |
SUPERSCRIPT_OFFSET
The recommended vertical offset from the baseline for superscripts for this font.
|
static int |
SUPERSCRIPT_SIZE
The recommended vertical size for superscripts for this font.
|
static String |
SYMBOL
This is a possible value of a base 14 type 1 font
|
static String |
TIMES_BOLD
This is a possible value of a base 14 type 1 font
|
static String |
TIMES_BOLDITALIC
This is a possible value of a base 14 type 1 font
|
static String |
TIMES_ITALIC
This is a possible value of a base 14 type 1 font
|
static String |
TIMES_ROMAN
This is a possible value of a base 14 type 1 font
|
static int |
UNDERLINE_POSITION
The underline position.
|
static int |
UNDERLINE_THICKNESS
The underline thickness.
|
protected char[] |
unicodeDifferences
same as differences but with the unicode codes
|
protected boolean |
vertical |
static int |
WEIGHT_CLASS
The weight class of the font, as defined by the font author
|
static int |
WIDTH_CLASS
The width class of the font, as defined by the font author
|
protected int[] |
widths
table of characters widths for this encoding
|
static String |
WINANSI
A possible encoding.
|
static String |
ZAPFDINGBATS
This is a possible value of a base 14 type 1 font
|
Modifier | Constructor and Description |
---|---|
protected |
BaseFont()
Creates new BaseFont
|
Modifier and Type | Method and Description |
---|---|
void |
addSubsetRange(int[] range)
Adds a character range when subsetting.
|
boolean |
charExists(int c)
Checks if a character exists in this font.
|
byte[] |
convertToBytes(String text)
Converts a String to a byte array according to the font's encoding.
|
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.
|
protected void |
createEncoding()
Creates the widths and the differences arrays
|
static BaseFont |
createFont()
Creates a new font.
|
static BaseFont |
createFont(PRIndirectReference fontRef)
Creates a font based on an existing document font.
|
static BaseFont |
createFont(String name, String encoding, boolean embedded)
Creates a new font.
|
static BaseFont |
createFont(String name, String encoding, boolean embedded, boolean forceRead)
Creates a new font.
|
static BaseFont |
createFont(String name, String encoding, boolean embedded, boolean cached, byte[] ttfAfm, byte[] pfb)
Creates a new font.
|
static BaseFont |
createFont(String name, String encoding, boolean embedded, boolean cached, byte[] ttfAfm, byte[] pfb, boolean noThrow)
Creates a new font.
|
static BaseFont |
createFont(String name, String encoding, boolean embedded, boolean cached, byte[] ttfAfm, byte[] pfb, boolean noThrow, boolean forceRead)
Creates a new font.
|
static String |
createSubsetPrefix()
Creates 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.
|
abstract String[][] |
getAllNameEntries()
Gets all the entries of the names-table.
|
static String[][] |
getAllNameEntries(String name, String encoding, byte[] ttfAfm)
Gets all the entries of the namestable from the font.
|
int |
getAscent(String text)
Gets the ascent of a String in normalized 1000 units.
|
float |
getAscentPoint(String text, float fontSize)
Gets the ascent of a String in points.
|
protected static String |
getBaseName(String name)
Gets the name without the modifiers Bold, Italic or BoldItalic.
|
int[] |
getCharBBox(int c)
Gets the smallest box enclosing the character contours.
|
int |
getCidCode(int c)
Gets the CID code given an Unicode.
|
String[] |
getCodePagesSupported()
Gets the code pages supported by the font.
|
int |
getCompressionLevel()
Returns the compression level used for the font streams.
|
int |
getDescent(String text)
Gets the descent of a String in normalized 1000 units.
|
float |
getDescentPoint(String text, float fontSize)
Gets the descent of a String in points.
|
String[] |
getDifferences()
Gets the array with the names of the characters.
|
static ArrayList<Object[]> |
getDocumentFonts(PdfReader reader)
Gets a list of all document fonts.
|
static ArrayList<Object[]> |
getDocumentFonts(PdfReader reader, int page)
Gets a list of the document fonts in a particular page.
|
String |
getEncoding()
Gets the encoding used to convert String into byte[] .
|
abstract String[][] |
getFamilyFontName()
Gets the family name of the font.
|
abstract float |
getFontDescriptor(int key, float fontSize)
Gets the font parameter identified by key .
|
double[] |
getFontMatrix()
get default array of six numbers specifying the font matrix, mapping glyph space to text space
|
int |
getFontType()
Gets the font type.
|
abstract String[][] |
getFullFontName()
Gets the full name of the font.
|
static String[][] |
getFullFontName(String name, String encoding, byte[] ttfAfm)
Gets the full name of the font.
|
abstract int |
getKerning(int char1, int char2)
Gets the kerning between two Unicode chars.
|
abstract String |
getPostscriptFontName()
Gets the postscript font name.
|
protected abstract int[] |
getRawCharBBox(int c, String name) |
String |
getSubfamily() |
char[] |
getUnicodeDifferences()
Gets the array with the unicode characters.
|
int |
getUnicodeEquivalent(int c)
Gets the Unicode equivalent to a CID.
|
int |
getWidth(int char1)
Gets the width of a char in normalized 1000 units.
|
int |
getWidth(String text)
Gets the width of a String in normalized 1000 units.
|
float |
getWidthPoint(int char1, float fontSize)
Gets the width of a char in points.
|
float |
getWidthPoint(String text, float fontSize)
Gets the width of a String in points.
|
float |
getWidthPointKerned(String text, float fontSize)
Gets the width of a String in points taking kerning into account.
|
int[] |
getWidths()
Gets the font width array.
|
abstract boolean |
hasKernPairs()
Checks if the font has any kerning pairs.
|
boolean |
isDirectTextToByte()
Gets the direct conversion of char to byte .
|
boolean |
isEmbedded()
Gets the embedded flag.
|
boolean |
isFontSpecific()
Gets the symbolic flag of the font.
|
boolean |
isForceWidthsOutput()
Gets the state of the property.
|
boolean |
isSubset()
Indicates if all the glyphs and widths for that particular encoding should be included in the document.
|
boolean |
isVertical()
Indicates whether the font is used for verticl writing or not.
|
protected static String |
normalizeEncoding(String enc)
Normalize the encoding names.
|
boolean |
setCharAdvance(int c, int advance)
Sets the character advance.
|
void |
setCompressionLevel(int compressionLevel)
Sets the compression level to be used for the font streams.
|
void |
setDirectTextToByte(boolean directTextToByte)
Sets the conversion of char directly to byte by casting.
|
void |
setFontDescriptor(int key, float value)
Sets the font parameter identified by key .
|
void |
setForceWidthsOutput(boolean forceWidthsOutput)
Set to true to force the generation of the widths array.
|
abstract boolean |
setKerning(int char1, int char2, int kern)
Sets the kerning between two Unicode chars.
|
abstract void |
setPostscriptFontName(String name)
Sets the font name that will appear in the pdf font dictionary.
|
void |
setSubset(boolean subset)
Indicates if all the glyphs and widths for that particular encoding should be included in the document.
|
public static final String COURIER
public static final String COURIER_BOLD
public static final String COURIER_OBLIQUE
public static final String COURIER_BOLDOBLIQUE
public static final String HELVETICA
public static final String HELVETICA_BOLD
public static final String HELVETICA_OBLIQUE
public static final String HELVETICA_BOLDOBLIQUE
public static final String SYMBOL
public static final String TIMES_ROMAN
public static final String TIMES_BOLD
public static final String TIMES_ITALIC
public static final String TIMES_BOLDITALIC
public static final String ZAPFDINGBATS
public static final int ASCENT
public static final int CAPHEIGHT
public static final int DESCENT
public static final int ITALICANGLE
public static final int BBOXLLX
public static final int BBOXLLY
public static final int BBOXURX
public static final int BBOXURY
public static final int AWT_ASCENT
public static final int AWT_DESCENT
public static final int AWT_LEADING
public static final int AWT_MAXADVANCE
public static final int UNDERLINE_POSITION
public static final int UNDERLINE_THICKNESS
public static final int STRIKETHROUGH_POSITION
public static final int STRIKETHROUGH_THICKNESS
public static final int SUBSCRIPT_SIZE
public static final int SUBSCRIPT_OFFSET
public static final int SUPERSCRIPT_SIZE
public static final int SUPERSCRIPT_OFFSET
public static final int WEIGHT_CLASS
public static final int WIDTH_CLASS
public static final int FONT_WEIGHT
public static final int FONT_TYPE_T1
public static final int FONT_TYPE_TT
public static final int FONT_TYPE_CJK
public static final int FONT_TYPE_TTUNI
public static final int FONT_TYPE_DOCUMENT
public static final int FONT_TYPE_T3
public static final String IDENTITY_H
public static final String IDENTITY_V
public static final String CP1250
public static final String CP1252
public static final String CP1257
public static final String WINANSI
public static final String MACROMAN
public static final int[] CHAR_RANGE_LATIN
public static final int[] CHAR_RANGE_ARABIC
public static final int[] CHAR_RANGE_HEBREW
public static final int[] CHAR_RANGE_CYRILLIC
public static final double[] DEFAULT_FONT_MATRIX
public static final boolean EMBEDDED
public static final boolean NOT_EMBEDDED
public static final boolean CACHED
public static final boolean NOT_CACHED
public static final String RESOURCE_PATH
public static final char CID_NEWLINE
public static final char PARAGRAPH_SEPARATOR
protected ArrayListsubsetRanges
public static final String notdef
protected int[] widths
protected String[] differences
protected char[] unicodeDifferences
protected int[][] charBBoxes
protected String encoding
protected boolean embedded
protected int compressionLevel
protected boolean fontSpecific
encoding
is only used to map a char to the position inside the font, not to the expected char name.
protected static ConcurrentHashMap<String,BaseFont> fontCache
protected static final HashMap<String,PdfName> BuiltinFonts14
protected boolean forceWidthsOutput
protected boolean directTextToByte
char
directly to byte
by casting.
protected boolean subset
protected boolean fastWinansi
protected IntHashtable specialMap
protected boolean vertical
public static BaseFont createFont() throws DocumentException, IOException
IOException
- This shouldn't occur ever
DocumentException
- This shouldn't occur ever
public static BaseFont createFont(String name, String encoding, boolean embedded) throws DocumentException, IOException
The fonts are cached and if they already exist they are extracted from the cache, not parsed again.
Besides the common encodings described by name, custom encodings can also be made. These encodings will only work for the single byte fonts Type1 and TrueType. The encoding string starts with a '#' followed by "simple" or "full". If "simple" there is a decimal for the first character position and then a list of hex values representing the Unicode codes that compose that encoding.
The "simple" encoding is recommended for TrueType fonts as the "full" encoding risks not matching the character with the right glyph if not done with care.
The "full" encoding is specially aimed at Type1 fonts where the glyphs have to be described by non standard names like the Tex math fonts. Each group of three elements compose a code position: the one byte code order in decimal or as 'x' (x cannot be the space), the name and the Unicode character used to access the glyph. The space must be assigned to character position 32 otherwise text justification will not work.
Example for a "simple" encoding that includes the Unicode character space, A, B and ecyrillic:
"# simple 32 0020 0041 0042 0454"
Example for a "full" encoding for a Type1 Tex font:
"# full 'A' nottriangeqlleft 0041 'B' dividemultiply 0042 32 space 0020"
This method calls:
createFont(name, encoding, embedded, true, null, null);
name
- the name of the font or its location on file
encoding
- the encoding to be applied to this font
embedded
- true if the font is to be embedded in the PDF
DocumentException
- the font is invalid
IOException
- the font file could not be read
public static BaseFont createFont(String name, String encoding, boolean embedded, boolean forceRead) throws DocumentException, IOException
The fonts are cached and if they already exist they are extracted from the cache, not parsed again.
Besides the common encodings described by name, custom encodings can also be made. These encodings will only work for the single byte fonts Type1 and TrueType. The encoding string starts with a '#' followed by "simple" or "full". If "simple" there is a decimal for the first character position and then a list of hex values representing the Unicode codes that compose that encoding.
The "simple" encoding is recommended for TrueType fonts as the "full" encoding risks not matching the character with the right glyph if not done with care.
The "full" encoding is specially aimed at Type1 fonts where the glyphs have to be described by non standard names like the Tex math fonts. Each group of three elements compose a code position: the one byte code order in decimal or as 'x' (x cannot be the space), the name and the Unicode character used to access the glyph. The space must be assigned to character position 32 otherwise text justification will not work.
Example for a "simple" encoding that includes the Unicode character space, A, B and ecyrillic:
"# simple 32 0020 0041 0042 0454"
Example for a "full" encoding for a Type1 Tex font:
"# full 'A' nottriangeqlleft 0041 'B' dividemultiply 0042 32 space 0020"
This method calls:
createFont(name, encoding, embedded, true, null, null);
name
- the name of the font or its location on file
encoding
- the encoding to be applied to this font
embedded
- true if the font is to be embedded in the PDF
forceRead
- in some cases (TrueTypeFont, Type1Font), the full font file will be read and kept in memory if forceRead is true
DocumentException
- the font is invalid
IOException
- the font file could not be read
public static BaseFont createFont(String name, String encoding, boolean embedded, boolean cached, byte[] ttfAfm, byte[] pfb) throws DocumentException, IOException
The fonts may or may not be cached depending on the flag cached
. If the byte
arrays are present the font will be read from them instead of the name. A name is still required to identify the font type.
Besides the common encodings described by name, custom encodings can also be made. These encodings will only work for the single byte fonts Type1 and TrueType. The encoding string starts with a '#' followed by "simple" or "full". If "simple" there is a decimal for the first character position and then a list of hex values representing the Unicode codes that compose that encoding.
The "simple" encoding is recommended for TrueType fonts as the "full" encoding risks not matching the character with the right glyph if not done with care.
The "full" encoding is specially aimed at Type1 fonts where the glyphs have to be described by non standard names like the Tex math fonts. Each group of three elements compose a code position: the one byte code order in decimal or as 'x' (x cannot be the space), the name and the Unicode character used to access the glyph. The space must be assigned to character position 32 otherwise text justification will not work.
Example for a "simple" encoding that includes the Unicode character space, A, B and ecyrillic:
"# simple 32 0020 0041 0042 0454"
Example for a "full" encoding for a Type1 Tex font:
"# full 'A' nottriangeqlleft 0041 'B' dividemultiply 0042 32 space 0020"
name
- the name of the font or its location on file
encoding
- the encoding to be applied to this font
embedded
- true if the font is to be embedded in the PDF
cached
- true if the font comes from the cache or is added to the cache if new, false if the font is always created new
ttfAfm
- the true type font or the afm in a byte array
pfb
- the pfb in a byte array
DocumentException
- the font is invalid
IOException
- the font file could not be read
public static BaseFont createFont(String name, String encoding, boolean embedded, boolean cached, byte[] ttfAfm, byte[] pfb, boolean noThrow) throws DocumentException, IOException
The fonts may or may not be cached depending on the flag cached
. If the byte
arrays are present the font will be read from them instead of the name. A name is still required to identify the font type.
Besides the common encodings described by name, custom encodings can also be made. These encodings will only work for the single byte fonts Type1 and TrueType. The encoding string starts with a '#' followed by "simple" or "full". If "simple" there is a decimal for the first character position and then a list of hex values representing the Unicode codes that compose that encoding.
The "simple" encoding is recommended for TrueType fonts as the "full" encoding risks not matching the character with the right glyph if not done with care.
The "full" encoding is specially aimed at Type1 fonts where the glyphs have to be described by non standard names like the Tex math fonts. Each group of three elements compose a code position: the one byte code order in decimal or as 'x' (x cannot be the space), the name and the Unicode character used to access the glyph. The space must be assigned to character position 32 otherwise text justification will not work.
Example for a "simple" encoding that includes the Unicode character space, A, B and ecyrillic:
"# simple 32 0020 0041 0042 0454"
Example for a "full" encoding for a Type1 Tex font:
"# full 'A' nottriangeqlleft 0041 'B' dividemultiply 0042 32 space 0020"
name
- the name of the font or its location on file
encoding
- the encoding to be applied to this font
embedded
- true if the font is to be embedded in the PDF
cached
- true if the font comes from the cache or is added to the cache if new, false if the font is always created new
ttfAfm
- the true type font or the afm in a byte array
pfb
- the pfb in a byte array
noThrow
- if true will not throw an exception if the font is not recognized and will return null, if false will throw an exception if the font is not recognized. Note that even if true an exception may be thrown in some circumstances. This parameter is useful for FontFactory that may have to check many invalid font names before finding the right one
DocumentException
- the font is invalid
IOException
- the font file could not be read
public static BaseFont createFont(String name, String encoding, boolean embedded, boolean cached, byte[] ttfAfm, byte[] pfb, boolean noThrow, boolean forceRead) throws DocumentException, IOException
The fonts may or may not be cached depending on the flag cached
. If the byte
arrays are present the font will be read from them instead of the name. A name is still required to identify the font type.
Besides the common encodings described by name, custom encodings can also be made. These encodings will only work for the single byte fonts Type1 and TrueType. The encoding string starts with a '#' followed by "simple" or "full". If "simple" there is a decimal for the first character position and then a list of hex values representing the Unicode codes that compose that encoding.
The "simple" encoding is recommended for TrueType fonts as the "full" encoding risks not matching the character with the right glyph if not done with care.
The "full" encoding is specially aimed at Type1 fonts where the glyphs have to be described by non standard names like the Tex math fonts. Each group of three elements compose a code position: the one byte code order in decimal or as 'x' (x cannot be the space), the name and the Unicode character used to access the glyph. The space must be assigned to character position 32 otherwise text justification will not work.
Example for a "simple" encoding that includes the Unicode character space, A, B and ecyrillic:
"# simple 32 0020 0041 0042 0454"
Example for a "full" encoding for a Type1 Tex font:
"# full 'A' nottriangeqlleft 0041 'B' dividemultiply 0042 32 space 0020"
name
- the name of the font or its location on file
encoding
- the encoding to be applied to this font
embedded
- true if the font is to be embedded in the PDF
cached
- true if the font comes from the cache or is added to the cache if new, false if the font is always created new
ttfAfm
- the true type font or the afm in a byte array
pfb
- the pfb in a byte array
noThrow
- if true will not throw an exception if the font is not recognized and will return null, if false will throw an exception if the font is not recognized. Note that even if true an exception may be thrown in some circumstances. This parameter is useful for FontFactory that may have to check many invalid font names before finding the right one
forceRead
- in some cases (TrueTypeFont, Type1Font), the full font file will be read and kept in memory if forceRead is true
DocumentException
- the font is invalid
IOException
- the font file could not be read
public static BaseFont createFont(PRIndirectReference fontRef)
fontRef
- the reference to the document font
public boolean isVertical()
true
if the writing mode is vertical for the given font, false
otherwise.
protected static String getBaseName(String name)
name
- the full name of the font
protected static String normalizeEncoding(String enc)
enc
- the encoding to be normalized
protected void createEncoding()
widths
and the differences
arrays
public abstract int getKerning(int char1, int char2)
char1
- the first char
char2
- the second char
public abstract boolean setKerning(int char1, int char2, int kern)
char1
- the first char
char2
- the second char
kern
- the kerning to apply in normalized 1000 units
true
if the kerning was applied, false
otherwise
public int getWidth(int char1)
char
in normalized 1000 units.
char1
- the unicode char
to get the width of
public int getWidth(String text)
String
in normalized 1000 units.
text
- the String
to get the width of
public int getDescent(String text)
String
in normalized 1000 units. The descent will always be less than or equal to zero even if all the characters have an higher descent.
text
- the String
to get the descent of
public int getAscent(String text)
String
in normalized 1000 units. The ascent will always be greater than or equal to zero even if all the characters have a lower ascent.
text
- the String
to get the ascent of
public float getDescentPoint(String text, float fontSize)
String
in points. The descent will always be less than or equal to zero even if all the characters have an higher descent.
text
- the String
to get the descent of
fontSize
- the size of the font
public float getAscentPoint(String text, float fontSize)
String
in points. The ascent will always be greater than or equal to zero even if all the characters have a lower ascent.
text
- the String
to get the ascent of
fontSize
- the size of the font
public float getWidthPointKerned(String text, float fontSize)
String
in points taking kerning into account.
text
- the String
to get the width of
fontSize
- the font size
public float getWidthPoint(String text, float fontSize)
String
in points.
text
- the String
to get the width of
fontSize
- the font size
public float getWidthPoint(int char1, float fontSize)
char
in points.
char1
- the char
to get the width of
fontSize
- the font size
public byte[] convertToBytes(String text)
String
to a byte array according to the font's encoding.
text
- the String
to be converted
byte
representing the conversion according to the font's encoding
public String getEncoding()
String
into byte[]
.
public abstract float getFontDescriptor(int key, float fontSize)
key
. Valid values for key
are ASCENT
, AWT_ASCENT
, CAPHEIGHT
, DESCENT
, AWT_DESCENT
, ITALICANGLE
, BBOXLLX
, BBOXLLY
, BBOXURX
and BBOXURY
.
key
- the parameter to be extracted
fontSize
- the font size in points
public void setFontDescriptor(int key, float value)
key
. Valid values for key
are ASCENT
, AWT_ASCENT
, CAPHEIGHT
, DESCENT
, AWT_DESCENT
, ITALICANGLE
, BBOXLLX
, BBOXLLY
, BBOXURX
and BBOXURY
.
key
- the parameter to be updated
value
- the parameter value
public int getFontType()
public boolean isEmbedded()
true
if the font is embedded.
public boolean isFontSpecific()
true
if the font is symbolic
public static String createSubsetPrefix()
public abstract String getPostscriptFontName()
public abstract void setPostscriptFontName(String name)
name
- the new font name
public String getSubfamily()
public abstract String[][] getFullFontName()
public abstract String[][] getAllNameEntries()
public static String[][] getFullFontName(String name, String encoding, byte[] ttfAfm) throws DocumentException, IOException
name
- the name of the font
encoding
- the encoding of the font
ttfAfm
- the true type font or the afm in a byte array
DocumentException
- on error
IOException
- on error
public static Object[] getAllFontNames(String name, String encoding, byte[] ttfAfm) throws DocumentException, IOException
name
- the name of the font
encoding
- the encoding of the font
ttfAfm
- the true type font or the afm in a byte array
DocumentException
- on error
IOException
- on error
public static String[][] getAllNameEntries(String name, String encoding, byte[] ttfAfm) throws DocumentException, IOException
name
- the name of the font
encoding
- the encoding of the font
ttfAfm
- the true type font or the afm in a byte array
DocumentException
- on error
IOException
- on error
public abstract String[][] getFamilyFontName()
public String[] getCodePagesSupported()
public static String[] enumerateTTCNames(String ttcFile) throws DocumentException, IOException
ttcFile
- the file name of the font
DocumentException
- on error
IOException
- on error
public static String[] enumerateTTCNames(byte[] ttcArray) throws DocumentException, IOException
ttcArray
- the font as a byte
array
DocumentException
- on error
IOException
- on error
public int[] getWidths()
public String[] getDifferences()
public char[] getUnicodeDifferences()
public boolean isForceWidthsOutput()
public void setForceWidthsOutput(boolean forceWidthsOutput)
true
to force the generation of the widths array.
forceWidthsOutput
- true
to force the generation of the widths array
public boolean isDirectTextToByte()
char
to byte
.
setDirectTextToByte(boolean directTextToByte)
public void setDirectTextToByte(boolean directTextToByte)
char
directly to byte
by casting. This is a low level feature to put the bytes directly in the content stream without passing through String.getBytes().
directTextToByte
- New value of property directTextToByte.
public boolean isSubset()
false
to include all the glyphs and widths.
public void setSubset(boolean subset)
true
only the glyphs used will be included in the font. When set to false
and addSubsetRange(int[])
was not called the full font will be included otherwise just the characters ranges will be included.
subset
- new value of property subset
public int getUnicodeEquivalent(int c)
c
- the CID code
public int getCidCode(int c)
c
- the Unicode
public abstract boolean hasKernPairs()
true
if the font has any kerning pairs
public boolean charExists(int c)
c
- the character to check
true
if the character has a glyph, false
otherwise
public boolean setCharAdvance(int c, int advance)
c
- the character
advance
- the character advance normalized to 1000 units
true
if the advance was set, false
otherwise
public static ArrayList<Object[]> getDocumentFonts(PdfReader reader)
ArrayList
contains a Object[]{String,PRIndirectReference}
with the font name and the indirect reference to it.
reader
- the document where the fonts are to be listed from
public static ArrayList<Object[]> getDocumentFonts(PdfReader reader, int page)
ArrayList
contains a Object[]{String,PRIndirectReference}
with the font name and the indirect reference to it.
reader
- the document where the fonts are to be listed from
page
- the page to list the fonts from
public int[] getCharBBox(int c)
null
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].
c
- the character to get the contour bounding box from
null
public double[] getFontMatrix()
null
protected abstract int[] getRawCharBBox(int c, String name)
public void correctArabicAdvance()
public void addSubsetRange(int[] range)
int
array where the first element is the start range inclusive and the second element is the end range inclusive. Several ranges are allowed in the same array.
range
- the character range
public int getCompressionLevel()
public void setCompressionLevel(int compressionLevel)
compressionLevel
- a value between 0 (best speed) and 9 (best compression)
Copyright © 1998–2022. All rights reserved.