Chaning fonts inline creates random spaces in generated word, pdf documents

Hi Team,
we are facing an issue where we are changing some specific fonts in a single line on text and the generated word, pdf contains random amount of spaces between the borders (it can be zero too).
Please see the attached simple console application I created, where you can easily reproduce the issue.
Thank you very much for your time and help!
ConsoleAppV1.zip (420.0 KB)

@ottap

It seems you are experiencing issues with random spaces appearing in generated Word and PDF documents when changing specific fonts inline. This can often be attributed to how Aspose.Words handles font rendering and substitution.

Here are a few suggestions to help you troubleshoot and potentially resolve the issue:

  1. Font Settings: Ensure that you are using the correct font settings. Aspose.Words requires TrueType fonts for rendering documents accurately. If the specified font is not available, Aspose.Words will substitute it with a similar font, which may lead to unexpected spacing. You can manage font settings using the FontSettings class to specify font sources and handle substitutions effectively.

  2. Font Substitution Warnings: Implement a warning callback to capture any font substitution warnings. This can help you identify if a font is being replaced during the rendering process, which might be causing the spacing issues. You can use the IWarningCallback interface to receive notifications about font substitutions.

  3. Line Spacing and Font Properties: Check the line spacing and other font properties in your document. Sometimes, specific font settings like line spacing or character spacing can lead to unexpected layout changes. You can retrieve and adjust these properties using the Font class.

  4. Testing with Different Fonts: Try using different fonts to see if the issue persists. This can help determine if the problem is specific to certain fonts or a broader issue with the document rendering.

  5. Reviewing Font Files: Ensure that the font files you are using are not corrupted and are compatible with Aspose.Words. Sometimes, issues can arise from using non-standard or improperly installed fonts.

If the problem continues, consider sharing a minimal reproducible example or the specific code snippet that demonstrates the issue. This will help in diagnosing the problem more effectively.

For more detailed information on managing fonts in Aspose.Words, you can refer to the official documentation on Manipulating and Substituting TrueType Fonts and Common Font Problems and Solutions.

If you have any further questions or need additional assistance, feel free to ask!

@ottap
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-27838

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like

@ottap We have completed analyzing the issue and currently we don’t consider this as a bug, because the result generated by Aspose.Words matches the result produced by MS Word. We are not sure if we can and will improve the font matching mechanism for SVG and CSS. So the issue has been postponed and is not yet scheduled for development.