Skip to content

Commit

Permalink
avoid a warning when rendering zero length strings
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmaclarty committed Mar 15, 2020
1 parent 52063ac commit 20fc64a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lua/text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ function am.text(font, str, color, halign, valign)
error("expecting a font in position 1", 2)
end
str = type(str) == "string" and str or tostring(str)
if str == "" then
-- zero length strings cause issues
str = " "
end
local len = utf8.len(str)
local num_verts = len * 4
local buffer, verts, uvs = make_buffer(num_verts)
Expand Down

0 comments on commit 20fc64a

Please sign in to comment.