Free Support Forum -

Font.Convert or Font.SaveAsFormat is not working as expected


Using Aspose.Font .NET, i would like to convert CFF font to a TTF one.
Based on documentation, the Font.Convert or Font.SaveAsFormat can do that (only to TTF format).

But when i try to convert this CFF font (9.4 KB)
i get an exception :

String reference not set to an instance of a String. (Parameter ‘s’) at System.Text.Encoding.GetBytes(String s).

using this code snippet :

FontDefinition fd = new FontDefinition(FontType.CFF, new FileSystemStreamSource(fontPath));
var cffFont = Font.Open(fd) as CffFont;
TtfFont realTTFFont = (TtfFont) cffFont.Convert(FontType.TTF);
realTTFFont.Save(fontPath + ".realTTFFont.ttf");

The same on this TTF font (with OpenType outline), i want to save it as a real TTF file : (6.1 KB)

using this code snippet :

FontDefinition fd = new FontDefinition(FontType.TTF, new FontFileDefinition("ttf", new FileSystemStreamSource(fontPath)));
var ttfFont = Font.Open(fd) as TtfFont;
if (ttfFont.CffFont != null)
   var cffFont = ttfFont.CffFont;
   var realTTF = (TtfFont) cffFont.Convert(FontType.TTF);

Can you help me on this ?

2 posts were merged into an existing topic: Unusable extracted embedded font in this PDF