Page 1 of 1

love.graphics.print makes pixelated text blurry.

Posted: Sun Feb 16, 2025 11:01 am
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)

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

Posted: Sun Feb 16, 2025 11:11 am
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.

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

Posted: Sun Feb 16, 2025 3:25 pm
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: )

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

Posted: Sun Feb 16, 2025 4:43 pm
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!"

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

Posted: Sun Feb 16, 2025 6:51 pm
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

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

Posted: Mon Feb 17, 2025 6:48 am
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.