Distinguish Unifont full/half-width & split sheets
23
api.lua
|
@ -342,6 +342,7 @@ local TP = signs_lib.path .. "/textures"
|
||||||
-- Font file formatter
|
-- Font file formatter
|
||||||
local CHAR_FILE = "%s_%02x.png"
|
local CHAR_FILE = "%s_%02x.png"
|
||||||
local CHAR_FILE_WIDE = "%s_%s.png"
|
local CHAR_FILE_WIDE = "%s_%s.png"
|
||||||
|
local UNIFONT_TEX = "signs_lib_uni%02x.png\\^[sheet\\:16x16\\:%d,%d"
|
||||||
-- Fonts path
|
-- Fonts path
|
||||||
local CHAR_PATH = TP .. "/" .. CHAR_FILE
|
local CHAR_PATH = TP .. "/" .. CHAR_FILE
|
||||||
local CHAR_PATH_WIDE = TP .. "/" .. CHAR_FILE_WIDE
|
local CHAR_PATH_WIDE = TP .. "/" .. CHAR_FILE_WIDE
|
||||||
|
@ -568,11 +569,15 @@ 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
|
local w, code
|
||||||
if wide_type == "x" then
|
if wide_type == "x" then
|
||||||
w = cwidth_tab_wide[wide_c]
|
w = cwidth_tab_wide[wide_c]
|
||||||
elseif wide_type == "u" and #wide_c <= 4 then
|
elseif wide_type == "u" and #wide_c <= 4 then
|
||||||
w = font_size
|
w = font_size
|
||||||
|
code = tonumber(wide_c, 16)
|
||||||
|
if signs_lib.unifont_halfwidth[code] then
|
||||||
|
w = math.floor(w / 2)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if w then
|
if w then
|
||||||
width = width + w + 1
|
width = width + w + 1
|
||||||
|
@ -583,17 +588,17 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
||||||
end
|
end
|
||||||
if #chars < MAX_INPUT_CHARS then
|
if #chars < MAX_INPUT_CHARS then
|
||||||
local tex
|
local tex
|
||||||
if wide_type == "x" then
|
if wide_type == "u" then
|
||||||
tex = char_tex_wide(font_name, wide_c)
|
local page = math.floor(code / 256)
|
||||||
else
|
local idx = code % 256
|
||||||
local code = tonumber(wide_c, 16)
|
local x = idx % 16
|
||||||
local x = code % 256
|
local y = math.floor(idx / 16)
|
||||||
local y = math.floor(code / 256)
|
tex = UNIFONT_TEX:format(page, x, y)
|
||||||
tex = string.format(
|
|
||||||
"signs_lib_unifont.png\\^[sheet\\:256x256\\:%d,%d", x, y)
|
|
||||||
if font_size == 32 then
|
if font_size == 32 then
|
||||||
tex = tex .. "\\^[resize\\:32x32"
|
tex = tex .. "\\^[resize\\:32x32"
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
tex = char_tex_wide(font_name, wide_c)
|
||||||
end
|
end
|
||||||
table.insert(chars, {
|
table.insert(chars, {
|
||||||
off = ch_offs,
|
off = ch_offs,
|
||||||
|
|
|
@ -331,3 +331,4 @@ function Utf8ToAnsi(s)
|
||||||
end
|
end
|
||||||
|
|
||||||
signs_lib.wide_character_codes = wide_character_codes
|
signs_lib.wide_character_codes = wide_character_codes
|
||||||
|
signs_lib.unifont_halfwidth = dofile(signs_lib.path.."/unifont-halfwidth.lua")
|
||||||
|
|
Before Width: | Height: | Size: 941 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 4.2 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 6.5 KiB |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 6.7 KiB |
After Width: | Height: | Size: 8.4 KiB |
After Width: | Height: | Size: 8.6 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 8.5 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 9.1 KiB |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 9.3 KiB |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 8.4 KiB |
After Width: | Height: | Size: 8.6 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 8.2 KiB |
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 9.1 KiB |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 7.7 KiB |
After Width: | Height: | Size: 6.8 KiB |
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 8.0 KiB |
After Width: | Height: | Size: 8.1 KiB |
After Width: | Height: | Size: 7.4 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 8.5 KiB |
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 8.1 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 8.2 KiB |
After Width: | Height: | Size: 8.3 KiB |