We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

HTML to PNG - Ad-hoc TTF Fonts not being used

Hello

I have an HTML document which I have successfully converted to PNG. In the HTML the TTFs are defined in the style tag. However the fonts are not being converted. The fonts are all in the Windows\Fonts folder as well as the directory where the HTML document is found. I added both folders to the SetFontsFolders method with recursive set to true. The fonts are still not used. What am I doing wrong?

Regards,
Simon

@Paula_Sartini,

Thanks for your inquiry. Please ZIP and attach your 1) input HTML file, 2) Aspose.Words generated output PNG file showing the undesired behavior and 3) font files used in the HTML here for testing. We will investigate the issue on our end and provide you more information.

Best regards,
Awais Hafeez

signature.zip (601.8 KB)

Hello Awais

I have attached the zip file with the signature.html file and the other supporting documents. You will see the fonts which we
are using in the Fonts folder. It is the San Source which we are using. You will see it referenced in the HTML file. If we view
the signature file in Google Chrome it converts perfectly. I am running v17.7 as I upgraded to the latest version last week.

Regards,
Simon

@Paula_Sartini,

We have logged this issue in our bug tracking system. The ID of this issue is WORDSNET-15711. Your thread has also been linked to this issue and you will be notified as soon as it is resolved. Sorry for the inconvenience.

Best regards,
Awais Hafeez

@Paula_Sartini,

Aspose.Words currently does not support @font-face rules on import and ignores all such declarations. Unfortunately, we currently have no plans to implement this feature. The reason why Aspose.Words ignores fonts when they are installed locally or specified via FontSettings is that in HTML fonts are referenced by names specified in @font-face rules, while Aspose.Words uses names specified in TTF files. If you please change HTML as follows, both browsers and Aspose.Words will be able to use the fonts:

<style>
    @font-face {
        font-family: 'Source Sans Pro Semibold';
        src: url("./fonts/SourceSansPro-Semibold.ttf") format("truetype");
    }
    
    @font-face {
        font-family: 'Source Sans Pro';
        src: url("./fonts/SourceSansPro-Regular.ttf") format("truetype");
    }
    
    @font-face {
        font-family: 'Source Sans Pro';
        font-weight: bold;
        src: url("./fonts/SourceSansPro-Bold.ttf") format("truetype");
    }
</style>
 
<!--
Font usage:
    <font face="Source Sans Pro" ...> instead of <font face="SourceSansPro-Regular" ...>
    <font face="Source Sans Pro" style="font-weight: bold" ...> instead of <font face="SourceSansPro-Bold" ...>
    <font face="Source Sans Pro Semibold" ...> instead of <font face="SourceSansPro-Semibold" ...>
-->

Best regards,
Awais Hafeez

Awaiz I am a bit lost here. You said the @font-face is not used by Aspose. Is this correct?

I tried another font family and it still doesn’t work. Must I open the TTF font in Windows and see what it is called and then use that font name in the face property in the tag and then drop the @font-face completely from the HTML?

@Paula_Sartini,

Yes, it is currently ignored by Aspose.Words.

Yes, you can use this as a temporary workaround (see my previous reply for details). We will inform you via this thread as soon as Aspose.Words supports @font-face rules.

Best regards,

It worked. Thank you very much.