|
Calling Sequence
|
|
TextSize( image, text, font, font_size, weight )
|
|
Parameters
|
|
image
|
-
|
ImageTools:-Image
|
text
|
-
|
string
|
font
|
-
|
(optional) integer := 14 (roman plain)
|
font_size
|
-
|
(optional) {numeric, [numeric,numeric]} := 12.0
|
weight
|
-
|
(optional) numeric := 1.0
|
|
|
|
|
Description
|
|
•
|
ImageTools:-Draw provides the TextSize function to aid in the manipulation of text. TextSize returns the width and height of a piece of text given a subset of the arguments accepted by the Text primitive
|
•
|
The font argument specifies which of the Hershey fonts to use. This is specified by number, but ImageTools:-Draw exports several symbolic names that can also be used. See ImageTools:-Text for a description of the font numbers and names.
|
•
|
The font_size argument, if given as a single numeric values, specifies the height, in pixels, of the capital letter "X". The size can also be specified as a list of two values, in which case the second value specifies the height. The first value specifies the width, not of a specific glyph, but relative to the second value. For example, font_size=[15,20] specifies than an "X" will be 20 pixels high, and that all glyphs should be scaled to 3/4 of their natural width at the specified height.
|
•
|
The default line weight can be given via the weight argument of the Text primitive. The value of this argument is interpreted as a multiplier for the default weight. Weights in the range of 1.2 to 1.8 will typically result in the glyphs becoming completely filled in. Weights that are too heavy will result in a blurring effect:
|
•
|
The options beginning with font are best provided as keyword equations, but can also be provided as positional arguments starting in the 3rd position as declared in the calling sequence above.
|
|
|
Package Usage
|
|
•
|
This function is part of the ImageTools:-Draw package, so it can be used in the short form TextSize(..) only after executing the command with(ImageTools:-Draw). However, it can always be accessed through the long form of the command by using ImageTools:-Draw:-TextSize(..).
|
|
|
Examples
|
|
>
|
|
Determining the extent of rendered text.
>
|
|
>
|
|
| (5.2) |
>
|
|
| (5.3) |
| (5.4) |
| (5.5) |
>
|
|
>
|
|
Draw a border 5 pixels outside the box.
>
|
|
| (5.7) |
>
|
|
|
|
Compatibility
|
|
•
|
The ImageTools[Draw][TextSize] command was introduced in Maple 2018.
|
|
|
|