View Single Post
07-14-18, 12:51 PM   #3
Ammako
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
Your line isn't working because your addon won't know what "SharedMedia" is unless you declare it. If you had lua errors enabled, it would give you an error telling you that you "attempted to use SharedMedia (a nil value)" or something like that (displaying lua errors may be disabled by default with no option given to enable them in the UI, thanks Blizzard.)

lua Code:
  1. local SharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
  2. SharedMedia:Register ("font", "Proza Regular", [[Interface\Addons\NewAddon\fonts\headlines.TTF]])

This should work as long as your addon is loaded after another addon which has LibStub and LibSharedMedia included, but if you want to be clever you could do it like this (as per SharedMedia_NoAsianFonts):

lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterEvent("ADDON_LOADED")
  3. f:SetScript("OnEvent", function()
  4.     local LSM = LibStub and LibStub("LibSharedMedia-3.0", true)
  5.     if not LSM then return end
  6.  
  7.     f:UnregisterAllEvents()
  8.     f:SetScript("OnEvent", nil)
  9.  
  10.     LSM:Register("font", "Proza Regular", [[Interface\Addons\NewAddon\fonts\headlines.TTF]])
  11. end)

This is more robust and should work regardless of the order in which addons are loaded. Or at least it works for me -shrugs-

Last edited by Ammako : 07-14-18 at 01:01 PM.
  Reply With Quote