Jump to content
  • 0
psychoanima

On-screen text messages

Question

9 answers to this question

Recommended Posts

  • 0

You can change the font and size by calling the correct methods. For example:

myfont = Font:Load("Fonts/arial.ttf",14)
context:SetFont(myfont)

 

Share this post


Link to post
  • 0

Since there aren't specific API calls for that I would assume it takes over from the active font that is set.

*post above beat me to it.

Edited by AggrorJorn

Share this post


Link to post
  • 0
6 hours ago, brndx said:

You can change the font and size by calling the correct methods. For example:


myfont = Font:Load("Fonts/arial.ttf",14)
context:SetFont(myfont)

 

It works, but it scales/changing all fonts in the game, including menus.

Share this post


Link to post
  • 0
1 hour ago, psychoanima said:

It works, but it scales/changing all fonts in the game, including menus.

Then save the old font:
 

oldfont = context:GetFont()
context:SetFont(myfont)
[write...]
context:SetFont(oldfont)

 

Share this post


Link to post
  • 0
1 hour ago, Ma-Shell said:

Then save the old font:
 


oldfont = context:GetFont()
context:SetFont(myfont)
[write...]
context:SetFont(oldfont)

 

Yes, but that still doesn't let me to use two different font size at the same time?

Share this post


Link to post
  • 1

You have to manage your fonts just like any asset.

window = Window:Create("font example",0,0,400,300)
context = Context:Create(window)
world = World:Create()
camera = Camera:Create()
light = DirectionalLight:Create()
light:SetRotation(45,45,0)
box = Model:Box()
box:SetPosition(0,0,3)
box:SetColor(1,0,0,1)
	
lilfont = context:GetFont()
medfont = Font:Load("Fonts/arial.ttf", 24, Font.Smooth)
bigfont = Font:Load("Fonts/arial.ttf", 48, Font.Smooth)

while window:KeyDown(Key.Escape)==false do
	if window:Closed() then break end

	box:Turn(Time:GetSpeed()*0.5,Time:GetSpeed()*0.5,0)
	
	Time:Update()
	world:Update()
	world:Render()
	context:SetBlendMode(Blend.Alpha)
	context:DrawText(string.format("FPS: %.2f",Time:UPS()),0,10)
	context:SetFont(bigfont)
	context:DrawText("BIG FONT",0,30)
	context:SetFont(medfont)
	context:DrawText("MEDIUM FONT",0,80)
	context:SetFont(lilfont)
	context:SetBlendMode(Blend.Solid)
	context:Sync(true)
end

 

font.jpg

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   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.

×
×
  • Create New...