int MeasureChar(int c) { if (FNT(0)) return FNT(0); // monospaced font if (c == 32) return FNT(1)>>2; // Space is 1/4 font height (yuk); int i = c - FNT(3); if (i < 0 || i >= FNT(4)) return 0; int ci = 6 + i * 2; int width = (FNT(ci) << 8) | FNT(ci + 1); // simplify int src = 0; if (i > 0) { src = (FNT(ci - 2) << 8) | FNT(ci - 1); width -= src; } return width; }
int DrawChar(int xx, int yy, int c) { //byte* f = Verdana_font_11; if (c == 32) return FNT(1)>>2; // Space is 1/4 font height (yuk); int i = c - FNT(3); if (i < 0 || i >= FNT(4)) return 0; int ci = 6 + i * 2; int width = (FNT(ci) << 8) | FNT(ci + 1); // simplify int height = FNT(1); int src = 0; if (i > 0) { src = (FNT(ci - 2) << 8) | FNT(ci - 1); width -= src; } // clip? src += (6 + 2 * FNT(4)) * 8; // start of pixels (roll into cols) byte mask = 0x80 >> (src & 7); // Mask at start of line int end = (src+width) >> 3; // number of bytes read src >>= 3; int makeup = FNT(5) - (end + 1 - src); for (byte y = 0; y < (byte)height; y++) { byte p = FNT(src++); byte m = mask; for (byte x = 0; x < (byte)width; x++) { if (p & m) Graphics::PutPixel(x + xx, y + yy); m >>= 1; if (m == 0) { p = FNT(src++); if (p == 0 && (width-x) <= 8) // early out break; m = 0x80; } } src += makeup; } return width; }
/** @brief Draws a char on the screen * @param xx Horizontal location to draw the char at * @param yy Vertical location to draw the char at * @param c char to draw * @todo clean this function up. It's messy and doesn't make sense (but it works..) */ int DrawChar(int xx, int yy, int c) { //uint8_t* f = Verdana_font_11; if (c == 32)// a space return FNT(1)>>2; // Space is 1/4 font height (yuk); int i = c - FNT(3); if (i < 0 || i >= FNT(4)) { return 0; } int ci = 6 + i * 2; int width = (FNT(ci) << 8) | FNT(ci + 1); // simplify int height = FNT(1); int src = 0; if (i > 0) { src = (FNT(ci - 2) << 8) | FNT(ci - 1); width -= src; } // clip? src += (6 + 2 * FNT(4)) * 8; // start of pixels (roll into cols) uint8_t mask = 0x80 >> (src & 7); // Mask at start of line int end = (src+width) >> 3; // number of bytes read src >>= 3; int makeup = FNT(5) - (end + 1 - src); for (uint8_t y = 0; y < (uint8_t)height; y++) { uint8_t p = FNT(src++); uint8_t m = mask; for (uint8_t x = 0; x < (uint8_t)width; x++) { if (p & m) { SetWrap(x + xx, y + yy, 1, 1); SetGRAM(); _ph = x; _pv = y; SolidFill(2); } m >>= 1; if (m == 0) { p = FNT(src++); if (p == 0 && (width-x) <= 8) // early out break; m = 0x80; } } src += makeup; } return width; }