When you say change the font density do you mean increase/decrease the space between each character in a string of text?
There are no methods of a font object for handling that from what I can tell, I think the only solution is to use a different font with the density that you desire.
I'll assume this topic is about "letter spacing".
You see, most fonts are designed to look well at a predefined spacing.
Some fonts contain kerning info that adjusts the positions of specific pairs of letters.
All you need to do is start FontForge and open up the font that you want to massacre... I mean edit!
...then press Ctrl-A to select all glyphs and choose Metrics->Set Width.
But yea, as you may have guessed, what you end up with will look awful.
You could cut the string and put each letter into an array. Then iterate the draw over each letter and add a custom spacing.
Could be sufficient for a spaced out title line. Don't know how much perf-loss it actually is over the build in version so a löve based ebook reader could be damn slow if not optimized well.
ivan wrote: ↑Thu Nov 30, 2017 6:16 am
I'll assume this topic is about "letter spacing".
You see, most fonts are designed to look well at a predefined spacing.
Some fonts contain kerning info that adjusts the positions of specific pairs of letters.
All you need to do is start FontForge and open up the font that you want to massacre... I mean edit!
...then press Ctrl-A to select all glyphs and choose Metrics->Set Width.
But yea, as you may have guessed, what you end up with will look awful.
This topic is NOT about "letter spacing"! How to fix pixelated font effect when the font is .ttf?
fixpixel.png (131.17 KiB) Viewed 5927 times
fonts.png (27.09 KiB) Viewed 5924 times
You didn't help me. I'll try super bad solution: I'll replace original love.graphics text functions.
Hey TC, we all tried to help you but your question was not stated clearly.
The problem is with the way you are loading the font:
Font=love.graphics.newFont("somefont.ttf",24)
tells Love2d that your font should be rasterized so that it's exactly 24 pixels high.
The easiest solution is to load multiple font sizes:
SmallFont=love.graphics.newFont("somefont.ttf",24)
LargeFont=love.graphics.newFont("somefont.ttf",48)
Or load just the largest font and then scale it down when drawing.
Never scale up your fonts UP or you will get pixelation.
ivan wrote: ↑Thu Nov 30, 2017 12:31 pm
Hey TC, we all tried to help you but your question was not stated clearly.
The problem is with the way you are loading the font:
Font=love.graphics.newFont("somefont.ttf",24)
tells Love2d that your font should be rasterized so that it's exactly 24 pixels high.
The easiest solution is to load multiple font sizes:
SmallFont=love.graphics.newFont("somefont.ttf",24)
LargeFont=love.graphics.newFont("somefont.ttf",48)
Or load just the largest font and then scale it down when drawing.
Never scale up your fonts UP or you will get pixelation.
Function love.graphics.newFont by default makes font rasterized with 12 pixel high.
TC1061 wrote: ↑Thu Nov 30, 2017 2:17 pm
Function love.graphics.newFont by default makes font rasterized with 12 pixel high.
You can just put the size you want, as ivan has shown you.
Oh. Yes. This variant is helped me, and I replaced text functions (because my game's code is very big and I'll waste a lot of time in search of them), and it really works without any bugs:
do
core=core or {}
fontsizes={}
local crf=love.graphics.newFont
function love.graphics.newFont(f,s)
local size=s or f
local font=crf(f,s)
fontsizes[font]=size
return font
end
local font=love.graphics.newFont(12)
local text=love.graphics.newText(font)
function love.graphics.setFont(font2)
font=font2
text:setFont(font)
end
local size=12
-- local fsize=12
local function getScale()
local scale=size/fontsizes[font]
return scale
end
function core.setTextSize(size2)
size=size2 end
function love.graphics.print(texts,x,y,r,sx,sy,...)
local scale=getScale()
text:set(texts)
local sx=sx or 1
local sy=sy or sx
love.graphics.draw(text,x,y,r,sx*scale,sy*scale,...)
end
function love.graphics.printf(texts,x,y,limit,align,r,sx,sy,...)
local scale=getScale()
local sx=sx or 1
local sy=sy or sx
text:setf(texts,(limit or love.graphics.getWidth())/scale,align or "left")
love.graphics.draw(text,x,y,0,sx*scale,sy*scale,...)
end
end