Page 1 of 1
How do I change the font color?
Posted: Wed Aug 15, 2012 3:29 pm
by Echo
How do I change the font color in Love2d/Lua? I already checked the
wiki and
Lua tutorials.
What I need is to have bold sharp ( no antialiasing ) white and black text. The white text will be over a grey background and the black will be over a white background in the same scene which means that I might need two text styles showing at the same time. Is this possible in Love2d?
Look at the font in the screenshot below.
This is what I am trying to do but when I use Bradley Handwriting as the font type it is aliased and sort of grayish white which is extremely hard to read over a grey or white background.
I
really want to use Bradly Handwriting (BRADHITC) as the font type like in the mock-up screenshot as it completes the notebook theme I am going for.
Re: How do I change the font color?
Posted: Wed Aug 15, 2012 3:41 pm
by Robin
Echo wrote:How do I change the font color in Love2d/Lua?
love.graphics.setColor.
I don't understand the rest of your question.
Re: How do I change the font color?
Posted: Wed Aug 15, 2012 6:47 pm
by josefnpat
Echo wrote:I really want to use Bradly Handwriting (BRADHITC) as the font type like in the mock-up screenshot as it completes the notebook theme I am going for.
Download the font, put it in your project, and then use
https://love2d.org/wiki/love.graphics.setFont
Re: How do I change the font color?
Posted: Wed Aug 15, 2012 7:43 pm
by Echo
I used love.graphics.setFont already but the font is aliased, like it has blurry edges, and so I was wondering if I could make the font bold and also if possible remove the antialiasing ( antialiasing is a way the computer makes small images like sprites and font appear smooth by adding shading to the edges ).
and in addition to that is there a way to use two different font styles at the same time, like if I want to have a heading in Ariel Black and then the adjacent text in Times New Roman. or if I want to have a specific word colored in red how would I go about this?
Re: How do I change the font color?
Posted: Wed Aug 15, 2012 7:53 pm
by Roland_Yonaba
Echo wrote:
and in addition to that is there a way to use two different font styles at the same time, like if I want to have a heading in Ariel Black and then the adjacent text in Times New Roman. or if I want to have a specific word colored in red how would I go about this?
Fairly simple. Create two new font objects using
love.graphics.newFont.
Then in the drawing part of your code, switch to the font you need using
love.graphics.setFont
Code: Select all
function love.load()
fontA = love.graphics.newFont(font_A_path)
fontB = love.graphics.newFont(font_B_path)
end
function love.draw()
love.graphics.setFont(fontA)
-- draw some stuff
love.graphics.setFont(fontB)
-- draw some stuff
...
Re: How do I change the font color?
Posted: Wed Aug 15, 2012 8:05 pm
by Santos
For non-anti-aliased fonts, you might want to try using a program to convert fonts to images like
Bitmap Font Generator and using it in LÖVE as an ImageFont
Re: How do I change the font color?
Posted: Wed Aug 15, 2012 8:43 pm
by Robin
There is also
RichText, which takes care of fonts, colors, and you can even embed images in your text.
Re: How do I change the font color?
Posted: Wed Oct 08, 2014 2:31 pm
by Sinono3
Robin wrote:There is also [wiki]RichText[/wiki], which takes care of fonts, colors, and you can even embed images in your text.
In RichText, how do I align the text?
Re: How do I change the font color?
Posted: Wed Oct 08, 2014 3:47 pm
by Robin
IIRC, it only supports left-alignment.