pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hesham G." <heshamgne...@gmail.com>
Subject Re: Using a system font file with loadTTF method
Date Sun, 03 Jun 2012 14:35:17 GMT
Andreas ,

Thanks for your reply 

>> These are all AWT-Fonts which can't be embedded to a pdf directly. They have to be
converted somehow. I guess there isn't any code to do that, but please prove me wrong if you
find something appropriate. ;-)
Actually there is, but for Windows operating system only :

File fontFile = new File( FontManager.getFontPath( true ) + "/" + "verdana.TTF" );
PDSimpleFont pdfFont = PDTrueTypeFont.loadTTF( pdfFile, fontFile );

The problem is that the FontManager does not work for Mac OS X.
Any idea Andreas how to do that ?


Best regards ,
Hesham 


---------------------------------------------
Included message :

> Hi,
> 
> Am 22.05.2012 15:45, schrieb Hesham G.:
>> Hello ,
>>
>> This is a more Java question rather than a PDFBox question : ) , but I can't find
an answer to it.
>>
>> I am trying to use a system font file in drawing text to a PDF file using PDFBox,
through the method :
>> PDTrueTypeFont.loadTTF( PDDocuent pdfFile, File fontFile );
>>
>> The problem here is that the loadTTF(...) method accepts a (File) object, while I
can only get the System font as a (Font) object using this code :
>> GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
>> Font[] fonts = e.getAllFonts();
> These are all AWT-Fonts which can't be embedded to a pdf directly. They have to
> be converted somehow. I guess there isn't any code to do that, but please prove
> me wrong if you find something appropriate. ;-)
> 
>> Where I get one of the (fonts) objects to use it. Is there a way to convert the Font
object to File object ?
>> I am using Mac OS X.
> All those awt-fonts should be related to a "real" font somewhere in the 
> filesystem. Maybe you are able to find them using the name from the AWT-Font? 
> Probably those have a suitable format which can be used within a pdf.
> 
>> Best regards ,
>> Hesham
> 
> 
> BR
> Andreas Lehmkühler
>
Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message