It has been quite a while since I made anything with freetype, but I seem to remember the vector format being fixed point. If that is the case, you'll need to convert the coordinates.
-----Original Message----- From: Marco Wertz Sent: 10/24/2014 14:55 To: [email protected] Subject: [ft] Drawing filled shapes with FreeType2 Hi, I'd like to use FreeType2 to draw some filled shapes (graphics primitives). To get started, I thought let's just try something very simple and have FreeType2 draw a filled rectangle. Unfortunately, it doesn't work. The code is supposed to draw a 640x480 filled rectangle into a memory buffer. However, FreeType2 draws only a very small rectangle that is maybe 16x16 into my memory buffer. Here's my code: --------------------------------------------------------------------------------------- #define WIDTH 640 #define HEIGHT 480 FT_Stroker stroker; FT_Outline outline; FT_Vector v; FT_Bitmap bm; void *buffer = malloc(WIDTH * HEIGHT); FT_Stroker_New(freetype_library, &stroker); v.x = 0; v.y = 0; FT_Stroker_BeginSubPath(stroker, &v, FALSE); v.x = WIDTH; FT_Stroker_LineTo(stroker, &v); v.y = HEIGHT; FT_Stroker_LineTo(stroker, &v); v.x = 0; FT_Stroker_LineTo(stroker, &v); v.y = 0; FT_Stroker_LineTo(stroker, &v); FT_Stroker_EndSubPath(stroker); FT_Outline_New(freetype_library, 1024, 512, &outline); FT_Stroker_Export(stroker, &outline); memset(&bm, 0, sizeof(FT_Bitmap)); bm.rows = HEIGHT; bm.width = WIDTH; bm.pitch = WIDTH; bm.buffer = buffer; bm.num_grays = 256; bm.pixel_mode = FT_PIXEL_MODE_GRAY; FT_Outline_Get_Bitmap(freetype_library, &outline, &bm); --------------------------------------------------------------------------------------- Can anybody say what's wrong there? I've checked out the documentation already but I don't see what's wrong there... I've also checked the outline's boundaries using FT_Outline_Get_BBox() and it returns the correct dimensions, i.e. 0/0/640/480. However, FreeType2 only draws a few pixels.... why? Thanks! Marco
_______________________________________________ Freetype mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/freetype
