Hi,

there's a bug in [CVS version of] the FT2 font provider when using 
Freetype build that only contains the monochrome ("raster") but not 
the grayscale ("smooth") rasterizer. DFB fails to render any text in 
this case, even though DFFA_MONOCHROME flag is used.

This is because even though load flags correctly contain 
FT_LOAD_TARGET_MONO, the get_glyph_info() function calls 
FT_Render_Glyph(face->glyph, ft_render_mode_normal) regardless of the 
flags. Attached patch fixes this by using ft_render_mode_mono if mono 
rendering was requested.

This should also make the returned glyph dimensions more accurate in 
the mono case, because now the exact same renderer that will be used 
to render the glyph is used to calculate the sizes.

Regards,
Vaclav

-- 
PGP key: 0x465264C9, available from http://pgp.mit.edu/
Index: interfaces/IDirectFBFont/idirectfbfont_ft2.c
===================================================================
RCS file: /cvs/directfb/DirectFB/interfaces/IDirectFBFont/idirectfbfont_ft2.c,v
retrieving revision 1.36
diff -u -u -r1.36 idirectfbfont_ft2.c
--- interfaces/IDirectFBFont/idirectfbfont_ft2.c	9 Nov 2006 10:59:30 -0000	1.36
+++ interfaces/IDirectFBFont/idirectfbfont_ft2.c	4 Dec 2006 13:13:50 -0000
@@ -55,6 +55,12 @@
 #include <misc/conf.h>
 #include <misc/util.h>
 
+#ifndef FT_LOAD_TARGET_MONO
+    /* FT_LOAD_TARGET_MONO was added in FreeType-2.1.3, we have to use (less good)
+       FT_LOAD_MONOCHROME with older versions. Make it an alias for code simplicity. */
+    #define FT_LOAD_TARGET_MONO FT_LOAD_MONOCHROME
+#endif
+
 
 static DFBResult
 Probe( IDirectFBFont_ProbeContext *ctx );
@@ -440,7 +446,8 @@
      }
 
      if (face->glyph->format != ft_glyph_format_bitmap) {
-          err = FT_Render_Glyph( face->glyph, ft_render_mode_normal );
+          err = FT_Render_Glyph( face->glyph,
+                                 (load_flags & FT_LOAD_TARGET_MONO) ? ft_render_mode_mono : ft_render_mode_normal );
           if (err) {
                D_ERROR( "DirectFB/FontFT2: Could not "
                          "render glyph for character index #%d!\n", index );
@@ -720,13 +727,8 @@
                load_mono = true;
      }
 
-     if (load_mono) {
-#ifdef FT_LOAD_TARGET_MONO  /* added in FreeType-2.1.3 */
+     if (load_mono)
           load_flags |= FT_LOAD_TARGET_MONO;
-#else
-          load_flags |= FT_LOAD_MONOCHROME;
-#endif
-     }
 
      if (!disable_charmap) {
           pthread_mutex_lock ( &library_mutex );
_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to