<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.returnofreckoning.com/index.php?action=history&amp;feed=atom&amp;title=API%3ALabelGetTextDimensions</id>
	<title>API:LabelGetTextDimensions - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.returnofreckoning.com/index.php?action=history&amp;feed=atom&amp;title=API%3ALabelGetTextDimensions"/>
	<link rel="alternate" type="text/html" href="https://wiki.returnofreckoning.com/index.php?title=API:LabelGetTextDimensions&amp;action=history"/>
	<updated>2026-10-17T11:51:29Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.returnofreckoning.com/index.php?title=API:LabelGetTextDimensions&amp;diff=30551&amp;oldid=prev</id>
		<title>Maintenance script: UI Lua API import (WAR 1.4.8)</title>
		<link rel="alternate" type="text/html" href="https://wiki.returnofreckoning.com/index.php?title=API:LabelGetTextDimensions&amp;diff=30551&amp;oldid=prev"/>
		<updated>2026-10-16T19:46:23Z</updated>

		<summary type="html">&lt;p&gt;UI Lua API import (WAR 1.4.8)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{LuaApi|group=Label|wrapper=interfacecore/source/windowstate.lua}}&lt;br /&gt;
Returns the width and height of the text in a Label.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
width, height = LabelGetTextDimensions(labelName)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Arguments ==&lt;br /&gt;
;labelName : &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; – Name of a Label window.&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
;width : &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; – Width of the widest line of text.&lt;br /&gt;
;height : &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; – Height of all lines: the number of lines times the line height.&lt;br /&gt;
&lt;br /&gt;
== Details ==&lt;br /&gt;
* Both values are divided by the label&amp;#039;s scale (see [[API:WindowGetScale|WindowGetScale]]).&lt;br /&gt;
* A label that has no text layout yet returns &amp;lt;code&amp;gt;0, 0&amp;lt;/code&amp;gt;.&lt;br /&gt;
* The client registers the C function as &amp;lt;code&amp;gt;_LabelGetTextDimensions&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;LabelGetTextDimensions&amp;lt;/code&amp;gt; that addons call is a Lua function defined in &amp;lt;code&amp;gt;interfacecore/source/windowstate.lua&amp;lt;/code&amp;gt;:&lt;br /&gt;
** If the global table named after the window (&amp;lt;code&amp;gt;_G[labelName]&amp;lt;/code&amp;gt;) has a &amp;lt;code&amp;gt;STATE&amp;lt;/code&amp;gt; table, it returns &amp;lt;code&amp;gt;STATE.LABEL_TEXTDIMS_X&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;STATE.LABEL_TEXTDIMS_Y&amp;lt;/code&amp;gt; without calling into the client.&lt;br /&gt;
** Otherwise it calls &amp;lt;code&amp;gt;_LabelGetTextDimensions(labelName)&amp;lt;/code&amp;gt;.&lt;br /&gt;
* For windows with state tracking enabled, the client writes the same two values to &amp;lt;code&amp;gt;&amp;#039;&amp;#039;labelName&amp;#039;&amp;#039;.STATE.LABEL_TEXTDIMS_X&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;LABEL_TEXTDIMS_Y&amp;lt;/code&amp;gt; when it lays out the label&amp;#039;s text.&lt;br /&gt;
* Avoid using &amp;lt;code&amp;gt;STATE&amp;lt;/code&amp;gt; as a field name on a global table that has the same name as a label.&lt;br /&gt;
&lt;br /&gt;
== Errors ==&lt;br /&gt;
Raised by &amp;lt;code&amp;gt;_LabelGetTextDimensions&amp;lt;/code&amp;gt;:&lt;br /&gt;
* &amp;lt;code&amp;gt;Error in function call &amp;#039;LabelGetTextDimensions&amp;#039;: Window %s does not exist&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;Error in function call &amp;#039;LabelGetTextDimensions&amp;#039;: Window %s is not a Label&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Sizing a tooltip to its text, from &amp;lt;code&amp;gt;easystem_tooltips/source/abilitytooltips.lua&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local nameWidth, nameHeight = LabelGetTextDimensions(windowName..&amp;quot;Name&amp;quot;)&lt;br /&gt;
local typeWidth, typeHeight = LabelGetTextDimensions(windowName..&amp;quot;Type&amp;quot;)&lt;br /&gt;
...&lt;br /&gt;
local width1 = nameWidth + typeWidth + c_TOOLTIP_BUFFER&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[API:LabelGetText|LabelGetText]]&lt;br /&gt;
* [[API:ButtonGetTextDimensions|ButtonGetTextDimensions]]&lt;br /&gt;
* [[API:WindowGetDimensions|WindowGetDimensions]]&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
</feed>