GetTextSize Method 146
The GetTextSize method obtains the size of the bounding rectangle of a text item in a given font. The result is given in the co-ordinate system of the object in question. This method is useful for positioning Text objects.
GetTextSize duplicates the functionality of the TextSize property. It is recommended that you use GetTextSize instead of TextSize which may be removed in a future release of Dyalog APL.
The argument to GetTextSize is a 1 or 2-element array as follows:
[1] | Text item | character array |
[2] | Font | character vector naming a Font object, or a reference to one |
When you invoke GetTextSize you give the text item in whose size you are interested and, optionally, a Font object. The Font can be given either by name or as a reference, as shown in the second and third examples below respectively. The text item can be a simple scalar, a vector, or a matrix. If the Font is omitted, the result is given using the current font for the object in question.
Examples
'F'⎕WC'Form'
F.GetTextSize'Hello World'
2.407407407 5.729166667
'FNT1'⎕WC'Font' 'Arial' 72
F.GetTextSize'Hello World' 'FNT1'
2.962962963 8.020833333
'FNT2'⎕WC'Font' 'Arial' 16 0 0 0 400 0
F.GetTextSize'Hello World'FNT2
2.962962963 6.979166667
F.Coord←'Pixel'
F.FontObj←'FNT1'
F.GetTextSize'Hello World'
72 335 Application
Objects: ActiveXControl, Animation, Bitmap, Button, ButtonEdit, Calendar, ColorButton, Combo, ComboEx, CoolBar, DateTimePicker, Edit, Form, Grid, Group, Label, List, ListView, MDIClient, Printer, ProgressBar, PropertyPage, RichEdit, Root, Scroll, SM, Spinner, Static, StatusBar, SubForm, TabBar, TabControl, ToolBar, ToolControl, TrackBar, TreeView, UpDown