WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   setfont error (https://www.wowinterface.com/forums/showthread.php?t=59326)

Lamebob 11-06-22 10:46 PM

setfont error
 
Not sure if this is the place to ask this but anyway..

Been using this addon for years to change all of the fonts but now with 10.0 it stopped working and I have 0 lua experience so kinda hoping someone knows how to fix it.

This is the error:

Lua Code:
  1. 12x Interface/AddOns/Fonts/Fonts.lua:3: Usage: self:SetFont(fontFile, height, flags)
  2. [string "=[C]"]: in function `SetFont'
  3. [string "@Interface/AddOns/Fonts/Fonts.lua"]:3: in function <Interface/AddOns/Fonts/Fonts.lua:1>
  4. [string "@Interface/AddOns/Fonts/Fonts.lua"]:46: in function <Interface/AddOns/Fonts/Fonts.lua:22>
  5.  
  6. Locals:
  7. (*temporary) = FriendsFont_Large {
  8. 0 = <userdata>
  9. }
  10. (*temporary) = "Fonts\ARIALN.ttf"
  11. (*temporary) = 11
  12. (*temporary) = nil

This is the addon:

Lua Code:
  1. local function SetFont(obj, font, size, style, sr, sg, sb, sa, sox, soy, r, g, b)
  2.     if not obj then return end
  3.     obj:SetFont(font, size, style)
  4.  
  5.     if sr and sg and sb then
  6.         obj:SetShadowColor(sr, sg, sb, sa)
  7.     end
  8.  
  9.     if sox and soy then
  10.         obj:SetShadowOffset(sox, soy)
  11.     end
  12.  
  13.     if r and g and b then
  14.         obj:SetTextColor(r, g, b)
  15.     elseif r then
  16.         obj:SetAlpha(r)
  17.     end
  18. end
  19.  
  20.     local f = CreateFrame("Frame")
  21.     f:RegisterEvent("ADDON_LOADED")
  22.     f:SetScript("OnEvent", function()
  23.    
  24.         local NORMAL        = [[Fonts\ARIALN.ttf]]
  25.         local BOLD          = [[Fonts\ARIALN.ttf]]  
  26.         local BOLDITALIC    = [[Fonts\ARIALN.ttf]]
  27.         local ITALIC        = [[Fonts\ARIALN.ttf]]
  28.         local NUMBER        = [[Fonts\ARIALN.ttf]] 
  29.  
  30.  
  31.         UIDROPDOWNMENU_DEFAULT_TEXT_HEIGHT = 12
  32.         CHAT_FONT_HEIGHTS = {7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}
  33.  
  34.         UNIT_NAME_FONT     = NORMAL
  35.         DAMAGE_TEXT_FONT   = BOLD
  36.         STANDARD_TEXT_FONT = NORMAL
  37.  
  38.         -- Base fonts
  39.         SetFont(AchievementFont_Small,              NORMAL, 11, "OUTLINE")
  40.         SetFont(AchievementPointsFont,              NORMAL, 11, "OUTLINE")
  41.         SetFont(AchievementPointsFontSmall,         NORMAL, 11, "OUTLINE")
  42.         SetFont(AchievementDateFont,                NORMAL, 11, "OUTLINE")
  43.         SetFont(AchievementCriteriaFont,            NORMAL, 11, "OUTLINE")
  44.         SetFont(AchievementDescriptionFont,         NORMAL, 11, "")
  45.        
  46.         SetFont(FriendsFont_Large,                  NORMAL, 11, nil, nil, nil, nil, 0, 0, 0, 1, -1, "THINOUTLINE")
  47.         SetFont(FriendsFont_Normal,                 NORMAL, 11, nil, nil, nil, nil, 0, 0, 0, 1, -1, "THINOUTLINE")
  48.         SetFont(FriendsFont_Small,                  NORMAL, 11, nil, nil, nil, nil, 0, 0, 0, 1, -1, "THINOUTLINE")
  49.         SetFont(FriendsFont_UserText,               NORMAL, 11, nil, nil, nil, nil, 0, 0, 0, 1, -1, "THINOUTLINE")
  50.         SetFont(GameTooltipHeader,                  NORMAL, 11, "THINOUTLINE")
  51.         SetFont(GameFont_Gigantic,                  NORMAL, 32, nil, nil, nil, nil, 0, 0, 0, 1, -1, "THINOUTLINE")
  52.         SetFont(InvoiceFont_Med,                    NORMAL, 11, nil, 0.15, 0.09, 0.04, "THINOUTLINE")
  53.         SetFont(InvoiceFont_Small,                  NORMAL, 11, nil, 0.15, 0.09, 0.04, "THINOUTLINE")
  54.         SetFont(MailFont_Large,                     NORMAL, 11, nil, 0.15, 0.09, 0.04, 0.54, 0.4, 0.1, 1, -1, "THINOUTLINE")
  55.        
  56.         SetFont(NumberFont_OutlineThick_Mono_Small, NORMAL, 12, "OUTLINE")
  57.        
  58.         SetFont(NumberFont_Outline_Huge,            NORMAL, 30, "THINOUTLINE", 30)
  59.         SetFont(NumberFont_Outline_Large,           NORMAL, 13, "THINOUTLINE")
  60.         SetFont(NumberFont_Outline_Med,             NORMAL, 11, "THINOUTLINE")
  61.         SetFont(NumberFont_Shadow_Med,              NORMAL, 11, "THINOUTLINE")
  62.         SetFont(NumberFont_Shadow_Small,            NORMAL, 11, "THINOUTLINE")
  63.        
  64.        
  65.        
  66.         SetFont(QuestFont_Shadow_Small,             NORMAL, 11, "THINOUTLINE")
  67.         SetFont(QuestFont_Shadow_Huge,              NORMAL, 15, nil, nil, nil, nil, 0.54, 0.4, 0.1)
  68.         SetFont(QuestFontHighlight,                 NORMAL, 14, "THINOUTLINE")
  69.         --SetFont(QuestFontNormalSmall,               NORMAL, 11, "THINOUTLINE")
  70.         --SetFont(QuestLogTitleText,                  NORMAL, 13, "THINOUTLINE")
  71.         SetFont(QuestTitleFont,                     NORMAL, 13)
  72.         SetFont(QuestFont,                          NORMAL, 12)
  73.         SetFont(QuestFont_Large,                    NORMAL, 14, "THINOUTLINE")
  74.         SetFont(QuestTitleFontBlackShadow,          NORMAL, 16, "THINOUTLINE")
  75.         SetFont(QuestFont_Super_Huge,               NORMAL, 16, "THINOUTLINE")
  76.  
  77.  
  78.        
  79.        
  80.         SetFont(ReputationDetailFont,               NORMAL, 11, nil, nil, nil, nil, 0, 0, 0, 1, -1, "THINOUTLINE") 
  81.         SetFont(SpellFont_Small,                    NORMAL, 12)
  82.         SetFont(SystemFont_InverseShadow_Small,     NORMAL, 11, "THINOUTLINE")
  83.         SetFont(SystemFont_Large,                   NORMAL, 12, "")
  84.         SetFont(SystemFont_Med1,                    NORMAL, 12, "")
  85.         SetFont(SystemFont_Med2,                    NORMAL, 13, nil, 0.15, 0.09, 0.04, "THICKOUTLINE")
  86.         SetFont(SystemFont_Med3,                    NORMAL, 13, "THICKOUTLINE")
  87.         SetFont(SystemFont_OutlineThick_Huge2,      NORMAL, 22, "THICKOUTLINE")
  88.         SetFont(SystemFont_OutlineThick_Huge4,      NORMAL, 27, "THICKOUTLINE")
  89.         SetFont(SystemFont_OutlineThick_WTF,        NORMAL, 31, "THICKOUTLINE", nil, nil, nil, 0, 0, 0, 1, -1)
  90.         SetFont(SystemFont_Outline_Small,           NORMAL, 11, "THINOUTLINE")
  91.         SetFont(SystemFont_Shadow_Huge1,            NORMAL, 20, "THINOUTLINE")
  92.         SetFont(SystemFont_Shadow_Huge3,            NORMAL, 25, "THINOUTLINE")
  93.         SetFont(SystemFont_Shadow_Large,            NORMAL, 17, "THINOUTLINE")
  94.         SetFont(SystemFont_Shadow_Med1,             NORMAL, 11, "THINOUTLINE")
  95.         SetFont(SystemFont_Shadow_Med2,             NORMAL, 11, "THINOUTLINE")
  96.         SetFont(SystemFont_Shadow_Med3,             NORMAL, 11, "THINOUTLINE")
  97.         --SetFont(SystemFont_Shadow_Outline_Huge2,    NORMAL, 22, "THINOUTLINE")
  98.         SetFont(SystemFont_Shadow_Small,            NORMAL, 11, "THINOUTLINE")
  99.         SetFont(SystemFont_Small,                   NORMAL, 12)
  100.         SetFont(SystemFont_Tiny,                    NORMAL, 11, "THINOUTLINE")
  101.         SetFont(Tooltip_Med,                        NORMAL, 11, "THINOUTLINE")
  102.         SetFont(Tooltip_Small,                      NORMAL, 11, "THINOUTLINE")
  103.         SetFont(ChatBubbleFont,                     NORMAL, 12, "THINOUTLINE")
  104.        
  105.  
  106.         -- Derived fonts
  107.         SetFont(BossEmoteNormalHuge,           NORMAL, 27, "THICKOUTLINE")
  108.         --SetFont(CombatTextFont,                BOLD,   26, "THINOUTLINE")
  109.         SetFont(ErrorFont,                     NORMAL, 16, nil, 60, "THINOUTLINE")
  110.         SetFont(QuestFontNormalSmall,          NORMAL, 11, nil, nil, nil, nil, 0.54, 0.4, 0.1)
  111.         SetFont(WorldMapTextFont,              NORMAL, 31, "THICKOUTLINE",  40, nil, nil, 0, 0, 0, 1, -1, "THINOUTLINE")
  112.  
  113.     end)


Thanks.

Kanegasi 11-06-22 11:23 PM

The "flags" argument of SetFont can not be nil. Before 10.0, that usage was silently ignored and assumed to be "none", now it drops a hard error.

Go through each font register line in the code you posted and make sure the third argument (the one after the 11 in most lines) is either the OUTLINE or THINOUTLINE that seems to be at the end for some or is an empty string (two quotes with nothing between ""

gmarco 11-07-22 12:18 AM

Hi,

I had the same error in my addon gmFonts and I have modified all the call adding a "" ( a void string ) to fill where there is a nil but it should not.

like:
Lua Code:
  1. SetFont(_G.QuestFontNormalSmall, GMFONTS["B"], 13, "", nil, nil, nil, 0.54, 0.4, 0.1)

Let me know.

Lamebob 11-07-22 02:15 AM

Quote:

Originally Posted by Kanegasi (Post 341506)
The "flags" argument of SetFont can not be nil. Before 10.0, that usage was silently ignored and assumed to be "none", now it drops a hard error.

Go through each font register line in the code you posted and make sure the third argument (the one after the 11 in most lines) is either the OUTLINE or THINOUTLINE that seems to be at the end for some or is an empty string (two quotes with nothing between ""

Quote:

Originally Posted by gmarco (Post 341507)
Hi,

I had the same error in my addon gmFonts and I have modified all the call adding a "" ( a void string ) to fill where there is a nil but it should not.

like:
Lua Code:
  1. SetFont(_G.QuestFontNormalSmall, GMFONTS["B"], 13, "", nil, nil, nil, 0.54, 0.4, 0.1)

Let me know.

:)
That fixed it thank you

SDPhantom 11-07-22 03:22 PM

To be fair, line 3 of your example could've been modified to this for less effort.
Code:

obj:SetFont(font, size, style or "")


All times are GMT -6. The time now is 03:35 PM.

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