[fpc-pascal] Implementing AggPas with PtcGraph
    James Richters 
    james at productionautomation.net
       
    Fri Jun 16 19:49:43 CEST 2017
    
    
  
I've been able to use windows fonts with aggpas with the following code:
 
   agg^.Font('ConsolaB.ttf' ,45 );
   agg^.Text(300 ,100 ,'Text Here' );
and it works fine if I copy the font to the same folder as my program.  I'm wondering how I can just use standard windows fonts without copying them... but not assuming windows is installed in c:\windows
agg^.Font('C:\Windows\Fonts\ConsolaB.ttf' ,45 )
works fine, but as I mentioned I can't be sure windows is installed in C:\Windows
I would like to do something like: 
agg^.Font('%windir%\Fonts\ConsolaB.ttf' ,45 );
but of course that won't work because the %windir% variable only works in batch files.   
Is there some other way I can capture the install directory of windows, or the system so I can make this work properly?
Also, while I was tinkering with this,  I also wanted to see what differences there are between Freetype and Windows True Type fonts, and I noticed something odd.. 
If I compile with {$DEFINE AGG2D_USE_FREETYPE }  it works fine... but if I compile with it commented out,  it does work, and I get text on the screen, but the font is not the one I selected.  It seems to be a default font that I can't change. Does the font need to be defined differently if using Win32 TT font engine?    I am using the current 'develop' branch of fpGUI version of aggpas now.  I have not tried it with the release version.
I'm also wondering if there is a way to specify the font by the name used by windows applications, or is that more complicated than it is really worth?
James
    
    
More information about the fpc-pascal
mailing list