Skip to content

PdfFontQuery class

View as Markdown

Namespace: PdfNetStack.Fonts
Assembly: PdfNetStack.dll
Package: PdfNetStack

What Find looks for in a family: weight, width and style, matched as CSS does, and for variable fonts the optical size and any other axis values to apply to the instance found.

public sealed class PdfFontQuery

Inheritance

object ← PdfFontQuery

PdfOpenTypeFont? caption = fonts.Find("Roboto Flex", new PdfFontQuery
{
    Weight = 650,
    Width = 87.5,
    Style = PdfFontStyle.Italic,
    OpticalSize = 9,
});

The slant in degrees for Oblique, -90 to 90, positive leaning right as in CSS. Default 14, the CSS default for oblique.

public double ObliqueAngle { get; init; }

double

ArgumentOutOfRangeException

The value is not a number from -90 to 90.

The size the text is set at, for a variable font’s optical size axis (opsz), in the axis’s units. Null leaves the axis at its default; fonts without the axis ignore it.

public double? OpticalSize { get; init; }

double?

ArgumentOutOfRangeException

The value is zero, negative, infinite or not a number.

Upright, italic or oblique. Default upright.

public PdfFontStyle Style { get; init; }

PdfFontStyle

Axis values by tag, applied last over the values the match chose, as CSS font-variation-settings: { [“wght”] = 625, [“GRAD”] = 50 }. Tags the font does not have are ignored and values are clamped to each axis’s range. The values are copied when set, so changing the dictionary afterwards does not change the query.

public IReadOnlyDictionary<string, double>? Variations { get; init; }

IReadOnlyDictionary<string, double>?

ArgumentException

A value is infinite or not a number.

CSS weight, 1 to 1000: 400 regular, 700 bold. Default 400.

public double Weight { get; init; }

double

ArgumentOutOfRangeException

The value is not a number from 1 to 1000.

Width as a percentage of normal, as CSS font-width: 75 condensed, 125 expanded. Default 100.

public double Width { get; init; }

double

ArgumentOutOfRangeException

The value is negative, infinite or not a number.