Thread Tools Display Modes
02-12-12, 12:19 PM   #1
Remyxamotosis
A Defias Bandit
Join Date: Sep 2009
Posts: 3
Changing font in LynStats

http://pastie.org/3368375

So the above is a copy of LynStats that I pulled out of one of LED++ UI's a good while back. It's rather simple and hasn't given me any problems, however I'm now trying to swap out the fonts and running into some issues.

The only thing I've changed is the file path to my new font on line 9 and now in addition to throwing lua errors roughly once per second, the clock has just plain disappeared. I do still get the popup showing latency/fps if I hover my mouse over the area that it's supposed to be though.

Here is the error that I'm getting in-game:

Code:
Message: Interface\AddOns\!Lyn\stats.lua:59: <unnamed>:SetText(): Font not set
Time: 02/12/12 11:58:13
Count: 993
Stack: [C]: in function `SetText'
Interface\AddOns\!Lyn\stats.lua:59: in function <Interface\AddOns\!Lyn\stats.lua:31>

Locals: (*temporary) = <unnamed> {
 0 = <userdata>
}
(*temporary) = "11:58"
SOLVED:

text:SetFont("Interface\Addons\SharedMedia\fonts\04B03.TTF", 8, "OUTLINEMONOCHROME")

should be

text:SetFont("Interface\\Addons\\SharedMedia\\fonts\\04B03.TTF", 8, "OUTLINEMONOCHROME")

I don't have the attention to detail to be a developer.

Last edited by Remyxamotosis : 02-12-12 at 12:42 PM. Reason: edited for resolution
  Reply With Quote
02-12-12, 07:11 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
That's because backslashes in Lua are "escape characters". They are normally used for special things like "line breaks\nin a string".

If you just write:

"Interface\AddOns\SharedMedia\Fonts\04B03.ttf"

Lua interprets it as:

"InterfaceddOnsharedMediaonts4B03.ttf"

In order to tell Lua that a backslash isn't an escape character, you have to escape it with a preceding backslash, hence:

"Interface\\AddOns\\SharedMedia\\Fonts\\04B03.ttf"

You can also tell Lua to ignore backslashes inside strings by using alternate delimiters; instead of surrounding your string with 'single quotations' or "double quotations", you can surround it with double square brackets:

[[Interface\AddOns\SharedMedia\Fonts\04B03.ttf]]

This is commonly used when a string contains literal backslashes (such as a file path) or when the string contains literal quotation marks (since you would normally have to escape those with an ugly backslash).

If a string contains double square brackets, you can further alter the string delimiters by adding any number of equals-signs between the square brackets:

[=[Interface\AddOns\SharedMedia\Fonts\04B03.ttf]=]

You can use as many equals-signs as you want/need, as long as there is the same number of them in both the opening and closing delimiters.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Changing font in LynStats


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