loadSnippet("#92")() fontWidth=width fontHeight=height fontPixels=pixels -- size of chars cw, ch = 16, 16 -- original text otext = {"!\"#$%&'()*+,-./0123456789:;<=>?@", "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`", "abcdefghijklmnopqrstuvwxyz{|}~ " } function render(text) newtext = text or "Hello world!" width=cw*#newtext height=ch pixels={} for i=1, #newtext do j = nil for line=1, #otext do local c = newtext:sub(i, i) j = otext[line]:find(c, 1, true) --print("line="..tostring(line)..", c="..c..", j="..tostring(j)) if j then l = line; break end end if j then --print("j="..tostring(j)..", l="..tostring(l)) for y = 0, ch-1 do for x = 0, cw-1 do assert(j, "j") assert(l, "l") assert(fontWidth, "fontWidth") local from = (j-1)*cw+x+((l-1)*ch+y)*fontWidth+1 local to = (i-1)*cw+x+y*width+1 pixels[to] = fontPixels[from] end end end end end