2023-03-17 03:39:41 +01:00
|
|
|
#!/usr/bin/env lua5.1
|
|
|
|
-- -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
dofile("init.lua")
|
|
|
|
dofile("tga_encoder.lua")
|
2023-03-18 22:33:18 +01:00
|
|
|
|
|
|
|
font_1 = unicode_text.hexfont()
|
|
|
|
font_1:load_glyphs(
|
|
|
|
io.lines("/usr/share/unifont/unifont.hex")
|
|
|
|
)
|
|
|
|
local text = "ABC 123 😀\
|
2023-03-17 03:39:41 +01:00
|
|
|
\
|
2023-03-18 22:33:18 +01:00
|
|
|
wð♥𐍈"
|
|
|
|
local pixels = font_1:render_text(text)
|
2023-03-17 03:39:41 +01:00
|
|
|
local image = tga_encoder.image(pixels)
|
|
|
|
image:save("test.tga")
|
|
|
|
|
2023-03-18 22:33:18 +01:00
|
|
|
font_2 = unicode_text.hexfont(
|
|
|
|
{
|
|
|
|
background_color = { 0x33, 0x66, 0x99 },
|
|
|
|
foreground_color = { 0xDD, 0x00, 0x00 },
|
|
|
|
}
|
|
|
|
)
|
|
|
|
font_2:load_glyphs(
|
|
|
|
io.lines("/usr/share/unifont/unifont.hex")
|
|
|
|
)
|
|
|
|
font_2:load_glyphs(
|
|
|
|
io.lines("unifont_upper.hex")
|
|
|
|
)
|
2023-03-17 03:39:41 +01:00
|
|
|
local file = io.open("UTF-8-demo.txt")
|
|
|
|
tga_encoder.image(
|
2023-03-18 22:33:18 +01:00
|
|
|
font_2:render_text(
|
2023-03-17 03:39:41 +01:00
|
|
|
file:read("*all")
|
|
|
|
)
|
|
|
|
):save("UTF-8-demo.tga")
|
|
|
|
file:close()
|