unicode_text/test.lua

37 lines
748 B
Lua
Executable File

#!/usr/bin/env lua5.1
-- -*- coding: utf-8 -*-
dofile("init.lua")
dofile("tga_encoder.lua")
font_1 = unicode_text.hexfont()
font_1:load_glyphs(
io.lines("/usr/share/unifont/unifont.hex")
)
local text = "ABC 123 😀\
\
wð♥𐍈"
local pixels = font_1:render_text(text)
local image = tga_encoder.image(pixels)
image:save("test.tga")
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")
)
local file = io.open("UTF-8-demo.txt")
tga_encoder.image(
font_2:render_text(
file:read("*all")
)
):save("UTF-8-demo.tga")
file:close()