Skip to content

PDFType3Font

Namespace: O2S.Components.PDF4NET.Graphics

Defines a Type3 font.

public class PDFType3Font : PDFFont

Inheritance ObjectPDFFontPDFType3Font

Constructors

PDFType3Font()

Initializes a new PDFType3Font object.

public PDFType3Font()

PDFType3Font(String)

Initializes a new PDFType3Font object.

public PDFType3Font(string name)

Parameters

name String
The font name.


PDFType3Font(PDFTrueTypeFont)

Initializes a new PDFType3Font object.

public PDFType3Font(PDFTrueTypeFont font)

Parameters

font PDFTrueTypeFont
Source TrueType font.


Properties

Bold

Gets or sets a value indicating whether the font is bold.

public bool Bold { get; set; }

Property Value

Boolean
If true, then the font has a bold appearance.


CharacterSpacing

Gets or sets the character spacing to be used by this font.

public double CharacterSpacing { get; set; }

Property Value

Double
Character spacing in unscaled text units.


CosFont

Gets the COS font dictionary.

public PDFCosDictionary CosFont { get; }

Property Value

PDFCosDictionary


FirstChar

Gets or sets the first char in the font.

public byte FirstChar { get; set; }

Property Value

Byte
The code of first character available in the font.


FontBBox

Gets or sets the font bbox.

public PDFStandardRectangle FontBBox { get; set; }

Property Value

PDFStandardRectangle
The smallest rectangle that encloses all the glyphs in the font.


FontMatrix

Gets or sets the font matrix.

public PDFMatrix FontMatrix { get; set; }

Property Value

PDFMatrix
The matrix that maps the glyph space to text space.

Remarks

common practice is to define glyphs in terms of a 1000-unit glyph coordinate system, in which case the font matrix is [0.001 0 0 0.001 0 0].


Glyphs

Gets the font glyphs.

public PDFType3GlyphCollection Glyphs { get; }

Property Value

PDFType3GlyphCollection
The collection of font glyphs.


HorizontalScaling

Gets or sets the text horizontal scaling to be used by this font.

public double HorizontalScaling { get; set; }

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.

public bool Italic { get; set; }

Property Value

Boolean
If true, then the font has an italic appearance.


LastChar

Gets or sets the last char in the font.

public byte LastChar { get; set; }

Property Value

Byte
The code of last character available in the font.


Metrics

Gets the font metrics.

public PDFFontMetrics Metrics { get; }

Property Value

PDFFontMetrics
A PDFFontMetrics that represents the metrics of the font.


Size

Gets or sets the font size.

public double Size { get; set; }

Property Value

Double
The font size in PDF points.


Strikethrough

Gets or sets a value indicating whether the font is strikethrough.

public bool Strikethrough { get; set; }

Property Value

Boolean
If true, then the font has a strikethrough appearance.


StrikethroughOffset

Gets or sets the strikethrough offset.

public double StrikethroughOffset { get; set; }

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.

public PDFTextRenderingMode TextRenderingMode { get; set; }

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.

public bool Underline { get; set; }

Property Value

Boolean
If true, then the font has an underlined appearance.


Widths

Gets or sets the character widths.

public Double[] Widths { get; set; }

Property Value

Double[]
An array of values that represent the character widths in glyph space.

Remarks

The number of elements in this array must be equal to PDFType3Font.LastChar - PDFType3Font.FirstChar + 1.


Methods

CreateGlyphFromUnicodeCodePoint(Byte, Int32)

Creates a PDFType3Glyph from the given code point and associates it with the given character code in this font.

public void CreateGlyphFromUnicodeCodePoint(byte characterCode, int codePoint)

Parameters

characterCode Byte
The character code in this font that is associated with the glyph image

codePoint Int32
Source code point for which the glyph image is extracted from the TrueType font

Remarks

This method can be used only if the PDFType3Font object has been created from a PDFTrueTypeFont object.


CreateGlyphFromUnicodeCodePoint(Byte, Int32, Boolean)

Creates a PDFType3Glyph from the given code point and associates it with the given character code in this font.

public void CreateGlyphFromUnicodeCodePoint(byte characterCode, int codePoint, bool coloredGlyph)

Parameters

characterCode Byte
The character code in this font that is associated with the glyph image

codePoint Int32
Source code point for which the glyph image is extracted from the TrueType font

coloredGlyph Boolean
True if the glyph contains color information, no if the glyph is painted using current fill color

Remarks

This method can be used only if the PDFType3Font object has been created from a PDFTrueTypeFont object.


EnableTextCopy()

This method sets up the proper structures to support text copy operations when character codes have been mapped to Unicode codepoints.

public void EnableTextCopy()

GetCharWidth(Char)

Gets the width of the given character when drawn with this font object.

public double GetCharWidth(char charCode)

Parameters

charCode Char
the char to get its width

Returns

Double
This method returns a float 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.