Thread Tools Display Modes
04-28-22, 10:15 PM   #1
onesock
A Murloc Raider
Join Date: May 2021
Posts: 6
Fontstring sizing or something else?

I am trying to create simple frame that displays text. I definitely made the containing frame wide enough to fit the string but it is still wrapping. The string is multiline (will have multiple \n).

Code:
raidLockoutFrame = CreateFrame("ScrollFrame", "NITRaidLockoutFrame", UIParent, "TooltipBorderedFrameTemplate");
raidLockoutFrame:SetPoint("Center", UIParent, "Center", 0, 0)
raidLockoutFrame:SetWidth(400);
raidLockoutFrame:SetHeight(400);
raidLockoutFrame:SetMovable(true);

local text = raidLockoutFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal");
text:SetPoint("TOPLEFT");
text:SetJustifyH("LEFT");
--text:SetNonSpaceWrap(false);
--text:SetWordWrap(false);
raidLockoutFrame.text = text;

...

raidLockoutFrame.text:SetText(CreateLockoutText())
It ends up wordwrapping to this:


I've looked for solutions, tested word wrapping on the fontstring itself (does not work), and the GetWidth function returns 220 for the string (and I am setting the parent frame width to 400).

Any help out there?
  Reply With Quote
04-28-22, 10:24 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Lua Code:
  1. text:SetPoint("TOPLEFT", 5, -15)
  2. text:SetSize(raidLockoutFrame:GetWidth() - 10, 12) -- fixed with/height

Adjust numbers to suit.

If the string itself has new line characters (\n) they will need to be stripped out:
Code:
raidLockoutFrame.text:SetText(gsub(CreateLockoutText(), "\n", " "))
I'm not sure where CreateLockoutText() comes from because it doesn't seem to be a Blizzard function so maybe that can be altered to return something useful?
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 04-29-22 at 12:12 AM.
  Reply With Quote
04-29-22, 06:45 AM   #3
onesock
A Murloc Raider
Join Date: May 2021
Posts: 6
Ahh - I missed SetSize (was looking for SetWidth/SetHeight).

Thanks!
  Reply With Quote
04-30-22, 11:27 AM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
You can use :SetWidth() and :SetHeight() instead of :SetSize(). But you didn't actually give your fontstring a width and height. Just your frame.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Fontstring sizing or something else?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off