LibFonts (1.0.0)

Overview

LibFonts provides a centralized location for a vast collection of fonts that can be easily integrated into your addon. All fonts are free to use in any way you like, with most sourced from the 1001 Free Fonts website. Currently, it supports over 80 fonts, and more can be added as needed. The fonts are not loaded into memory until they are used, so you don’t have to worry about memory or resource management.

If you find any bugs, please let me know and I will address them as soon as possible.

Library Dependencies

LibDebugLogger
LibMediaProvider-1

Usage

Slash Commands:

/lfversion
Display version information in the chat window

Examples:

LibFontsSample_1.txt:

## Title: LibFontsSample1
## APIVersion: 101044
## Version: 1.0
## Author: YourName
## Description: Displays “Libfonts Library Sample 1” in the chat window using a font from the library

## DependsOn: LibFonts

LibFontsSample1.lua

LibFontsSample_1.lua:

local LibFontsSample1 = {}

LibFontsSample1.AddName = “LibFontsSample1”
LibFontsSample1.AddId = “LibFontsSample1”
LibFontsSample1.Version = 10000
LibFontsSample1.Author = “TheJoltman”

if LibFonts then
MyAddonLf = LibFonts
else
d(“Error loading LibFonts!”)
end

LibFontsSample1.Window = GetWindowManager()
LibFontsSample1.InfoText = LibFontsSample1.Window:CreateTopLevelWindow(“LibFontsSample1DisplayBar”)

local function OnLoad(event, addonName)
if addonName == LibFontsSample1.AddName then
LibFontsSample1.InfoText:SetAnchor(CENTER, GuiRoot, nil, 0, -250)
LibFontsSample1.InfoText.Text = LibFontsSample1.Window:CreateControl(“LibFontsSample1.InfoText”, LibFontsSample1.InfoText, CT_LABEL)
LibFontsSample1.InfoText.Text:SetAnchor(CENTER, LibFontsSample1.InfoText, CENTER, 0, 0)
LibFontsSample1.InfoText.Text:SetFont(MyAddonLf.GetFontByFriendlyName(“AvenueX_Regular”)..”|”..”50″..”|shadow”)
LibFontsSample1.InfoText.Text:SetText(“|c00CCCCLibfonts Library Sample 1|r”)

EVENT_MANAGER:UnregisterForEvent(LibFontsSample1.AddName..”_OnLoad”, EVENT_ADD_ON_LOADED)
end
end

EVENT_MANAGER:RegisterForEvent(LibFontsSample1.AddName..”_OnLoad”, EVENT_ADD_ON_LOADED, OnLoad)

LibFontsSample_2.txt:

## Title: LibFonts Sample Addon 2
## APIVersion: 101044
## Version: 1.0
## Author: YourName
## Description: Displays a combobox containing all of the LibFonts font names to choose from. When one is selected it updates a text control on the screen using the selected font.

## DependsOn: LibFonts

LibFontsSample_2.lua

LibFontsSample_2.lua:

local LibFontsSample2 = {}

LibFontsSample2.AddName = “LibFontsSample2”
LibFontsSample2.AddId = “LibFontsSample2”
LibFontsSample2.Version = 10000
LibFontsSample2.Author = “TheJoltman”

if LibFonts then
LibFontsSample2Lf = LibFonts
else
d(“Error loading LibFonts!”)
end

function LibFontsSample2:Initialize()
— Create a TopLevelWindow to hold the dropdown
local mainWindow = WINDOW_MANAGER:CreateTopLevelWindow(“MyDropdownWindow”)
mainWindow:SetDimensions(300, 100)
mainWindow:SetAnchor(CENTER, GuiRoot, CENTER, 0, -500)
mainWindow:SetMovable(true)
mainWindow:SetMouseEnabled(true)

— Add a backdrop for styling
local backdrop = WINDOW_MANAGER:CreateControl(nil, mainWindow, CT_BACKDROP)
backdrop:SetAnchorFill(mainWindow)
backdrop:SetCenterColor(0, 0, 0, 0.5)
backdrop:SetEdgeColor(1, 1, 1, 1)
backdrop:SetEdgeTexture(“”, 1, 1, 1.0)

— Create the dropdown control
local dropdown = WINDOW_MANAGER:CreateControlFromVirtual(“MyDropdownControl”, mainWindow, “ZO_ComboBox”)
dropdown:SetAnchor(CENTER, mainWindow, CENTER, 0, 0)
dropdown:SetDimensions(200, 30)

— Get the combo box object
local comboBox = ZO_ComboBox_ObjectFromContainer(dropdown)

— Ensure the combo box is valid
if not comboBox then
d(“Error: Failed to create combo box”)
return
end

— Disable sorting (optional)
comboBox:SetSortsItems(false)

— Populate the combo box
local items = LibFontsSample2Lf.GetFontNameList()
for _, item in ipairs(items) do
local entry = comboBox:CreateItemEntry(item, function()
— Callback triggered when this item is selected
LibFontsSample2.InfoText.Text:SetFont(LibFontsSample2Lf.GetFontByFriendlyName(item)..”|”..”50″..”|shadow”)
LibFontsSample2.InfoText.Text:SetText(“|c00CCCC”..item..”|r”)
end)
comboBox:AddItem(entry)
end

end

LibFontsSample2.Window = GetWindowManager()
LibFontsSample2.InfoText = LibFontsSample2.Window:CreateTopLevelWindow(“LibFontsSample2DisplayBar”)

local function OnLoad(event, addonName)
if addonName == LibFontsSample2.AddName then
LibFontsSample2:Initialize()

LibFontsSample2.InfoText:SetAnchor(CENTER, GuiRoot, nil, 0, -350)
LibFontsSample2.InfoText.Text = LibFontsSample2.Window:CreateControl(“LibFontsSample2.InfoText”, LibFontsSample2.InfoText, CT_LABEL)
LibFontsSample2.InfoText.Text:SetAnchor(CENTER, LibFontsSample2.InfoText, CENTER, 0, 0)

EVENT_MANAGER:UnregisterForEvent(LibFontsSample2.AddName..”_OnLoad”, EVENT_ADD_ON_LOADED)
end
end

EVENT_MANAGER:RegisterForEvent(LibFontsSample2.AddName..”_OnLoad”, EVENT_ADD_ON_LOADED, OnLoad)

Leave a Reply

Your email address will not be published. Required fields are marked *

For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.