PDFTrueTypeFont¶
Namespace: O2S.Components.PDF4NET.Graphics
Defines the base class for TrueType fonts.
Inheritance Object → PDFFont → PDFTrueTypeFont
Properties¶
Bold¶
Gets or sets a value indicating whether the font is bold.
Property Value
Boolean
True if the font has a bold appearance.
Remarks
This property has no effect if the font is embedded.
CharacterSpacing¶
Gets or sets the character spacing to be used by this font.
Property Value
Double
Character spacing in unscaled text units.
CosFont¶
Gets the COS font dictionary.
Property Value
EnableFontSubset¶
Gets or sets a value indicating whether this font must be subset or not.
Property Value
Boolean
True if the font data should be subset in order to reduce the final font size, false if the whole font file should be embedded in the PDF file. Default is true.
HorizontalScaling¶
Gets or sets the text horizontal scaling to be used by this font.
Property Value
Double
Percentage of the normal width of the glyphs, with 100 being the normal width.
Remarks
The horizontal scaling property adjusts the width of glyphs by stretching or compressing them in the horizontal direction.
Italic¶
Gets or sets a value indicating whether the font is italic.
Property Value
Boolean
True if the font has an italic appearance.
Remarks
This property has no effect if the font is embedded.
Metrics¶
Gets the font metrics.
Property Value
PDFFontMetrics
A PDFFontMetrics that represents the metrics of the font.
Name¶
Gets the name of this font.
Property Value
String
The name of the font as it appears in the font file.
Size¶
Gets or sets the font size.
Property Value
Double
The font size in PDF points.
Strikethrough¶
Gets or sets a value indicating whether the font is strikethrough.
Property Value
Boolean
If true, then the font has a strikethrough appearance.
StrikethroughOffset¶
Gets or sets the strikethrough offset.
Property Value
Double
Offset from text baseline for drawing the strikethrough.
Remarks
The offset is given in PDF points. 0 means default strikethrough offset.
TextRenderingMode¶
Gets or sets the text rendering mode.
Property Value
PDFTextRenderingMode
A PDFTextRenderingMode specifying how the text is rendered using this font.
Underline¶
Gets or sets a value indicating whether the font is underlined.
Property Value
Boolean
If true, then the font has an underlined appearance.
Methods¶
EncodeString(String)¶
Encodes the given text to a byte array based on font's encoding.
Parameters
text String
String to convert.
Returns
Byte[]
An array of bytes representing the string according to font encoding.
GetCharWidth(Char)¶
Gets the width of the given character when drawn with this font object.
Parameters
charCode Char
the char to get its width
Returns
Double
This method returns a double value that represents the width, in
unscaled glyph units, of the given character.
Remarks
To scale this value to font's current size, divide it by 1000 and multiply it by font size. For example, if font size is 20pt, then the width, in points, of a character for this font is 20 * GetCharWidth( charCode ) / 1000.
GetGlyphEmWidth(Int32)¶
Gets the Em width of the given glyph when drawn with this font object.
Parameters
glyph Int32
the index of the glyph to get its width
Returns
Int32
The width of the glyph in Em units.
Remarks
To scale this value to font's current size, divide it by 2048 and multiply it by font size. For example, if font size is 20pt, then the width, in points, of a character for this font is 20 * GetGlyphEmWidth(glyph) / 2048.
GetGlyphOutline(Int32)¶
Gets the outline of the specified character, given as a Unicode code point.
Parameters
codePoint Int32
The Unicode code point of the character for which the glyph outline should be retrieved
Returns
PDFPath
The glyph outline as a PDFPath object
UpdateCharsSubset(Char[])¶
Updates the set of characters that must be subset in the final font data.
Parameters
chars Char[]
Array of characters to be included in the subset.
Remarks
This method is called automatically when using the DrawString methods in the PDFCanvas class but when the low level methods in PDFContentStream class are used then the characters to be subset must be added manually.
UpdateGlyphsSubset(Int32[])¶
Updates the set of glyphs that must be subset in the final font data.
Parameters
glyphs Int32[]
Array of glyph indexes to be included in the subset.
Remarks
This method is called automatically when using the DrawString methods in the PDFCanvas class but when the low level methods in PDFContentStream class are used then the glyphs to be subset must be added manually.