Browse Source

Patch from Dirk Fellenberg to fix freetype font output, see bug #17156. Also other improvements made by me to improve how freetype linking and font searching under Mac OS X

git-svn-id: trunk@15827 -
sekelsenmat 15 years ago
parent
commit
fdbcb24aef
2 changed files with 38 additions and 7 deletions
  1. 11 1
      packages/fcl-image/src/freetype.pp
  2. 27 6
      packages/fcl-image/src/freetypeh.pp

+ 11 - 1
packages/fcl-image/src/freetype.pp

@@ -162,7 +162,14 @@ const
   sErrDestroying : string = 'finalizing FreeType';
 
   DefaultFontExtention : string = '.ttf';
+
+  // Standard location for fonts in the Operating System
+  {$ifdef Darwin}
+  DefaultSearchPath : string = '/Library/Fonts/';
+  {$else}
   DefaultSearchPath : string = '';
+  {$endif}
+
   {$IFDEF MAC}
   DefaultResolution : integer = 72;
   {$ELSE}
@@ -729,7 +736,10 @@ begin
         end;
       end;
     // place position for next glyph
-    pos.x := pos.x + (gl^.advance.x shr 10);
+    // The previous code in this place used shr 10, which
+    // produces wrongly spaced text and looks very ugly
+    // for more information see: http://bugs.freepascal.org/view.php?id=17156
+    pos.x := pos.x + (gl^.advance.x shr 11);
     // pos.y := pos.y + (gl^.advance.y shr 6); // for angled texts also
     if prevx > pos.x then
       pos.x := prevx;

+ 27 - 6
packages/fcl-image/src/freetypeh.pp

@@ -15,17 +15,38 @@
 {$mode objfpc}
 unit freetypeh;
 
-{ These are not all the availlable calls from the dll, but only those
-  I needed for the TStringBitMaps }
+{ Note that these are not all the availlable calls from the dll yet.
+  This unit is used by TStringBitMaps and FTFont }
 
 interface
 
 const
-{$ifdef win32}
+
+{$packrecords c}
+
+// Windows
+{$ifdef windows}
   freetypedll = 'freetype-6.dll';   // version 2.1.4
-  {$packrecords c}
-{$else}
-  // I don't know what it will be ??
+  {$define ft_found_platform}
+{$endif}
+// Mac OS X
+{$ifdef darwin}
+  freetypedll = 'libfreetype'; // Doesn't seam to matter much.
+  {$linklib freetype}          // This one is the important part,
+                               // but you also need to pass to fpc
+                               // the following command:
+                               // -k-L/usr/X11/lib
+                               // or another place where it can find
+                               // libfreetype.dylib
+  {$define ft_found_platform}
+{$endif}
+// LINUX
+{$if defined(UNIX) and not defined(darwin)}
+  freetypedll = 'freetype';
+  {$define ft_found_platform}
+{$endif}
+// Other platforms
+{$ifndef ft_found_platform}
   freetypedll = 'freetype';
 {$endif}