1. #1
    Deleted

    Question Struggle with method SetFont()

    Hello there,

    I was hoping that someone could be able to help me here. I'm working on an addon to provide a bar that fills up according to Resolve buff (the new "revenge"), which is ResolveStatus on curse.

    My problem lies within the method SetFont(), which is associated with texts. According to the API documentation, this method works like this:
    TextObject.SetFont(filepath,size)
    And should return 1 (or -1, can't remember), if the filepath is correct within the WoW directory.

    The call that I do is like that:
    Code:
    Local fontname = "arial.ttf"
    TextObject.SetFont("Interface\\AddOns\\ResolveStatus\\Fonts\\"..fontname,14)
    However, this method seems to only work on realoading UI, let me explain:
    The fontname is a savedvariable of the addon, set by the user, if the user type a new file name (ex: "font2.ttf"), it is saved into saved variables, and I execute the method above, but it doesn't work, and seems to indicate that the font path is incorrect. However, if I reload UI, the variable is still set in SavedVariables, and the addon on load executes the same SetFont call, and this time it works.

    Once a new font has been added through a reload UI, simply calling the method once again without reloading UI seems to work (as if the game cached the font correctly).

    Do you have any idea if this is intended behavior ? (Sorry I might have not been clear as I'm on my phone on my way to work, I might be able to provide parts of the incriminating code later if needed).

    Thanks for your help

  2. #2
    Deleted
    Bumping, and adding some informations.

    Here is the code that I'm using to set the font:
    Code:
    local fontpath
    local SelectedFont = self:GetText()
    if not (SelectedFont == "" or SelectedFont == "Default" or SelectedFont == "default" or SelectedFont == "DEFAULT") then
    	-- Add ".ttf" if not specified by user
    	if string.find(SelectedFont,"\.ttf$") then
    		fontpath = SelectedFont
    	else
    		fontpath = SelectedFont.."\.ttf"
    	end
    	-- This is the part not working currently, SetFont should return something if the path is correct
    	-- but it returns nothing (eventhough the path is correct). However this works on reload UI
    	if f.StatusBar.Text:SetFont("Interface\\Addons\\ResolveStatus\\Fonts\\"..fontpath,ResolveStatusDB.fontsize) then
    		ResolveStatusDB.fontpath = fontpath
    		UpdateResolveStatusBar()
    		self:SetText(ResolveStatusDB.fontpath)
    	else
    		self:SetText("Invalid file")
    	end
    else
    	ResolveStatusDB.fontpath = "Default"
    	UpdateResolveStatusBar()
    	self:SetText("Default")
    end
    Need clueeeees

  3. #3
    Hey there,
    a little bit late but I have the same problem as you...
    This problem seems to be a major thing, cause it's in 6.2.4 (WoD) and 7.0.3 (Legion).
    I have posted my problem in an external forum, maybe there would be an answer...

    Can't post links here so If I could get an answer I let you know

    - - - Updated - - -

    So have testet a lot...
    For whatever reason WOW load it in there or not its like a russian roulette.
    Have send a bug report to Blizzard maybe it's clientside and will be fixed soon... maybe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •