Hello team,
I have a document which uses windings font (to set & unset the checkbox) & calibiri body.
We set the checkbox & this works perfect with local. Now, when we deploy the changes using docker, we see that the checkbox set symbol is changed.
Ideally, we took the next step to add the font in out image, post this we saw the bullets got changed to a clock symbol.
Is there a way, via which we can preserve the formatting of the doc?
or
Can we have all the default fonts in the docker image which are supported by Microsoft word?
@nileshmishra
To address the issue of fonts not displaying correctly in your document when using Docker, particularly with the Wingdings font for checkboxes and Calibri for body text, you can take the following steps:
-
Ensure Font Availability: Make sure that the required fonts (Wingdings and Calibri) are installed in your Docker image. Aspose.Words requires access to TrueType fonts to render documents accurately. If the fonts are not available, Aspose.Words will substitute them with similar fonts, which can lead to unexpected symbols or formatting changes.
-
Font Settings Configuration: Utilize the FontSettings
class in Aspose.Words to specify the locations of your TrueType fonts. This allows you to define custom font sources that Aspose.Words will use when processing documents. Here’s a code snippet to set up font settings:
// Create an instance of FontSettings
FontSettings fontSettings = new FontSettings();
// Specify the folder where your fonts are located
fontSettings.setFontsFolder("/path/to/your/fonts", true);
// Assign the font settings to the document
Document doc = new Document("your-document.docx");
doc.setFontSettings(fontSettings);
-
Font Substitution and Fallback: If certain characters are not available in the specified font, Aspose.Words may use a fallback mechanism. You can control this behavior by configuring font fallback settings. This is particularly useful if you are using special symbols like checkboxes.
-
Testing in Docker: After making these changes, rebuild your Docker image and test the document rendering again. Ensure that the fonts are correctly installed and accessible within the Docker environment.
-
Consider Default Fonts: If you want to include all default fonts supported by Microsoft Word, you may need to install the Microsoft Office fonts in your Docker image. This can be done by adding the necessary font files to your Docker image during the build process.
By following these steps, you should be able to preserve the formatting of your document and ensure that the fonts render correctly in your Docker environment.
If you continue to experience issues, consider checking the Aspose documentation on font manipulation and substitution for more detailed guidance.
Sources:
[1]: Manipulate and Substitute TrueType Fonts - Aspose Documentation