12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #include "font.h"
- #include "odroid/display.h"
- #include "text.h"
-
-
- static const int MAX_GLYPHS_PER_ROW = LCD_WIDTH / GLYPH_WIDTH;
- static const int MAX_GLYPHS_PER_COL = LCD_HEIGHT / GLYPH_HEIGHT;
-
- void DrawText(uint16_t* framebuffer, char* string, int length, int x, int y, uint16_t color)
- {
- assert(x + length <= MAX_GLYPHS_PER_ROW);
- assert(y <= MAX_GLYPHS_PER_COL);
-
- for (int charIndex = 0; charIndex < length; ++charIndex)
- {
- char c = string[charIndex];
-
- if (c == ' ')
- {
- continue;
- }
-
- int xStart = GLYPH_WIDTH * (x + charIndex);
- int yStart = GLYPH_HEIGHT * y;
-
- for (int row = 0; row < GLYPH_HEIGHT; ++row)
- {
- for (int col = 0; col < GLYPH_WIDTH; ++col)
- {
- int bitPosition = 1U << (15U - col);
- int glyphIndex = GetGlyphIndex(c);
-
- uint16_t pixel = glyphMap[glyphIndex][row] & bitPosition;
-
- if (pixel)
- {
- int screenX = xStart + col;
- int screenY = yStart + row;
-
- framebuffer[screenY * LCD_WIDTH + screenX] = color;
- }
- }
- }
- }
- }
|