Render `&#u...;` chars using Unifont
This commit is contained in:
parent
2ba26cc9cc
commit
850bfa74a7
39
api.lua
39
api.lua
|
@ -533,27 +533,7 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
||||||
local word_l = #word
|
local word_l = #word
|
||||||
local i = 1
|
local i = 1
|
||||||
while i <= word_l do
|
while i <= word_l do
|
||||||
local wide_c
|
local wide_type, wide_c = string.match(word:sub(i), "^&#([xu])(%x+);")
|
||||||
if "&#x" == word:sub(i, i + 2) then
|
|
||||||
local j = i + 3
|
|
||||||
local collected = ""
|
|
||||||
while j <= word_l do
|
|
||||||
local c = word:sub(j, j)
|
|
||||||
if c == ";" then
|
|
||||||
wide_c = collected
|
|
||||||
break
|
|
||||||
elseif c < "0" then
|
|
||||||
break
|
|
||||||
elseif "f" < c then
|
|
||||||
break
|
|
||||||
elseif ("9" < c) and (c < "a") then
|
|
||||||
break
|
|
||||||
else
|
|
||||||
collected = collected .. c
|
|
||||||
j = j + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local c = word:sub(i, i)
|
local c = word:sub(i, i)
|
||||||
local c2 = word:sub(i+1, i+1)
|
local c2 = word:sub(i+1, i+1)
|
||||||
if c == "#" and c2 ~= "#" then
|
if c == "#" and c2 ~= "#" then
|
||||||
|
@ -563,7 +543,10 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
||||||
cur_color = cc
|
cur_color = cc
|
||||||
end
|
end
|
||||||
elseif wide_c then
|
elseif wide_c then
|
||||||
local w = cwidth_tab_wide[wide_c]
|
local w = font_size
|
||||||
|
if wide_type == "x" then
|
||||||
|
w = cwidth_tab_wide[wide_c]
|
||||||
|
end
|
||||||
if w then
|
if w then
|
||||||
width = width + w + 1
|
width = width + w + 1
|
||||||
if width >= (line_width - cwidth_tab[" "]) then
|
if width >= (line_width - cwidth_tab[" "]) then
|
||||||
|
@ -572,9 +555,19 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
||||||
maxw = math_max(width, maxw)
|
maxw = math_max(width, maxw)
|
||||||
end
|
end
|
||||||
if #chars < MAX_INPUT_CHARS then
|
if #chars < MAX_INPUT_CHARS then
|
||||||
|
local tex
|
||||||
|
if wide_type == "x" then
|
||||||
|
tex = char_tex_wide(font_name, wide_c)
|
||||||
|
else
|
||||||
|
local code = tonumber(wide_c, 16)
|
||||||
|
local x = code % 256
|
||||||
|
local y = math.floor(code / 256)
|
||||||
|
tex = string.format(
|
||||||
|
"signs_lib_unifont.png\\^[sheet\\:256x256\\:%d,%d", x, y)
|
||||||
|
end
|
||||||
table.insert(chars, {
|
table.insert(chars, {
|
||||||
off = ch_offs,
|
off = ch_offs,
|
||||||
tex = char_tex_wide(font_name, wide_c),
|
tex = tex,
|
||||||
col = ("%X"):format(cur_color),
|
col = ("%X"):format(cur_color),
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue