-
Notifications
You must be signed in to change notification settings - Fork 4
Home
This guide will walk you through the process of creating your own media pack to register fonts with the LibSharedMedia-3.0 library, which will make them available to PhanxFont and many other addons. You can also add bar textures and sounds to your media pack.
For the purposes of this guide, your media pack addon will be called "MyMedia". If you want to call it something else, replace all instances of "MyMedia" with your chosen name when following these instructions.
-
Create a "MyMedia" folder in your addons folder (World of Warcraft » Interface » AddOns) and enter it.
-
Create a file named "MyMedia.toc" with the following contents:
## Interface: 70300 ## Title: MyMedia addon.lua font.lua
-
Create a file named "addon.lua" with the following contents:
local NAME, ns = ... local PATH = "Interface\\AddOns\\" .. NAME local LSM local pending = {} local frame = CreateFrame("Frame") frame:RegisterEvent("ADDON_LOADED") frame:SetScript("OnEvent", function(self, event, name) LSM = LibStub and LibStub("LibSharedMedia-3.0", true) if not LSM then return end self:UnregisterEvent(event) for type, media in pairs(pending) do for name, filename in pairs(media) do ns.Register(type, name, filename) end end end) function ns.Register(type, name, filename) if LSM then LSM:Register(type, name, PATH .. "\\" .. type .. "\\" .. filename) else pending[type] = pending[type] or {} pending[type][name] = filename end end
It's not actually important that you understand what the above code is doing, but basically it's waiting for the LibSharedMedia-3.0 library to be loaded by some other addon (saving us the trouble of loading it ourselves, since we know some other addon is already doing it) and then registering all of your media with it.
World of Warcraft only recognizes TrueType font files with a .ttf
filename extension. If your font files do not meet these criteria, they will not work in the game.
-
Create a folder named "font" (important; must be exact) inside your "MyMedia" folder.
-
Place all of your font files inside the "font" folder.
-
Back in the "MyMedia" folder, create a file named "font.lua" with the following contents:
local _, ns = ... ns.Register("font", "My Font Name", "MyFontFile.ttf")
-
Change "My Font Name" to the name you want to appear for your font in the in-game options menu.
-
Change "MyFontFile.ttf" to the name of your font file.
-
Repeat the last line for each font file you added to the "font" folder.
This step is easy. Just save and close all your files if you haven't already, and start WoW. If WoW was already running, you'll need to completely exit the game and restart it in order for it to detect the new files you've added.
You should now see "MyMedia" in the in-game addon list. If you don't see it, you did something wrong. Go through the above steps and make sure all your files are in the right place, with the right names, and restart WoW again. If you do see it, then all your fonts should now appear in the options menus for PhanxFont and other addons that use LibSharedMedia-3.0 for their font selection.
This step is not required or useful for PhanxFont, but may be useful for other addons. LibSharedMedia-3.0 also supports sounds, and textures (images) for status bars, borders, and backgrounds. To add your own media of these types, repeat Step 2 above, but replace all instances of "font" with the correct media type identifier:
- "sound" for sound files
- "statusbar" for bar textures
- "background" for background textures
- "border" for border textures
Note the following requirements for media files recognized by World of Warcraft:
- Sound files must be in OGG or MP3 format.
- Texture (image) files must be in BLP or TGA format, and must have power-of-two dimensions. TGA images may have 8, 24, or 32 bits per pixel for grayscale, RGB, and RGBA images respectively; RLE is supported. (source)
- Border textures are used as sprites, and must match the expected layout. See the UI-Tooltip-Border texture for an example.
To convert images from the PNG format, which is widely supported by image editing tools, to the BLP format, which WoW can read, use the BLPNG Converter tool by DigitalUtopia (Mac version here).