TextSize - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


ImageTools[Draw]

  

TextSize

  

determine the size of ImageTools:-Draw:-Text

 

Calling Sequence

Parameters

Description

Package Usage

Examples

Compatibility

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 image parameter is an image created using ImageTools:-Create, or loaded via ImageTools:-Read.

• 

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

withImageTools:

withImageTools:-Draw:

Determining the extent of rendered text.

w,h500,120

w,h500,120

(5.1)

imgCreateh,w,channels=3,background=0.5:

msgRed Box Fits the Text

msgRed Box Fits the Text

(5.2)

boxW,boxHTextSizeimg,msg,font=10,font_size=25,weight=1.5

boxW,boxH435.659090909091049,26.5681818181818166

(5.3)

x1,y1wboxW2,hboxH2

x1,y132.1704546,46.71590909

(5.4)

x2,y2w+boxW2,h+boxH2

x2,y2467.8295454,73.28409091

(5.5)

SolidRectangleimg,x1,y1,x2,y2,color=0.75,0,0

Textimg,w2,h2,msg,position=*,font=10,font_size=25,weight=1.5,color=1

25.,25.

(5.6)

Draw a border 5 pixels outside the box.

x1,y1,x2,y2x15,y15,x2+5,y2+5

x1,y1,x2,y227.1704546,41.71590909,472.8295454,78.28409091

(5.7)

Polyimg,x1,y1,x1,y2,x2,y2,x2,y1,x1,y1,color=yellow

Embedimg

Compatibility

• 

The ImageTools[Draw][TextSize] command was introduced in Maple 2018.

• 

For more information on Maple 2018 changes, see Updates in Maple 2018.

See Also

ImageTools

ImageTools:-Draw:-Circle

ImageTools:-Draw:-Line

ImageTools:-Draw:-Poly

ImageTools:-Draw:-SolidRectangle

ImageTools:-Draw:-Text