mirror of
https://github.com/mt-mods/signs_lib.git
synced 2024-11-07 02:20:18 +01:00
Revert "Fix out-of-bounds textures in [combine
(#27)"
This reverts commit 4fb53b67e8
.
This commit is contained in:
parent
4fb53b67e8
commit
0847176bdb
24
api.lua
24
api.lua
|
@ -467,11 +467,10 @@ signs_lib.charwidth_wide32 = build_char_db(32)
|
|||
|
||||
local math_max = math.max
|
||||
|
||||
local function fill_line(x, y, w, c, font_size, colorbgw, line_width)
|
||||
local function fill_line(x, y, w, c, font_size, colorbgw)
|
||||
c = c or "0"
|
||||
local tex = { }
|
||||
for xx = 0, w, colorbgw do
|
||||
if x + xx > line_width then break end
|
||||
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)
|
||||
|
@ -584,10 +583,9 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
|||
end
|
||||
end
|
||||
if w then
|
||||
width = width + w
|
||||
width = width + w + 1
|
||||
if width >= (line_width - cwidth_tab[" "]) then
|
||||
width = 0
|
||||
break
|
||||
else
|
||||
maxw = math_max(width, maxw)
|
||||
end
|
||||
|
@ -617,10 +615,9 @@ 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
|
||||
width = width + w + 1
|
||||
if width >= (line_width - cwidth_tab[" "]) then
|
||||
width = 0
|
||||
break
|
||||
else
|
||||
maxw = math_max(width, maxw)
|
||||
end
|
||||
|
@ -636,7 +633,7 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
|||
end
|
||||
i = i + 1
|
||||
end
|
||||
width = width + cwidth_tab[" "]
|
||||
width = width + cwidth_tab[" "] + 1
|
||||
maxw = math_max(width, maxw)
|
||||
table.insert(words, { chars=chars, w=ch_offs })
|
||||
end
|
||||
|
@ -655,16 +652,17 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
|||
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, line_width))
|
||||
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, line_width))
|
||||
table.insert(texture, fill_line(xpos + ch.off, ypos, maxw, cur_color, font_size, colorbgw))
|
||||
end
|
||||
table.insert(texture, (":%d,%d=%s"):format(xpos + ch.off, ypos, ch.tex))
|
||||
end
|
||||
|
@ -673,9 +671,11 @@ local function make_line_texture(line, lineno, pos, line_width, line_height, cwi
|
|||
(":%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, line_width))
|
||||
table.insert(texture, fill_line(start_xpos, ypos + line_height, maxw, "n", font_size, colorbgw, line_width))
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user