Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2010-12

Possible bugs in TFreeTypeFont

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Darius Blaszyk

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

Reply by email

Darius Blaszyk
to Darius Blaszyk

Should I create a bug report for this?

Regards, Darius

Darius Blaszyk wrote 47 lines
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 _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email