Shiny Language Reference

Language Reference > Font Functions


getstringwidth

int getstringwidth(string Text);

 

 

Returns the width in pixels of the text

GETSTRINGWIDTH returns the width in pixels of the specified text if it were to be drawn using the currently selected font (using SELECTFONT).Because it relies on SELECTFONT this function can only be used in the Render handler.

This statement is only valid in the Render handler.

 

Parameters

Text

The text string to calculate the width of

 

Return Value

The width in pixels of the specified text.

 

Example Code

font MyFont;
createfont(MyFont, "Arial", 12);
selectfont(MyFont);

// Width will contain the width in pixels of the string
int Width = getstringwidth("A text string");