Load TTC font?

Hello,

I have an exception when i try to load a TTC (TrueType Collection) file.
Is Aspose.Font compatible with this Font type ?

To reproduce, try loading C:\WINDOWS\Fonts\cambria.ttc (on a windows machine of course…) with aspose.font (in .net)

If not, it should be added to Aspose.Font. If yes, this is a bug so.
Thanks

@tfipsrd

An investigation ticket as FONTNET-213 has been logged in our issue tracking system to analyze the support of TTC fonts. We will look into ticket details and keep you posted with the status of its resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

@tfipsrd

TTC (TrueType Collection) font file is a collection of fonts and it usually includes more than one font. So, the approach to use method Aspose.Font.Font.Open(FontDefinition) cannot get what you want, cause this method can return only single font and there is a question - what font (by number) must be returned?

In order to access TTC files, Aspose.Font provides class Aspose.Font.Ttf.TtcFontSource. Method GetFontDefinitions() of this class returns Aspose.Font.Sources.FontDefinition object for every font in font collection. In order to get desired font, just pass correspondent FontDefinition object to method Aspose.Font.Font.Open(FontDefinition).

For example, fonts from file cambria.ttc can be loaded with code snippet like this:

TtcFontSource source = new TtcFontSource(@"C:\Windows\Fonts\cambria.ttc");
FontDefinition[] fds = source.GetFontDefinitions();
for (int index = 0; index < fds.Length; index++)
{
 TtfFont ttfFont = Aspose.Font.Font.Open(fds[index]) as TtfFont;            
}
// 2 fonts - "Cambria", "Cambria Math" will be loaded 

The ticket has been closed now.