1
0
mirror of https://github.com/pyrollo/display_modpack.git synced 2024-11-13 05:40:30 +01:00
display_modpack/unifont/init.lua
2021-12-04 14:44:04 +08:00

36 lines
733 B
Lua

local widths = {}
for i = 0,0xd7ff do
widths[i] = 16
end
for i = 0xe000,0xfffd do
widths[i] = 16
end
local halfwidth = dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/halfwidth.lua")
for i, codepoint in ipairs(halfwidth) do
widths[codepoint] = 8
end
local function get_glyph(codepoint)
if codepoint == 0 or codepoint > 0xffff or widths[codepoint] == nil then
codepoint = 0xfffd
end
local x = codepoint % 256
local y = math.floor(codepoint / 256)
return string.format("font_unifont_sheet.png^[sheet:256x256:%d,%d", x, y)
end
font_api.register_font(
"unifont",
{
default = true,
margintop = 2,
marginbottom = 2,
linespacing = -3,
height = 16,
widths = widths,
get_glyph = get_glyph,
}
)