Wimp_TextOp

Introduction and Overview

In order to address certain issues with fonts which 'overhang' their right hand edge (such as oblique or italic fonts), a new flag bit has been added to Wimp_TextOp 1 (read size of string). This allows applications (such as the Filer) to calculate icon bounding boxes more reliably where such fonts are in use.

Since RISC OS 4 a number of additional flags have been available for Wimp_TextOp 2 (plot string). These allow the text strings to be rendered within the current window and make the font appear vertically centred at the position specified.

Two additional reason codes have been added to centralise the splitting of system font text and its truncation.

Technical Details

The operation is selected by the reason code in R0 bits 0-7:

Bit(s)Meaning
0-7Operation:
ValueMeaning
0Set colours to use
1Read string size
2Plot font
3Find split point in string
4Truncate string with ellipsis
8-31Dependent on operation

Other registers are dependent on the operation. The SWI is used to perform text string operations using the desktop font.

SWI Calls

Wimp_TextOp 0Wimp_TextOp_SetColoursSWI &400F9
Set colours for desktop font operations
R0=0 (set font colours)
R1=Foreground colour (&BBGGRR00)
R2=Background colour (&BBGGRR00)
R0 - R2=Preserved
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI sets the colours to use for subsequent desktop font operations.

Wimp_TextOp 1Wimp_TextOp_ReadStringSizeSWI &400F9
Read the width of a string in the desktop font
R0=1 (read string size) + flags:
Bit(s)Meaning
31Return size covered by string
R1=Pointer to string
R2=Number of characters to process, or 0 for the entire string
R0=Width of string in desktop font in OS units
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI is used to read the width of a string when rendered on the screen. Bit 31 controls whether the space covered by the string is returned rather than the baseline offset at which the string ends. This distinction must be made because certain fonts (italic fonts, for example) will end at a baseline position before the end of the rendered font. With the bit set the whole area covered will be returned. Thus, if this call is required for locating the end of a string such that another may be added (for example, in another colour) then bit 31 should be clear. If, however, this call is being used to calculate the size required for the font such that it is entirely rendered (for example, in calculating the size of an icon's bounding box), bit 31 should be set.

Wimp_TextOp 2Wimp_TextOp_PlotStringSWI &400F9
Plot a text string in the desktop font
R0=2 (plot text string) + flags:
Bit(s)Meaning
8-26Reserved, must be 0
27Reserved for future expansion
28Centre text vertically
29X/Y offsets are offsets within the current redraw window, rather than screen offsets
30Vertically justify to make the baseline the same as system font
31Right justify string
R1=Pointer to string
R2=Reserved (must be -1)
R3=Reserved (must be -1)
R4=X co-ordinate, in OS units
R5=Y co-ordinate, in OS units
R0 - R5=Preserved
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI is used to plot a text string in the desktop font.

Wimp_TextOp 3Wimp_TextOp_GetSplitPointSWI &400F9
Find the split point in a string
R0=3 (get split point)
R1=Pointer to string
R2=Width to split at in OS units
R3=Split character, or -1 for none
R0=Pointer to split point in supplied string
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI is used to read a split point by limiting to a given length. It is similar in function to the SWI Font_ScanString SWI.

Wimp_TextOp 4Wimp_TextOp_TruncateSWI &400F9
Truncate a string with an ellipsis
R0=4 (truncate string with ellipsis)
R1=Pointer to string
R2=Pointer to output buffer
R3=Size of output buffer, or 0 to request size required
R4=Maximum width in OS units
R0=Size of buffer required
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI is used to truncate a string by using an ellipsis character for the currently selected alphabet, or three full stops. If the string fits within the size specified, no ellipsis will be added.