Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
3e6328ac43 | |||
64902b845d | |||
1fdff47dc8 |
58
api.lua
@ -467,15 +467,6 @@ signs_lib.charwidth_wide32 = build_char_db(32)
|
||||
|
||||
local math_max = math.max
|
||||
|
||||
local function fill_line(x, y, w, c, font_size, colorbgw)
|
||||
c = c or "0"
|
||||
local tex = { }
|
||||
for xx = 0, math.max(0, w), colorbgw do
|
||||
table.insert(tex, (":%d,%d=signs_lib_color_"..font_size.."px_%s.png"):format(x + xx, y, c))
|
||||
end
|
||||
return table.concat(tex)
|
||||
end
|
||||
|
||||
-- make char texture file name
|
||||
-- if texture file does not exist use fallback texture instead
|
||||
local function char_tex(font_name, ch)
|
||||
@ -511,6 +502,26 @@ local function char_tex_wide(font_name, ch)
|
||||
end
|
||||
end
|
||||
|
||||
-- sign colour table
|
||||
local colgrid = {
|
||||
["0"] = "000000", -- black
|
||||
["1"] = "000080", -- blue
|
||||
["2"] = "008000", -- dark green
|
||||
["3"] = "008080", -- dark cyan
|
||||
["4"] = "800000", -- red
|
||||
["5"] = "800080", -- purple
|
||||
["6"] = "804000", -- brown
|
||||
["7"] = "808080", -- light grey
|
||||
["8"] = "404040", -- dark grey
|
||||
["9"] = "8080ff", -- light blue
|
||||
["A"] = "80ff80", -- green
|
||||
["B"] = "80ffff", -- cyan
|
||||
["C"] = "ff8080", -- skin pink
|
||||
["D"] = "ff80ff", -- pink
|
||||
["E"] = "ffff00", -- yellow
|
||||
["F"] = "ffffff" -- white
|
||||
}
|
||||
|
||||
local function make_line_texture(line, lineno, pos, line_width, line_height, cwidth_tab, font_size, colorbgw, cwidth_tab_wide, force_unicode_font)
|
||||
local width = 0
|
||||
local maxw = 0
|
||||
@ -583,7 +594,7 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
||||
end
|
||||
end
|
||||
if w then
|
||||
width = width + w + 1
|
||||
width = width + w
|
||||
if width >= (line_width - cwidth_tab[" "]) then
|
||||
width = 0
|
||||
else
|
||||
@ -615,7 +626,7 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
||||
else
|
||||
local w = cwidth_tab[c]
|
||||
if w then
|
||||
width = width + w + 1
|
||||
width = width + w
|
||||
if width >= (line_width - cwidth_tab[" "]) then
|
||||
width = 0
|
||||
else
|
||||
@ -633,7 +644,7 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
width = width + cwidth_tab[" "] + 1
|
||||
width = width + cwidth_tab[" "]
|
||||
maxw = math_max(width, maxw)
|
||||
table.insert(words, { chars=chars, w=ch_offs })
|
||||
end
|
||||
@ -647,36 +658,25 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
||||
local xpos = start_xpos
|
||||
local ypos = (line_height + def.line_spacing)* lineno + def.y_offset
|
||||
|
||||
cur_color = nil
|
||||
|
||||
for word_i, word in ipairs(words) do
|
||||
local xoffs = (xpos - start_xpos)
|
||||
if (xoffs > 0) and ((xoffs + word.w) > maxw) then
|
||||
table.insert(texture, fill_line(xpos, ypos, maxw, "n", font_size, colorbgw))
|
||||
xpos = start_xpos
|
||||
ypos = ypos + line_height + def.line_spacing
|
||||
lineno = lineno + 1
|
||||
if lineno >= def.number_of_lines then break end
|
||||
table.insert(texture, fill_line(xpos, ypos, maxw, cur_color, font_size, colorbgw))
|
||||
end
|
||||
for ch_i, ch in ipairs(word.chars) do
|
||||
if ch.col ~= cur_color then
|
||||
cur_color = ch.col
|
||||
table.insert(texture, fill_line(xpos + ch.off, ypos, maxw, cur_color, font_size, colorbgw))
|
||||
|
||||
-- colorize character texture
|
||||
local newtex = ch.tex .. '\\^[colorize\\:#' .. colgrid[ch.col]
|
||||
|
||||
table.insert(texture, (":%d,%d=%s"):format(xpos + ch.off, ypos, newtex))
|
||||
end
|
||||
table.insert(texture, (":%d,%d=%s"):format(xpos + ch.off, ypos, ch.tex))
|
||||
end
|
||||
table.insert(
|
||||
texture,
|
||||
(":%d,%d="):format(xpos + word.w, ypos) .. char_tex(font_name, " ")
|
||||
)
|
||||
xpos = xpos + word.w + cwidth_tab[" "]
|
||||
if xpos >= (line_width + cwidth_tab[" "]) then break end
|
||||
end
|
||||
|
||||
table.insert(texture, fill_line(xpos, ypos, maxw, "n", font_size, colorbgw))
|
||||
table.insert(texture, fill_line(start_xpos, ypos + line_height, maxw, "n", font_size, colorbgw))
|
||||
|
||||
return table.concat(texture), lineno
|
||||
end
|
||||
|
||||
@ -721,7 +721,7 @@ function signs_lib.make_sign_texture(lines, pos)
|
||||
table.insert(texture, linetex)
|
||||
lineno = ln + 1
|
||||
end
|
||||
table.insert(texture, "^[makealpha:0,0,0")
|
||||
|
||||
return table.concat(texture, "")
|
||||
end
|
||||
|
||||
|
Before Width: | Height: | Size: 89 B |
Before Width: | Height: | Size: 85 B |
Before Width: | Height: | Size: 85 B |
Before Width: | Height: | Size: 85 B |
Before Width: | Height: | Size: 85 B |
Before Width: | Height: | Size: 85 B |
Before Width: | Height: | Size: 85 B |
Before Width: | Height: | Size: 89 B |
Before Width: | Height: | Size: 89 B |
Before Width: | Height: | Size: 85 B |
Before Width: | Height: | Size: 85 B |
Before Width: | Height: | Size: 85 B |
Before Width: | Height: | Size: 85 B |
Before Width: | Height: | Size: 85 B |
Before Width: | Height: | Size: 85 B |
Before Width: | Height: | Size: 89 B |
Before Width: | Height: | Size: 99 B |
Before Width: | Height: | Size: 87 B |
Before Width: | Height: | Size: 87 B |
Before Width: | Height: | Size: 87 B |
Before Width: | Height: | Size: 87 B |
Before Width: | Height: | Size: 87 B |
Before Width: | Height: | Size: 87 B |
Before Width: | Height: | Size: 99 B |
Before Width: | Height: | Size: 99 B |
Before Width: | Height: | Size: 87 B |
Before Width: | Height: | Size: 87 B |
Before Width: | Height: | Size: 87 B |
Before Width: | Height: | Size: 87 B |
Before Width: | Height: | Size: 87 B |
Before Width: | Height: | Size: 87 B |
Before Width: | Height: | Size: 98 B |
Before Width: | Height: | Size: 95 B After Width: | Height: | Size: 103 B |
Before Width: | Height: | Size: 115 B After Width: | Height: | Size: 124 B |
Before Width: | Height: | Size: 117 B After Width: | Height: | Size: 123 B |
Before Width: | Height: | Size: 115 B After Width: | Height: | Size: 125 B |
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 126 B |
Before Width: | Height: | Size: 106 B After Width: | Height: | Size: 118 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 118 B |
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 118 B |
Before Width: | Height: | Size: 113 B After Width: | Height: | Size: 123 B |
Before Width: | Height: | Size: 114 B After Width: | Height: | Size: 124 B |
Before Width: | Height: | Size: 113 B After Width: | Height: | Size: 122 B |
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 117 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 116 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 124 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 123 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 120 B |
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 122 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 117 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 128 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 128 B |
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 127 B |
Before Width: | Height: | Size: 103 B After Width: | Height: | Size: 122 B |
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 120 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 116 B |
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 120 B |
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 113 B |
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 127 B |
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 118 B |
Before Width: | Height: | Size: 114 B After Width: | Height: | Size: 123 B |
Before Width: | Height: | Size: 106 B After Width: | Height: | Size: 121 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 117 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 125 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 113 B |
Before Width: | Height: | Size: 95 B After Width: | Height: | Size: 103 B |
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 127 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 122 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 117 B |
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 119 B |
Before Width: | Height: | Size: 106 B After Width: | Height: | Size: 117 B |
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 116 B |
Before Width: | Height: | Size: 68 B After Width: | Height: | Size: 74 B |
Before Width: | Height: | Size: 90 B After Width: | Height: | Size: 94 B |
Before Width: | Height: | Size: 90 B After Width: | Height: | Size: 92 B |
Before Width: | Height: | Size: 98 B After Width: | Height: | Size: 115 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 120 B |
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 131 B |
Before Width: | Height: | Size: 114 B After Width: | Height: | Size: 129 B |
Before Width: | Height: | Size: 88 B After Width: | Height: | Size: 91 B |
Before Width: | Height: | Size: 92 B After Width: | Height: | Size: 104 B |
Before Width: | Height: | Size: 92 B After Width: | Height: | Size: 106 B |
Before Width: | Height: | Size: 98 B After Width: | Height: | Size: 109 B |
Before Width: | Height: | Size: 95 B After Width: | Height: | Size: 97 B |
Before Width: | Height: | Size: 91 B After Width: | Height: | Size: 96 B |
Before Width: | Height: | Size: 89 B After Width: | Height: | Size: 90 B |
Before Width: | Height: | Size: 88 B After Width: | Height: | Size: 87 B |
Before Width: | Height: | Size: 90 B After Width: | Height: | Size: 104 B |
Before Width: | Height: | Size: 96 B After Width: | Height: | Size: 108 B |
Before Width: | Height: | Size: 102 B After Width: | Height: | Size: 112 B |
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 119 B |
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 117 B |
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 120 B |
Before Width: | Height: | Size: 103 B After Width: | Height: | Size: 114 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 117 B |
Before Width: | Height: | Size: 96 B After Width: | Height: | Size: 111 B |
Before Width: | Height: | Size: 104 B After Width: | Height: | Size: 114 B |
Before Width: | Height: | Size: 103 B After Width: | Height: | Size: 117 B |
Before Width: | Height: | Size: 88 B After Width: | Height: | Size: 89 B |