Lore archive · Warcraft Wiki, 2023 dump
API FontString GetStringWidth
Last wiki revision 2020-04-05
provides three methods to determine the width of its text independently from the value returned by : stringWidth = fontString:GetStringWidth unboundedStringWidth = fontString:GetUnboundedStringWidth wrappedWidth = fontString:GetWrappedWidth
- GetStringWidth ignores but includes
- GetUnboundedStringWidth ignores word wrap and truncation
- GetWrappedWidth includes word wrap and truncation
- stringWidth : Number - The minimum width necessary to contain the currently-displayed, possibly-truncated, text on a single line if WordWrap became forbidden; e.g. the width if word-wrapped lines were strung end-to-end
- unboundedStringWidth : Number - The minimum width necessary to contain the entire text without truncation if WordWrap became forbidden; e.g. the width if ignoring any fixed or
- wrappedWidth : Number - The minimum width necessary to contain the currently-displayed text without changing its shape; e.g. the width of the widest line after applying word wrap and truncation
- By default, a FontString expands and shrinks to fit its text.
- returns the width that the FontString has dynamically adopted
- Conversly, a FontString may have explicitly defined width using or ; shorter texts fit inside and longer ones must wrap or truncate.
- will return the explicitly defined width
- because GetWrappedWidth only ever describes a single line (either the whole text or the biggest line that could fit)
- However, GetStringWidth and GetUnboundedStringWidth reflect wrapping and truncation:
- If the text fits on one line,
- If the text fits on multiple lines,
- If the text cannot wrap and must truncate,
- If the text wraps but truncates after multiple lines,
- Notwithstanding, a text with manual line breaks (such as the escape sequence) could have a smaller width
- Manually broken lines are not strung end-to-end when calculating GetStringWidth or GetUnboundedStringWidth
- In other words, a manually broken text does not need its FontString to be as wide (but it does need more height)
Source
https://warcraft.wiki.gg/wiki/API_FontString_GetStringWidth · retrieved 2023-11-13 · CC BY-SA 4.0
Converted from wikitext with templates, tables and images removed, so some sentences may be missing values.
This archive predates WoW: Forever. For collected gameplay facts see the Forever database. Search the archive.