ARTICLE

Working with Fonts in GDI+

Posted by Dinesh Beniwal Articles | GDI+ in VB.NET February 25, 2010
In this article I will explain about working with Fonts in GDI+.
 
Reader Level:

In this section we will concentrate on fonts .The discussion starts with a description of the types of fonts in the Windows operating system, followed by a little background material on fonts. After these basic concepts are covered the discussion turns to how fonts are handled in GDI+ and .NET.

 
Font Types in Windows
 
Windows supports two type of fonts: GDI fonts and device fonts. Device Fonts are native to output devices such as a monitor or a printer. GDI fonts are stored in files on your system normally in the Window/Fonts directory. Each font has its own file. For example, Arial, Arial Black, Arial Bold, Arial Italic, Arial Black Italic, Arial Bold Italic, Arial Narrow, Arial Narrow Bold Italic, and Arial Narrow Italic are different fonts in the Arial font family, and each one has its own file.

 
GDI fonts can be further divided into four major categories: raster, stroke, TrueType, and OpenType. The raster and stroke fonts are the oldest way to display text (they pre-date Windows 3.1).Raster fonts (also known as bitmap fonts) store each character in pixel format. Each raster font is designed for specific aspect ratio and character size, which are generally not scalable to other sizes. The main advantage of raster fonts is high performance because rendering a raster font usually just requires copying it to video memory. Raster fonts supports boldface, italics, underlining and strikethrough formatting.
 
Stroke fonts (also known as vector fonts) are defined as series of license and dots-in much the same way that characters are drawn with a pen plotter. Stroke fonts are thus quite scalable (they can be increased or decreased to any size), and they can be used with output device of any resolution. Examples of stroke fonts support boldface, italics, underlining, and strikethrough formatting.
 
Next we come to TrueType fonts, which were developed by Apple and Microsoft and supported by many manufactures. TrueType fonts are also called outline fonts because the individual characters are defined by filled outlines of straight lines and curves. Altering the coordinates that define the outlines provides great scalability .The original 13 Truetype fonts were:
  1. Courier New
  2. Courier New Bold
  3. Courier New Italic
  4. Courier New Bold Italic
  5. Times New Roman
  6. Times New Roman Bold
  7. Times New Roman Italic
  8. Times New Roman Bold Italic
  9. Arial
  10. Arial Bold
  11. Arial Italic
  12. Arial Bold Italic
  13. Symbol

    Figure 5.5.gif
 
FIGURE 5.5: Fonts available in windows
 
Adobe and Microsoft announced yet another format in 1997, called Open type. It is a combination of TrueType and Type 1 outline format of Adobe's page-description language. Window 2000 installs 82 fonts, including TrueType fonts, OpenType fonts, and other types. The TrueType fonts are represented by a "T" icon, and Open type fonts are represented by an "O" icon in windows Explorer.
 
The file extension of both TrueType and OpenType fonts is .ttf. If you double-click on the Verdana OpenType font File, it displays the information shown in Figure 5.7.
 
The Arial Black Italic TrueType font file, on the other hand, looks like Figure 5.8.

Figure 5.6.gif

FIGURE 5.6: Font icons represent font types
 
In 1998 Microsoft announced a new display technology called ClearType. ClearType increase the readability and smoothness of text on existing LCDs (liquid crystal display), such as laptop screens, flat-screen monitors, and Pocket PC screens. In normal displays, a pixel has only two pixel states: on and off. ClearType technology adds additional information to a pixel besides the on and off states. With ClearType, the words on the display device look almost as sharp and clear as those on the printed page.
 
Figure 5.7.gif
 
FIGURE 5.7: An OpenType font
 
Figure 5.8.gif
 
FIGURE 5.8: A TrueTypefont

Note: To learn more about Microsoft's ClearType technology, visit http://www.microsoft.com/typography/cleartype/default.html

Conclusion

Hope the article would have helped you in understanding working with Fonts in GDI+. Read other articles on GDI+ on the website.

Login to add your contents and source code to this article
share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor