Jump to content

Unable to change Font size


Thirsty Panther
 Share

Recommended Posts

I'm unable to change the size of the Font in Leadwerks.

 

I originally had the problem in my own project. To remove all of my own interference I made a map with code from the Documentation Font:GetFont.

 

To change the font size I alter this line:

 

local font = Font:Load("Fonts/Arial.ttf",36)

 

Changing the "36" to 12,18,24,48,60 or 72 makes no change to the size of the font.

 

Am I doing something wrong or is it a bug?

font Test.zip

Link to comment
Share on other sites

are you setting the context's font after you load the font size you want?

local font = Font:Load("Fonts/Arial.ttf",36)

self.context:SetFont(font)

 

Edit- On a side note, I am not sure why you uploaded a *.map file? It would be more helpful to see your script.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Thanks for the quick reply.

As stated in my OP I used the example script from the Font: Get Font documentation.

 

function App:Start()

 

self.window = Window:Create()

self.context = Context:Create(self.window)

local font = Font:Load("Fonts/arial.ttf",36)

self.context:SetFont(font)

font:Release()

return true

end

 

function App:Loop()

 

if (self.window:Closed() or self.window:KeyDown(Key.Escape)) then return false end

 

self.context:SetColor(0,0,0)

self.context:Clear()

 

--Draw some centered text on the screen

local text = "Leadwerks"

 

local font = self.context:GetFont()

 

local x = self.window:GetWidth()/2

local y = self.window:GetHeight()/2

 

x = x - font:GetTextWidth(text)/2

y = y - font:GetHeight()/2

 

self.context:SetBlendMode(Blend.Alpha)

self.context:SetColor(1,1,1)

self.context:DrawText(text,x,y)

self.context:SetBlendMode(Blend.Solid)

 

self.context:Sync()

return true

end

 

Yes the self.context:SetFont (font) is there. My problem is changing the 36 to 60 or 72 makes no difference to the text size.

Does the script work for you?

 

Re the map file, last time I posted a question and included a script I was asked for a map blink.png

 

Cheers

Link to comment
Share on other sites

yep, the script works just fine for me. Do you get any errors/warnings? Have you tried another font?

 

As for what you need to provide to reproduce the problem - if its model/csg/physics related then typically the model or a map will be needed; if it is something driven by code, then provide a simple example script.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...