Thread Tools Display Modes
09-23-14, 08:56 AM   #1
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Fonts and ActionButtons

For as long as I can remember, my actionbar skinning addon has had this issue where it doesn't want to replace the font on ActionButtonN on the first client startup.

Here is what I use:
Code:
local FONT = [[Interface\AddOns\MyAddon\font.ttf]]
for index = 1, NUM_ACTIONBAR_BUTTONS do
    _G['ActionButton' .. index .. 'HotKey']:SetFont(FONT, 8)
end
When I start the client and log in to a character, this will do nothing. Running :GetFont() shows the default font (ARIALN.ttf), size and flags.

This issue only occurs on ActionButtonN, it works fine on the other buttons I skin (MultiBarBottomLeftButtonN etc).

If I /reload or relog (logging out to the character screen then logging in on any character) it works fine.

I've also tried delaying this to PLAYER_LOGIN and other later events without success.

Delaying it with an OnUpdate script past login works, but I don't know how long I have to wait, and it is not a good solution.

Setting the font to any of the other built-in fonts (like FRIZQT__.ttf) works fine.



So, I'm not sure what's causing this or how to fix it.

Last edited by p3lim : 09-23-14 at 09:03 AM.
  Reply With Quote
09-23-14, 09:02 AM   #2
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Are you doing something with the SPELLS_CHANGED Event that could be causing that? As this event fires in an early phase during login (before PLAYER_LOGIN and PLAYER_ENTERING_WORLD) but not during an UI reload (both actions do fire SPELLS_CHANGED after PLAYER_LOGIN and PLAYER_ENTERING_WORLD).
  Reply With Quote
09-23-14, 09:29 AM   #3
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Duugu View Post
Are you doing something with the SPELLS_CHANGED Event that could be causing that? As this event fires in an early phase during login (before PLAYER_LOGIN and PLAYER_ENTERING_WORLD) but not during an UI reload (both actions do fire SPELLS_CHANGED after PLAYER_LOGIN and PLAYER_ENTERING_WORLD).
I have no clue what you mean by that.
  Reply With Quote
09-23-14, 09:48 AM   #4
sticklord
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 57
Sounds to me like the font doesn't exist when you run SetFont() maybe? Better to make sure now than later
  Reply With Quote
09-23-14, 09:49 AM   #5
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by p3lim View Post
For as long as I can remember, my actionbar skinning addon has had this issue where it doesn't want to replace the font on ActionButtonN on the first client startup.

Here is what I use:
Code:
local FONT = [[Interface\AddOns\MyAddon\font.ttf]]
for index = 1, NUM_ACTIONBAR_BUTTONS do
    _G['ActionButton' .. index .. 'HotKey']:SetFont(FONT, 8)
end
When I start the client and log in to a character, this will do nothing. Running :GetFont() shows the default font (ARIALN.ttf), size and flags.

This issue only occurs on ActionButtonN, it works fine on the other buttons I skin (MultiBarBottomLeftButtonN etc).

If I /reload or relog (logging out to the character screen then logging in on any character) it works fine.

I've also tried delaying this to PLAYER_LOGIN and other later events without success.

Delaying it with an OnUpdate script past login works, but I don't know how long I have to wait, and it is not a good solution.

Setting the font to any of the other built-in fonts (like FRIZQT__.ttf) works fine.



So, I'm not sure what's causing this or how to fix it.
Have you tried waiting till the ADDON_LOADED event, the game might load the custom fonts there.
  Reply With Quote
09-23-14, 09:55 AM   #6
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
The events on login are:

ADDON_LOADED xxx
ADDON_LOADED xxx
ADDON_LOADED xxx
SPELLS_CHANGED
ADDON LOADED Blizzard_TimeManager
ADDON LOADED Blizzard_CombatLog
PLAYER_LOGIN
ADDON_Loaded Blizzard_CombatText
PLAYER_ENERING_WORLD
SPELLS_CHANGED

The events on reload are:

ADDON_LOADED xxx
ADDON_LOADED xxx
ADDON_LOADED xxx
ADDON LOADED Blizzard_TimeManager
ADDON LOADED Blizzard_CombatLog
PLAYER_LOGIN
ADDON_Loaded Blizzard_CombatText
PLAYER_ENERING_WORLD
SPELLS_CHANGED

So, maybe you're doing something on SPELLS_CHANGED that fails if this event is triggered during login (as PLAYER_LOGIN and PLAYER_ENERING_WORLD are not triggered at this point), but is ok on reload as there's no additional SPELLS_CHANGED before the player has entered the world?
  Reply With Quote
09-23-14, 10:09 AM   #7
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by sticklord View Post
Sounds to me like the font doesn't exist when you run SetFont() maybe? Better to make sure now than later
I set it on all the other buttons in the same way at the same time, and they work just fine.

Originally Posted by Resike View Post
Have you tried waiting till the ADDON_LOADED event, the game might load the custom fonts there.
I've tried doing it on load and on every event part of the loading process, none of them work, and, as I previously mentioned, using OnUpdate to delay it by X amount of seconds it works, but it's bad practice.

Originally Posted by Duugu View Post
The events on login are:

.. snip
And no, I'm not doing anything at that point, or at any point for that matter. That piece of code is the only thing in that addon right now, and that addon is the only one I load (I'm really trying to eliminate every possibility).

Last edited by p3lim : 09-23-14 at 10:13 AM.
  Reply With Quote
09-23-14, 10:19 AM   #8
sticklord
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 57
Hm. I haven't noticed this problem. I'm skinning every actionbutton on PLAYER_LOGIN and also hooking "ActionButton_UpdateHotkeys" to set the font if it isn't already, and to change the displayed hotkey. But if you just need this once per startup of the game, I guess this isnt much better than an onupdate script.

Last edited by sticklord : 09-23-14 at 10:26 AM.
  Reply With Quote
09-23-14, 10:37 AM   #9
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
I've tested it with a single addon containing
Lua Code:
  1. local FONT = [[Interface\AddOns\test\STROKEYB.ttf]]
  2. for index = 1, NUM_ACTIONBAR_BUTTONS do
  3.     _G['ActionButton' .. index .. 'HotKey']:SetFont(FONT, 20)
  4. end

It's working on any scenario.

Does the problem persists with other fonts?

Last edited by Duugu : 09-23-14 at 10:43 AM.
  Reply With Quote
09-23-14, 10:49 AM   #10
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Unless you want to specifically target action button hotkeys, you can also change NumberFontNormalSmall instead:

Code:
local nfns, font, size
nfns = NumberFontNormalSmall
font, size = nfns:GetFont()
nfns:SetFont(font, size, 'OUTLINE')
nfns:SetShadowColor(0, 0, 0, 0)
That's CleanHotKey.

Or you can make it as simple as:
Code:
NumberFontNormalSmall:SetFont([[Interface\AddOns\MyAddon\font.ttf]], 8)
If the font is used elsewhere(ItemButtonTemplate, TargetDebuffFrameTemplate), I see that as an added bonus.

Last edited by ravagernl : 09-23-14 at 10:53 AM.
  Reply With Quote
09-23-14, 11:32 AM   #11
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
I ended up reinstalling the game completely which seem to have fixed this.
  Reply With Quote
09-26-14, 03:31 AM   #12
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
...what? That sounds odd.

I just wanted to post that I do the same in my button styler but delay the styling process until PLAYER_LOGIN. Never had any issues with it.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Fonts and ActionButtons

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