Important: The information in this document is obsolete and should not be used for new development.
| Framework | ApplicationServices/ApplicationServices.h |
| Declared in | QuickdrawText.h |
You can use the QuickDraw text routines to measure and draw text ranging in complexity from a single glyph to a line of justified text containing multiple languages and styles. In addition to measuring and drawing text, the QuickDraw text routines also help you to determine which characters to highlight and where to position the caret to mark the insertion point. These routines translate pixel locations into byte offsets and vice versa.
To understand the routines described in this document, it is helpful to be familiar with the other parts of QuickDraw. It is also helpful to be familiar with the Font Manager, because of the close relationship between QuickDraw and the Font Manager. To understand the tasks involved in text layout, you should also be acquainted with the Text Utilities and the Script Manager.
Carbon supports the majority of QuickDraw Text.
CharToPixel Deprecated in Mac OS X v10.4
HiliteText Deprecated in Mac OS X v10.4
PixelToChar Deprecated in Mac OS X v10.4
DrawChar Deprecated in Mac OS X v10.4
DrawJustified Deprecated in Mac OS X v10.4
DrawString Deprecated in Mac OS X v10.4
DrawText Deprecated in Mac OS X v10.4
StandardGlyphs Deprecated in Mac OS X v10.4
StdText Deprecated in Mac OS X v10.4
stdtext Deprecated in Mac OS X v10.4
GetFormatOrder Deprecated in Mac OS X v10.4
PortionLine Deprecated in Mac OS X v10.4
VisibleLength Deprecated in Mac OS X v10.4
CharWidth Deprecated in Mac OS X v10.4
MeasureJustified Deprecated in Mac OS X v10.4
MeasureText Deprecated in Mac OS X v10.4
StdTxMeas Deprecated in Mac OS X v10.4
StringWidth Deprecated in Mac OS X v10.4
TextWidth Deprecated in Mac OS X v10.4
CharExtra Deprecated in Mac OS X v10.4
GetFontInfo Deprecated in Mac OS X v10.4
SpaceExtra Deprecated in Mac OS X v10.4
TextFace Deprecated in Mac OS X v10.4
TextFont Deprecated in Mac OS X v10.4
TextMode Deprecated in Mac OS X v10.4
TextSize Deprecated in Mac OS X v10.4
StyledLineBreak Deprecated in Mac OS X v10.4
TruncString Deprecated in Mac OS X v10.4
TruncText Deprecated in Mac OS X v10.4
DisposeStyleRunDirectionUPP Deprecated in Mac OS X v10.4
InvokeStyleRunDirectionUPP Deprecated in Mac OS X v10.4
NewStyleRunDirectionUPP Deprecated in Mac OS X v10.4
Defines a pointer to a style run direction callback function that calculates, for a style run identified by number, the direction of that style run.
typedef Boolean (*StyleRunDirectionProcPtr) ( short styleRunIndex, void * dirParam );
If you name your function MyStyleRunDirectionProc, you would declare it like this:
Boolean StyleRunDirectionProcPtr ( short styleRunIndex, void * dirParam );
A value that identifies the style run whose direction is needed.
A pointer to an application-defined parameter block that contains the font and script information for each style run in the text. The contents of this parameter block are used to determine the direction of the style run. Because of the relationship between the font family ID and the script code, the font family ID can be used to determine the text direction.
A Boolean value that is TRUE for right-to-left text direction, FALSE for left-to-right.
To fill the ordering array (type FormatOrder) for style runs on a line, the GetFormatOrder function calls MyStyleRunDirectionCallback for each style run numbered from firstFormat to lastFormat. GetFormatOrder passes MyStyleRunDirectionCallback a number identifying the style run in storage order, and a pointer to the parameter information block, dirParam, that contains the font and style information for the style run. Given dirParam and a style run identifier, the application-defined MyStyleRunDirectionCallback function should be able to determine the style run direction.
You should store your style run information in a way that makes it convenient for MyStyleRunDirectionCallback. One obvious way to do this is to declare a structure type for style runs that allows you to save things like font style, font family ID, script number, and so forth. You then can store these structures in an array. When the time comes for GetFormatOrder to fill the ordering array, MyStyleRunDirectionCallback can consult the style run array for direction information for each of the numbered style runs in turn.
For more information, see GetFormatOrder.
When you provide the Component Manager with a pointer to your function, you should use a universal procedure pointer (UPP). The definition of the UPP data type for your file identification function is as follows:
typedef (StyleRunDirectionProcPtr) StyleRunDirectionUPP;
Before using your style run direction callback function, you must first create a new universal procedure pointer to it, using the NewStyleRunDirectionUPP function, as shown here:
StyleRunDirectionUPP MyStyleRunDirectionUPP;
MyStyleRunDirectionUPP = StyleRunDirectionUPP(&MyStyleRunDirectionCallback)
You then pass MyStyleRunDirectionUPP to the function GetFormatOrder. If you wish to call your own callback function, you can use the InvokeStyleRunDirectionUPP function:
direction = InvokeStyleRunDirectionUPP(styleRunIndex, ¶mInfo, MyStyleRunDirectionUPP)
When you are finished using your callback function, you should dispose of the universal procedure pointer associated with it, using the DisposeStyleRunDirectionUPP function.
DisposeStyleRunDirectionUPP(MyStyleRunDirectionUPP);
QuickdrawText.hContains font metric information.
struct FontInfo {
short ascent;
short descent;
short widMax;
short leading;
};
typedef struct FontInfo FontInfo;
ascentThe measurement, in pixels, from the baseline to the ascent line of the font.
descentThe measurement, in pixels, from the baseline to the descent line of the font.
widMaxThe width, in pixels, of the largest glyph in the font.
leadingThe measurement, in pixels, from the descent line to the ascent line below it.
The FontInfo data type defines a font information structure. The GetFontInfo function uses the font information structure to return measurement information based on the font of the current graphics port. If the current font has an associated font, as do Arabic and Hebrew, GetFontInfo returns information based on both fonts. The font information structure contains the ascent, the descent, the width of the largest glyph, and the leading for a given font. The StdTxMeas function also uses a structure of type FontInfo to return information about the current font.
QuickdrawText.h
Contains and array of display orders for style runs.
typedef FormatOrder[1];
The GetFormatOrder function fills the supplied format order array with the display order of each style run.
QuickdrawText.h
Defines a universal procedure pointer to a style run direction callback.
typedef StyleRunDirectionProcPtr StyleRunDirectionUPP;
For more information, see the description of the StyleRunDirectionProcPtr callback function.
QuickdrawText.hSpecify a caret position.
enum {
leftCaret = 0,
rightCaret = -1,
kHilite = 1
};
leftCaretPlace caret for left-to-right text direction.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
rightCaretPlace caret for right-to-left text direction.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
kHiliteSpecifies that the caret position should be determined according to the primary line direction, based on the value of SysDirection.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
You can use these constants to specify a value for direction, as used in the CharToPixel function.
Returned as result codes for the functions TruncString and TruncText.
enum {
notTruncated = 0,
truncated = 1,
truncErr = -1,
smNotTruncated = 0,
smTruncated = 1,
smTruncErr = -1
};
notTruncatedSpecifies that truncation is not necessary.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
truncatedSpecifies that truncation was performed.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
truncErrSpecifies a general error occurred.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
smNotTruncatedSpecifies that truncation is not necessary. This is obsolete.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
smTruncatedSpecifies that truncation was performed. This is obsolete.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
smTruncErrSpecifies a general error occurred. This is obsolete.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
Specify a line break.
typedef SInt8 StyledLineBreakCode;
enum {
smBreakWord = 0,
smBreakChar = 1,
smBreakOverflow = 2
};
smBreakWord
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
smBreakChar
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
smBreakOverflow
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
Specify where to place a caret.
enum {
smLeftCaret = 0,
smRightCaret = -1,
smHilite = 1
};
smLeftCaretSpecifies to place caret for left block. This is obsolete.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
smRightCaretSpecifies to place caret for right block. This is obsolete.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
smHiliteSpecifies the direction is TESysJust. This is obsolete.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
Specify style run positions.
typedef short JustStyleCode;
enum {
onlyStyleRun = 0,
leftStyleRun = 1,
rightStyleRun = 2,
middleStyleRun = 3,
smOnlyStyleRun = 0,
smLeftStyleRun = 1,
smRightStyleRun = 2,
smMiddleStyleRun = 3
};
onlyStyleRunThis is the only style run on the line.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
leftStyleRunThis is the leftmost of multiple style runs on the line.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
rightStyleRunThis is the rightmost of multiple style runs on the line
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
middleStyleRunThe line and this one is interior: neither leftmost nor rightmost.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
smOnlyStyleRunThis is obsolete.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
smLeftStyleRunThis is obsolete.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
smRightStyleRunThis is obsolete.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
smMiddleStyleRunThis is obsolete.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
Use one of the following constants (defined as type JustStyleCode) in the styleRunPosition parameter for PortionLine DrawJustified, MeasureJustified, CharToPixel, and PixelToChar.
Specify constants for txFlags.
enum {
tfAntiAlias = 1 << 0,
tfUnicode = 1 << 1
};
tfAntiAliasAvailable in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
tfUnicodeAvailable in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
These used to be the pad field after txFace.
Specify where to truncate a string.
typedef TruncCode;
enum {
truncEnd = 0,
truncMiddle = 0x4000,
smTruncEnd = 0,
smTruncMiddle = 0x4000
};
truncEndTruncate at end.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
truncMiddleTruncate in middle.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
smTruncEndTruncate at end. This is obsolete.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
smTruncMiddleTruncate in middle. This is obsolete.
Available in Mac OS X v10.0 and later.
Declared in QuickdrawText.h.
© 2003, 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-07-13)