proper font scaling
This commit is contained in:
parent
d150205535
commit
756bbfdc99
5 changed files with 26 additions and 17 deletions
BIN
assets/fonts/Inter-Italic.otf
Normal file
BIN
assets/fonts/Inter-Italic.otf
Normal file
Binary file not shown.
14
main.lua
14
main.lua
|
@ -4,7 +4,19 @@ for k, v in pairs(_G) do
|
|||
end
|
||||
|
||||
love.graphics.setDefaultFilter('nearest', 'nearest')
|
||||
interfaceFont = love.graphics.newFont('assets/fonts/Inter-Regular.otf', 20)
|
||||
|
||||
local fontSize = 20
|
||||
interfaceFont = love.graphics.newFont('assets/fonts/Inter-Regular.otf', fontSize)
|
||||
|
||||
local fontCache = {}
|
||||
|
||||
function getFont(size, italic)
|
||||
if fontCache[size] and fontCache[size][italic] then return fontCache[size][italic] end
|
||||
|
||||
fontCache[size] = fontCache[size] or {}
|
||||
fontCache[size][italic] = love.graphics.newFont('assets/fonts/Inter-' .. (italic and 'Italic' or 'Regular') .. '.otf', math.floor(fontSize * size))
|
||||
return fontCache[size][italic]
|
||||
end
|
||||
|
||||
ease = require 'src.ease'
|
||||
|
||||
|
|
|
@ -281,13 +281,10 @@ function self.render()
|
|||
str = str .. ' ' .. string.sub(p.name, 1, 1)
|
||||
end
|
||||
|
||||
love.graphics.push()
|
||||
love.graphics.translate(x + w, y + lineWidth/2)
|
||||
love.graphics.shear(-0.2, 0)
|
||||
love.graphics.scale(0.8, 0.8)
|
||||
love.graphics.setFont(getFont(0.8, true))
|
||||
love.graphics.setColor(0.8, 0.8, 1, 0.8 * a)
|
||||
love.graphics.printf(str, -w, -lineWidth/2, w - 2, 'right')
|
||||
love.graphics.pop()
|
||||
love.graphics.printf(str, x, y, w - 2, 'right')
|
||||
love.graphics.setFont(interfaceFont)
|
||||
end
|
||||
|
||||
::continue::
|
||||
|
|
|
@ -77,7 +77,7 @@ function self.createSliders()
|
|||
for i,v in ipairs(param1) do
|
||||
insertSlider(s, {
|
||||
x = outerpadding + dropdownWidth + padding,
|
||||
y = outerpadding + (fontHeight * 2.5 + padding) * i,
|
||||
y = outerpadding + (fontHeight * 3 + padding) * i - padding,
|
||||
width = dropdownWidth,
|
||||
min = v.min,
|
||||
max = v.max,
|
||||
|
@ -92,7 +92,7 @@ function self.createSliders()
|
|||
for i,v in ipairs(param2) do
|
||||
insertSlider(s, {
|
||||
x = outerpadding + dropdownWidth + padding + dropdownWidth + padding,
|
||||
y = outerpadding + (fontHeight * 2.5 + padding) * i,
|
||||
y = outerpadding + (fontHeight * 3 + padding) * i - padding,
|
||||
width = dropdownWidth,
|
||||
min = v.min,
|
||||
max = v.max,
|
||||
|
@ -172,11 +172,9 @@ function self.render()
|
|||
|
||||
if v.topdisplayname then
|
||||
love.graphics.setColor(0.4, 0.4, 0.55, 1)
|
||||
love.graphics.push()
|
||||
love.graphics.translate(v.x, v.y - ssize * 1.4)
|
||||
love.graphics.scale(0.75, 0.75)
|
||||
love.graphics.printf(v.topdisplayname, -ssize * 6, 0, ssize * 12, 'center')
|
||||
love.graphics.pop()
|
||||
love.graphics.setFont(getFont(0.75, true))
|
||||
love.graphics.printf(v.topdisplayname, v.x - ssize * 6, v.y - ssize * 1.45, ssize * 12, 'center')
|
||||
love.graphics.setFont(interfaceFont)
|
||||
end
|
||||
|
||||
if dragging then
|
||||
|
|
|
@ -44,10 +44,10 @@ function self.render()
|
|||
if tooltipwidth > 1 then
|
||||
local a = math.min((tooltipwidth - 1) / 6, 1)
|
||||
|
||||
local x, y, w, h = mx + 8, my + 8, (tooltipwidth + 4 + margin), (fontHeight + margin)
|
||||
local x, y, w, h = mx + 8, my + 8, (tooltipwidth + 4 + margin) * 0.8, (fontHeight + margin) * 0.8
|
||||
|
||||
local easiness = 3 -- hehe. magic numbers
|
||||
local scale = 0.8
|
||||
local scale = 1
|
||||
local sx, sy = ((w - softlimit(mx - tooltipx, w/easiness)/easiness) / w) * scale, ((h - softlimit(my - tooltipy, h/easiness)/easiness) / h) * scale
|
||||
|
||||
love.graphics.push()
|
||||
|
@ -61,7 +61,9 @@ function self.render()
|
|||
love.graphics.setScissor(0, 0, math.max(mx + (tooltipwidth + 2 + margin/2 + 16) * sx, 0), love.graphics.getHeight())
|
||||
|
||||
love.graphics.setColor(1, 1, 1, a)
|
||||
love.graphics.print(tooltiptext, 2 + margin/2, 2 + margin/2)
|
||||
love.graphics.setFont(getFont(0.8, false))
|
||||
love.graphics.print(tooltiptext, 2, 2)
|
||||
love.graphics.setFont(interfaceFont)
|
||||
|
||||
love.graphics.setScissor()
|
||||
|
||||
|
|
Loading…
Reference in a new issue