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
Font(string, float, FontStyle)
Constructs a Font using a specified size and style.
public Font(string family, float size, FontStyle style)
Parameters
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
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
stringsize
floatstyle
FontStyleunit
FontUnitweight
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
stringsize
floatstyle
FontStyleweight
FontWeight
Font(string, float, FontUnit)
Constructs a Font using a specified size and unit.
public Font(string family, float size, FontUnit unit)
Parameters
Font(string, float, FontWeight)
Constructs a Font using a specified size and style.
public Font(string family, float size, FontWeight weight)
Parameters
family
stringsize
floatweight
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
stringsize
floatweight
FontWeightunit
FontUnit
Properties
Family
This read-only property returns the font's family.
public string Family { get; }
Property Value
Remarks
The default value is "Segoe UI"
.
IsItalic
This read-only property returns whether this Font is italic.
public bool IsItalic { get; }
Property Value
Size
This read-only property returns the font's size in units specified by Unit.
public float Size { get; }
Property Value
Remarks
The default value is 13
.
Style
This read-only property returns the font's style.
public FontStyle Style { get; }
Property Value
Remarks
Unit
This read-only property returns the font's unit of measure.
public FontUnit Unit { get; }
Property Value
Remarks
The default value is Pixel.
Weight
This read-only property returns the font's weight.
public FontWeight Weight { get; }
Property Value
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
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
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
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
ToString()
Returns a string representation of the Font.
public override string ToString()
Returns
- string
A string representation of the current Font.