Aspose.Words

How Aspose.Words Uses True Type Fonts

Aspose.Words requires TrueType fonts when rendering documents to fixed-page formats (PDF, XPS or SWF).

When Aspose.Words renders a document, it needs to subset and embed TrueType fonts into the resulting document. This is a normal practice during PDF or XPS generation and it ensures the document will appear identical for any viewer. Moreover, the XPS specification requires that fonts are always embedded in the document.

For Aspose.Words to ensure the best fidelity, to successfully measure characters and embed fonts, the following conditions need to be met:

·          Aspose.Words needs to be able to find and access TrueType fonts files on the system.

·          There should be sufficient TrueType fonts available to Aspose.Words, preferably with the same font family names as used in the document.

Font Availability and Substitution

Text in a document is formatted using various fonts such as Arial, Times New Roman, Verdana and others. When Aspose.Words renders a document it attempts to select the fonts that are specified by the document. However there are situations when the exact font cannot be found and Aspose.Words must substitute a similar font instead. The exact process of this is explained below.

Aspose.Words selects the fonts according to the following process:

1.       Aspose.Words tries to find the required font among the fonts embedded in the original document. Some document formats such as DOCX can contain embedded fonts.

2.       Next, Aspose.Words tries to find a font on the file system with an exact font name match.

3.       If Aspose.Words cannot find a font with the exact name match, Aspose.Words attempts to select the most suitable font from all of the available fonts.

4.       Finally, if Aspose.Words cannot find any fonts on the file system, it renders the document using the free Gentium font that is embedded into the Aspose.Words assembly.

Where Aspose.Words Looks for Fonts

Aspose.Words attempts to find TrueType fonts on the file system automatically. Most of the time you can rely on the default behavior of Aspose.Words to find TrueType fonts, but sometimes you need to specify your own folders with TrueType fonts. Where Aspose.Words looks for fonts and how to specify your own font locations is explained in further topics.

Typical Font-Related Problems and Solutions

This table lists some of the problems that you might encounter when rendering documents to PDF, XPS and SWF using Aspose.Words and their solutions.

Please keep in mind when copying any fonts, most fonts are copyrighted. First locate the license of a font before hand to check if they can be freely transferred to another machine.

Problem

Solution

The layout and fonts in the output document is different from the original.

You are using Aspose.Words on Linux or Mac OS. The document uses fonts that are not present on your computer or Aspose.Words cannot locate fonts on your computer.

Copy True Type font files from a Windows machine or install a True Type font package. Use the FontSettings class to specify the location of the font files.

List bullets come out as squares or other symbols.

You are using Aspose.Words on Linux or Mac OS. List bullets most likely require the Symbol or the Wingding font and these fonts are not present on your system.

Copy the font files from a Windows machine to your Linux or Mac OS machine to the directory where True Type fonts are installed.

Copy the following files:

·          C:\Windows\Fonts\symbol.ttf

·          C:\Windows\Fonts\wingding.ttf