do ------------------------- -- Custom font routine -- ------------------------- local CHAR_HEIGHT = 12 local CHAR_WIDTH = 8 local charMap_ascii = { {0,0,0,0,0,0,0,0,0,0,0,0}, -- NULL 0 {0,126,129,165,129,129,189,153,129,126,0,0}, {0,126,255,219,255,255,195,231,255,126,0,0}, {0,0,108,238,254,254,254,124,56,16,0,0}, {0,0,16,56,124,254,124,56,16,0,0,0}, {0,0,16,56,16,108,238,108,16,56,0,0}, {0,16,56,124,124,254,254,108,16,56,0,0}, {0,0,0,0,24,60,60,24,0,0,0,0}, {255,255,255,255,231,195,195,231,255,255,255,255}, {0,0,0,24,60,102,102,60,24,0,0,0}, {255,255,255,231,195,153,153,195,231,255,255,255}, {0,30,14,30,54,120,204,204,204,120,0,0}, {0,60,102,102,102,60,24,126,24,24,0,0}, {0,30,26,30,24,24,24,120,248,112,0,0}, {62,54,62,54,54,118,246,102,14,30,12,0}, {24,219,126,60,102,102,60,126,219,24,0,0}, {0,128,224,240,252,254,252,240,224,128,0,0}, {0,2,14,62,126,254,126,62,14,2,0,0}, {0,24,60,126,24,24,24,126,60,24,0,0}, {0,102,102,102,102,102,102,0,102,102,0,0}, {0,127,219,219,219,123,27,27,27,27,0,0}, {124,198,198,96,124,246,222,124,12,198,198,124}, {0,0,0,0,0,0,0,254,254,254,0,0}, {0,24,60,126,24,24,126,60,24,126,0,0}, {0,24,60,126,24,24,24,24,24,24,0,0}, {0,24,24,24,24,24,24,126,60,24,0,0}, {0,0,0,12,14,255,14,12,0,0,0,0}, {0,0,0,48,112,254,112,48,0,0,0,0}, {0,0,0,0,192,192,192,254,0,0,0,0}, {0,0,0,36,102,255,102,36,0,0,0,0}, {0,16,56,56,56,124,124,254,254,0,0,0}, {0,254,254,124,124,124,56,56,16,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, {0,24,60,60,60,24,24,0,24,24,0,0}, {54,54,54,20,0,0,0,0,0,0,0,0}, {0,108,108,108,254,108,108,254,108,108,0,0}, {24,24,124,198,192,120,60,6,198,124,24,24}, {0,0,0,98,102,12,24,48,102,198,0,0}, {0,56,108,56,56,118,246,206,204,118,0,0}, {12,12,12,24,0,0,0,0,0,0,0,0}, {0,12,24,48,48,48,48,48,24,12,0,0}, {0,48,24,12,12,12,12,12,24,48,0,0}, {0,0,0,108,56,254,56,108,0,0,0,0}, {0,0,0,24,24,126,24,24,0,0,0,0}, {0,0,0,0,0,0,0,12,12,12,24,0}, {0,0,0,0,0,254,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,24,24,0,0}, {0,0,2,6,12,24,48,96,192,128,0,0}, {0,124,198,206,222,246,230,198,198,124,0,0}, {0,24,120,24,24,24,24,24,24,126,0,0}, {0,124,198,198,12,24,48,96,198,254,0,0}, {0,124,198,6,6,60,6,6,198,124,0,0}, {0,12,28,60,108,204,254,12,12,12,0,0}, {0,254,192,192,192,252,6,6,198,124,0,0}, {0,124,198,192,192,252,198,198,198,124,0,0}, {0,254,198,12,24,48,48,48,48,48,0,0}, {0,124,198,198,198,124,198,198,198,124,0,0}, {0,124,198,198,198,126,6,6,198,124,0,0}, {0,0,0,12,12,0,0,12,12,0,0,0}, {0,0,0,12,12,0,0,12,12,12,24,0}, {0,12,24,48,96,192,96,48,24,12,0,0}, {0,0,0,0,254,0,254,0,0,0,0,0}, {0,96,48,24,12,6,12,24,48,96,0,0}, {0,124,198,198,12,24,24,0,24,24,0,0}, {0,124,198,198,222,222,222,220,192,126,0,0}, {0,56,108,198,198,198,254,198,198,198,0,0}, {0,252,102,102,102,124,102,102,102,252,0,0}, {0,60,102,192,192,192,192,192,102,60,0,0}, {0,248,108,102,102,102,102,102,108,248,0,0}, {0,254,102,96,96,124,96,96,102,254,0,0}, {0,254,102,96,96,124,96,96,96,240,0,0}, {0,124,198,198,192,192,206,198,198,124,0,0}, {0,198,198,198,198,254,198,198,198,198,0,0}, {0,60,24,24,24,24,24,24,24,60,0,0}, {0,60,24,24,24,24,24,216,216,112,0,0}, {0,198,204,216,240,240,216,204,198,198,0,0}, -- 'K' 75 {0,240,96,96,96,96,96,98,102,254,0,0}, -- 'L' 76 {0,198,198,238,254,214,214,214,198,198,0,0}, {0,198,198,230,230,246,222,206,206,198,0,0}, {0,124,198,198,198,198,198,198,198,124,0,0}, {0,252,102,102,102,124,96,96,96,240,0,0}, {0,124,198,198,198,198,198,198,214,124,6,0}, {0,252,102,102,102,124,120,108,102,230,0,0}, {0,124,198,192,96,56,12,6,198,124,0,0}, {0,126,90,24,24,24,24,24,24,60,0,0}, {0,198,198,198,198,198,198,198,198,124,0,0}, {0,198,198,198,198,198,198,108,56,16,0,0}, {0,198,198,214,214,214,254,238,198,198,0,0}, {0,198,198,108,56,56,56,108,198,198,0,0}, {0,102,102,102,102,60,24,24,24,60,0,0}, {0,254,198,140,24,48,96,194,198,254,0,0}, {0,124,96,96,96,96,96,96,96,124,0,0}, {0,0,128,192,96,48,24,12,6,2,0,0}, {0,124,12,12,12,12,12,12,12,124,0,0}, {16,56,108,198,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,255}, {24,24,24,12,0,0,0,0,0,0,0,0}, {0,0,0,0,120,12,124,204,220,118,0,0}, {0,224,96,96,124,102,102,102,102,252,0,0}, {0,0,0,0,124,198,192,192,198,124,0,0}, {0,28,12,12,124,204,204,204,204,126,0,0}, {0,0,0,0,124,198,254,192,198,124,0,0}, {0,28,54,48,48,252,48,48,48,120,0,0}, {0,0,0,0,118,206,198,198,126,6,198,124}, {0,224,96,96,108,118,102,102,102,230,0,0}, {0,24,24,0,56,24,24,24,24,60,0,0}, {0,12,12,0,28,12,12,12,12,204,204,120}, {0,224,96,96,102,108,120,108,102,230,0,0}, {0,56,24,24,24,24,24,24,24,60,0,0}, {0,0,0,0,108,254,214,214,198,198,0,0}, {0,0,0,0,220,102,102,102,102,102,0,0}, {0,0,0,0,124,198,198,198,198,124,0,0}, {0,0,0,0,220,102,102,102,124,96,96,240}, {0,0,0,0,118,204,204,204,124,12,12,30}, {0,0,0,0,220,102,96,96,96,240,0,0}, {0,0,0,0,124,198,112,28,198,124,0,0}, {0,48,48,48,252,48,48,48,54,28,0,0}, {0,0,0,0,204,204,204,204,204,118,0,0}, {0,0,0,0,198,198,198,108,56,16,0,0}, {0,0,0,0,198,198,214,214,254,108,0,0}, {0,0,0,0,198,108,56,56,108,198,0,0}, {0,0,0,0,198,198,198,206,118,6,198,124}, {0,0,0,0,254,140,24,48,98,254,0,0}, {0,14,24,24,24,112,24,24,24,14,0,0}, {0,24,24,24,24,0,24,24,24,24,0,0}, {0,112,24,24,24,14,24,24,24,112,0,0}, {0,118,220,0,0,0,0,0,0,0,0,0}, {0,0,0,16,56,56,108,108,254,0,0,0}, {0,60,102,192,192,192,198,102,60,24,204,56}, {0,198,198,0,198,198,198,198,206,118,0,0}, {12,24,48,0,124,198,254,192,198,124,0,0}, {48,120,204,0,120,12,124,204,220,118,0,0}, {0,204,204,0,120,12,124,204,220,118,0,0}, {96,48,24,0,120,12,124,204,220,118,0,0}, {56,108,56,0,120,12,124,204,220,118,0,0}, {0,0,0,124,198,192,192,198,124,24,108,56}, {48,120,204,0,124,198,254,192,198,124,0,0}, {0,204,204,0,124,198,254,192,198,124,0,0}, {48,24,12,0,124,198,254,192,198,124,0,0}, {0,102,102,0,56,24,24,24,24,60,0,0}, {24,60,102,0,56,24,24,24,24,60,0,0}, {96,48,24,0,56,24,24,24,24,60,0,0}, {198,198,0,56,108,198,254,198,198,198,0,0}, {56,108,56,0,56,108,198,198,254,198,198,0}, {12,24,48,0,254,96,96,124,96,96,254,0}, {0,0,0,102,219,27,127,216,223,118,0,0}, {126,216,216,216,216,254,216,216,216,222,0,0}, {48,120,204,0,124,198,198,198,198,124,0,0}, {0,198,198,0,124,198,198,198,198,124,0,0}, {48,24,12,0,124,198,198,198,198,124,0,0}, {48,120,204,0,198,198,198,198,206,118,0,0}, {96,48,24,0,198,198,198,198,206,118,0,0}, {0,198,198,0,198,198,198,206,118,6,198,124}, {198,198,0,124,198,198,198,198,198,124,0,0}, {198,198,0,198,198,198,198,198,198,124,0,0}, {24,24,60,102,96,96,102,60,24,24,0,0}, {0,56,108,96,96,240,96,102,246,108,0,0}, {0,102,102,60,24,126,24,60,24,24,0,0}, {252,198,252,192,204,222,204,204,204,198,0,0}, {14,27,24,24,24,126,24,24,24,24,216,112}, {12,24,48,0,120,12,124,204,220,118,0,0}, {12,24,48,0,56,24,24,24,24,60,0,0}, {12,24,48,0,124,198,198,198,198,124,0,0}, {24,48,96,0,204,204,204,204,220,118,0,0}, {0,118,220,0,188,102,102,102,102,230,0,0}, {118,220,0,198,198,230,246,222,206,198,0,0}, {60,108,108,62,0,126,0,0,0,0,0,0}, {56,108,108,56,0,124,0,0,0,0,0,0}, {0,48,48,0,48,48,96,198,198,124,0,0}, {0,0,0,0,0,126,96,96,96,0,0,0}, {0,0,0,0,0,126,6,6,6,0,0,0}, {96,98,102,108,24,48,96,220,54,12,24,62}, {96,98,102,108,24,54,110,222,54,126,6,6}, {0,24,24,0,24,24,60,60,60,24,0,0}, {0,0,0,54,108,216,108,54,0,0,0,0}, {0,0,0,216,108,54,108,216,0,0,0,0}, {17,68,17,68,17,68,17,68,17,68,17,68}, {85,170,85,170,85,170,85,170,85,170,85,170}, {221,119,221,119,221,119,221,119,221,119,221,119}, {24,24,24,24,24,24,24,24,24,24,24,24}, {24,24,24,24,24,24,248,24,24,24,24,24}, {24,24,24,24,248,24,248,24,24,24,24,24}, {54,54,54,54,54,54,246,54,54,54,54,54}, {0,0,0,0,0,0,254,54,54,54,54,54}, {0,0,0,0,248,24,248,24,24,24,24,24}, {54,54,54,54,246,6,246,54,54,54,54,54}, {54,54,54,54,54,54,54,54,54,54,54,54}, {0,0,0,0,254,6,246,54,54,54,54,54}, {54,54,54,54,246,6,254,0,0,0,0,0}, {54,54,54,54,54,54,254,0,0,0,0,0}, {24,24,24,24,248,24,248,0,0,0,0,0}, {0,0,0,0,0,0,248,24,24,24,24,24}, {24,24,24,24,24,24,31,0,0,0,0,0}, {24,24,24,24,24,24,255,0,0,0,0,0}, {0,0,0,0,0,0,255,24,24,24,24,24}, {24,24,24,24,24,24,31,24,24,24,24,24}, {0,0,0,0,0,0,255,0,0,0,0,0}, {24,24,24,24,24,24,255,24,24,24,24,24}, {24,24,24,24,31,24,31,24,24,24,24,24}, {54,54,54,54,54,54,55,54,54,54,54,54}, {54,54,54,54,55,48,63,0,0,0,0,0}, {0,0,0,0,63,48,55,54,54,54,54,54}, {54,54,54,54,247,0,255,0,0,0,0,0}, {0,0,0,0,255,0,247,54,54,54,54,54}, {54,54,54,54,55,48,55,54,54,54,54,54}, {0,0,0,0,255,0,255,0,0,0,0,0}, {54,54,54,54,247,0,247,54,54,54,54,54}, {24,24,24,24,255,0,255,0,0,0,0,0}, {54,54,54,54,54,54,255,0,0,0,0,0}, {0,0,0,0,255,0,255,24,24,24,24,24}, {0,0,0,0,0,0,255,54,54,54,54,54}, {54,54,54,54,54,54,63,0,0,0,0,0}, {24,24,24,24,31,24,31,0,0,0,0,0}, {0,0,0,0,31,24,31,24,24,24,24,24}, {0,0,0,0,0,0,63,54,54,54,54,54}, {54,54,54,54,54,54,255,54,54,54,54,54}, {24,24,24,24,255,24,255,24,24,24,24,24}, {24,24,24,24,24,24,248,0,0,0,0,0}, {0,0,0,0,0,0,31,24,24,24,24,24}, {255,255,255,255,255,255,255,255,255,255,255,255}, {0,0,0,0,0,0,255,255,255,255,255,255}, {240,240,240,240,240,240,240,240,240,240,240,240}, {15,15,15,15,15,15,15,15,15,15,15,15}, {255,255,255,255,255,255,0,0,0,0,0,0}, {0,0,0,118,220,216,216,216,220,118,0,0}, {0,0,0,120,204,216,252,198,230,220,192,192}, {0,254,102,98,96,96,96,96,96,96,0,0}, {0,0,0,0,254,108,108,108,108,108,0,0}, {0,254,198,98,48,24,48,98,198,254,0,0}, {0,0,0,0,126,216,204,204,204,120,0,0}, {0,0,0,102,102,102,102,124,96,192,128,0}, {0,0,0,0,118,220,24,24,24,24,0,0}, {0,254,56,108,198,198,198,108,56,254,0,0}, {0,56,108,198,198,254,198,198,108,56,0,0}, {0,56,108,198,198,198,108,108,108,238,0,0}, {0,62,96,48,60,102,198,198,204,120,0,0}, {0,0,0,0,126,219,219,126,0,0,0,0}, {0,6,12,124,222,246,230,124,96,192,0,0}, {0,28,48,96,96,124,96,96,48,28,0,0}, {0,124,198,198,198,198,198,198,198,198,0,0}, {0,0,0,0,254,0,254,0,254,0,0,0}, {0,0,0,24,24,126,24,24,0,126,0,0}, {0,48,24,12,6,12,24,48,0,126,0,0}, {0,12,24,48,96,48,24,12,0,126,0,0}, {0,0,12,30,26,24,24,24,24,24,24,24}, {24,24,24,24,24,24,24,24,88,120,48,0}, {0,0,24,24,0,126,0,24,24,0,0,0}, {0,0,0,0,118,220,0,118,220,0,0,0}, {0,120,204,204,120,0,0,0,0,0,0,0}, {0,0,0,0,0,24,24,0,0,0,0,0}, {0,0,0,0,0,0,24,0,0,0,0,0}, {0,0,31,24,24,24,24,216,120,56,24,0}, {216,108,108,108,108,0,0,0,0,0,0,0}, {112,216,48,96,248,0,0,0,0,0,0,0}, {0,0,0,126,126,126,126,126,126,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0}, } local charMapImages = {} local TEXT_FG = platform.isColorDisplay() and "\224\139" or "\0\128" -- green or black; depending display local TEXT_BG = "la" -- alpha local IMG_HEADER = "\8\0\0\0\12\0\0\0\0\0\0\0\16\0\0\0\16\0\1\0" local function rowToImageRow(row) local r = "" for i=1, CHAR_WIDTH do r = (row%2 == 0 and TEXT_BG or TEXT_FG) .. r row = math.floor(row / 2) end return r end local function charToImage(charData) local r = IMG_HEADER for i=1, CHAR_HEIGHT do r = r .. rowToImageRow(charData[i]) end return image.new(r) end local function genCharImages() for i=1, 256 do charMapImages[i-1] = charToImage(charMap_ascii[i]) end end local function drawChar(gc, char, x, y) gc:drawImage(charMapImages[char:byte()], x, y) end local function drawString(gc, str, x, y) for i=1, #str do drawChar(gc, str:sub(i, i), x + i * CHAR_WIDTH - CHAR_WIDTH, y) end end AddToGC("drawStringM", drawString) _G.M_CHAR_HEIGHT = CHAR_HEIGHT _G.M_CHAR_WIDTH = CHAR_WIDTH _G.m_font_init = genCharImages end