Filtering Fonts

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Triplenox
Prole
Posts: 26
Joined: Fri Jul 13, 2012 5:48 pm

Filtering Fonts

Post by Triplenox »

Hey, I'd like to know how to filter fonts, not images fonts, .ttf fonts etc my text looks like this when I scale my camera, I do not know how to filter the font so i'd love to know how :)

Image

(Also, I have looked on the Forums etc, I may not have looked hard, but I really do not want to look any further as I am busy as it is, so I'd just like a straight on answer, not a re-direct to another post that won't help me like I usually get -_-)

-Triplenox
User avatar
slime
Solid Snayke
Posts: 3134
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Filtering Fonts

Post by slime »

You can't in 0.8.0. Font:setFilter will likely be added to 0.8.1.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Filtering Fonts

Post by Jasoco »

Yes you can if you filter the image first.

Code: Select all

local fontImage = love.graphics.newImage("fontfile.png")
fontImage:setFilter("nearest", "nearest")
fontName = love.graphics.newImageFont(fontImage, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 :-!.,\"?<>_()")
User avatar
slime
Solid Snayke
Posts: 3134
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Filtering Fonts

Post by slime »

Jasoco wrote:Yes you can if you filter the image first.
Triplenox wrote:Hey, I'd like to know how to filter fonts, not images fonts, .ttf fonts
:P
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Filtering Fonts

Post by Jasoco »

My mistake. Your image above looks like a pixellated image font. In which case you should just use a pixellated image instead of an actual font file. It would probably be smaller in size anyway.

To answer it now, you can't apply a filter to normal fonts yet, but can fake it if you're willing to use canvases. Though you then risk the wrath of all the people here who can't use them. Basically you'd print to the canvas and then draw the canvas with a filter applied to it instead.

But then you're going overboard. Just use an image font as it seems you're looking for that kind of result anyway.

Otherwise if you're bent on using a normal font, just create a larger version of the font to use when scaled up instead of trying to use the scale features. (You'll need to move the text printing parts of the code OUTSIDE the camera drawing stuff in this case.)
Post Reply

Who is online

Users browsing this forum: No registered users and 41 guests