Advertisement
HugoBDesigner

Spacing Shtuff

Dec 7th, 2014
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.57 KB | None | 0 0
  1. local spaceTable = {"i" = -1}
  2. local lgprint = love.graphics.print
  3. function love.graphics.print(t, x, y)
  4.     local font = love.graphics.getFont()
  5.     local last = {size = 0, off = false, t = ""}
  6.     for i = 1, string.len(t) do
  7.         local v = string.sub(t, i, i)
  8.         if spaceTable[v] then
  9.             if not last.off then
  10.                 last.off = spaceTable[v]
  11.             else
  12.                 last.off = last.off+spaceTable[v]
  13.             end
  14.             last.size = font:getWidth(string.sub(t, 1, i-1))
  15.             if last.t ~= "" then
  16.                 lgprint(last.t, x+last.size+last.off, y)
  17.             end
  18.             last.t = v
  19.         else
  20.             last.t = last.t .. v
  21.         end
  22.     end
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement