Use codepoints for charmap

This commit is contained in:
Mikita Wiśniewski 2025-01-31 09:17:43 +07:00
parent 77b39e25c9
commit ee3e358d8f
5 changed files with 5 additions and 11 deletions

View file

@ -64,4 +64,4 @@ The format expects 1 row with 3 columns per character:
All character textures must be 12 pixels high and 5 or 6 pixels wide (5
is preferred).
Can be accessed by other mods via `mcl_signs.charmap["?"]`.
Can be accessed by other mods via `mcl_signs.charmap[<utf-8 codepoint>]`.

View file

@ -4,7 +4,7 @@
* Adapted for MineClone2 by Wuzzy
* Later massively extended by Michieal
* Mostly rewritten for Mineclonia and simplified by cora
* Re-adapted for VoxeLibre and improved upon by rudzik8
* Reworked for VoxeLibre with UTF-8 support by rudzik8
## Characters

View file

@ -148,8 +148,7 @@ local function generate_line(codepoints, ypos)
for _, code in ipairs(codepoints) do
local file = "_rc"
local char = utf8.char(code)
if charmap[char] then file = charmap[char] end
if charmap[code] then file = charmap[code] end
width = width + printed_char_width
table.insert(parsed, file)

View file

@ -303,12 +303,6 @@ _ _un 3
А _a_ 7
а _a 5
А̀ _a_grave_ 7
а̀ _a_grave 5
А̂ _a_circumflex_ 7
а̂ _a_circumflex 5
А̄ _a_macron_ 7
а̄ _a_macron 5
Ӑ _a_breve_ 7
ӑ _a_breve 5
Ӓ _ae_ 7

Can't render this file because it contains an unexpected character in line 509 and column 20.

View file

@ -14,7 +14,8 @@ for line in io.lines(modpath .. DIR_DELIM .. "characters.tsv") do
local split = line:split("\t")
if #split == 3 then
local char, img, _ = split[1], split[2], split[3] -- 3rd is ignored, reserved for width
charmap[char] = img
local code = utf8.codepoint(char)
charmap[code] = img
end
end
mcl_signs.charmap = charmap