WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Carbonite Archive (https://www.wowinterface.com/forums/forumdisplay.php?f=158)
-   -   Custom fonts in Carbonite (from LibSharedMedia) (https://www.wowinterface.com/forums/showthread.php?t=46445)

vladscrutin 05-10-13 10:59 PM

Custom fonts in Carbonite (from LibSharedMedia)
 
Hi all

I've been messing around with trying to set up a nice UI, but Carbonite has been letting me down since I couldn't get my Carbonite font to match my custom UI font. OCD lead me to investigate why Carbonite ignored LibSharedMedia fonts (a couple of old threads shed no light on the situation: http://www.wowinterface.com/forums/s...ad.php?t=37722 and http://wowinterface.com/forums/showthread.php?t=37244)

Had a look at NxUI.lua, and it looks like Carbonite is expecting Ace2 to be installed before being able to gather LibSharedMedia fonts.

I made a change on my local machine to use LibStub instead (which could be bundled with Carbonite):

Previous code:
Code:

function Nx.Font:AddonLoaded()

        if not self.Inited then
                return
        end

        local ace = _G["AceLibrary"]

        if ace then
--                ace ("AceAddon-2.0")

                local found

                found = self:FontScan (ace, "LibSharedMedia-2.0")
                found = found or self:FontScan (ace, "LibSharedMedia-3.0")

                if found then
                        self:Update()
                end
        end
end

function Nx.Font:FontScan (ace, libName)

        local sm

        if ace["HasInstance"] (ace, libName) then
                sm = ace (libName)
        end

        if sm then

                local found

                local fonts = sm["List"](sm, "font")

--                Nx.prtVar ("SM", fonts)

                for k, name in ipairs (fonts) do

                        if not self.AddonFonts[name] then
                                found = true
--                                Nx.prtVar ("Font", name)
--                                Nx.prtVar ("Fetch", sm["Fetch"] (sm, "font", name))
                                self.AddonFonts[name] = sm["Fetch"] (sm, "font", name)
                                tinsert (self.Faces, { name, self.AddonFonts[name] })
                        end
                end

                return found
        end
end

My changes:
Code:

function Nx.Font:AddonLoaded()

        if not self.Inited then
                return
        end

        local found

        found = self:FontScan ("LibSharedMedia-3.0")

        if found then
                self:Update()
        end
end

function Nx.Font:FontScan (libName)

        local sm

        sm = LibStub(libName)

        if sm then

                local found

                local fonts = sm.List(sm, "font")

--                Nx.prtVar ("SM", fonts)

                for k, name in ipairs (fonts) do

                        if not self.AddonFonts[name] then
                                found = true
--                                Nx.prtVar ("Font", name)
--                                Nx.prtVar ("Fetch", sm["Fetch"] (sm, "font", name))
                                self.AddonFonts[name] = sm.Fetch(sm, "font", name)
                                tinsert (self.Faces, { name, self.AddonFonts[name] })
                        end
                end

                return found
        end
end

Only other addition is to add LibStub.lua to the root Carbonite directory and add the line for LibStub.lua to the Carbonite.toc file.

Hope this helps for people wanting custom fonts in Carbonite without installing Ace2. Feel free to move this to the development forum if it seems more appropriate.

Cheers


All times are GMT -6. The time now is 01:07 AM.

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