OsGetDrawStringSize

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Page created.)
 
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Template:Quicklinks}}
+
{{osslfunc
[[Technical Reference | Technical Reference]] -> [[Technical Reference/terms | Terms]] -> [[Status | Status Page]] -> [[OSSL_Implemented| OSSL Implemented Functions]] -> [[Dynamic textures]] -> [[OsGetDrawStringSize | osGetDrawStringSize]]
+
|threat_level=ignored
 
+
|permissions=true
 
+
|delay=0
LSL: '''[[vector]] osGetDrawStringSize( [[string]] contentType, [[string]] text, [[string]] fontName, [[integer]] fontSize )'''<br />
+
|function_syntax=vector osGetDrawStringSize(string contentType, string text, string fontName, integer fontSize)
C#: '''[[LSL_Vector]] osGetDrawStringSize( [[string]] contentType, [[string]] text, [[string]] fontName, [[int]] fontSize )'''
+
|ossl_example=<source lang="lsl">
 
+
 
+
Returns a vector containing the horizontal and vertical dimensions in pixels of the specified text, if drawn in the specified font and at the specified point size. The horizontal extent is returned in the '''.x''' component of the vector, and the vertical extent is returned in '''.y'''.  The '''.z''' component is not used.
+
 
+
The '''contentType''' parameter should be "vector".
+
 
+
If the '''[[OSSetFontSize | osSetFontSize]]'''() function has not been used, and neither the '''[[Drawing_commands#FontName | FontName]]''' nor '''[[Drawing_commands#FontProp | FontProp]]''' commands have been added to the draw list, specify "Arial" as the font name, and 14 as the font size.
+
 
+
Example:
+
<source lang="lsl">
+
 
// Example of osGetDrawStringSize
 
// Example of osGetDrawStringSize
 
default
 
default
Line 35: Line 25:
 
}
 
}
 
</source>
 
</source>
 +
|description=Returns a vector containing the horizontal and vertical dimensions in pixels of the specified text, if drawn in the specified font and at the specified point size. The horizontal extent is returned in the '''.x''' component of the vector, and the vertical extent is returned in '''.y'''.  The '''.z''' component is not used.
 +
 +
The contentType parameter should be "vector".
 +
 +
If the  [[OsSetFontSize|osSetFontSize()]] function has not been used, and neither the  [[Drawing commands#FontName|FontName]] nor  [[Drawing commands#FontProp|FontProp]] commands have been added to the draw list, specify "Arial" as the font name, and 14 as the font size.
 +
|additional_info=This function does not take in to account any font properties specified in the draw list when computing the bounds of the text to be rendered.
 +
}}

Latest revision as of 13:37, 14 November 2018

vector osGetDrawStringSize(string contentType, string text, string fontName, integer fontSize)
Returns a vector containing the horizontal and vertical dimensions in pixels of the specified text, if drawn in the specified font and at the specified point size. The horizontal extent is returned in the .x component of the vector, and the vertical extent is returned in .y. The .z component is not used.

The contentType parameter should be "vector".

If the osSetFontSize() function has not been used, and neither the FontName nor FontProp commands have been added to the draw list, specify "Arial" as the font name, and 14 as the font size.

Threat Level This function does not do a threat level check
Permissions Use of this function is always allowed by default
Extra Delay 0 seconds
Example(s)
// Example of osGetDrawStringSize
default
{
    state_entry()
    {
        string CommandList = ""; // Storage for our drawing commands
        string TextToDraw = "Hello, World!"; // text to draw
 
        vector Extents = osGetDrawStringSize( "vector", TextToDraw, "Arial", 14 );
 
        integer xpos = 128 - ((integer) Extents.x >> 1);            // Center the text horizontally
        integer ypos = 127 - ((integer) Extents.y >> 1);            //   and vertically
        CommandList = osMovePen( CommandList, xpos, ypos );         // Position the text
        CommandList = osDrawText( CommandList, TextToDraw );        // Place the text
 
        // Now draw the text
        osSetDynamicTextureData( "", "vector", CommandList, "width:256,height:256", 0 );
    }
}
Notes
This function does not take in to account any font properties specified in the draw list when computing the bounds of the text to be rendered.


Personal tools
General
About This Wiki