Class BaseFont
- Namespace
- iTextSharp.text.pdf
- Assembly
- iTextSharp.LGPLv2.Core.dll
Summary description for BaseFont.
public abstract class BaseFont
- Inheritance
-
BaseFont
- Derived
- Inherited Members
Constructors
BaseFont()
protected BaseFont()
Fields
ASCENT
The maximum height above the baseline reached by glyphs in this font, excluding the height of glyphs for accented characters.
public const int ASCENT = 1
Field Value
AWT_ASCENT
java.awt.Font property
public const int AWT_ASCENT = 9
Field Value
AWT_DESCENT
java.awt.Font property
public const int AWT_DESCENT = 10
Field Value
AWT_LEADING
java.awt.Font property
public const int AWT_LEADING = 11
Field Value
AWT_MAXADVANCE
java.awt.Font property
public const int AWT_MAXADVANCE = 12
Field Value
BBOXLLX
The lower left x glyph coordinate.
public const int BBOXLLX = 5
Field Value
BBOXLLY
The lower left y glyph coordinate.
public const int BBOXLLY = 6
Field Value
BBOXURX
The upper right x glyph coordinate.
public const int BBOXURX = 7
Field Value
BBOXURY
The upper right y glyph coordinate.
public const int BBOXURY = 8
Field Value
BuiltinFonts14
list of the 14 built in fonts.
protected static readonly INullValueDictionary<string, PdfName> BuiltinFonts14
Field Value
CACHED
if the font has to be cached
public const bool CACHED = true
Field Value
CAPHEIGHT
The y coordinate of the top of flat capital letters, measured from the baseline.
public const int CAPHEIGHT = 2
Field Value
CID_NEWLINE
The fake CID code that represents a newline.
public const char CID_NEWLINE = '翿'
Field Value
COURIER
This is a possible value of a base 14 type 1 font
public const string COURIER = "Courier"
Field Value
COURIER_BOLD
This is a possible value of a base 14 type 1 font
public const string COURIER_BOLD = "Courier-Bold"
Field Value
COURIER_BOLDOBLIQUE
This is a possible value of a base 14 type 1 font
public const string COURIER_BOLDOBLIQUE = "Courier-BoldOblique"
Field Value
COURIER_OBLIQUE
This is a possible value of a base 14 type 1 font
public const string COURIER_OBLIQUE = "Courier-Oblique"
Field Value
CP1250
A possible encoding.
public const string CP1250 = "Cp1250"
Field Value
CP1252
A possible encoding.
public const string CP1252 = "Cp1252"
Field Value
CP1257
A possible encoding.
public const string CP1257 = "Cp1257"
Field Value
CharBBoxes
protected int[][] CharBBoxes
Field Value
- int[][]
CharRangeArabic
public static readonly int[] CharRangeArabic
Field Value
- int[]
CharRangeCyrillic
public static readonly int[] CharRangeCyrillic
Field Value
- int[]
CharRangeHebrew
public static readonly int[] CharRangeHebrew
Field Value
- int[]
CharRangeLatin
public static readonly int[] CharRangeLatin
Field Value
- int[]
DESCENT
The maximum depth below the baseline reached by glyphs in this font. The value is a negative number.
public const int DESCENT = 3
Field Value
EMBEDDED
if the font has to be embedded
public const bool EMBEDDED = true
Field Value
Embedded
true if the font is to be embedded in the PDF
protected bool Embedded
Field Value
FONT_TYPE_CJK
The font is CJK.
public const int FONT_TYPE_CJK = 2
Field Value
FONT_TYPE_DOCUMENT
A font already inside the document.
public const int FONT_TYPE_DOCUMENT = 4
Field Value
FONT_TYPE_T1
The font is Type 1.
public const int FONT_TYPE_T1 = 0
Field Value
FONT_TYPE_T3
A Type3 font.
public const int FONT_TYPE_T3 = 5
Field Value
FONT_TYPE_TT
The font is True Type with a standard encoding.
public const int FONT_TYPE_TT = 1
Field Value
FONT_TYPE_TTUNI
The font is True Type with a Unicode encoding.
public const int FONT_TYPE_TTUNI = 3
Field Value
FastWinansi
protected bool FastWinansi
Field Value
FontCache
cache for the fonts already used.
protected static readonly INullValueDictionary<string, BaseFont> FontCache
Field Value
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 bool FontSpecific
Field Value
HELVETICA
This is a possible value of a base 14 type 1 font
public const string HELVETICA = "Helvetica"
Field Value
HELVETICA_BOLD
This is a possible value of a base 14 type 1 font
public const string HELVETICA_BOLD = "Helvetica-Bold"
Field Value
HELVETICA_BOLDOBLIQUE
This is a possible value of a base 14 type 1 font
public const string HELVETICA_BOLDOBLIQUE = "Helvetica-BoldOblique"
Field Value
HELVETICA_OBLIQUE
This is a possible value of a base 14 type 1 font
public const string HELVETICA_OBLIQUE = "Helvetica-Oblique"
Field Value
IDENTITY_H
The Unicode encoding with horizontal writing.
public const string IDENTITY_H = "Identity-H"
Field Value
IDENTITY_V
The Unicode encoding with vertical writing.
public const string IDENTITY_V = "Identity-V"
Field Value
ITALICANGLE
The 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.
public const int ITALICANGLE = 4
Field Value
MACROMAN
A possible encoding.
public const string MACROMAN = "MacRoman"
Field Value
NOT_CACHED
if the font doesn't have to be cached
public const bool NOT_CACHED = false
Field Value
NOT_EMBEDDED
if the font doesn't have to be embedded
public const bool NOT_EMBEDDED = false
Field Value
RESOURCE_PATH
The path to the font resources.
public const string RESOURCE_PATH = "iTextSharp.LGPLv2.Core.iTextSharp.text.pdf.fonts."
Field Value
ResourceSearch
protected static readonly List<object> ResourceSearch
Field Value
STRIKETHROUGH_POSITION
The strikethrough position.
public const int STRIKETHROUGH_POSITION = 15
Field Value
STRIKETHROUGH_THICKNESS
The strikethrough thickness.
public const int STRIKETHROUGH_THICKNESS = 16
Field Value
SUBSCRIPT_OFFSET
The recommended vertical offset from the baseline for subscripts for this font. Usually a negative value.
public const int SUBSCRIPT_OFFSET = 18
Field Value
SUBSCRIPT_SIZE
The recommended vertical size for subscripts for this font.
public const int SUBSCRIPT_SIZE = 17
Field Value
SUPERSCRIPT_OFFSET
The recommended vertical offset from the baseline for superscripts for this font.
public const int SUPERSCRIPT_OFFSET = 20
Field Value
SUPERSCRIPT_SIZE
The recommended vertical size for superscripts for this font.
public const int SUPERSCRIPT_SIZE = 19
Field Value
SYMBOL
This is a possible value of a base 14 type 1 font
public const string SYMBOL = "Symbol"
Field Value
SpecialMap
Custom encodings use this map to key the Unicode character to the single byte code.
protected NullValueDictionary<int, int> SpecialMap
Field Value
SubsetRanges
protected List<int[]> SubsetRanges
Field Value
TIMES_BOLD
This is a possible value of a base 14 type 1 font
public const string TIMES_BOLD = "Times-Bold"
Field Value
TIMES_BOLDITALIC
This is a possible value of a base 14 type 1 font
public const string TIMES_BOLDITALIC = "Times-BoldItalic"
Field Value
TIMES_ITALIC
This is a possible value of a base 14 type 1 font
public const string TIMES_ITALIC = "Times-Italic"
Field Value
TIMES_ROMAN
This is a possible value of a base 14 type 1 font
public const string TIMES_ROMAN = "Times-Roman"
Field Value
UNDERLINE_POSITION
The underline position. Usually a negative value.
public const int UNDERLINE_POSITION = 13
Field Value
UNDERLINE_THICKNESS
The underline thickness.
public const int UNDERLINE_THICKNESS = 14
Field Value
WINANSI
A possible encoding.
public const string WINANSI = "Cp1252"
Field Value
ZAPFDINGBATS
This is a possible value of a base 14 type 1 font
public const string ZAPFDINGBATS = "ZapfDingbats"
Field Value
compressionLevel
The compression level for the font stream. @since 2.1.3
protected int compressionLevel
Field Value
differences
encoding names
protected string[] differences
Field Value
- string[]
directTextToByte
Converts char directly to byte by casting.
protected bool directTextToByte
Field Value
encoding
encoding used with this font
protected string encoding
Field Value
forceWidthsOutput
Forces the output of the width array. Only matters for the 14 built-in fonts.
protected bool forceWidthsOutput
Field Value
notdef
a not defined character in a custom PDF encoding
public const string notdef = ".notdef"
Field Value
subset
Indicates if all the glyphs and widths for that particular encoding should be included in the document.
protected bool subset
Field Value
unicodeDifferences
same as differences but with the unicode codes
protected char[] unicodeDifferences
Field Value
- char[]
widths
table of characters widths for this encoding
protected int[] widths
Field Value
- int[]
Properties
AllNameEntries
Gets all the entries of the names-table. If it is a True Type font each array element will have {Name ID, 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 {"4", "", "", "", font name}.
public abstract string[][] AllNameEntries { get; }
Property Value
- string[][]
the full name of the font
CodePagesSupported
Gets the code pages supported by the font. This has only meaning with True Type fonts.
public virtual string[] CodePagesSupported { get; }
Property Value
- string[]
the code pages supported by the font
CompressionLevel
Sets the compression level to be used for the font streams. @since 2.1.3
public int CompressionLevel { get; set; }
Property Value
Differences
Gets the array with the names of the characters.
public string[] Differences { get; }
Property Value
- string[]
the array with the names of the characters
DirectTextToByte
Sets the conversion of 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().
public bool DirectTextToByte { get; set; }
Property Value
Encoding
Gets the encoding used to convert string into byte[] .
public string Encoding { get; }
Property Value
- string
the encoding name
FamilyFontName
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}.
public abstract string[][] FamilyFontName { get; }
Property Value
- string[][]
the family name of the font
FontType
Gets the font type. The font types can be: FONT_TYPE_T1, FONT_TYPE_TT, FONT_TYPE_CJK and FONT_TYPE_TTUNI.
public int FontType { get; set; }
Property Value
- int
the font type
ForceWidthsOutput
Set to true to force the generation of the widths array. widths array
public bool ForceWidthsOutput { get; set; }
Property Value
FullFontName
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}.
public abstract string[][] FullFontName { get; }
Property Value
- string[][]
the full name of the font
PostscriptFontName
Gets the postscript font name.
public abstract string PostscriptFontName { get; set; }
Property Value
- string
the postscript font name
Subset
Indicates if all the glyphs and widths for that particular encoding should be included in the document. When set to true only the glyphs used will be included in the font. When set to false and {@link #addSubsetRange(int[])} was not called the full font will be included otherwise just the characters ranges will be included.
public bool Subset { get; set; }
Property Value
UnicodeDifferences
Gets the array with the unicode characters.
public char[] UnicodeDifferences { get; }
Property Value
- char[]
the array with the unicode characters
Widths
Gets the font width array.
public int[] Widths { get; }
Property Value
- int[]
the font width array
Methods
AddSubsetRange(int[])
Adds a character range when subsetting. The range is an 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.
public void AddSubsetRange(int[] range)
Parameters
range
int[]the character range
AddToResourceSearch(object)
public static void AddToResourceSearch(object obj)
Parameters
obj
object
CharExists(int)
Checks if a character exists in this font. false otherwise
public virtual bool CharExists(int c)
Parameters
c
intthe character to check
Returns
- bool
true if the character has a glyph,
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.
public void CorrectArabicAdvance()
CreateEncoding()
Creates the widths and the differences arrays @throws UnsupportedEncodingException the encoding is not supported
protected void CreateEncoding()
CreateFont()
Creates a new font. This will always be the default Helvetica font (not embedded). This method is introduced because Helvetica is used in many examples. @throws IOException This shouldn't occur ever @throws DocumentException This shouldn't occur ever @since 2.1.1
public static BaseFont CreateFont()
Returns
- BaseFont
a BaseFont object (Helvetica, Winansi, not embedded)
CreateFont(string, string, bool)
Creates a new font. This font can be one of the 14 built in types, a Type1 font referred to by an AFM or PFM 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. 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); @throws DocumentException the font is invalid @throws IOException the font file could not be read
public static BaseFont CreateFont(string name, string encoding, bool embedded)
Parameters
name
stringthe name of the font or its location on file
encoding
stringthe encoding to be applied to this font
embedded
booltrue if the font is to be embedded in the PDF
Returns
- BaseFont
returns a new font. This font may come from the cache
CreateFont(string, string, bool, bool)
Creates a new font. This font can be one of the 14 built in types, a Type1 font referred to by an AFM or PFM 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. 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); @throws DocumentException the font is invalid @throws IOException the font file could not be read @since 2.1.5
public static BaseFont CreateFont(string name, string encoding, bool embedded, bool forceRead)
Parameters
name
stringthe name of the font or its location on file
encoding
stringthe encoding to be applied to this font
embedded
booltrue if the font is to be embedded in the PDF
forceRead
boolin some cases (TrueTypeFont, Type1Font), the full font file will be read and kept in memory if forceRead is true
Returns
- BaseFont
returns a new font. This font may come from the cache
CreateFont(string, string, bool, bool, byte[], byte[])
Creates a new font. This font can be one of the 14 built in types, a Type1 font referred to by an AFM or PFM 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 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" the cache if new, false if the font is always created new is true, otherwise it will always be created new @throws DocumentException the font is invalid @throws IOException the font file could not be read @since iText 0.80
public static BaseFont CreateFont(string name, string encoding, bool embedded, bool cached, byte[] ttfAfm, byte[] pfb)
Parameters
name
stringthe name of the font or its location on file
encoding
stringthe encoding to be applied to this font
embedded
booltrue if the font is to be embedded in the PDF
cached
booltrue if the font comes from the cache or is added to
ttfAfm
byte[]the true type font or the afm in a byte array
pfb
byte[]the pfb in a byte array
Returns
- BaseFont
returns a new font. This font may come from the cache but only if cached
CreateFont(string, string, bool, bool, byte[], byte[], bool)
Creates a new font. This font can be one of the 14 built in types, a Type1 font referred to by an AFM or PFM 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 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" the cache if new, false if the font is always created new 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 is true, otherwise it will always be created new @throws DocumentException the font is invalid @throws IOException the font file could not be read @since 2.0.3
public static BaseFont CreateFont(string name, string encoding, bool embedded, bool cached, byte[] ttfAfm, byte[] pfb, bool noThrow)
Parameters
name
stringthe name of the font or its location on file
encoding
stringthe encoding to be applied to this font
embedded
booltrue if the font is to be embedded in the PDF
cached
booltrue if the font comes from the cache or is added to
ttfAfm
byte[]the true type font or the afm in a byte array
pfb
byte[]the pfb in a byte array
noThrow
boolif true will not throw an exception if the font is not recognized and will return null, if false will throw
Returns
- BaseFont
returns a new font. This font may come from the cache but only if cached
CreateFont(string, string, bool, bool, byte[], byte[], bool, bool)
Creates a new font. This font can be one of the 14 built in types, a Type1 font referred to by an AFM or PFM 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 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" the cache if new, false if the font is always created new 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 is true, otherwise it will always be created new @throws DocumentException the font is invalid @throws IOException the font file could not be read @since 2.1.5
public static BaseFont CreateFont(string name, string encoding, bool embedded, bool cached, byte[] ttfAfm, byte[] pfb, bool noThrow, bool forceRead)
Parameters
name
stringthe name of the font or its location on file
encoding
stringthe encoding to be applied to this font
embedded
booltrue if the font is to be embedded in the PDF
cached
booltrue if the font comes from the cache or is added to
ttfAfm
byte[]the true type font or the afm in a byte array
pfb
byte[]the pfb in a byte array
noThrow
boolif true will not throw an exception if the font is not recognized and will return null, if false will throw
forceRead
boolin some cases (TrueTypeFont, Type1Font), the full font file will be read and kept in memory if forceRead is true
Returns
- BaseFont
returns a new font. This font may come from the cache but only if cached
CreateFont(PrIndirectReference)
Creates a font based on an existing document font. The created font font may not behave as expected, depending on the encoding or subset.
public static BaseFont CreateFont(PrIndirectReference fontRef)
Parameters
fontRef
PrIndirectReferencethe reference to the document font
Returns
- BaseFont
the font
EnumerateTtcNames(byte[])
Enumerates the postscript font names present inside a True Type Collection. @throws DocumentException on error @throws IOException on error
public static string[] EnumerateTtcNames(byte[] ttcArray)
Parameters
ttcArray
byte[]the font as a byte array
Returns
- string[]
the postscript font names
EnumerateTtcNames(string)
Enumerates the postscript font names present inside a True Type Collection. @throws DocumentException on error @throws IOException on error
public static string[] EnumerateTtcNames(string ttcFile)
Parameters
ttcFile
stringthe file name of the font
Returns
- string[]
the postscript font names
GetAllFontNames(string, string, byte[])
Gets all the names from the font. Only the required tables are read. @throws DocumentException on error @throws IOException on error
public static object[] GetAllFontNames(string name, string encoding, byte[] ttfAfm)
Parameters
name
stringthe name of the font
encoding
stringthe encoding of the font
ttfAfm
byte[]the true type font or the afm in a byte array
Returns
- object[]
an array of Object[] built with {getPostscriptFontName(), GetFamilyFontName(), GetFullFontName()}
GetAllNameEntries(string, string, byte[])
Gets all the entries of the namestable from the font. Only the required tables are read. @throws DocumentException on error @throws IOException on error
public static string[][] GetAllNameEntries(string name, string encoding, byte[] ttfAfm)
Parameters
name
stringthe name of the font
encoding
stringthe encoding of the font
ttfAfm
byte[]the true type font or the afm in a byte array
Returns
- string[][]
an array of Object[] built with {getPostscriptFontName(), getFamilyFontName(), getFullFontName()}
GetAscent(string)
Gets the ascent of a 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.
public int GetAscent(string text)
Parameters
text
stringthe String to get the ascent of
Returns
- int
the ascent in normalized 1000 units
GetAscentPoint(string, float)
Gets the ascent of a String in points. The ascent will always be greater than or equal to zero even if all the characters have a lower ascent.
public float GetAscentPoint(string text, float fontSize)
Parameters
Returns
- float
the ascent in points
GetBaseName(string)
Gets the name without the modifiers Bold, Italic or BoldItalic.
protected static string GetBaseName(string name)
Parameters
name
stringthe full name of the font
Returns
- string
the name without the modifiers Bold, Italic or BoldItalic
GetCharBBox(int)
Gets the smallest box enclosing the character contours. It will return 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]. null
public virtual int[] GetCharBBox(int c)
Parameters
c
intthe character to get the contour bounding box from
Returns
- int[]
an array of four floats with the bounding box in the format [llx,lly,urx,ury] or
GetCidCode(int)
Gets the CID code given an Unicode. It has only meaning with CJK fonts.
public virtual int GetCidCode(int c)
Parameters
c
intthe Unicode
Returns
- int
the CID equivalent
GetDescent(string)
Gets the descent of a 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.
public int GetDescent(string text)
Parameters
text
stringthe String to get the descent of
Returns
- int
the dexcent in normalized 1000 units
GetDescentPoint(string, float)
Gets the descent of a String in points. The descent will always be less than or equal to zero even if all the characters have an higher descent.
public float GetDescentPoint(string text, float fontSize)
Parameters
Returns
- float
the dexcent in points
GetDocumentFonts(PdfReader)
Gets a list of all document fonts. Each element of the ArrayList contains a Object[]{String,PRIndirectReference} with the font name and the indirect reference to it.
public static List<object[]> GetDocumentFonts(PdfReader reader)
Parameters
reader
PdfReaderthe document where the fonts are to be listed from
Returns
GetDocumentFonts(PdfReader, int)
Gets a list of the document fonts in a particular page. Each element of the ArrayList contains a Object[]{String,PRIndirectReference} with the font name and the indirect reference to it.
public static List<object[]> GetDocumentFonts(PdfReader reader, int page)
Parameters
reader
PdfReaderthe document where the fonts are to be listed from
page
intthe page to list the fonts from
Returns
GetFontDescriptor(int, float)
Gets the font parameter identified by key . Valid values for key are ASCENT , CAPHEIGHT , DESCENT , ITALICANGLE , BBOXLLX , BBOXLLY , BBOXURX and BBOXURY .
public abstract float GetFontDescriptor(int key, float fontSize)
Parameters
Returns
- float
the parameter in points
GetFullFontName(string, string, byte[])
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}. @throws DocumentException on error @throws IOException on error
public static string[][] GetFullFontName(string name, string encoding, byte[] ttfAfm)
Parameters
name
stringthe name of the font
encoding
stringthe encoding of the font
ttfAfm
byte[]the true type font or the afm in a byte array
Returns
- string[][]
the full name of the font
GetFullFontStream()
Returns a PdfStream object with the full font program (if possible). This method will return null for some types of fonts (CJKFont, Type3Font) or if there is no font program available (standard Type 1 fonts). @since 2.1.3
public abstract PdfStream GetFullFontStream()
Returns
- PdfStream
a PdfStream with the font program
GetKerning(int, int)
Gets the kerning between two Unicode chars.
public abstract int GetKerning(int char1, int char2)
Parameters
Returns
- int
the kerning to be applied
GetRawCharBBox(int, string)
protected abstract int[] GetRawCharBBox(int c, string name)
Parameters
Returns
- int[]
GetResourceStream(string)
Gets the font resources. null if not found
public static Stream GetResourceStream(string key)
Parameters
key
stringthe name of the resource
Returns
- Stream
the Stream to get the resource or
GetUnicodeEquivalent(int)
Gets the Unicode equivalent to a CID. The (inexistent) CID FF00 is translated as '\n'. It has only meaning with CJK fonts with Identity encoding.
public virtual int GetUnicodeEquivalent(int c)
Parameters
c
intthe CID code
Returns
- int
the Unicode equivalent
GetWidth(int)
Gets the width of a char in normalized 1000 units.
public virtual int GetWidth(int char1)
Parameters
char1
intthe unicode char to get the width of
Returns
- int
the width in normalized 1000 units
GetWidth(string)
Gets the width of a string in normalized 1000 units.
public virtual int GetWidth(string text)
Parameters
text
stringthe string to get the witdth of
Returns
- int
the width in normalized 1000 units
GetWidthPoint(int, float)
Gets the width of a char in points.
public float GetWidthPoint(int char1, float fontSize)
Parameters
Returns
- float
the width in points
GetWidthPoint(string, float)
Gets the width of a string in points.
public float GetWidthPoint(string text, float fontSize)
Parameters
Returns
- float
the width in points
GetWidthPointKerned(string, float)
Gets the width of a String in points taking kerning into account.
public float GetWidthPointKerned(string text, float fontSize)
Parameters
Returns
- float
the width in points
HasKernPairs()
Checks if the font has any kerning pairs.
public abstract bool HasKernPairs()
Returns
- bool
true if the font has any kerning pairs
IsEmbedded()
Gets the embedded flag.
public bool IsEmbedded()
Returns
- bool
true if the font is embedded.
IsFontSpecific()
Gets the symbolic flag of the font.
public bool IsFontSpecific()
Returns
- bool
true if the font is symbolic
NormalizeEncoding(string)
Normalize the encoding names. "winansi" is changed to "Cp1252" and "macroman" is changed to "MacRoman".
protected static string NormalizeEncoding(string enc)
Parameters
enc
stringthe encoding to be normalized
Returns
- string
the normalized encoding
SetCharAdvance(int, int)
Sets the character advance. false otherwise
public virtual bool SetCharAdvance(int c, int advance)
Parameters
Returns
- bool
true if the advance was set,
SetKerning(int, int, int)
Sets the kerning between two Unicode chars.
public abstract bool SetKerning(int char1, int char2, int kern)
Parameters
char1
intthe first char
char2
intthe second char
kern
intthe kerning to apply in normalized 1000 units
Returns
- bool
true if the kerning was applied, false otherwise