Frame:CreateFontString

From Warcraft Wiki
Jump to navigation Jump to search

Creates a fontstring.

line = Frame:CreateFontString([name, drawLayer, templateName])

Arguments

name
string? - The global variable name that will be assigned, or nil for an anonymous fontstring.
drawLayer
string? : DrawLayer = ARTWORK - The layer the font should be drawn in.
templateName
string? - The name of a virtual template. If nil, the font string does not inherit any properties.

Returns

line
FontString🔗 - The new fontstring object as a child of this frame.

Details

  • Unlike Textures, FontStrings do not support sublayers, and will always be drawn above textures sharing the same layer.

Example

Shows "Hello world" on the screen.

local fs = UIParent:CreateFontString(nil, "OVERLAY", "GameTooltipText")
fs:SetPoint("CENTER")
fs:SetText("Hello world")

Patch changes

Dragonflight Patch 10.0.0 (2022-10-25): Now strictly validates the drawLayer parameter, raising a script error if an invalid layer name is supplied.