Word to html font issue

I have issue of while converting word to html. it is not giving exact font like word.

Font name in word : Bahnschrift Condensed
Font family in html : Bahnschrift

@mayurb Could you please attach sample input and output documents here for testing? We will check the issue and provide you more information.

TextFontTypesAll.docx (31.9 KB)
input.zip (1.8 MB)
@alexey.noskov
I attached input and output in screen shot where font mismatch

@mayurb The problem might occur because the specified fonts are not available in the environment where document rendering is performed. In this case Aspose.Words substitutes the missed fonts. You can implement IWarningCallback to get a notification when font substitution is performed.

On my side the following fonts used in your document are not available. Could you please attach them for testing?

  • Bahnschrift Condensed
  • Bahnschrift Light
  • Bahnschrift Light Condensed
  • Bahnschrift Light SemiCondensed
  • Bahnschrift SemiBold
  • Bahnschrift SemiBold Condensed
  • Bahnschrift SemiBold SemiConden
  • Bahnschrift SemiCondensed
  • Bahnschrift SemiLight
  • Bahnschrift SemiLight Condensed
  • Bahnschrift SemiLight SemiConde
  • Source Sans Pro

@alexey.noskov I can see all font loaded when document in loaded and i also can see that font in wordtohtml.FontInfos property but when it is converting to html it taking only parent font like * Bahnschrift Condensed then * Bahnschrift.

This is not see when using htmlSaveoption(it’s work) but we find this issue in HtmlFixedSaveoption.

Thank you
Mayur

myfonts.zip (410.5 KB)
@alexey.noskov
I am attaching that font. it work only window because it’s MS office inbuilt font family.

@mayurb Thank you for additional information. HTML is flow format and fonts are not required to render it, but HTML Fixed is fixed page format, more like PDF or XPS. To save in HtmlFixed format document layout should be performed and fonts are required for this process. The fonts you have attached does not include all requested fonts. For example see the following code:

Document doc = new Document(@"C:\Temp\in.docx");
doc.FontSettings = new FontSettings();
doc.FontSettings.SetFontsSources(new FontSourceBase[] { new SystemFontSource(), new FolderFontSource(@"C:\Temp\fonts", true) });
doc.WarningCallback = new WarningCallback();
HtmlFixedSaveOptions opt = new HtmlFixedSaveOptions();
opt.PrettyFormat = true;
doc.Save(@"C:\Temp\out.html", opt);
private class WarningCallback : IWarningCallback
{
    public void Warning(WarningInfo info)
    {
        if (info.WarningType == WarningType.FontSubstitution)
            Console.WriteLine(info.Description);
    }
}

C:\Temp\fonts folder contain the fonts you have attached. And here are warnings produced by this code:

Font 'Bahnschrift Condensed' has not been found. Using 'Bahnschrift' font instead. Reason: font info substitution.
Font 'Bahnschrift Light' has not been found. Using 'Bahnschrift' font instead. Reason: font info substitution.
Font 'Bahnschrift Light Condensed' has not been found. Using 'Bahnschrift' font instead. Reason: font info substitution.
Font 'Bahnschrift Light SemiCondensed' has not been found. Using 'Bahnschrift' font instead. Reason: font info substitution.
Font 'Bahnschrift SemiBold' has not been found. Using 'Bahnschrift' font instead. Reason: font info substitution.
Font 'Bahnschrift SemiBold Condensed' has not been found. Using 'Bahnschrift' font instead. Reason: font info substitution.
Font 'Bahnschrift SemiBold SemiConden' has not been found. Using 'Bahnschrift' font instead. Reason: font info substitution.
Font 'Bahnschrift SemiCondensed' has not been found. Using 'Bahnschrift' font instead. Reason: font info substitution.
Font 'Bahnschrift SemiLight' has not been found. Using 'Bahnschrift' font instead. Reason: font info substitution.
Font 'Bahnschrift SemiLight Condensed' has not been found. Using 'Bahnschrift' font instead. Reason: font info substitution.
Font 'Bahnschrift SemiLight SemiConde' has not been found. Using 'Bahnschrift' font instead. Reason: font info substitution.
Font 'Source Sans Pro' has not been found. Using 'Arial' font instead. Reason: font info substitution.

Since Aspose.Words cannot find the font by it’s exact name specified in the document, it substitutes it and warns.

@mayurb “Bahnschrift” is a OpenType Variations font. Unfortunately Aspose.Words do not support such fonts for now and can use only default instance. I have logged it as WORDSNET-18994 in our defect tracking system. We will keep you informed and let you know once it is resolved.

@Konstantin.Kornilov you said that it is not supported by aspose word here in document it mentioned that it is supported
https://docs.aspose.com/words/net/manipulating-and-substitution-truetype-fonts/

This all font is true type of font and it is supported.

@mayurb As Konstantin mentioned the font is OpenType Font Variations, which is not fully supported by Aspose.Words. This is described in the documentaiton:
https://docs.aspose.com/words/net/manipulating-and-substitution-truetype-fonts/#differences-in-processing-of-font-formats-in-asposewords-and-microsoft-word
OpenType Font Variations is supported for only default instance.

@alexey.noskov
@Konstantin.Kornilov is there any way to work all of font in HtmlFixedOption?

@mayurb Unfortunately, without full support of OpenType Font Variations there is no way to preserve “Bahnschrift” font properly. For now Aspose.Words can use only default instance of this font. OpenType Font Variations will be supported once WORDSNET-18994 issue is resolved. At the moment this issue is not yet scheduled for development.

@mayurb Just as an addition, you could check that font is OpenType Variations in Windows Fonts panel