Applying Italic font to a TextArea

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v6)  /  Applying Italic font to a TextArea

DynamicPDF CoreSuite for .NET (v6) Forum

 Mar 01 2012 10:18 AM
It looks like it possible to create italic font using a FormattedTextArea.  Is is possible to create italic fonts using a TextArea?

I am creating a new OpenTypeFont:
ceTe.DynamicPDF.Text.OpenTypeFont font = new ceTe.DynamicPDF.Text.OpenTypeFont(@"C:\Windows\Fonts\LCALLIG.TTF");

I was hoping that I could make all the text italic that is in this TextArea:
TextArea taName = new TextArea("My text that should be italic", 50, 50, 200, 42, font, 42f, ceTe.DynamicPDF.TextAlign.Center);

I'm just not sure how to apply the italics to it.
Posted by a ceTe Software moderator
Hello,

Yes,  if you setting any font to the TextArea page element then the whole text in the TextArea is set with that font. You can set font to the TextArea at the time of creating TextArea object or by using Font property. Also you will need to make sure that the font which you are using supports italic style and this should work for you.

If you are observing any differences in the output then please send over the following details to our support team at: support@cete.com so that they can look into it further.

1.Complete code which you are using.
2.Output PDF document.
3.Font file which you are using.


Thanks,
ceTe Software Support Team.
Great.  So how to I make it be italics?  How would I make this font variable italics.  For example, what do I need to do to the "font" variable below to make it display in italics?

ceTe.DynamicPDF.Text.OpenTypeFont font = new ceTe.DynamicPDF.Text.OpenTypeFont(@"C:\Windows\Fonts\LCALLIG.TTF");
Posted by a ceTe Software moderator
Hello,

You will need to use font file path which has support for Italic text style.  Create OpenTypeFont object and set it to the TextArea object at the time of creating TextArea object or using Font property. Below is the sample code for it.

            Document document = new Document();
            Page page = new Page();
            document.Pages.Add(page);
        //Create font object using Italic font.        
            OpenTypeFont font = new OpenTypeFont(@"C:\WINDOWS\Fonts\ARIALI.TTF");
            TextArea textArea = new TextArea("This is text of a TextArea", 100, 100, 400, 30, font, 18);
            //textArea.Font = font;
            page.Elements.Add(textArea);
            document.Draw(@"C:\MyDocument.pdf");

Thanks,
ceTe Software Support Team.
I see. So it sounds like the font for italics is actually a different font file. As far as I can tell the font I am using is an italics font according to the properties displayed when I go to my windows/font directory in windows 7.  So when I open a word document and type something in a specific font and then I hit slanted "I" icon for italic how it that happening in Microsoft Word?  That italic font for "Lucida Calligraphy" is what I am trying to get in my pdf.  But it always comes out as the regular font.  In my fonts directory it shows as "Lucida Calligraphy Italic" as "LCALLIG.TTF".  But when I can't seem to get it to actually be italic, like it is in a Word Doc and that is how I must have it. Any suggestions?
Posted by a ceTe Software moderator
Hello,

In our API there is no equivalent of italic (I) button available in MS Word. The "Lucida Calligraphy Italic (LCALLIG.TTF) is already an italic font. If you run the below code you will notice the difference between the italic font and the regular font “Lucida Console Regular”. MS Word seems to be further italicizing the already italic font when you use the italic button and it is not possible to do the same in our API.

           Document document = new Document();
           Page page = new Page();
           document.Pages.Add(page);
          
           OpenTypeFont italicFont = new OpenTypeFont(@"C:\Windows\Fonts\LCALLIG.TTF"); //Lucida Calligraphy Italic
           TextArea textArea = new TextArea("This is text of a TextArea", 0, 100, 400, 30, italicFont, 18);
           
           OpenTypeFont regularFont = new OpenTypeFont(@"C:\Windows\Fonts\lucon.TTF"); //Lucida Console Regular
           TextArea textArea1 = new TextArea("This is text of a TextArea", 0, 200, 400, 30, regularFont, 18);
          
           page.Elements.Add(textArea);
           page.Elements.Add(textArea1);

           document.Draw(@"C:\MyDocument.pdf");

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 2:47 AM.