Fonts and Document Layout
TX Text Control .NET for WPF lays out a document with the fonts installed on Windows and the text dimensions of a printer. When a font of the document isn't installed on a machine, another font replaces it, and lines and pages can break in other places. The problems below start from what you see in the document; the first section shows how to find out which fonts are replaced.
Find Out Which Fonts Are Replaced
Before you change anything, find out which fonts TX Text Control replaces. Set FontSettings.AdaptFontEvent to true, handle the AdaptFont event and log its FontName, the font of the document, and AdaptedFontName, the font that replaces it. Without AdaptFontEvent, the event doesn't occur. Choose the Replacement Fonts shows the handler, which can also set another replacement from SupportedFonts.
Text Appears in Another Font on Another Machine
A document looks right on your machine, but on another one, text is shown in another font, and lines or pages break in other places.
On Windows, TX Text Control uses the fonts installed on the system. Windows usually has fonts such as Arial, Calibri and Times New Roman, but newer systems, such as Windows Server 2025, don't always have a full set of fonts. When a font of the document isn't installed, TX Text Control adapts it while it loads and renders the document, and the changed text metrics move line and page breaks.
- Find out which fonts are replaced, as the previous section shows.
- Install the missing fonts on the machine, if their licenses allow it.
- Or choose the replacement yourself: set
AdaptedFontNamein theAdaptFonthandler to one of the fonts inSupportedFonts.
The blog article Check TX Text Control Template Dependencies Before Deployment checks the fonts of templates before they are deployed.
The Layout Depends on the Printer
Line and page breaks change when another printer is the default printer, or the list of available fonts differs between machines with the same fonts installed.
TX Text Control formats a document with the text dimensions of the printer that FormattingPrinter names. The fonts that GetSupportedFonts returns depend on that device as well, and AdaptFont occurs when another printer is set. Standard means the standard printer of the system, which differs between machines, and a printer that isn't installed is replaced with the standard printer. Display uses the font dimensions of the screen, which are the same on all machines.
- Set
FormattingPrinterto the printer you print on, or toDisplayfor a layout that is the same on every machine. - Read
GetSupportedFontsonly after the control is initialized; before, it returnsnull.
Printing describes the effect on printed documents.
A Document Can't Be Saved as PDF/A
Saving with StreamType.AdobePDFA fails with one of these messages:
To save PDF/A the FontSettings.EmbeddableFontsOnly property must be set to true.
Text filter error: The document cannot be saved, because it contains a non-embeddable font.
A PDF/A document must contain its fonts, but not every font can be embedded: the license of a font can forbid it, or the font depends on a device. TX Text Control treats only OpenType and TrueType fonts as embeddable. FontSettings.EmbeddableFontsOnly restricts the document to such fonts and must be true to save PDF/A. The second message is a FilterException with the reason NonEmbeddableFont.
- Set
FontSettings.EmbeddableFontsOnlytotrue, as Create a PDF shows. - Handle
AdaptFontto see which fonts are replaced by embeddable ones, and choose the replacements yourself if needed. - Save the document again with
StreamType.AdobePDFA.