TextWidthHook
TextEdit Width Hooks
TextEdit's width hooks are called each the time the width of various components of a line is calculated. This section describes two new hooks,
original WIDTHHook hook. The new hook nWIDTHHook allows you access to
TextEdit's measuring routine for non-Roman script systems and provides a way for you to replace this routine with your own script- compatible
measuring routine. TextWidthHook provides a way for you to replace the new routine.
Note: To test for the availability of the new width-measuring hooks, you
can call the Gestalt function with the gestaltTextEditVersion selector. A result of gestaltTE2 or greater returned in the response parameter
indicates that the new width measurement hook nWIDTHHook is available.
A result of gestaltTE5 or greater returned in the response parameter
indicates that the new text width measurement hook TextWidthHook is available. (For details, see
TextWidthHook is available for version 6.0.7 (or higher) systems with non-Roman script systems installed. However, there is no Gestalt constant that indicates this availability.
The original WIDTHHook hook is available to provide backward
compatibility for your applications. TextEdit still uses WIDTHHook; however, it now performs additional checks to determine whether to use
WIDTHHook or nWIDTHHook. TextEdit first determines whether a non-Roman script system is installed. If it is, TextEdit uses the new nWIDTHHook routine even if an application has overridden WIDTHHook
with a different measuring routine. If TextEdit finds that only the Roman Script System is installed, it checks to see if WIDTHHook contains the
the nWIDTHHook routine. Otherwise, an application has provided a different
measuring routine to be used for system software with only the Roman Script
System installed, so TextEdit uses this routine instead of its own default routine.
It is possible for you to provide alternate routines for both of these hooks to
guarantee that your routine is always used. However, unless the routine
measures correctly for non-Roman scripts, you should only replace
The appropriate font, face, and size characteristics have already been set into
the current port by the time any of these routines is called.
The default action for WIDTHHook is to call the QuickDraw function Worldwide Software Overview. For comprehensive details, refer to
Macintosh Worldwide Development: Guide to System Software.
For a discussion of the slop value, see Worldwide Software Overview
description.
measuring routine. You must use TextWidthHook in addition to WIDTHHook and nWIDTHHook to replace TextEdit's measuring routines completely. use this hook because no edit record is allocated.
TextWidth function (the same default action as for the original WIDTHHook routine).