Free Support Forum - aspose.com

How to use TTC fonts

Hi ,

I tried but doesn't work. I believed it is because of the font.

Here is my simple xml file
.

Here is my code

Pdf pdf1 = new Pdf();
pdf1.BindXML("name.xml", null);
Section sec1 = pdf1.Sections[0];
Text text1 = (Text) sec1.Paragraphs[0];
Segment s1 = text1.Segments[0];
s1.TextInfo.FontName = "SimSun & NSimSun";
pdf1.Save("name.pdf");



How should I do to make it right. The PDF file generated is alright for my english name, but the Chinese counter part is blank. BTW I am using Traditional Chinese(Big 5) if you can't see the above xml file.
Thanks.

Dear Dean,

Thank you for considering aspose.

A TrueType Collection(TTC) contains more than one TrueType fonts. For example, MSMINCHO.TTC contains two TrueType fonts: MS Mincho and MS PMincho. In Aspose.Pdf, If you want to use TTC, you should specify the font file name like “c:/windows/fonts/MSMINCHO.TTC,0”. The string before the comma is the font collection file name and the number after the comma is the font number. “c:/windows/fonts/MSMINCHO.TTC,0” means the first font in the MS Mincho collection. Please refer to Truetype Fonts for detail.

Add in order to use chinese, you should set IsUnicode to true and IsAlignedByWord to false.
So your code should be:

s1.TextInfo.TruetypeFontFileName = “c:/windows/fonts/simsun.ttc,0”;
s1.TextInfo.IsUnicode = true;
text1.IsAlignedByWord = false;