cssLengthToPixel()
Calculates the lenght of a given font in pixel.
Synopsis
int cssLenghtToPixel(string font, float length, string unit);
Parameter
Parameter | Description |
---|---|
font | The font used in the shape. The font should be given in the same syntax as used by the font selector. |
length | The length of the text. |
unit |
Unit of the given font, can be one of:
|
Return Value
The text length in pixel.
Errors
In case of error, -1 is returned.
Description
The function calculates the length of a given text in pixel. The parameters used for the calculation are the font (a string which includes the font name, font style, font size and other descriptive values), the number of characters and the unit used by the font.
If the given unit is already "px", the return value will be the rounded given value.
example
Following example shows how you get the font and the size in pixels for the text of a button.
main()
{
string sFont;
string sText = this.text();
getValue(this, "font",sFont);
float fSize = strlen(sText);
int iRet = cssLengthToPixel(sFont, fSize, "px");
DebugN("font size", sFont, iRet);
}
Assignment
Widgets
Availability
UI