[fpc-devel] Possible bugs in TFreeTypeFont

Darius Blaszyk dhkblaszyk at zeelandnet.nl
Thu Dec 16 01:26:51 CET 2010


IMHO there is a bug in TFreeTypeFont.SetFlags. The check that determines
if the inherited method should be called seems to be wrong. Can someone
confirm? Please consider the following patch:

@@ -183,7 +183,7 @@
 
 procedure TFreeTypeFont.SetFlags (index:integer; AValue:boolean);
 begin
-  if not (index in [5,6]) then   // bold,italic
+  if (index in [5,6]) then   // bold,italic
     inherited SetFlags (index, AValue);
 end;

Secondly TFreeTypeFont.GetFlags seems to have a bug in as well. My class
that descends from TFreeTypeFont calls the Bold and Italic methods, but
never the correct setting is returned. Because the SetXXX method stores
the settings in FFlags, I would expect FFlags to be used to restore the
settings and not some value of FFace. I have modified the code (as seen
below), but I guess someone should reconsider this and determine if I am
right at this, or some other evaluation algorithm should be implemented
instead.
 
@@ -198,14 +198,14 @@
   if index = 5 then        //bold
     begin
     GetFace;
-    result := (FFace^.style_flags and FT_STYLE_FLAG_BOLD) <> 0;
+    //result := (FFace^.style_flags and FT_STYLE_FLAG_BOLD) <> 0;
     end
   else if index = 6 then    //italic
     begin
     GetFace;
-    result := (FFace^.style_flags and FT_STYLE_FLAG_ITALIC) <> 0;
-    end
-  else
+    //result := (FFace^.style_flags and FT_STYLE_FLAG_ITALIC) <> 0;
+    end;
+  //else
     result := inherited GetFlags (index);
 end;

Regards, Darius




More information about the fpc-devel mailing list