Page 1 of 2

Change default font in KTM and chatbox borders

PostPosted: Thu Feb 25, 2016 6:06 am
by crimsonsage
Wondering if anyone knows how to change the default font that's used in KTM. I have 17.35 installed right now, and in KTM_Frame.xml there is this starting at line 5

Code: Select all
   <!-- The base font -->
   <Font name="KLHTM_FontDefault" inherits="GameFontNormal" virtual="true">
      <Color r="1.0" g="1.0" b="1.0"/>
   </Font>


I understand from some research that "GameFontNormal" is the default font, but I can't figure out how to change that. I've tried adding a font to the folder and specifying a path, with a few different parameters, but haven't got it. I guess you can't "inherit" a font, but specifying one didn't work either. Guessing I have the syntax wrong.


In a separate issue, I'm wondering if anyone knows of a lightweight addon or a way to change the default chat box to have square / sharp edges instead of soft rounded ones. I've got ChatMOD and Prat installed but didn't see any built in options there.

Re: Change default font in KTM and chatbox borders

PostPosted: Thu Feb 25, 2016 12:26 pm
by tankafarian
You should try Fontify, It basically changes the original font.

The borders I have no idea how to change

Re: Change default font in KTM and chatbox borders

PostPosted: Thu Feb 25, 2016 3:44 pm
by crimsonsage
Appreciate the recommendation, but I think I tried Fontify before and the problem I had is that it changes the font for everything -- not just a single addon. I'd also like to learn a little bit more about how fonts are used within addons, but I'll check it out anyway.

Re: Change default font in KTM and chatbox borders

PostPosted: Thu Feb 25, 2016 7:06 pm
by Roadblock
KTM doesn't have very many fontstrings from a quick look.
If you search that xml file for
Code: Select all
<FontString
you'd find 9 occurrences

You'd need to make a note of fontstring names. When the Fontstring name= starts with a $parent token, the actual name is the name of the nearest frame ancestor + whatever is after $parent.

Example: line 45 reads
Code: Select all
<FontString name="$parentText"
The parent frame on line 42 is called
Code: Select all
KLHTM_StringTemplate
so the actual FontString name is KLHTM_StringTemplateText

After you collect the FontString names you will need to call SetFont on them with a font file path.
Example:
Code: Select all
KLHTM_StringTemplateText:SetFont("Interface\\AddOns\\KLHThreatMeter\\Fonts\\my_nice_font.ttf",14,"OUTLINE")

This assumes you've put custom fonts in a Fonts subfolder in KLHThreatMeter addon folder with your font files in it.
2nd parameter is font height, 3rd is font flags and is optional (choices between "OUTLINE", "MONOCHROME", "THICKOUTLINE" can be combined with "MONOCHROME, THICKOUTLINE" for example)

So you need to :SetFont() on all the fontstring names you collected after the UI is fully loaded.

This is not really a tutorial, more like hints but since you said you wanted to look into fonts more, might give you a starting point.

Re: Change default font in KTM and chatbox borders

PostPosted: Thu Feb 25, 2016 10:12 pm
by crimsonsage
Hey Roadblock, thanks for the information you provided. I have a semi-working knowledge of basic lua, but almost no understanding of XML.

It looks like "SetFont" is a lua method, but I'm not sure that it applies in XML, does it?

My understanding is that your example would work in a *.lua file, but that in XML I'd need to use some font attribute to set the font.

I've tried using the SetFont method but can't quite get it to work. Will keep poking around but if you have any other tips / examples I'd appreciate them.

Re: Change default font in KTM and chatbox borders

PostPosted: Thu Feb 25, 2016 11:13 pm
by Roadblock
After KLHThreatMeter fully loads all those frames and regions (including textures and fontstrings) that make up its UI are present in the Lua environment.

They are actually in the global environment as it's called.

You are correct that the SetFont() stuff would have to be in a .lua file loaded by KLHThreatMeter (or a separate addon that loads after KLHThreatMeter and modifies its appearance)

You can also try them in a macro or the command-line, but the font files you might reference need to be in place before you start WoW.

One place you could put such customization code is at the end of the KLHTM_SetupGui() function found in KLHThreatMeter\Code\GUI\KTM_Gui.lua line 115 to 143.

Re: Change default font in KTM and chatbox borders

PostPosted: Thu Feb 25, 2016 11:51 pm
by crimsonsage
Well, thanks again. Made a tiny bit of progress. I wasn't able to get anything working in the SetupGUI function though.

I tried adding
Code: Select all
KLHTM_StringTemplateText:SetFont("Interface\\AddOns\\KLHThreatMeter\\FuturaBold.ttf")


To line 143 (inside the function, pushing the end to close the function to line 144) but got nothing. Tried a few other things too and couldn't quite get it. I was able to find a "setFont" method already being used in the KLHTM_AddOutline function. By changing

Code: Select all
function KLHTM_AddOutline(fontstring)
   
   local path, height;
   path, height = fontstring:GetFont();
   
   fontstring:SetFont(path, height, "OUTLINE");
   fontstring:SetShadowColor(0,0,0,0.3);
end


to this

Code: Select all
fontstring:SetFont("Interface\\AddOns\\KLHThreatMeter\\FuturaBold.ttf", height, "OUTLINE");


I ended up with this:

Image


I poked around in KTM_TitleGui.lua but couldn't figure out a way to change the font for the title either. Will probably take a little break for now and try again with some fresh eyes in a day or two. Getting there slowly. Thanks again.

Re: Change default font in KTM and chatbox borders

PostPosted: Fri Feb 26, 2016 5:53 am
by Kaiji
Unpack this to your Interface folder (not your Addons folder) for square chatframes.

Re: Change default font in KTM and chatbox borders

PostPosted: Fri Feb 26, 2016 6:21 am
by crimsonsage
Link just takes me to an empty Cloud Drive page (even after creating an account)

Re: Change default font in KTM and chatbox borders

PostPosted: Fri Feb 26, 2016 11:53 pm
by Kaiji