Skip to content

StringWidth

Narta Xaymar Dirks edited this page Oct 28, 2026 · 6 revisions

Blitz3DBlitzPlusBlitzBasic

StringWidth

StringWidth:Int32 string:String
Parameter Mode Type Default Description
string In String required The text to measure.

Returns: The width of the text.

Description

The width in pixels that a text has in the current font. It helps to center text or to put things after it.

Differences

  • With the built-in bitmap font every character has the same width, so this is the number of characters times FontWidth. Widths of real fonts depend on the font that was found on the system.

Examples

Graphics 320, 240, 0, 2
SetBuffer BackBuffer()
Cls
Local msg$ = "How wide is this?"
Local w = StringWidth(msg)
Color 60, 60, 140
Rect 20, 90, w, StringHeight(msg), 1
Color 255, 255, 255
Text 20, 90, msg
Text 20, 120, "StringWidth = " + w
Flip
WaitKey

Media

StringWidth

Related Commands

FontWidth, SetFont, StringHeight, Text

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally