GH_FontServer
Maintains a collection of standard fonts and mays to measure them.
Properties
ConsoleAdjusted
#public static Font ConsoleAdjusted { get; }
FontFamily.GenericMonospace, 10pt, regular, adjusted to counter UI scaling.
ConsoleSmallAdjusted
#public static Font ConsoleSmallAdjusted { get; }
FontFamily.GenericMonospace, 8pt, regular, adjusted to counter UI scaling.
LargeAdjusted
#public static Font LargeAdjusted { get; }
SystemFonts.CaptionFont, 10pt, bold, adjusted for logical pixel size.
StandardAdjusted
#public static Font StandardAdjusted { get; }
SystemFonts.CaptionFont, 8pt, regular, adjusted for logical pixel size.
Methods
FontToString
#Convert a font to a string.
Parameters:
| font (Font) | Font to convert. |
Returns: Strig representing the font family, size, bold and italic flags.
MeasureString
#Measure the size of a string
NewFont
#Safe font constructor.
NewFont
#Safe font constructor.
Parameters:
| family (FontFamily) | Font family. |
| size (float) | Size (in points). |
| style (FontStyle) | Style (if available). |
Returns: 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
#Safe font constructor.
Parameters:
| family (FontFamily) | Font family. |
| size (float) | Size (in points). |
NewFont
#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.
Parameters:
| 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. |
Returns: A font that might or might not be what you asked for.
StringToFont
#Convert a font description string back into a font.
Parameters:
| text (string) | Text to parse. |
Returns: Font represented by the text, or null if no font could be created.
StringWidth
#Measure the maximum width of a collection of strings
Parameters:
| text (IEnumerable<string>) | The strings to measure |
| font (Font) | The font to measure with |