Advanced Font Features

Microchip Graphics Library

Microchip Graphics Library
Advanced Font Features

Font Anti-Aliasing 

Anti-aliasing is a technique used to make the edges of text appear smooth. This is useful especially with characters like 'A', 'O', etc which has slant or curved lines. Since the pixels of the display are arranged in rectangular fashion, slant edges can't be represented smoothly. To make them appear smooth, a pixel adjacent to the pixels is painted with an average of the foreground and background colors as depicted in Figure 1. 

 

 

Figure 1: Font with Anti-Aliasing 

 

 

Figure 2: Font with No Anti-Aliasing

 

When anti-aliasing is turned off, the pixels abruptly changes from background color to foreground color shown in Figure 2. To implement anti-aliasing, adjacent pixels transitions from background to foreground color using 25% or 75% mid-color values from background to foreground colors. This feature in fonts will require roughly twice the size of memory storage required for font glyphs with no anti-aliasing. 

Since the average of foreground and background colors needs to be calculated at runtime, the rendering of anti-aliased fonts take more time than rendering normal fonts. To optimize the rendering speed, a macro named GFX_Font_SetAntiAliasType() is available where anti-alias type can be set to ANTIALIAS_OPAQUE or ANTIALIAS_TRANSLUCENT.

  • ANTIALIAS_OPAQUE (default after initialization of graphics) - mid colors are calculated once while rendering each character which is ideal for rendering text over a constant background.
  • ANTIALIAS_TRANSLUCENT - the mid values are calculated for every necessary pixel and this feature is useful while rendering text over an image or on a non-constant color background.
As a result, rendering anti-aliased text takes longer with ANTIALIAS_TRANSLUCENT type than compared to ANTIALIAS_OPAQUE type. 

 

To use anti-aliasing, enable the compiler switch #define USE_ANTIALIASED_FONTS in the GraphicsConfig.h file and enable the anti-alias checkbox in the Graphics Resource Converter (GRC) tool while selecting the font. 

 

Note: Even when anti-aliasing is enabled, normal fonts can be used without the antialias effect. 

 

Extended Glyphs 

Extended glyphs are needed to render characters of certain languages which use more than one byte to represent a single character. For example: Asian languages like Thai, Hindi, etc. In these character set, more than one glyph overlaps each other to form a single character of that language as shown in Figure 3. To use this feature, enable the Extended Glyph checkbox in the Graphics Resource Converter (GRC) tool while selecting the font. 

 

 

Figure 3: Example of a Character that is Formed by Two Overlapping Glyphs

 

Note: The fonts used with extended glyphs are normal ANSI fonts and not Unicode fonts.

Links
Microchip Graphics Library Version 3.06.02 - October 15, 2012
Copyright © 2012 Microchip Technology, Inc.  All rights reserved