The Text Objects: 3.1 The Text Object Library: Character Attribute Definitions

Up: GEOS SDK TechDocs | Up | Prev: 3 The Text Object Library | Next: 3.2 Paragraph Attribute Definitions

The text object library provides a multitude of ways to shape the appearance of individual characters. Each character within a text object may even exhibit its own individual attributes, if the object is defined to use multiple character attributes. The definitions within this section show the full range of possibilities for character attributes.

The VisTextCharAttr Structure

The VisTextCharAttr structure provides a great variety of attributes for characters within text objects. Many of the VisTextCharAttr fields use graphics structures to tailor the appearance of individual characters within the text object. You may wish to review the Graphics Environment chapter to discover the full features of this structure.

Code Display 10-1 The VisTextCharAttr Structure

typedef struct {
    StyleSheetElementHeader				VTCA_meta;
    FontID				VTCA_fontID;
    WBFixed				VTCA_pointSize;
    TextStyle				VTCA_textStyles;
    ColorQuad				VTCA_color;
    sword				VTCA_trackKerning;
    byte				VTCA_fontWeight;
    byte				VTCA_fontWidth;
    VisTextExtendedStyles				VTCA_extendedStyles;
    SystemDrawMask				VTCA_grayScreen;
    GraphicPattern				VTCA_pattern;
    ColorQuad				VTCA_bgColor;
    SystemDrawMask				VTCA_bgGrayScreen;
    GraphicPattern				VTCA_bgPattern;
    byte				VTCA_reserved[7];
} VisTextCharAttr;

VTCA_ meta stores a StyleSheetElementHeader . This structure field allows the VisTextCharAttr structure to act as an element in an element array. For complete information on using character attribute element arrays to implement character style runs, see Character Runs .

VTCA_ fontID stores the FontID of the font to be used for this character. Any current font allowed by the system is valid. There may exist up to 65536 fonts of type FontID .

VTCA_ pointSize stores the point size of the character. This may be any fixed point value between 4 and 792.

VTCA_ textStyles stores the text styles (of type TextStyle ) to be applied to this character. For a list of text styles, see the Drawing Shapes chapter.

VTCA_ color stores the current color (of type ColorQuad ) of the foreground text character.

VTCA_ trackKerning stores the kerning value (either positive or negative) for this character. This value is expressed in points and reflects how much extra space (if positive) or removal of space (if negative) to apply between this character and the next character.

VTCA_ fontWeight stores the font-weight (thickness) of the character. This value is expressed as a FontWeight value, a percentage between 75% and 125%.

VTCA_ fontWidth stores the width of the font, expressed as a FontWidth value, a percentage between 25% and 200%. Several constants are defined in font.h with common font widths, including FWI_CONDENSED and FWI_EXPANDED.

VTCA_ extendedStyles stores any VisTextExtendedStyles (separate from the TextStyle in VTCA_ textStyles ) in use by this character. These styles are defined in the text object library. See VisTextExtendedStyles for a list of extended styles.

VTCA_ grayScreen stores the SystemDrawMask to use when displaying this text. This mask is applied to the text characters but not to the background.

VTCA_ pattern stores the GraphicPattern to use when displaying this text. This pattern is applied to the text characters but not to the background.

VTCA_bgColor stores the background color to apply to the character's background (but not to the character itself).

VTCA_ bgGrayScreen stores the SystemDrawMask to apply to the character's background.

VTCA_ bgPattern stores the GraphicPattern to apply to the character's background.

Code Display 10-2 VisTextExtendedStyles

  /* These flags are stored in the VisTextCharAttr entry VTCA_extendedStyles */
typedef WordFlags VisTextExtendedStyles;
#define VTES_BOXED				0x8000
#define VTES_BUTTON				0x4000
#define VTES_INDEX				0x2000
#define VTES_ALL_CAP				0x1000
#define VTES_SMALL_CAP				0x0800
#define VTES_HIDDEN				0x0400
#define VTES_CHANGE_BAR				0x0200
#define VTES_BACKGROUND_COLOR				0x0100

VTES_BOXED draws the character within a box (a rectangle surrounding the character). If consecutive characters are marked VTES_BOXED they will all be drawn within a single rectangular outline.

VTES_BUTTON frames the text characters within a drop shadow. Consecutive characters marked VTES_BUTTON will be framed within a single drop-shadow.

VTES_INDEX marks the character for indexing purposes. This feature is currently not implemented.

VTES_ALL_CAP indicates that the character should be capitalized in the current point size.

