### Text Display

#### Unicode Text

The Text and International Frameworks use the Unicode-based class IText as the storage mechanism for underlying text. The text can contain a mixture of runs of different character- and paragraph-styling information.

IGraphicText lets you display a single line of styled text as a static graphic object.

#### Static Text

The most straightforward mechanism for drawing the styled text represented in an instance of IText is provided by IGraphicText. IGraphicText implements functions inherited from IMGraphic for drawing, performing graphic transformations, and computing the bounds of the graphic in a device-specific manner.

IGraphicText also provides access functions for the text and for the current transform.

This figure shows the IGraphicText interface:

After initial construction, IGraphicText lets you use setText to reset the text or the setTransform function to reset the current transform. You can also use the convenience function setLocation to set a new drawing position. This resets the current transform to translate the origin to the specified location. The containing view should call the draw function to redraw the string.

You can use the bounds returned by looseFitBounds to position the graphic. For example, you can create a matrix that rotates the graphic by 45 degrees around the center of the bounding rectangle:

For computing the bounding rectangle, the function looseFitBounds returns more accurate results than geometricBounds because geometricBounds returns an approximate bounds based on an untransformed root screen port.

Some graphic transformations may also cause the bounding rectangle to change slightly. You should apply the transformation before computing and using the bounds.

IGraphicText is a subclass of the 2D Graphics class IMGraphic that you use to draw static text strings. IGraphicText draws the styled text in an IText object as a single line of text, beginning at a specified point. IGraphicText also supports basic graphic transformations.

This figure shows IGraphicText and related classes:

IGraphicText is not intended to be subclassed. To implement your own static text display class, derive directly from classes in the 2D Graphics Framework.

You can specify an IGPoint2D object to represent the anchor position at which to draw the text. For English text, the origin is at the left baseline, as illustrated in the following figure:

To draw the text, you specify the IGrafPort into which to display the text. For example, this code demonstrates simple usage of IGraphicText:

    void drawSomeText (const IText& styledText,

    		   IGPoint2D anchorLocation,

       		IGrafPort* displayPort)

    {

    	IGraphicText graphicText(styledText, IGraphicText::kSingleLine);

    	graphicText.setLocation(anchorLocation);

    	graphicText.draw(*displayPort);

    }

#### Summary of Text Display Classes

The text display classes consist of the following classes:

Class | Description
--- | ---
IGraphicText | Lets you draw styled Unicode text strings as static graphics

Graphics Class Architecture
GrafPorts
IMGraphic Models