From 1627172cce23e2a7753ff5beebc3701ac188a159 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Fri, 1 Jul 2022 17:15:10 +0200 Subject: [PATCH] Check string limits correctly --- src/gui.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui.lua b/src/gui.lua index 0196db5..2ba4b0e 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -38,7 +38,7 @@ local function weird_desc(str) end local function snip(str, limit) - return #str > limit and fmt("%s...", sub(str, 1, limit - 3)) or str + return fmt("%s...", sub(str, 1, limit - 3)) end local function get_desc(item) @@ -175,11 +175,11 @@ local function get_award_list(data, fs, ctn_len, yextra, award_list, awards_unlo local desc_lim, _desc = 39 local icon_size = 1.1 - if #title > title_lim then + if utf8_len(title) > title_lim then _title = snip(title, title_lim) end - if #desc > desc_lim then + if utf8_len(desc) > desc_lim then _desc = snip(desc, desc_lim) end @@ -318,7 +318,7 @@ local function get_waypoint_fs(fs, data, player, yextra, ctn_len) local waypoint_name, lim = v.name, 18 - if #v.name > lim then + if utf8_len(v.name) > lim then waypoint_name = snip(waypoint_name, lim) end @@ -1189,12 +1189,12 @@ local function get_header(fs, data) local Y1 = data.yoffset + 0.47 local Y2 = Y1 + 0.5 - if #desc > desc_lim then + if utf8_len(desc) > desc_lim then tooltip(X, Y1 - 0.1, 5.7, 0.24, desc) desc = snip(desc, desc_lim) end - if #tech_name > name_lim then + if utf8_len(tech_name) > name_lim then tooltip(X, Y2 - 0.1, 5.7, 0.24, tech_name) tech_name = snip(tech_name, name_lim) end