mirror of
https://github.com/pyrollo/display_modpack.git
synced 2025-01-10 09:00:17 +01:00
Add GNU Unifont
This commit is contained in:
parent
f5bd6d1046
commit
79aac655b3
@ -229,7 +229,7 @@ function Font:render(text, texturew, textureh, style)
|
||||
return ""
|
||||
end
|
||||
|
||||
local x, y, codepoint
|
||||
local x, y, codepoint, glyph
|
||||
local texture = ""
|
||||
local textheight = self:get_height(#lines)
|
||||
|
||||
@ -258,8 +258,13 @@ function Font:render(text, texturew, textureh, style)
|
||||
|
||||
-- Add image only if it is visible (at least partly)
|
||||
if x + self.widths[codepoint] >= 0 and x <= texturew then
|
||||
if self.get_glyph == nil then
|
||||
glyph = string.format("font_%s_%04x.png", self.name, codepoint)
|
||||
else
|
||||
glyph = self.get_glyph(codepoint):gsub("[\\^:]", "\\%0")
|
||||
end
|
||||
texture = texture..
|
||||
string.format(":%d,%d=font_%s_%04x.png", x, y, self.name, codepoint)
|
||||
string.format(":%d,%d=%s", x, y, glyph)
|
||||
end
|
||||
x = x + self.widths[codepoint]
|
||||
end
|
||||
|
1
unifont/depends.txt
Normal file
1
unifont/depends.txt
Normal file
@ -0,0 +1 @@
|
||||
font_api
|
28
unifont/init.lua
Normal file
28
unifont/init.lua
Normal file
@ -0,0 +1,28 @@
|
||||
local widths = {}
|
||||
for i = 0,65535 do
|
||||
widths[i] = 16
|
||||
end
|
||||
for i = 32,126 do
|
||||
widths[i] = 8
|
||||
end
|
||||
|
||||
local function get_glyph(codepoint)
|
||||
if codepoint == 0 or codepoint > 0xffff 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,
|
||||
linespacing = -1,
|
||||
height = 16,
|
||||
widths = widths,
|
||||
get_glyph = get_glyph,
|
||||
}
|
||||
)
|
3
unifont/mod.conf
Normal file
3
unifont/mod.conf
Normal file
@ -0,0 +1,3 @@
|
||||
name=unifont
|
||||
description=GNU Unifont (full Unicode Plane 0 coverage) for font_api
|
||||
depends=font_api
|
BIN
unifont/textures/font_unifont_sheet.png
Normal file
BIN
unifont/textures/font_unifont_sheet.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 955 KiB |
Loading…
Reference in New Issue
Block a user