VTES_SMALL_CAP indicates that the character should be capitalized, but at a smaller point size.

VTES_HIDDEN indicates that this character acts as hidden text. Hidden text may exhibit special properties (such as being masked out when printing).

VTES_CHANGE_BAR is currently unimplemented.

VTES_BACKGROUND_COLOR indicates that this character exhibits a special background color.

Default Character Attributes

You may decide that you do not need your characters to exhibit the many attributes available within the VisTextCharAttr structure. If your text object is simple, you may want instead to use the default character attributes provided in the text object library. These default attributes supersede the use of the VisTextCharAttr structure. All of these attributes will fit into a single word record.

The VisTextDefaultCharAttr record allows your text object to exhibit three styles (underline, bold, and italic), 16 color indexes of type Color , eight point sizes, and 32 different fonts.

Code Display 10-3 VisTextDefaultCharAttr

typedef WordFlags VisTextDefaultCharAttr;
#define VTDCA_UNDERLINE			0x8000
#define VTDCA_BOLD			0x4000
#define VTDCA_ITALIC			0x2000
#define VTDCA_COLOR			0x0f00	/* Color */
#define VTDCA_SIZE			0x00e0	/* VisTextDefaultSize */
#define VTDCA_FONT			0x001f	/* VisTextDefaultFont */
#define VTDCA_COLOR_OFFSET				8
#define VTDCA_SIZE_OFFSET				5
#define VTDCA_FONT_OFFSET				0
  typedef ByteEnum VisTextDefaultSize;
    #define		VTDS_8	0		/* Point size of 8 */
    #define		VTDS_9	1		/* Point size of 9 */
    #define		VTDS_10	2		/* Point size of 10 */
    #define		VTDS_12	3		/* Point size of 12 */
    #define		VTDS_14	4		/* Point size of 14 */
    #define		VTDS_18	5		/* Point size of 18 */
    #define		VTDS_24	6		/* Point size of 24 */
    #define		VTDS_36	7		/* Point size of 36 */
  typedef ByteEnum VisTextDefaultFont;
    #define		VTDF_BERKELEY		0		/* Berkeley Font */
    #define		VTDF_CHICAGO		1		/* Chicago Font */
    #define		VTDF_BISON		2		/* Bison Font */
    #define		VTDF_WINDOWS		3		/* Windows Font */
    #define		VTDF_LED		4		/* LED Font */
    #define		VTDF_ROMA		5		/* Roma Font */
    #define		VTDF_UNIVERSITY		6		/* University Font */
    #define		VTDF_URW_ROMAN		7		/* URW Roman Font */
    #define		VTDF_URW_SANS		8		/* URW Sans Font */
    #define		VTDF_URW_MONO		9		/* URW Mono Font */
    #define		VTDF_URW_SYMBOLPS 10				/* URW Symbols Font */
    #define		VTDF_CENTURY_SCHOOLBOOK 11				/* Century Schoolbook Font */
#define  VIS_TEXT_INITIAL_CHAR_ATTR \
	((VTDS_12 << VTDCA_SIZE_OFFSET) | VTDF_BERKELEY) 

Macros for Defining VisTextCharAttr Structures

The text object library also provides several macros to make the definition of the VisTextCharAttr structure simpler. These macros are listed in VisTextCharAttr Macros . In many cases, these macros make the definition of character style runs vastly easier.

Code Display 10-4 VisTextCharAttr Macros

 #define CHAR_ATTR_STYLE_FONT_SIZE_STYLE_COLOR(ref, style, font, psize, tstyle, \ color) { \
    {{{ref, 0}}, style}, font, {0, psize}, tstyle, \
	{color, CF_INDEX, 0, 0}, 0, FWI_MEDIUM, FW_NORMAL, 0, SDM_100, {0}, \
	{C_WHITE, CF_INDEX, 0, 0}, SDM_0, {0}, {0, 0, 0, 0, 0, 0, 0}}
 #define CHAR_ATTR_FONT_SIZE_STYLE(font, psize, tstyle) \
	CHAR_ATTR_STYLE_FONT_SIZE_STYLE_COLOR(2, CA_NULL_ELEMENT, font, \
						psize, tstyle, C_BLACK)
 #define CHAR_ATTR_FONT_SIZE(font, psize) \
	CHAR_ATTR_STYLE_FONT_SIZE_STYLE_COLOR(2, CA_NULL_ELEMENT, font, \
						psize, 0, C_BLACK)

Up: GEOS SDK TechDocs | Up | Prev: 3 The Text Object Library | Next: 3.2 Paragraph Attribute Definitions