From 7143abd3288308e4da7898e60e45f75ae74b780a Mon Sep 17 00:00:00 2001 From: Buds Date: Wed, 18 Oct 2023 20:09:16 +0200 Subject: [PATCH] Workaround fonts not loading correctly on first login To reproduce issue before this change, install Prat-3.0, set an aura with text or subtext using font DorisPP, and text should not show, it will work after a /reload but will break if you restart wow client --- WeakAuras/RegionTypes/Text.lua | 6 ++++++ WeakAuras/SubRegionTypes/SubText.lua | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/WeakAuras/RegionTypes/Text.lua b/WeakAuras/RegionTypes/Text.lua index 3aa1e68c29..170562792c 100644 --- a/WeakAuras/RegionTypes/Text.lua +++ b/WeakAuras/RegionTypes/Text.lua @@ -83,6 +83,12 @@ local function modify(parent, region, data) local fontPath = SharedMedia:Fetch("font", data.font); text:SetFont(fontPath, data.fontSize, data.outline); + if not text:GetFont() and fontPath then -- workaround font not loading correctly + local objectName = "WeakAuras-Font-" .. data.text_font + local fontObject = _G[objectName] or CreateFont(objectName) + fontObject:SetFont(fontPath, data.text_fontSize, data.text_fontType) + text:SetFontObject(fontObject) + end if not text:GetFont() then -- Font invalid, set the font but keep the setting text:SetFont(STANDARD_TEXT_FONT, data.fontSize, data.outline); end diff --git a/WeakAuras/SubRegionTypes/SubText.lua b/WeakAuras/SubRegionTypes/SubText.lua index 76e40a3c23..a166bc1cf7 100644 --- a/WeakAuras/SubRegionTypes/SubText.lua +++ b/WeakAuras/SubRegionTypes/SubText.lua @@ -200,6 +200,12 @@ local function modify(parent, region, parentData, data, first) local fontPath = SharedMedia:Fetch("font", data.text_font); text:SetFont(fontPath, data.text_fontSize, data.text_fontType); + if not text:GetFont() and fontPath then -- workaround font not loading correctly + local objectName = "WeakAuras-Font-" .. data.text_font + local fontObject = _G[objectName] or CreateFont(objectName) + fontObject:SetFont(fontPath, data.text_fontSize, data.text_fontType) + text:SetFontObject(fontObject) + end if not text:GetFont() then -- Font invalid, set the font but keep the setting text:SetFont(STANDARD_TEXT_FONT, data.text_fontSize, data.text_fontType); end