Hello Werner, Alexie,
> I've polished your SDF driver; see the 'sdf' branches in both the
> 'freetype2' and 'freetype2-demos' repositories. Basically, it's ready
> to be merged with 'master' :-)
Thanks for polishing the modules, they look great now. I'm happy that
the driver will finally be merged with 'master' :-)
> Note, however, that there is a problem with the graphics display: On
> Linux, something has changed in the graphics driver of the demos –
> instead of a single image I get four, with stripes (see attached
> image).
The issue is on windows as well. It is a mistake from my end, when I
wrote the demo program I assumed that the surface bitmap is 24 bits
per pixel, but it is 32 bits per pixel now. I have attached a patch below
( sdf_fix.txt ) to fix the problem, if you'd like, I can apply it to the
`sdf' branch.
There are a couple more issues on windows:
Firstly, Building the library on windows with gnu make give me the
following error:
---
Copying files from `submodules/dlg' to `src/dlg'
A subdirectory or file src\dlg\dlg already exists.
builds/toplevel.mk:127: *** missing separator. Stop.
---
I tried using two versions of gnu make ( i.e. 3.81 and 4.3 ), and both
give me the exact same error. I don't have much idea about the error, but
it only occurs with the '$(COPY)' command ( 'mkdir' and 'del' works fine ).
Please do check it out. It might as well be the case with my system, so
I will let you know if I figure something out.
Lastly, in the demos program, the symbol 'LCS_sRGB' is not defined, due
to which the build fails on windows. The MSDN page only list one value for
the field 'bV4CSType' and that is 'LCS_CALIBRATED_RGB', so changing the
value on line 267 fixes the error. I have attached a patch for this too. (
fix_build_windows.txt )
> In the long run, ftsdf needs to become more agnostic to the display
> mode. Right now it writes directly to the buffer assuming 24-bit
> (rgb888).
Right! I initially just wrote the program quickly to view the output of the
renderers, I hardcoded a few things which can cause issues in the future.
I will rewrite the entire program once I get some time from my college.
If there is anything else please do let me know.
Thanks and Regards,
Anuj
diff --git a/graph/win32/grwin32.c b/graph/win32/grwin32.c
index 85a6ebe..9dfcf1e 100644
--- a/graph/win32/grwin32.c
+++ b/graph/win32/grwin32.c
@@ -264,7 +264,7 @@ gr_win32_surface_set_icon( grWin32Surface* surface,
BITMAPV4HEADER hdr = { sizeof( BITMAPV4HEADER ),
0, 0, 1, 32, BI_BITFIELDS, 0, 0, 0, 0, 0,
0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000,
- LCS_sRGB };
+ LCS_CALIBRATED_RGB };
if ( !icon )
diff --git a/ChangeLog b/ChangeLog
index 73db727..fcfebf1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2020-12-23 Anuj Verma <[email protected]>
+
+ [ftsdf] Fix glyph rendering issue.
+
+ * src/ftsdf.c (draw): Compute the number of
+ bits per pixel, rather than assuming 24 bits
+ per pixel.
+
2020-08-24 Anuj Verma <[email protected]>
[ftsdf] Add better usage section.
diff --git a/src/ftsdf.c b/src/ftsdf.c
index 8d7ef88..568da89 100644
--- a/src/ftsdf.c
+++ b/src/ftsdf.c
@@ -437,11 +437,16 @@
Vec2 center;
FT_Short* buffer;
-
+ FT_Int bytes_per_pixel;
if ( !bitmap || !bitmap->buffer )
return FT_Err_Invalid_Argument;
+ /* compute the number of bytes per pixel of the window surface */
+ bytes_per_pixel = display->bitmap->pitch / display->bitmap->width;
+ bytes_per_pixel = bytes_per_pixel < 0 ?
+ -bytes_per_pixel : bytes_per_pixel;
+
/* compute center of display */
center.x = display->bitmap->width / 2;
center.y = display->bitmap->rows / 2;
@@ -600,10 +605,11 @@
alpha *= 255;
/* finally copy the target value to the display buffer */
- display_index *= 3;
- display->bitmap->buffer[display_index + 0] = (unsigned char)alpha;
- display->bitmap->buffer[display_index + 1] = (unsigned char)alpha;
- display->bitmap->buffer[display_index + 2] = (unsigned char)alpha;
+ display_index *= bytes_per_pixel;
+ for ( FT_Int pixel = 0; pixel < bytes_per_pixel; pixel++ ) {
+ display->bitmap->buffer[display_index + pixel] =
+ (unsigned char)alpha;
+ }
}
else
{
@@ -622,10 +628,11 @@
final_dist *= 255;
/* finally copy the target value to the display buffer */
- display_index *= 3;
- display->bitmap->buffer[display_index + 0] = (unsigned
char)final_dist;
- display->bitmap->buffer[display_index + 1] = (unsigned
char)final_dist;
- display->bitmap->buffer[display_index + 2] = (unsigned
char)final_dist;
+ display_index *= bytes_per_pixel;
+ for ( FT_Int pixel = 0; pixel < bytes_per_pixel; pixel++ ) {
+ display->bitmap->buffer[display_index + pixel] =
+ (unsigned char)final_dist;
+ }
}
}
}