GH_FontServer

public sealed class GH_FontServer
Maintains a collection of standard fonts and mays to measure them.

Properties

Console

#
public static Font Console { get; }
FontFamily.GenericMonospace, 10pt, regular

ConsoleAdjusted

#
public static Font ConsoleAdjusted { get; }
FontFamily.GenericMonospace, 10pt, regular, adjusted to counter UI scaling.

ConsoleSmall

#
public static Font ConsoleSmall { get; }
FontFamily.GenericMonospace, 8pt, regular

ConsoleSmallAdjusted

#
public static Font ConsoleSmallAdjusted { get; }
FontFamily.GenericMonospace, 8pt, regular, adjusted to counter UI scaling.

FamilyConsole

#
public static FontFamily FamilyConsole { get; set; }
Gets or sets the FontFamily used for monospaced fonts in Grasshopper.

FamilyScript

#
public static FontFamily FamilyScript { get; set; }
Gets or sets the FontFamily used for scripted fonts in Grasshopper.

FamilyStandard

#
public static FontFamily FamilyStandard { get; set; }
Gets or sets the FontFamily used for standard fonts in Grasshopper.

Large

#
public static Font Large { get; }
SystemFonts.CaptionFont, 10pt, bold

LargeAdjusted

#
public static Font LargeAdjusted { get; }
SystemFonts.CaptionFont, 10pt, bold, adjusted for logical pixel size.

Script

#
public static Font Script { get; }
FontFamily.GenericSansSerif, 10pt, italic

ScriptSmall

#
public static Font ScriptSmall { get; }
FontFamily.GenericSansSerif, 8pt, italic

Small

#
public static Font Small { get; }
SystemFonts.CaptionFont, 6pt, regular

Standard

#
public static Font Standard { get; }
SystemFonts.CaptionFont, 8pt, regular

StandardAdjusted

#
public static Font StandardAdjusted { get; }
SystemFonts.CaptionFont, 8pt, regular, adjusted for logical pixel size.

StandardBold

#
public static Font StandardBold { get; }
SystemFonts.CaptionFont, 8pt, bold

StandardItalic

#
public static Font StandardItalic { get; }
SystemFonts.CaptionFont, 8pt, italic

Methods

FontToString

#
public static string FontToString(Font font)
Convert a font to a string.
font (Font)Font to convert.
Strig representing the font family, size, bold and italic flags.

MeasureString

#
public static Size MeasureString(string text, Font font, float maxwidth)
Measure the size of a string
text (string)The string to measure
font (Font)The font to measure with
maxwidth (float)The maximum width (in pixels) for the layout

MeasureString

#
public static Size MeasureString(string text, Font font, SizeF iLayout)
Measure the size of a string
text (string)The string to measure
font (Font)The font to measure with
iLayout (SizeF)The layout rectangle

MeasureString

#
public static Size MeasureString(string text, Font font)
Measure the size of a string
text (string)The string to measure
font (Font)The font to measure with

NewFont

#
public static Font NewFont(Font font, float size, FontStyle style)
Safe font constructor.
font (Font)Base font.
size (float)New size (points)
style (FontStyle)New style.

NewFont

#
public static Font NewFont(Font font, float size)
Safe font constructor.
font (Font)Base font.
size (float)New size (points)

NewFont

#
public static Font NewFont(Font font, FontStyle style)
Safe font constructor.
font (Font)Base font.
style (FontStyle)New style.

NewFont

#
public static Font NewFont(FontFamily family, float size, FontStyle style)
Safe font constructor.
family (FontFamily)Font family.
size (float)Size (in points).
style (FontStyle)Style (if available).
A font, or null if family is null. A null family means the machine could not supply one at all; returning null degrades text rather than sinking the shared constructor, which is how the LINUX branches have always behaved and what the measuring methods below already expect.

NewFont

#
public static Font NewFont(FontFamily family, float size)
Safe font constructor.
family (FontFamily)Font family.
size (float)Size (in points).

NewFont

#
public static Font NewFont(string family, float size, FontStyle style)
High level function for Font creation. We've ran into loads of trouble in the past with missing Fonts. Never create a font directly via GDI+, always use this method.
family (string)Font Family Name. If a font is found with the exact name, it will be loaded.
size (float)Size of font.
style (FontStyle)Font style, if the requested family does not support the requested style, the style flags will be ignored.
A font that might or might not be what you asked for.

StringToFont

#
public static Font StringToFont(string text)
Convert a font description string back into a font.
text (string)Text to parse.
Font represented by the text, or null if no font could be created.

StringWidth

#
public static int StringWidth(IEnumerable<string> text, Font font)
Measure the maximum width of a collection of strings
text (IEnumerable<string>)The strings to measure
font (Font)The font to measure with

StringWidth

#
public static int StringWidth(string text, Font font)
Measure the width of a string in pixels
text (string)The string to measure
font (Font)The font to measure with

Events

ConsoleFamilyChanged

#
public static event GH_FontServer.ConsoleFamilyChangedEventHandler ConsoleFamilyChanged
Raised whenever the MonospacedFamily is changed.

ScriptFamilyChanged

#
public static event GH_FontServer.ScriptFamilyChangedEventHandler ScriptFamilyChanged
Raised whenever the ScriptFamily is changed.

StandardFamilyChanged

#
public static event GH_FontServer.StandardFamilyChangedEventHandler StandardFamilyChanged
Raised whenever the StandardFamily is changed.