Thread Tools Display Modes
05-10-13, 10:59 PM   #1
vladscrutin
A Kobold Labourer
Join Date: May 2013
Posts: 1
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
 
 

WoWInterface » Featured Projects » Carbonite » Carbonite Archive » Custom fonts in Carbonite (from LibSharedMedia)


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