int error = MeasureText(APTR handle, STRPTR str, int count, int encoding, struct hwTextExtent *te, struct hwTextLayout *tl, struct hwTagList *tags);
str
when rendered
with the font passed in handle
. Note that str
is not null-terminated. Instead, the
string's length in bytes is passed in the count
parameter. The encoding
parameter
specifies the character encoding of the string. This will be either HWOS_ENCODING_UTF8
or HWOS_ENCODING_ISO8859_1
.
If the plugin hasn't set the HWFONTFLAGS_LAYOUT
flag for the font in its LoadFont()
implementation, the string passed in str
will never contain any line breaks. Handling line
breaks is only necessary if your plugin has requested to do its own layouting by setting the
HWFONTFLAGS_LAYOUT
flag in LoadFont().
Your MeasureText()
implementation has to return the dimensions of the text in
the te
parameter that points to a struct hwTextExtent
which looks like
this:
struct hwTextExtent { int MinX; [out] int MinY; [out] int MaxX; [out] int MaxY; [out] int Width; [out] int Height; [out] }; |
Your implementation of MeasureText()
must set all the structure members to the correct
dimensions. Here is a description of the individual structure members:
MinX:
MinY:
MaxX:
MaxY:
Width:
Height:
All values are in struct hwTextExtent
are in pixels.
The tl
parameter contains a pointer to a struct hwTextLayout
. This
structure contains detailed information about the text layout. Most of the
structure members are only initialized for fonts that have requested to do
their own layouting by setting the HWFONTFLAGS_LAYOUT
flag in LoadFont().
The only structure members that are supported for fonts that haven't set
HWFONTFLAGS_LAYOUT
are CharSpacing
and Style
but the only style flag that
can be set for fonts that haven't set HWFONTFLAGS_LAYOUT
is HWFONTSTYLE_ANTIALIAS
.
struct hwTextLayout
looks like this:
struct hwTextLayout { ULONG Color; [in] ULONG Style; [in] int Align; [in] int WrapWidth; [in] int LineSpacing; [in] int CharSpacing; [in] int Indent; [in] int AdvanceX; [out] int AdvanceY; [out] int *Tabs; [in] int TabCount; [in] }; |
Here is a description of the individual structure members:
Color:
Style:
HWFONTSTYLE_ANTIALIAS:
HWFONTSTYLE_BOLD:
HWFONTSTYLE_ITALIC:
HWFONTSTYLE_UNDERLINED:
Align:
HWTEXTALIGN_LEFT:
HWTEXTALIGN_RIGHT:
HWTEXTALIGN_CENTER:
HWTEXTALIGN_JUSTIFIED:
WrapWidth:
LineSpacing:
CharSpacing:
Indent:
AdvanceX:
AdvanceY:
Tabs:
Tabs
array is indicated by the TabCount
member (see below).
Note that this can also be NULL
.
TabCount:
Tab
member (see above).
struct hwTextExtent
that receives the text's dimensionsstruct hwTextLayout
that contains layout informationNULL