PDFsharp-net6

XFont

Namespace: PdfSharp.Drawing

Defines an object used to draw text.

public sealed class XFont

Inheritance ObjectXFont

Properties

FontFamily

Gets the XFontFamily object associated with this XFont object.

public XFontFamily FontFamily { get; }

Property Value

XFontFamily

Name

WRONG: Gets the face name of this Font object. Indeed, it returns the font family name.

public string Name { get; }

Property Value

String

FromDocument

Indicates, whether this font was created from an existing document.
Intended to avoid unnecessary adding of new Fonts to the document when filling existing AcroForms.

public bool FromDocument { get; }

Property Value

Boolean

DocumentFontName

Gets or sets the name this Font is referenced by in an existing document

public string DocumentFontName { get; internal set; }

Property Value

String

Size

Gets the em-size of this font measured in the unit of this font object.

public double Size { get; }

Property Value

Double

Style

Gets style information for this Font object.

public XFontStyleEx Style { get; }

Property Value

XFontStyleEx

Bold

Indicates whether this XFont object is bold.

public bool Bold { get; }

Property Value

Boolean

Italic

Indicates whether this XFont object is italic.

public bool Italic { get; }

Property Value

Boolean

Strikeout

Indicates whether this XFont object is stroke out.

public bool Strikeout { get; }

Property Value

Boolean

Underline

Indicates whether this XFont object is underlined.

public bool Underline { get; }

Property Value

Boolean

PdfOptions

Gets the PDF options of the font.

public XPdfFontOptions PdfOptions { get; }

Property Value

XPdfFontOptions

CellSpace

Gets the cell space for the font. The CellSpace is the line spacing, the sum of CellAscent and CellDescent and optionally some extra space.

public int CellSpace { get; internal set; }

Property Value

Int32

CellAscent

Gets the cell ascent, the area above the base line that is used by the font.

public int CellAscent { get; internal set; }

Property Value

Int32

CellDescent

Gets the cell descent, the area below the base line that is used by the font.

public int CellDescent { get; internal set; }

Property Value

Int32

Metrics

Gets the font metrics.

public XFontMetrics Metrics { get; }

Property Value

XFontMetrics
The metrics.

Height

Gets the line spacing of this font.

public int Height { get; }

Property Value

Int32

Constructors

XFont(String, Double)

Initializes a new instance of the XFont class.

public XFont(string familyName, double emSize)

Parameters

familyName String
Name of the font family.

emSize Double
The em size.

XFont(String, Double, XFontStyleEx)

Initializes a new instance of the XFont class.

public XFont(string familyName, double emSize, XFontStyleEx style)

Parameters

familyName String
Name of the font family.

emSize Double
The em size.

style XFontStyleEx
The font style.

XFont(String, Double, XFontStyleEx, XPdfFontOptions)

Initializes a new instance of the XFont class.

public XFont(string familyName, double emSize, XFontStyleEx style, XPdfFontOptions pdfOptions)

Parameters

familyName String
Name of the font family.

emSize Double
The em size.

style XFontStyleEx
The font style.

pdfOptions XPdfFontOptions
Additional PDF options.

XFont(String, Double, XFontStyle, XFontWeight, XFontStretch, XPdfFontOptions, Nullable<XStyleSimulations>)

Caution

Not yet implemented.


Initializes a new instance of the XFont class. Not yet implemented.

public XFont(string familyName, double emSize, XFontStyle style, XFontWeight weight, XFontStretch fontStretch, XPdfFontOptions pdfOptions, Nullable<XStyleSimulations> styleSimulations)

Parameters

familyName String
Name of the family.

emSize Double
The em size.

style XFontStyle
The style.

weight XFontWeight
The weight.

fontStretch XFontStretch
The font stretch.

pdfOptions XPdfFontOptions
The PDF options.

styleSimulations Nullable<XStyleSimulations>
The style simulations.

Exceptions

NotImplementedException
XFont

XFont(XTypeface, Double, XPdfFontOptions, Nullable<XStyleSimulations>)

Caution

Not yet implemented.


Initializes a new instance of the XFont class. Not yet implemented.

public XFont(XTypeface typeface, double emSize, XPdfFontOptions pdfOptions, Nullable<XStyleSimulations> styleSimulations)

Parameters

typeface XTypeface
The typeface.

emSize Double
The em size.

pdfOptions XPdfFontOptions
The PDF options.

styleSimulations Nullable<XStyleSimulations>
The style simulations.

Exceptions

NotImplementedException
XFont

Methods

GetHeight()

Returns the line spacing, in pixels, of this font. The line spacing is the vertical distance between the base lines of two consecutive lines of text. Thus, the line spacing includes the blank space between lines along with the height of the character itself.

public double GetHeight()

Returns

Double

GetHeight(XGraphics)

Caution

Use GetHeight() without parameter.


Returns the line spacing, in the current unit of a specified Graphics object, of this font. The line spacing is the vertical distance between the base lines of two consecutive lines of text. Thus, the line spacing includes the blank space between lines along with the height of

public double GetHeight(XGraphics graphics)

Parameters

graphics XGraphics

Returns

Double

GetSupportedCharacters()

Gets the sorted list of characters supported by this font.

public IReadOnlyList<int> GetSupportedCharacters()

Returns

IReadOnlyList<Int32>
The list of characters supported by this font, sorted in ascending order

Remarks:

The returned list may contain surrogates and/or surrogate pairs, so calling applications should use Char.ConvertFromUtf32(Int32) to convert such values to a valid string.