Table of Contents

Struct FontStyle

Namespace
Egami.Fonts
Assembly
Egami.Fonts.dll

A face's style, or the style asked for when matching: weight from 1 to 1000 (400 normal, 700 bold), width from 1 to 9 (5 normal, as OS/2 usWidthClass), and slant.

public readonly record struct FontStyle : IEquatable<FontStyle>
Implements
Inherited Members

Examples

// Installed fonts, found without native calls and indexed on first use; a style is matched by the CSS rules.
FontMatch? match = FontCollection.System.Match(GenericFamily.SansSerif, FontStyle.Bold);

// Your own fonts work the same way; System is read-only, so add the installed fonts to your collection to have both.
var fonts = new FontCollection();
fonts.AddFile(FontFile);
fonts.AddSystemFonts();
FontMatch noto = fonts.Match("Noto Sans", FontStyle.BoldItalic)!.Value;
Font font = noto.ToFont(16);

Constructors

FontStyle(int, int, FontSlant)

A face's style, or the style asked for when matching: weight from 1 to 1000 (400 normal, 700 bold), width from 1 to 9 (5 normal, as OS/2 usWidthClass), and slant.

public FontStyle(int Weight = 400, int Width = 5, FontSlant Slant = FontSlant.Upright)

Parameters

Weight int

The weight, 1 to 1000; 400 is normal and 700 bold.

Width int

The width class, 1 (ultra-condensed) to 9 (ultra-expanded); 5 is normal.

Slant FontSlant

Upright, italic or oblique.

Examples

// Installed fonts, found without native calls and indexed on first use; a style is matched by the CSS rules.
FontMatch? match = FontCollection.System.Match(GenericFamily.SansSerif, FontStyle.Bold);

// Your own fonts work the same way; System is read-only, so add the installed fonts to your collection to have both.
var fonts = new FontCollection();
fonts.AddFile(FontFile);
fonts.AddSystemFonts();
FontMatch noto = fonts.Match("Noto Sans", FontStyle.BoldItalic)!.Value;
Font font = noto.ToFont(16);

Properties

Bold

Gets weight 700, width 5, upright.

public static FontStyle Bold { get; }

Property Value

FontStyle

BoldItalic

Gets weight 700, width 5, italic.

public static FontStyle BoldItalic { get; }

Property Value

FontStyle

Italic

Gets weight 400, width 5, italic.

public static FontStyle Italic { get; }

Property Value

FontStyle

Normal

Gets weight 400, width 5, upright.

public static FontStyle Normal { get; }

Property Value

FontStyle

Slant

Upright, italic or oblique.

public FontSlant Slant { get; init; }

Property Value

FontSlant

Weight

The weight, 1 to 1000; 400 is normal and 700 bold.

public int Weight { get; init; }

Property Value

int

Width

The width class, 1 (ultra-condensed) to 9 (ultra-expanded); 5 is normal.

public int Width { get; init; }

Property Value

int