Skip to content

Instantly share code, notes, and snippets.

@Meorawr
Last active January 12, 2022 13:41
Show Gist options
  • Save Meorawr/1661be13add068bcee532afdda6e309f to your computer and use it in GitHub Desktop.
Save Meorawr/1661be13add068bcee532afdda6e309f to your computer and use it in GitHub Desktop.
Rotated FontString
local Button = CreateFrame("Button", nil, UIParent, "UIPanelButtonTemplate");
Button:SetPoint("CENTER");
Button:SetText("Resistances");
local ButtonFontString = Button:GetFontString();
ButtonFontString:ClearAllPoints();
ButtonFontString:SetPoint("CENTER", -5, -10);
-- FontStrings can't be rotated like textures, but you can fake it with
-- an animation that either infinitely repeats or just never ends.
local AnimationGroup = ButtonFontString:CreateAnimationGroup();
local Rotation = AnimationGroup:CreateAnimation("Rotation");
Rotation:SetDegrees(90);
Rotation:SetDuration(0);
Rotation:SetEndDelay(math.huge);
AnimationGroup:Play();
-- Note that using animations means the logical rect of the fontstring
-- thinks it's always horizontal, as you can see via /fstack.
--
-- When updating the size of the host button you'll need to swap the
-- width and height as below.
local width = ButtonFontString:GetHeight() + 20;
local height = ButtonFontString:GetWidth() + 40;
Button:SetSize(width, height);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment