Issue: Embedded Clario Font Is Substituted on Linux During DOCX → PDF Conversion

Description

We are encountering a platform-specific font substitution issue while converting DOCX to PDF using Aspose.Words.

The DOCX document contains the Clario font embedded.
When the document is converted to PDF on Windows environments, Aspose correctly picks and renders the embedded Clario font.
However, when the same document is converted on a Linux server, Aspose does not pick the embedded Clario font and instead substitutes it with a different font.


Expected Behavior

Aspose.Words should consistently use the embedded Clario font during DOCX → PDF conversion across all platforms, including Linux, without requiring the font to be installed on the OS.


Actual Behavior

  • Windows (Server / Local): :white_check_mark: Correct embedded Clario font is used in the output PDF
  • Linux Server: :x: Embedded Clario font is ignored and a substitute font is applied

Environment Details

  • Aspose.Words version: 25.11.0
  • Input: DOCX with embedded Clario font
  • Output: PDF
  • OS:
    • Windows Server / Windows Laptop – Working as expected
    • Linux Server (VM / Container) – Font substitution occurs
      a3FPA000006S59P2AS_Template.docx (207.5 KB)

@sfulari

  1. Aspose.Words may apply font substitution on Linux when embedded fonts are not properly accessed. While the DOCX contains the Clario font embedded, Aspose.Words on Linux might not utilize it during DOCX to PDF conversion, leading to substitution with another font. This behavior does not occur on Windows, indicating a platform-specific difference in embedded font handling.

  2. Font substitution is triggered when fonts are unavailable. If Aspose.Words cannot use the required font—whether embedded or installed—it applies internal substitution rules. When no suitable font is found, it may default to Fanwood, a fallback font embedded in the Aspose.Words library .

  3. Aspose.Words requires access to TrueType fonts for accurate rendering. Although embedded fonts should suffice, the library may attempt to resolve font names against system-available fonts, particularly on Linux. If Clario is not recognized or accessible, substitution can occur [3, 4].

Recommended Actions:

  • Ensure Clario is available to Aspose.Words on Linux by either installing it system-wide or specifying a custom font source using FontSettings.SetFontsFolder or FontSettings.SetFontsSources.
  • Verify the font is fully embedded in the DOCX (not just subset) and confirm no restrictions prevent its use.
  • Configure explicit font substitution rules to map Clario to itself, helping ensure it is selected:
var fontSettings = new FontSettings();
fontSettings.SubstitutionSettings.TableSubstitution.AddSubstitution("Clario", "Clario");
doc.FontSettings = fontSettings;
  • Enable font substitution logging to monitor when substitutions occur:
fontSettings.SubstitutionSettings.FontInfoSubstitution.Enabled = true;
doc.WarningCallback = new FontSubstitutionWarningCallback();

class FontSubstitutionWarningCallback : IWarningCallback
{
public void Warning(WarningInfo info)
{
if (info.WarningType == WarningType.FontSubstitution)
Console.WriteLine($"Font substitution: {info.Description}");
}
}

Execution did not complete due to an execution error, so the code above is a hypothesis based on documented Aspose.Words behavior.

Is there any way to extract the embedded fonts from the docx file?

@sfulari

The query seems related to Aspose.Words. Therefore, we have moved it to the respective forum category where you will be assisted accordingly.

@sfulari As I can see your document does not contain any embedded fonts. So both Aspose.Words and MS Word use fonts available on the machine where document is processed. The fonts are required to build document layout. If Aspose.Words cannot find the font used in the document, the font is substituted . This might lead into fonts mismatch and document layout differences due to the different fonts metrics. You can implement IWarningCallback to get notifications when font substitution is performed.
Please see our documentation to learn where Aspose.Words looks for fonts:
https://docs.aspose.com/words/net/specifying-truetype-fonts-location/
https://docs.aspose.com/words/net/installing-truetype-fonts-on-linux/