Correct the rendering backend glyph API, and add a missing #include
For some reason, FT_BITMAP's 'width' member specifies subpixels, not pixels as the documentation says.
This commit is contained in:
parent
b56a49a1d5
commit
7e04741c29
2 changed files with 3 additions and 2 deletions
|
@ -3,6 +3,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
|
@ -386,7 +387,7 @@ void Backend_DrawGlyph(Backend_Surface *surface, Backend_Glyph *glyph, long x, l
|
||||||
case FONT_PIXEL_MODE_LCD:
|
case FONT_PIXEL_MODE_LCD:
|
||||||
for (unsigned int iy = MAX(-y, 0); y + iy < MIN(y + glyph->height, surface->height); ++iy)
|
for (unsigned int iy = MAX(-y, 0); y + iy < MIN(y + glyph->height, surface->height); ++iy)
|
||||||
{
|
{
|
||||||
for (unsigned int ix = MAX(-x, 0); x + ix < MIN(x + glyph->width / 3, surface->width); ++ix)
|
for (unsigned int ix = MAX(-x, 0); x + ix < MIN(x + glyph->width, surface->width); ++ix)
|
||||||
{
|
{
|
||||||
const double *font_pixel = (double*)glyph->pixels + (iy * glyph->width + ix) * 3;
|
const double *font_pixel = (double*)glyph->pixels + (iy * glyph->width + ix) * 3;
|
||||||
|
|
||||||
|
|
|
@ -1757,7 +1757,7 @@ static CachedGlyph* GetGlyphCached(FontObject *font_object, unsigned long unicod
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
glyph->backend = Backend_LoadGlyph(bitmap.buffer, bitmap.width, bitmap.rows, bitmap.pitch, bitmap.num_grays, pixel_mode);
|
glyph->backend = Backend_LoadGlyph(bitmap.buffer, pixel_mode == FONT_PIXEL_MODE_LCD ? bitmap.width / 3 : bitmap.width, bitmap.rows, bitmap.pitch, bitmap.num_grays, pixel_mode);
|
||||||
|
|
||||||
FT_Bitmap_Done(font_object->library, &bitmap);
|
FT_Bitmap_Done(font_object->library, &bitmap);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue