Chapter 9. Fonts, Text, and Printing

 < Day Day Up > 

Topics in This Chapter

  • Fonts: .NET classes support the creation of individual font objects and font families. Treating a font as an object allows an application to set a font's style and size through properties.

  • Text: The Graphics.DrawString method and StringFormat class are used together to draw and format text on a drawing surface.

  • Printing: The PrintDocument class provides the methods, properties, and events used to control .NET printing. It exposes properties that allow printer selection, page setup, and choice of pages to be printed.

  • Creating a Custom PrintDocument Class: A custom PrintDocument class provides an application greater control over the printing process and can be used to ensure a consistent format for reports.

Chapter 8, ".NET Graphics Using GDI+," focused on the use of GDI+ for creating graphics and working with images. This chapter continues the exploration of GDI+ with the focus shifting to its use for "drawing text." One typically thinks of text as being printed rather than drawn. In the .NET world, however, the display and rendering of text relies on techniques similar to those required to display any graphic: a Graphics object must be created, and its methods used to position and render text strings the shape of which is determined by the font used.

This chapter begins with a look at fonts and an explanation of the relationship between fonts, font families, and typefaces. It then looks at the classes used to create fonts and the options for sizing them and selecting font styles. The Graphics.DrawString method is the primary tool for rendering text and has several overloads that support a number of formatting features: text alignment, text wrapping, the creation of columnar text, and trimming, to name a few.

The chapter concludes with a detailed look at printing. An incremental approach is taken. A simple example that illustrates the basic classes is presented. Building on these fundamentals, a more complex and realistic multi-page report with headers, multiple columns, and end-of-page handling is presented. Throughout, the emphasis is on understanding the GDI+ classes that support printer selection, page layout, and page creation.

     < Day Day Up > 

    Core C# and  .NET
    Core C# and .NET
    ISBN: 131472275
    EAN: N/A
    Year: 2005
    Pages: 219 © 2008-2017.
    If you may any questions please contact us: