C# Class ARCed.Helpers.FontHelper

Static class for loading and creating Fonts in memory without the need to have them installed.
In order for a memory font to be drawn on a control, it must be rendered with GDI+, so "SetCompatibleTextRenderingDefault" must be set for the application, or "UseCompatibleTextRendering" for individual controls.
Show file Open project: borisblizzard/arcreator

Public Methods

Method Description
AddFileFont ( string filename ) : void

Adds a private memory font from a file

AddFont ( Stream stream ) : void

Adds a private memory font from a stream

The stream will be closed automatically after the font is loaded

AddResourceFont ( byte bytes ) : void

Adds a font from an array of bytes

AddResourceFont ( string resourceName ) : void

Adds a private memory font from an embedded resource

GetFont ( string familyName, float size, FontStyle style ) : Font

Creates and returns a font, first checking memorized fonts.

GetMemoryFont ( string familyName, float size, FontStyle style ) : Font

Finds and creates a font from a font family previously loaded into memory

IsInstalled ( string fontName ) : bool

Checks if a font is installed on the machine and returns the result

LoadUserFonts ( ) : void

Loads all TrueType fonts found in the application's "Fonts" folder into memory.

This method also loads resource fonts embedded into the application.

Method Details

AddFileFont() public static method

Adds a private memory font from a file
public static AddFileFont ( string filename ) : void
filename string The path of the file
return void

AddFont() public static method

Adds a private memory font from a stream
The stream will be closed automatically after the font is loaded
public static AddFont ( Stream stream ) : void
stream Stream The stream to load the font from
return void

AddResourceFont() public static method

Adds a font from an array of bytes
public static AddResourceFont ( byte bytes ) : void
bytes byte Array of bytes to read
return void

AddResourceFont() public static method

Adds a private memory font from an embedded resource
public static AddResourceFont ( string resourceName ) : void
resourceName string The full names, including namespaces, of the resource file
return void

GetFont() public static method

Creates and returns a font, first checking memorized fonts.
public static GetFont ( string familyName, float size, FontStyle style ) : Font
familyName string Name of the font family
size float Size of the font
style FontStyle Style to apply to the font
return System.Drawing.Font

GetMemoryFont() public static method

Finds and creates a font from a font family previously loaded into memory
public static GetMemoryFont ( string familyName, float size, FontStyle style ) : Font
familyName string Name of the font family
size float Size of the font
style FontStyle Style to apply to the font
return System.Drawing.Font

IsInstalled() public static method

Checks if a font is installed on the machine and returns the result
public static IsInstalled ( string fontName ) : bool
fontName string The names of the font to check for
return bool

LoadUserFonts() public static method

Loads all TrueType fonts found in the application's "Fonts" folder into memory.
This method also loads resource fonts embedded into the application.
public static LoadUserFonts ( ) : void
return void