WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Fontstring sizing or something else? (https://www.wowinterface.com/forums/showthread.php?t=59113)

onesock 04-28-22 10:15 PM

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?

Fizzlemizz 04-28-22 10:24 PM

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?

onesock 04-29-22 06:45 AM

Ahh - I missed SetSize (was looking for SetWidth/SetHeight).

Thanks!

Seerah 04-30-22 11:27 AM

You can use :SetWidth() and :SetHeight() instead of :SetSize(). But you didn't actually give your fontstring a width and height. Just your frame.


All times are GMT -6. The time now is 12:19 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI