You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by "Hesham G." <he...@gmail.com> on 2010/01/07 22:42:50 UTC

How to sent font bold or italic ?

Hello ,

This seems an easy question, but I couldn't find an answer for it yet. I load a font file to draw text using it, but I want to make this font italic or bold .... How can I do that ?

PDTrueTypeFont font = PDTrueTypeFont.loadTTF( pdfFile, new File( "fonts/georgia.TTF" ) );

font.getFontDescriptor().setItalic( true );   // Not working !!

font.getFontDescriptor().setItalicAngle(45);   // Not working !!

font.getFontDescriptor().setForceBold( true );   // Not working !!


Best regards ,
Hesham

Re: How to sent font bold or italic ?

Posted by "Hesham G." <he...@gmail.com>.
I can now define my font file normally, and i wrote text using it in the PDF 
nicely ... There is a small issue about highlighting :
When I open the generated PDF file and select the text that was drawn using 
the external font, the highlighting does not select all the text height ... 
It seems it detects the height wrong.

I have seen a class in PDFBox concerning highlighting ... So can I set the 
right font height through it  ?
Here is a PDF file sample : 
http://www.4shared.com/file/192188394/a13fcfd3/test-highlight.html

Best regards ,
Hesham



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


From: "Andreas Lehmkuehler" <an...@lehmi.de>
Sent: Friday, January 08, 2010 10:27 AM
To: <us...@pdfbox.apache.org>
Subject: Re: How to sent font bold or italic ?

> Hi,
>
> Hesham G. schrieb:
>> Hello ,
>>
>> This seems an easy question, but I couldn't find an answer for it yet. I 
>> load a font file to draw text using it, but I want to make this font 
>> italic or bold .... How can I do that ?
>>
>> PDTrueTypeFont font = PDTrueTypeFont.loadTTF( pdfFile, new File( 
>> "fonts/georgia.TTF" ) );
>>
>> font.getFontDescriptor().setItalic( true );   // Not working !!
>>
>> font.getFontDescriptor().setItalicAngle(45);   // Not working !!
>>
>> font.getFontDescriptor().setForceBold( true );   // Not working !!
> Just try to use the italic type of the wanted font. AFAIU those attributes 
> are only used as a description of the font and not for rendering it.
>
>> Best regards ,
>> Hesham
>
>
> BR
> Andreas Lehmkühler
> 

Re: How to sent font bold or italic ?

Posted by "Hesham G." <he...@gmail.com>.
Thanks Andreas ... I have opened the fonts folder in my operating system, 
and I noticed that there is a font/font-italic/font-bold files for each font 
.... It's my first time to understand this. I thought when I say 
setForceBold( true ); it will automatically draw the font thicker.


Best regards ,
Hesham


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

--------------------------------------------------
From: "Andreas Lehmkuehler" <an...@lehmi.de>
Sent: Friday, January 08, 2010 10:27 AM
To: <us...@pdfbox.apache.org>
Subject: Re: How to sent font bold or italic ?

> Hi,
>
> Hesham G. schrieb:
>> Hello ,
>>
>> This seems an easy question, but I couldn't find an answer for it yet. I 
>> load a font file to draw text using it, but I want to make this font 
>> italic or bold .... How can I do that ?
>>
>> PDTrueTypeFont font = PDTrueTypeFont.loadTTF( pdfFile, new File( 
>> "fonts/georgia.TTF" ) );
>>
>> font.getFontDescriptor().setItalic( true );   // Not working !!
>>
>> font.getFontDescriptor().setItalicAngle(45);   // Not working !!
>>
>> font.getFontDescriptor().setForceBold( true );   // Not working !!
> Just try to use the italic type of the wanted font. AFAIU those attributes 
> are only used as a description of the font and not for rendering it.
>
>> Best regards ,
>> Hesham
>
>
> BR
> Andreas Lehmkühler
> 

Re: How to sent font bold or italic ?

Posted by Andreas Lehmkuehler <an...@lehmi.de>.
Hi,

Hesham G. schrieb:
> Hello ,
> 
> This seems an easy question, but I couldn't find an answer for it yet. I load a font file to draw text using it, but I want to make this font italic or bold .... How can I do that ?
> 
> PDTrueTypeFont font = PDTrueTypeFont.loadTTF( pdfFile, new File( "fonts/georgia.TTF" ) );
> 
> font.getFontDescriptor().setItalic( true );   // Not working !!
> 
> font.getFontDescriptor().setItalicAngle(45);   // Not working !!
> 
> font.getFontDescriptor().setForceBold( true );   // Not working !!
Just try to use the italic type of the wanted font. AFAIU those attributes are 
only used as a description of the font and not for rendering it.

> Best regards ,
> Hesham


BR
Andreas Lehmkühler