NOV fully supports the TrueType font specification (fonts with the extension of ".ttf" or ".ttc"). Such fonts can be installed and uninstalled from the NOV font service at runtime, provided that you can obtain a stream object to the font data. The following sections will teach you how to install fonts.
By default the NOV framework comes with four built-in fonts - Arimo, Cousine, Tinos and Symbol Neu. Those are the Google Chrome OS fonts, which are the standard fonts in NOV as they are shipped with the SIL Open Font License, which permits redistribution in packaged software. Those fonts cover the four major font styles - San Serif, Monospaced, Serif and Symbol respectively.
In addition, depending on the environment NOV will automatically determine which fonts are accessible and automatically register them in the font service:
Environment |
Installed Fonts |
Windows (WinForm of WPF) |
Built-in fonts and all TrueType fonts present in the Windows\Fonts directory. |
Silverlight |
Built-in fonts only. |
When you request a font the system will automatically search for it in the list of registered fonts and if present it will use that font. Otherwise, depending on the request it will perform a fallback to the font that most closely matches the requested font.
In order to install a font you need to be able to provide a stream based access to the font binary data. NOV provides several classes that facilitate the most common font sources:
Class |
Description |
NOTFileInstalledFont |
Represents a font that resides in a hard drive - for example "c:\windows\fonts\arial.ttf" |
NOTMemoryInstalledFont |
Represents a font that resides in memory (byte array) |
NOTResourceInstalledFont |
Represents a font that resides in a resource |
The following code snippet shows how to install a font from different sources:
Installing fonts |
Copy Code
|
// Installing font from memory
NApplication.FontService.InstalledFontsMap.InstallFont(new NOTMemoryInstalledFont(someByteArray));
// Installing font from file
NApplication.FontService.InstalledFontsMap.InstallFont(new NOTFileInstalledFont(@"c:\windows\fonts\arial.ttf"));
// Installing font from resource
NApplication.FontService.InstalledFontsMap.InstallFont(new NOTResourceInstalledFont(someEmbeddedResource));
|