Skip to content

PDFType1Font

Namespace: O2S.Components.PDF4NET.Graphics

Defines a Type1 PDF font.

public class PDFType1Font : PDFFont

Inheritance ObjectPDFFontPDFType1Font

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


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.


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.


Methods

CreateWithAfmMetrics(String, String, Double, Boolean)

Creates a Type1 font from a combination of .afm and .pfb files.

public static PDFType1Font CreateWithAfmMetrics(string metricsFile, string fontFile, double size, bool embed)

Parameters

metricsFile String
Path to .afm file.

fontFile String
Path to .pfb file.

size Double
Font size.

embed Boolean
True if the font should be embedded in the PDF file.

Returns

PDFType1Font
A Type1 font object.


CreateWithAfmMetrics(Stream, Stream, Double, Boolean)

Creates a Type1 font from a combination of .afm and .pfb files.

public static PDFType1Font CreateWithAfmMetrics(Stream metricsStream, Stream fontStream, double size, bool embed)

Parameters

metricsStream Stream
afm data stream.

fontStream Stream
pfb data stream.

size Double
Font size.

embed Boolean
If true, the font will be embedded in the PDF file.

Returns

PDFType1Font
A Type1 font object.


CreateWithPfmMetrics(String, String, Double, Boolean)

Creates a Type1 font from a combination of .pfm and .pfb files.

public static PDFType1Font CreateWithPfmMetrics(string metricsFile, string fontFile, double size, bool embed)

Parameters

metricsFile String
Path to .pfm file.

fontFile String
Path to .pfb file.

size Double
Font size.

embed Boolean
True if the font should be embedded in the PDF file.

Returns

PDFType1Font
A Type1 font object.


CreateWithPfmMetrics(Stream, Stream, Double, Boolean)

Creates a Type1 font from a combination of .pfm and .pfb files.

public static PDFType1Font CreateWithPfmMetrics(Stream metricsStream, Stream fontStream, double size, bool embed)

Parameters

metricsStream Stream
pfm data stream.

fontStream Stream
pfb data stream.

size Double
Font size.

embed Boolean
If true, the font will be embedded in the PDF file.

Returns

PDFType1Font
A Type1 font object.


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.