Font objects are used to specify the appearance of text in labels, text boxes etc. They contain information about the font family, font size, font style and rasterization.
Creating Font objects
Font objects are represented by an instance of the NFont class - the following example shows how to assign a font object to a label:
Creating a Shadow |
Copy Code
|
---|---|
NShadow shadow = new NShadow(); shadow.Color = new NColor(180, 180, 180, 255); shadow.OffsetX = 14; shadow.OffsetY = 10; |
Properties
Name - specifies the font family name - like "Arial", "Times New Roman" etc. The following example shows how to change the font name:
Setting Font Name |
Copy Code
|
---|---|
someLabel.Font.Name = "Times New Roman";
|
Size - specifies the font size in points. The following example shows how to set the font size:
Setting Font Size |
Copy Code
|
---|---|
someLabel.Font.Name = "Times New Roman";
|
Style - specifies the font style - bold, italic, underline or strike through. This property accepts values from the ENFontStyle enum which contains the following values:
ENFontStyle | Description |
Regular | Normal text |
Bold | Bold text. |
Italic | Italic text. |
Underline | Underlined text. |
Strikethrough | Text with a line through the middle. |
You can specify any combination of the above enum values. The following example shows how to display italic, underlined text:
Setting Font Style |
Copy Code
|
---|---|
someLabel.Font.Style = ENFontStyle.Italic | ENFontStyle.Underline; |
Rastererization Mode
NOV implements all major text rasterization modes and you can specify which one should be used through the font object. This is controlled from the RasterizationMode property which accepts values from the ENFontRasterizationMode enum:
ENFontRasterizationMode | Description |
Aliased | Font is rasterized in aliased mode. In this mode each pixel is either filled or non filled. Each glyph is represented by a single raster. You should use Aliased mode for if you wish to improved performance or memory usage. |
Antialiased | Font is rasterized in antialiased mode. In this mode NOV renders each glyph with 256 levels of grayscale and uses subpixel positioned rasters for optimal readablity ,appearance and resolution independence of text output. This mode is the default. |
AntialiasedGridFit | Font is rasterized in antialiased mode, with grid fitting enabled. In this mode each glyph is rendered with 256 levels of grayscale, but with a single raster per glyph. All glyph positioning occurs on exact pixels boundaries. You should use this mode only if you want to reduce the memory footprint. |
SubPixel | Font is rasterized in subpixel antialiased mode. Reserved. |
SubPixelGridFit | Font is rasterized in subpixel antialiased mode, with grid fitting enabled. Reserved. |
The following text shows the famous text "The quick brown fox jumps over the lazy dog" rasterized in Aliased, Antialiased and AntialiasedGridFit modes:
Aliased |
Antialiased |
AntialiasedGridFit |