[fpc-pascal] Implementing AggPas with PtcGraph

James Richters james at productionautomation.net
Wed Jun 14 20:15:08 CEST 2017


I finally got freetype to work with AggPas, but I had to make a few changes.  I am wondering if there is a way to submit a request for changes so they will be part of the next release?

Here is what I found out... 
Freetype.dll included in fpgui_src_1.4.1.zip indeed does not have a dependency for msvcr71.dll... however,  it only works if I compile with Win32.

I did some searching and came up with something called libfreetype-6.dll listed as a 64bit Freetype library, so I copied that over and renamed it to freetype.lib, and now my Win64 program uses it and works... but as expected, the Win32 program no longer works.  

So I did some digging and fount 'freetype.dll' being assigned in agg_font_freetype_lib.pas on line 42 as follows:
-------------------------------------------------------------------------
const
{$IFDEF WINDOWS }
  ft_lib = 'freetype.dll';
{$ENDIF }

// Linux, FreeBSD etc.
{$if defined(UNIX) and not defined(darwin)}
  ft_lib = 'freetype';
{$ENDIF }

// Mac OS X
{$ifdef darwin}
  ft_lib = 'libfreetype';
{$ENDIF }
-------------------------------------------------------------------------
So I changed the Windows section to:
{$IFDEF WINDOWS }
{$IFDEF CPU64 }
  ft_lib = 'libfreetype-6.dll';
{$Else }
  ft_lib = 'freetype.dll';
{$ENDIF }
{$ENDIF }

Now if I compile it Win64 it uses the 64bit library and if I compile it Win32 it uses the 32bit library, this way I can just randomly create whatever type program I want and get the correct library.   I suppose something similar would be needed for other platforms but have no way to test it.

Also I had issues with using freetype at all.  I used 
Writeln('FreeType: ',Agg2DUsesFreeType,'  Win32 True Type: ',Agg2DUsesWin32TrueType); 
To show which font method was being used and found my program was using win32 true type fonts

So I went to Agg_2D.pas on line 25 and found this:

// With this define uncommented you can use FreeType font engine
{ $DEFINE AGG2D_USE_FREETYPE }

It took me a while to figure out that the space between ( and $ was making this into a comment,  it would have been more clear to comment it out like:
//{$DEFINE AGG2D_USE_FREETYPE}  

But in any case I did figure it out and uncommented it,  but then I could not compile it because of:
agg_2D.pas(142,15) Error: Duplicate identifier "FontEngine"

So Agg_2D.pas line 138 - 143 are:
{$IFDEF AGG2D_USE_FREETYPE }
 FontEngine = font_engine_freetype_int32;
{$ENDIF }
{$IFDEF AGG2D_USE_WINFONTS}
 FontEngine = font_engine_win32_tt_int32;
{$ENDIF }

The only way the FontEngine = font_engine_win32_tt_int32; on line 142 could cause this error is if both  AGG2D_USE_WINFONTS and  AGG2D_USE_FREETYPE were defined.  I looked around and could not find where AGG2D_USE_WINFONTS was defined, but it seems obvious that both cannot be defined at once so I changed from line 25 in Agg_2D.pas to this:
// With this define uncommented you can use FreeType font engine
//{$DEFINE AGG2D_USE_FREETYPE}

{$IFDEF AGG2D_USE_FREETYPE }
  {$UNDEF AGG2D_USE_WINFONTS}
{$ENDIF }

And now if I run it as above I get Win32 true type fonts and if I comment out the freetype define I get freetype fonts.

I noticed that with the freetype define comment out, adding it to my program could not make it work.  I would prefer a method that did not involve modifying the Agg_2D unit to change which font package to use.

Also,  I have copied Agg_2D.pas to Agg_2D_RBG565.pas and modified that one as needed for ptcgraph.  I wonder if it would be beneficial to add this modified version of the unit to the development system so eventually it will be included in the official release.  That way everyone working on it and / or testing it are using the same thing, and people can have programs that use either unit side by side without remembering how to modify / unmodify a unit to make it work.    I'm not sure where the proper place is to submit things like this, but I would be happy to contribute these changes if possible.

James



-----Original Message-----
From: fpc-pascal [mailto:fpc-pascal-bounces at lists.freepascal.org] On Behalf Of James Richters
Sent: Wednesday, June 14, 2017 11:54 AM
To: 'FPC-Pascal users discussions' <fpc-pascal at lists.freepascal.org>
Subject: Re: [fpc-pascal] Implementing AggPas with PtcGraph

All this has me wondering about the freetype.dll version.  I've been using freetype.dll that I found in AggPas24-rm3.zip modified 9/17/2007 I notice there is another one in fpgui_src_1.4.1.zip in the fpgui-1.4.1\extras\freetype_windows directory modified 12/9/2012  Is this the best version to use?  

I was hoping to figure out a way to not have the dependency of msvcr71.dll I tried going all over https://www.freetype.org and even downloaded ft28.zip from there and tried to make sense of it, but just got more confused I haven't tried the version of freetype.dll included with fpgui yet, I thought I would just ask first

James

_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal




More information about the fpc-pascal mailing list