Display Text Using Frames?

Greetings,

I’ve been trying to display text using frames and am evidently missing something. Here’s a snippet I’ve been working with:

local tf = CreateFrame( "Frame" )
tf.Text = f:CreateFontString("Bazooka")
tf.Text:SetFont( "Interface\\Addons\\DPS_Tracker\\LibFonts\\Bazooka.ttf", 16 )
tf.Text:SetWidth( 600 )
tf.Text:SetJustifyH("LEFT")
tf.Text:SetJustifyV("TOP")
tf:SetPoint( "CENTER", UIParent, "CENTER", 0, 0 )
tf.Text:SetText("Hello World.")
tf:Show()   -- ?
tf.Text:Show()  -- ?

Any help would be greatly appreciated.

Cheers,

You don’t need to Show() widgets on creation as they are shown by default but:

tf.Text = f:CreateFontString("Bazooka")

is using f to create the fontstring. This should generate an error unless you have assigned a local f (or global f) using CreateFrame elsewhere in the code.

Change f to tf

Also, you’re anchoring the frame to the CENTER of UIParent but not anchoring the FontString to anything

local tf = CreateFrame("Frame", nil, UIParent)
tf:SetSize(5, 5)
tf:SetPoint( "CENTER")
tf.Text = tf:CreateFontString("Bazooka")
tf.Text:SetPoint("CENTER")
tf.Text:SetFont( "Interface\\Addons\\DPS_Tracker\\LibFonts\\Bazooka.ttf", 16 )
--tf.Text:SetWidth( 600 )
tf.Text:SetJustifyH("LEFT")
tf.Text:SetJustifyV("TOP")
tf.Text:SetText("Hello World.")

The FontString will default to the size of the text or if a size is set will wrap or terminate with a … depending on the text length vs FontString size.

1 Like

Worked great. Didn’t see the tf v f issue. Is amazing to me that one can stare at code for hours and not see such obvious booboos.

Thanks for your patience,