Fix bug in hx8357: rasterizing glyphs with width>16.

This commit is contained in:
Serge Vakulenko
2015-10-09 13:21:29 -07:00
parent 08edaaba8c
commit d2fb9b98a6
2 changed files with 42 additions and 32 deletions

View File

@@ -26,6 +26,9 @@ extern const struct gpanel_font_t font_digits20;
#define COLOR_YELLOW COLOR_RGB(31, 63, 0)
#define COLOR_MAGENTA COLOR_RGB(31, 0, 31)
#define COLOR_CYAN COLOR_RGB(0, 63, 31)
#define COLOR_RED COLOR_RGB(31, 0, 0)
#define COLOR_GREEN COLOR_RGB(0, 63, 0)
#define COLOR_BLUE COLOR_RGB(0, 0, 31)
/*
* Screen size.
@@ -35,26 +38,27 @@ int xsize, ysize;
void show(const struct gpanel_font_t *font, const char *title, int digits_only)
{
char line[100];
int x = 10;
int y = 10;
int x = 0, y = 0, i, color;
const char *phrase = digits_only ? "0123456789" :
"The quick brown fox jumps over the lazy dog.";
static const int colortab[] = {
COLOR_YELLOW, COLOR_CYAN, COLOR_MAGENTA,
COLOR_RED, COLOR_GREEN, COLOR_BLUE,
0,
};
gpanel_clear(COLOR_BLACK, 0, 0);
gpanel_text(&font_lucidasans15, COLOR_WHITE, COLOR_BLACK, x, y, title);
y += font_lucidasans15.height;
y += font_lucidasans15.height * 2;
gpanel_text(font, COLOR_YELLOW, COLOR_BLACK, x, y,
digits_only ? "0123456789"
: "The quick brown fox");
y += font->height;
for (i=0; y<ysize; i++) {
color = colortab[i];
if (color == 0)
color = colortab[i = 0];
gpanel_text(font, COLOR_CYAN, COLOR_BLACK, x, y,
digits_only ? "3456789012"
: "jumps over");
y += font->height;
gpanel_text(font, COLOR_MAGENTA, COLOR_BLACK, x, y,
digits_only ? "6789012345"
: "the lazy dog.");
gpanel_text(font, color, COLOR_BLACK, x, y, phrase);
y += font->height;
}
printf("Font %s: press Enter...", title);
fflush(stdout);

View File

@@ -420,7 +420,8 @@ static void newLine(const struct gpanel_font_t *font)
void drawGlyph(const struct gpanel_font_t *font,
int color, int background, int width, const unsigned short *bits)
{
int i, j;
int h, w;
unsigned bitmask = 0;
if (background >= 0) {
/*
@@ -430,33 +431,38 @@ void drawGlyph(const struct gpanel_font_t *font,
while (PMMODE & PIC32_PMMODE_BUSY);
PMADDR = 0x0001;
/* Loop on each glyph row, backwards from bottom to top. */
for (i=0; i<font->height; i++) {
unsigned glyph_row = bits[i];
/* Loop on each glyph row. */
for (h=0; h<font->height; h++) {
/* Loop on every pixel in the row (left to right). */
for (w=0; w<width; w++) {
if ((w & 15) == 0)
bitmask = *bits++;
else
bitmask <<= 1;
/* Loop on every two pixels in the row (left to right). */
for (j=0; j<width; j++) {
while (PMMODE & PIC32_PMMODE_BUSY);
if (glyph_row & 0x8000)
while (PMMODE & PIC32_PMMODE_BUSY)
;
if (bitmask & 0x8000)
PMDIN = color;
else
PMDIN = background;
glyph_row <<= 1;
}
}
} else {
/*
* Transparent background.
*/
/* Loop on each glyph row, backwards from bottom to top. */
for (i=0; i<font->height; i++) {
unsigned glyph_row = bits[i];
/* Loop on each glyph row. */
for (h=0; h<font->height; h++) {
/* Loop on every pixel in the row (left to right). */
for (w=0; w<width; w++) {
if ((w & 15) == 0)
bitmask = *bits++;
else
bitmask <<= 1;
/* Loop on every two pixels in the row (left to right). */
for (j=0; j<width; j++) {
if (glyph_row & 0x8000)
setPixel(_col + j, _row + i, color);
glyph_row <<= 1;
if (bitmask & 0x8000)
setPixel(_col + w, _row + h, color);
}
}
}