7 if type(k) == "number" then
8 str = str .. "[" .. k .. "] = "
10 str = str .. tostring(k) .. " = "
12 if type(v) == "table" then
13 str = str .. "{ " .. tostr(v) .. " }"
15 str = str .. tostring(v)
21 local canvas -- holds the current canvas (from startcanvas())
24 startcanvas() is called at the start of each picture file, passing the
25 canvas that we will be drawing into, and the name of the file.
27 Following this call, there will be some number of calls to accumulate(t)
28 where t is a table of parameters that were passed to that draw-op.
30 t.verb is a string holding the name of the draw-op (e.g. "drawRect")
32 when a given picture is done, we call endcanvas(canvas, fileName)
34 function sk_scrape_startcanvas(c, fileName)
39 Called when the current canvas is done drawing.
41 function sk_scrape_endcanvas(c, fileName)
46 Called with the parameters to each canvas.draw call, where canvas is the
47 current canvas as set by startcanvas()
50 local gCounts = {} -- [fontID_pointsize] = [] unique glyphs
51 local gFirstGlyphs = {}
54 function array_count(array)
56 for k in next, array do
62 function sk_scrape_accumulate(t)
64 if verb == "drawPosText" or verb == "drawPosTextH" then
66 local key = array_count(t.glyphs)
67 local n = gCounts[key]
75 local first = t.glyphs[1];
76 local n = gFirstGlyphs[first]
82 gFirstGlyphs[first] = n
85 gTotalCount = gTotalCount + 1
91 lua_pictures will call this function after all of the pictures have been
94 function sk_scrape_summarize()
95 for k, v in next, gCounts do
96 io.write("glyph_count ", k, ",frequency ", v * 100 / gTotalCount, "\n")
100 io.write("\n\nFirst glyph spread\n\n")
101 for k, v in next, gFirstGlyphs do
102 io.write("glyph, ", k, ",count, ", v, "\n")
107 function test_summary()
108 io.write("just testing test_summary\n")