love.graphics.print makes pixelated text blurry.

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
417_TheFog
Prole
Posts: 10
Joined: Sun Dec 29, 2024 1:37 pm

love.graphics.print makes pixelated text blurry.

Post by 417_TheFog »

my font (created in bitfontmaker2) is pixilated, but love2d blurrs it. how to stop it???
(`setDefaultFilter("nearest", "nearest")` or `t.window.highfpi = false` are useless)

Code: Select all

th = 1
function love.load()
  monospaced = love.graphics.newFont("Monospaced.ttf", 11)
  love.graphics.setFont(monospaced)
  love.graphics.setDefaultFilter("nearest", "nearest")
end
function love.draw()
  love.graphics.print("...###...#...#.#...###\n...#.#...#...#.#...#.#\n...##....#...#.#...##.\n...#.#...#...#.#...#.#\n...###...#...###...#.#\n", 0, 0, 0, th, th)
end
function love.wheelmoved(x, y)
  th = th + y * 0.1
end
EDIT: I found a solution -

Code: Select all

monospaced = love.graphics.newFont("Monospaced.ttf", 11, "mono", 11)
Attachments
game.love
already zipped
(4.13 KiB) Downloaded 25 times
Monospaced.lua
rename this into *.ttf (invalid file format :sob:)
(11.88 KiB) Downloaded 35 times
Last edited by 417_TheFog on Sun Feb 16, 2025 3:37 pm, edited 1 time in total.
User avatar
dusoft
Party member
Posts: 765
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: love.graphics.print makes pixelated text blurry.

Post by dusoft »

Only draw to integer pixel positions, i.e. round your x,y coords.

You mean your scaling... You need to create your font in different sizes and not use scaling for that.
User avatar
417_TheFog
Prole
Posts: 10
Joined: Sun Dec 29, 2024 1:37 pm

Re: love.graphics.print makes pixelated text blurry.

Post by 417_TheFog »

dusoft wrote: Sun Feb 16, 2025 11:11 am create your font in different sizes
Thanks but...
I think you should test before posting with task manager open. It eats up a HUGE amount of memory.

but changing the initial font size is definitely one of the possible solutions, if you initially set a large resolution and then change the size. but the question is still open.

EDIT: (closed :awesome: )
User avatar
dusoft
Party member
Posts: 765
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: love.graphics.print makes pixelated text blurry.

Post by dusoft »

Not sure what you mean, also docs clearly state: "This function can be slow if it is called repeatedly, such as from love.update or love.draw. If you need to use a specific resource often, create it once and store it somewhere it can be reused!"
User avatar
darkfrei
Party member
Posts: 1250
Joined: Sat Feb 08, 2020 11:09 pm

Re: love.graphics.print makes pixelated text blurry.

Post by darkfrei »

417_TheFog wrote: Sun Feb 16, 2025 11:01 am my font (created in bitfontmaker2) is pixilated, but love2d blurrs it. how to stop it???
https://love2d.org/wiki/Font:setFilter

Code: Select all

monospaced = love.graphics.newFont("Monospaced.ttf", 11)
monospaced:setFilter( 'nearest', 'nearest' )

Code: Select all


function love.draw()
  love.graphics.scale (5)
  love.graphics.print("...###...#...#.#...###\n...#.#...#...#.#...#.#\n...##....#...#.#...##.\n...#.#...#...#.#...#.#\n...###...#...###...#.#\n")
end
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
zorg
Party member
Posts: 3477
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: love.graphics.print makes pixelated text blurry.

Post by zorg »

A bit more explanation, setDefaultFilter should have been called *before* you create a font, and it would have worked as well... if that was the only issue.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests