improved error mitigation

This commit is contained in:
Alexsandro Percy 2024-07-20 09:18:19 -03:00
parent 0beb2b1077
commit a9c8560136

View file

@ -234,18 +234,20 @@ function airutils.convert_text_to_texture(text, default_color, horizontal_aligme
text = text or "" text = text or ""
default_color = default_color or 0 default_color = default_color or 0
horizontal_aligment = horizontal_aligment or 3 horizontal_aligment = horizontal_aligment or 3
local font_size if not signs_lib then return "" end
local line_width local font_size = 16
local line_height local line_width = 1
local char_width local line_height = 1
local colorbgw local char_width = 1
local chars_per_line local colorbgw = ""
local widemult local chars_per_line = 21
local widemult = 0.5
local count = 0 local count = 0
--text = string.sub(text,1,max_lenght) --text = string.sub(text,1,max_lenght)
text, count = clamp_characters(text, max_lenght) text, count = clamp_characters(text, max_lenght)
if count <= 10 then if count <= 10 then
if signs_lib.avgwidth32 then
widemult = 0.75 widemult = 0.75
font_size = 32 font_size = 32
chars_per_line = 10 chars_per_line = 10
@ -254,6 +256,10 @@ function airutils.convert_text_to_texture(text, default_color, horizontal_aligme
char_width = signs_lib.charwidth32 char_width = signs_lib.charwidth32
colorbgw = signs_lib.colorbgw32 colorbgw = signs_lib.colorbgw32
else else
return ""
end
else
if signs_lib.avgwidth16 then
widemult = 0.5 widemult = 0.5
font_size = 16 font_size = 16
chars_per_line = 21 chars_per_line = 21
@ -261,6 +267,9 @@ function airutils.convert_text_to_texture(text, default_color, horizontal_aligme
line_height = signs_lib.lineheight16 line_height = signs_lib.lineheight16
char_width = signs_lib.charwidth16 char_width = signs_lib.charwidth16
colorbgw = signs_lib.colorbgw16 colorbgw = signs_lib.colorbgw16
else
return ""
end
end end
local texture = { ("[combine:%dx%d"):format(line_width, line_height) } local texture = { ("[combine:%dx%d"):format(line_width, line_height) }