Thread Tools Display Modes
05-12-20, 08:20 AM   #1
jezzi23
A Murloc Raider
Join Date: Apr 2020
Posts: 4
Unable to use SetFontObject on a custom .ttf font

I have this really simple problem that I just can't seem to figure out...

I'm trying to use a custom font for my addon. As an example, I'll try to use arial.ttf, which exists at the wow base directory, and in every directory along the way to my addon directory, e.g. "Interface\\AddOns\\MY_ADDON_NAME\\fonts\\arial.ttf"

font_str = UIParent:CreateFontString(nil, "OVERLAY")
font_str:SetFontObject("arial.ttf"); -- try to find it at wow base directory
font_str:SetText("TEST");
font_str:SetPoint("TOP", 0, -30);

I have tried looking for it in the addon directory as well but it never works and I get "<unnamed>:SetFontObject(): Couldn't find font named arial.ttf".

What is going on here? : (

EDIT: This is Wow Classic

Last edited by jezzi23 : 05-12-20 at 08:31 AM.
  Reply With Quote
05-12-20, 09:12 AM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
A font object is a font defined in an xml file. SetFontObject does not accept file paths.

You're looking for SetFont.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Unable to use SetFontObject on a custom .ttf font

Thread Tools
Display Modes

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