shithub: cstory

Download patch

ref: 7e04741c29d747c56000b78e4847b4be5d39ac13
parent: b56a49a1d590e4a1efac0ea93af08faee746daa2
author: Clownacy <Clownacy@users.noreply.github.com>
date: Wed Aug 7 18:31:45 EDT 2019

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.

--- a/src/Backends/Rendering/Software.cpp
+++ b/src/Backends/Rendering/Software.cpp
@@ -3,6 +3,7 @@
 #include <math.h>
 #include <stddef.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include "SDL.h"
 
@@ -386,7 +387,7 @@
 		case FONT_PIXEL_MODE_LCD:
 			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;
 
--- a/src/Font.cpp
+++ b/src/Font.cpp
@@ -1757,7 +1757,7 @@
 				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);
 	}