Frame:CreateFontString()

From Wowpedia
Jump to: navigation, search

Constructs a new FontString as a child of a frame.

fontString = Frame:CreateFontString([name, layer, inheritsFrom, subLayer])

Arguments

name 
string?Optional. Could be nil. - The name for a global variable that points to the newly created font string. If nil, the texture is anonymous and no global variable will be created.
layer 
string?Optional. Could be nil. - The layer the font should be drawn in, e.g. "ARTWORK"; while technically optional, the string cannot appear until this is set.
inheritsFrom 
string?Optional. Could be nil. - The name of a virtual template previously defined with <LayoutFrame virtual="true">; if nil, the font string does not inherit any properties.
subLayer 
number?Optional. Could be nil. - The z-axis subdivision (-7 to +7) of the layer; if nil, defaults to 0.

Returns

fontString 
FontString - Reference to the newly constructed object.

Example

The following code displays "Hello, World!" in the center of the screen:

local f = CreateFrame("Frame", nil, UIParent)
f:SetWidth(1) 
f:SetHeight(1)
f:SetPoint("CENTER", 0, 0)
local t = f:CreateFontString(f, "OVERLAY", "GameTooltipText")
t:SetPoint("CENTER", 0, 0)
t:SetText("Hello, World!")

See also