fontEnv = newCleanEnv()
loadSnippet("#92", fontEnv)()
get("#109") -- copyRect
-- 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))
      copyRect(fontEnv, _G, (j-1)*cw, (l-1)*ch, cw, ch, (i-1)*cw, 0)
    end
  end
end
\n\nBegan life as a copy of #178
test run test run with input download show line numbers
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
| ID | Author/Program | Comment | Date | |
|---|---|---|---|---|
| 878 | #1000610 | Edit suggestion: !636 !629 main { static Object androidContext; static String programID; public static void main(String[] args) throws Exception { fontEnv = newCleanEnv() loadSnippet("#92", fontEnv)() get("#109") -- copyRect -- 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)) copyRect(fontEnv, _G, (j-1)*cw, (l-1)*ch, cw, ch, (i-1)*cw, 0) end end end }} | 2015-08-19 22:48:37 | delete | 
| 753 | #1000604 (pitcher) | 2015-08-18 00:07:22 | 
| Recognizer | Recognition Result | Visualize | Recalc | 
|---|---|---|---|
| #308 | 800 | [visualize] | 
| Snippet ID: | #186 | 
| Snippet name: | Font renderer as function, optimized (Commodore PET font, 16x16) | 
| Eternal ID of this version: | #186/1 | 
| Text MD5: | 69bfcd501a0007048229bbb2a3118f3f | 
| Author: | stefan | 
| Category: | font rendering | 
| Type: | Lua code | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2014-01-25 08:45:47 | 
| Source code size: | 800 bytes / 35 lines | 
| Pitched / IR pitched: | Yes / Yes | 
| Views / Downloads: | 1813 / 882 | 
| Referenced in: | [show references] |