Table of Contents

Class Font

Namespace
Northwoods.Go
Assembly
Northwoods.GoDiagram.WinForms.dll

Defines a particular format for text, including font face, size, weight, and style.

[JsonConverter(typeof(FontJsonConverter))]
public class Font
Inheritance
Font
Inherited Members

Remarks

When constructing a font, properties have the following defaults if not provided:

Note that the default size unit is pixels, not points.

To use a custom font file, specify a family ending with '.ttf' when constructing the font.

Constructors

Font()

Constructs a Font with default properties.

public Font()

Font(string, float)

Constructs a Font using a specified size.

public Font(string family, float size)

Parameters

family string
size float

Font(string, float, FontStyle)

Constructs a Font using a specified size and style.

public Font(string family, float size, FontStyle style)

Parameters

family string
size float
style FontStyle

Font(string, float, FontStyle, FontUnit)

Constructs a Font using a specified size, style, and unit.

public Font(string family, float size, FontStyle style, FontUnit unit)

Parameters

family string
size float
style FontStyle
unit FontUnit

Font(string, float, FontStyle, FontUnit, FontWeight)

Constructs a Font using a specified size, style, unit, and weight.

public Font(string family, float size, FontStyle style, FontUnit unit, FontWeight weight)

Parameters

family string
size float
style FontStyle
unit FontUnit
weight FontWeight

Font(string, float, FontStyle, FontWeight)

Constructs a Font using a specified size, style, and weight.

public Font(string family, float size, FontStyle style, FontWeight weight)

Parameters

family string
size float
style FontStyle
weight FontWeight

Font(string, float, FontUnit)

Constructs a Font using a specified size and unit.

public Font(string family, float size, FontUnit unit)

Parameters

family string
size float
unit FontUnit

Font(string, float, FontWeight)

Constructs a Font using a specified size and style.

public Font(string family, float size, FontWeight weight)

Parameters

family string
size float
weight FontWeight

Font(string, float, FontWeight, FontUnit)

Constructs a Font using a specified size, weight, and unit.

public Font(string family, float size, FontWeight weight, FontUnit unit)

Parameters

family string
size float
weight FontWeight
unit FontUnit

Properties

Family

This read-only property returns the font's family.

public string Family { get; }

Property Value

string

Remarks

The default value is "Segoe UI".

IsItalic

This read-only property returns whether this Font is italic.

public bool IsItalic { get; }

Property Value

bool

Size

This read-only property returns the font's size in units specified by Unit.

public float Size { get; }

Property Value

float

Remarks

The default value is 13.

Style

This read-only property returns the font's style.

public FontStyle Style { get; }

Property Value

FontStyle

Remarks

The default value is Regular.

This value allows a bitwise combination of FontStyle values.

Unit

This read-only property returns the font's unit of measure.

public FontUnit Unit { get; }

Property Value

FontUnit

Remarks

The default value is Pixel.

Weight

This read-only property returns the font's weight.

public FontWeight Weight { get; }

Property Value

FontWeight

Remarks

The default value is Regular.

Methods

Parse(object)

This is a convenience method for Parse(string) that can be used as a Converter.

public static object Parse(object str)

Parameters

str object

Returns

object

Parse(string)

This static method can be used to read in a Font from a string that was produced by Stringify(Font).

public static Font Parse(string str)

Parameters

str string

Returns

Font

Remarks

Font.Parse("Segoe UI;13;Pixel;Bold|Italic") produces the Font new Font("Segoe UI", 13, FontWeight.Bold | FontStyle.Italic, FontUnit.Pixel).

Stringify(Font)

This static method can be used to write out a Point as a string that can be read by Parse(string).

public static string Stringify(Font val)

Parameters

val Font

Returns

string

Remarks

Font.Stringify(new Font("Segoe UI", 13, FontStyle.Italic, FontUnit.Pixel, FontWeight.Bold)) produces the string "Segoe UI;13;Pixel;Italic;Bold".

Stringify(object)

This is a convenience method for Stringify(Font) that can be used as a BackConverter.

public static object Stringify(object pt)

Parameters

pt object

Returns

object

ToString()

Returns a string representation of the Font.

public override string ToString()

Returns

string

A string representation of the current Font.