How do I change the font color?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Echo
Prole
Posts: 46
Joined: Fri Jul 13, 2012 4:50 pm
Location: Lucid Moon

How do I change the font color?

Post 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.
Image

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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: How do I change the font color?

Post 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. :(
Help us help you: attach a .love.
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: How do I change the font color?

Post 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
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
User avatar
Echo
Prole
Posts: 46
Joined: Fri Jul 13, 2012 4:50 pm
Location: Lucid Moon

Re: How do I change the font color?

Post 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?
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: How do I change the font color?

Post 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
   ...
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Re: How do I change the font color?

Post 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
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: How do I change the font color?

Post by Robin »

There is also RichText, which takes care of fonts, colors, and you can even embed images in your text.
Help us help you: attach a .love.
User avatar
Sinono3
Prole
Posts: 7
Joined: Mon Aug 18, 2014 5:52 pm

Re: How do I change the font color?

Post 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?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: How do I change the font color?

Post by Robin »

IIRC, it only supports left-alignment.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests