Thread Tools Display Modes
07-13-10, 02:18 AM   #1
wellbeing
A Cliff Giant
Join Date: Oct 2009
Posts: 71
fontsting:SetFont

i'm having trouble setting the font for my fontstring.

how do i point to those in the wow directory.

I know that i can go another route using "normalgamefont" or whatever, but i need to scale the size of this particular fontstring up quite a bit. From what i can tell, i wasnt allowed to define the size after setting an inherent font.

for the purpose of clarity, i'm trying to recreate a "raidwarning" style message for which i can define the duration. the built in raidwarning_sendmessage won't allow definition of duration.

in summary.. how can i make my fontstring use a font that is included in wow AND quite large?
  Reply With Quote
07-13-10, 02:30 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,961
The way I do it is as follows :

local Path, Size, Flags = self.Cooldown.Text:GetFont()
self.Cooldown.Text:SetFont(Path,myFontSize,Flags);

This should then resize to the size you want.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
07-13-10, 02:49 AM   #3
wellbeing
A Cliff Giant
Join Date: Oct 2009
Posts: 71
Originally Posted by Xrystal View Post
The way I do it is as follows :

local Path, Size, Flags = self.Cooldown.Text:GetFont()
self.Cooldown.Text:SetFont(Path,myFontSize,Flags);

This should then resize to the size you want.

i'm not sure how to apply that to my situation..

here is my function for creating a text frame. i need it a few times with specific variables, so i just want to make it up top for use later.. i got the general format from some addon or another and modified it to my needs. i'm just unable to sort the facts on how to define the font/size.

function CreateText(name,text,x,y,parent,w,h,relto,relpt,just)

Parent = parent


local Name = name
local TextX = x
local TextY = y
local RelativeTo = relto
local RelativePoint = rept
local TextWidth = w
local TextHeight = h
local Text = text

local FrameLevel = 4

local TextFrame = CreateFrame("FRAME",Name,Parent)
TextFrame:ClearAllPoints()
TextFrame:SetWidth(TextWidth)
TextFrame:SetHeight(TextHeight)
local TextFrameFont = TextFrame:CreateFontString(nil, "BACKGROUND")





if(justify) then
TextFrameFont:SetJustifyH(justify)
end


TextFrameFont:SetAllPoints()
TextFrameFont:SetText(Text)
TextFrameFont:SetFont("Fonts\\FRIZQT__.TTF", 11) -- these are the two lines im TRYING to use.
TextFrameFont:SetSize(24, 78)
--TextFrameFont:SetTextHeight(450)
--TextFrameFont:SetWidth(50)
TextFrame:SetPoint(RelativeTo,Parent,RelativePoint,TextX,TextY)
TextFrame:SetMovable(false)
TextFrame:SetFrameLevel(FrameLevel)




end
  Reply With Quote
07-13-10, 03:10 AM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,961
Okay, this line is possibly causing the problem. There is possibly something missing here but I can't remember exactly what else you need at the moment.

TextFrameFont:SetFont("Fonts\\FRIZQT__.TTF", 11)


Try changing these specific lines ( keep the other ones in for now ).

-- Create a Font String based on GameFontNormal
local TextFrameFont = TextFrame:CreateFontString(nil, "BACKGROUND",GameFontNormal)

--Now this is where we see what the rest of the font is holding and store it
local Path, Size, Flags = TextFrameFont :GetFont()

-- Your code to set the text contents
TextFrameFont:SetText(Text)

-- Now we want to set the font with our chosen settings but keep what it is already using
TextFrameFont:SetFont("Fonts\\FRIZQT__.TTF", 11,Flags)


Try that out and see if that works.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
07-13-10, 03:29 AM   #5
wellbeing
A Cliff Giant
Join Date: Oct 2009
Posts: 71
Originally Posted by Xrystal View Post
Okay, this line is possibly causing the problem. There is possibly something missing here but I can't remember exactly what else you need at the moment.

TextFrameFont:SetFont("Fonts\\FRIZQT__.TTF", 11)


Try changing these specific lines ( keep the other ones in for now ).

-- Create a Font String based on GameFontNormal
local TextFrameFont = TextFrame:CreateFontString(nil, "BACKGROUND",GameFontNormal)

--Now this is where we see what the rest of the font is holding and store it
local Path, Size, Flags = TextFrameFont :GetFont()

-- Your code to set the text contents
TextFrameFont:SetText(Text)

-- Now we want to set the font with our chosen settings but keep what it is already using
TextFrameFont:SetFont("Fonts\\FRIZQT__.TTF", 11,Flags)


Try that out and see if that works.


TextFrameFont:SetFont(Path, Size,Flags)

did you mean to have that as the last line or am i missing the point?
  Reply With Quote
07-13-10, 03:36 AM   #6
wellbeing
A Cliff Giant
Join Date: Oct 2009
Posts: 71
Originally Posted by wellbeing View Post
TextFrameFont:SetFont(Path, Size,Flags)

did you mean to have that as the last line or am i missing the point?

function CreateText(name,text,x,y,parent,w,h,relativeto,relativepoint,justify)

Parent = parent


local Name = name
local TextX = x
local TextY = y
local RelativeTo = relativeto
local RelativePoint = relativepoint
local TextWidth = w
local TextHeight = h
local Text = text

local FrameLevel = 4

local TextFrame = CreateFrame("FRAME",Name,Parent)
TextFrame:ClearAllPoints()
TextFrame:SetWidth(TextWidth)
TextFrame:SetHeight(TextHeight)

TextFrameFont = TextFrame:CreateFontString(nil, "BACKGROUND",GameFontNormal)
local Path, Size, Flags = TextFrameFont:GetFont()
TextFrameFont:SetText(Text)
TextFrameFont:SetFont(Path, Size,Flags)


if(justify) then
TextFrameFont:SetJustifyH(justify)
end

end

this isnt working. hmmm.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » fontsting:SetFont


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