Xbasic

TEXT_WIDTH Function

Syntax

Numeric Width = TEXT_WIDTH(C text)

Arguments

text

The text to measure. Character

Description

Get the width of the text using the current font.

Discussion

TEXT_WIDTH() returns the width of the text in inches. Used only in the Code sections of UI_BITMAP_DRAW(), UI_SCREEN_DRAW(), and UI_PRINTER_DRAW().

The following example displays the text "Sample" centered vertically and horizontally on the bitmap. This is actually the more complicated way to write this code. Refer to BITMAP_HEIGHT()and BITMAP_WIDTH()for simpler examples.

ui_bitmap_create("test", 4, 1)
ui_bitmap_draw("test",
set_font("Verdana,20,biu", "blue", "white")
inner_Rect(0, 0, 4, 1)
text("Sample", bitmap_width("test")/2 - text_width("Sample")/2, bitmap_height("test")/2 - text_height("Sample")/2)
%code%)
ui_dlg_box("","{image=test}")

See Also