about summary refs log tree commit diff stats
path: root/run.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-04-01 14:48:59 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-04-01 16:12:55 -0700
commit4ab901c92e11f47828bc7f5f16d8d2250812d53f (patch)
tree288dcf758b377c9b8586a9fc4bd7706d3a91e1f4 /run.lua
parentfd2e5acb464c439325455acb63683d4fa316497c (diff)
downloadlines.love-4ab901c92e11f47828bc7f5f16d8d2250812d53f.tar.gz
get rid of to_text
I've been misunderstanding what Text objects are. They can render a lot
of text with a given line height, word wrap, colors in various places.
And I've been creating one for every word :facepalm:

Unwinding this will take some time. This is just a first baby step for
ad hoc text objects. Turns out I don't need to convert to Text to get
something's rendered width, just the Font can do that.

Thanks to the LÖVE Discord for educating me:
  https://discord.com/channels/329400828920070144/330089431379869708/1091535487333826580
Diffstat (limited to 'run.lua')
-rw-r--r--run.lua8
1 files changed, 2 insertions, 6 deletions
diff --git a/run.lua b/run.lua
index 049362e..6da1c59 100644
--- a/run.lua
+++ b/run.lua
@@ -197,10 +197,6 @@ function run.key_release(key, scancode)
   return edit.key_release(Editor_state, key, scancode)
 end
 
--- use this sparingly
-function to_text(s)
-  if Text_cache[s] == nil then
-    Text_cache[s] = App.newText(love.graphics.getFont(), s)
-  end
-  return Text_cache[s]
+function width(s)
+  return love.graphics.getFont():getWidth(s)
 end