TX Text Control .NET Server

Fonts

Topic

Text that appears in another font, with other line breaks or with more pages than expected is almost always a font that isn't available where the document is rendered. The Core engine of TX Text Control .NET Server doesn't take its fonts from the operating system: it uses the Fonts folder that its NuGet package adds to your application. Start from what you see, and follow it to the font that's missing.

Find Out Which Fonts Are Replaced

When a document uses a font that isn't available, TX Text Control replaces it, and the AdaptFont event reports each replacement with the font of the document and the font that replaces it. The event occurs only when FontSettings.AdaptFontEvent, whose default is false, is set to true before the document is loaded. Load a document that looks wrong with the code in Make Fonts Available on the Server, which logs every replacement.

Text Appears in Another Font

A document created on Linux, in a container or with the Core engine uses, for example, Liberation Sans where the original used Arial, and line and page breaks have moved.

The Core engine reads fonts from the Fonts folder in the folder of the application, which the package TXTextControl.TextControl.Core.SDK fills with fonts under the SIL Open Font License. Arial, Times New Roman, Calibri and Courier New aren't among them, and their replacements have other widths. The Fonts in the Package lists the fonts.

  1. Find the replaced fonts as described in Find Out Which Fonts Are Replaced.
  2. Add the font files your documents use to the Fonts folder, if their license allows it. Add Company Fonts to the Fonts Folder shows the entry for the project file.
  3. Or choose the replacement yourself: set AdaptedFontName in the AdaptFont event to one of the fonts in SupportedFonts. See Use the Right Fonts.

To find missing fonts in templates before they're deployed, the blog article Check TX Text Control Template Dependencies Before Deployment checks them in a build.

A Font Installed on the Server Isn't Used

A font was installed on the Linux server or with a package in the Dockerfile, but documents still use a replacement.

The Core engine doesn't use the fonts of the operating system on Linux, so font packages have no effect on your documents. Copy the font file into the Fonts folder of the application, or register another folder as described in Fonts in a Second Folder Aren't Found. Where the Core Engine Finds Fonts explains the rules.

The Classic engine in TXTextControl.TextControl.ASP.SDK is different: it uses the fonts installed on Windows, which newer systems such as Windows Server 2025 often don't provide in a full set. Install the fonts your documents use on the server; see Fonts With the Classic Engine and, for Windows containers, Classic Engine in Windows Containers.

The Default Font Installation Failed

Creating the first ServerTextControl throws a TextEditorException with this message:

The default font installation failed.

The Core engine found no folder named Fonts in the folder of the application. On Linux, names are case-sensitive, so a folder named fonts isn't found either.

  1. Make sure the project references TXTextControl.TextControl.Core.SDK, which copies the Fonts folder to the build and publish output.
  2. Deploy the complete publish output, including Fonts.
  3. Keep the name of the folder exactly Fonts. Articles for version 33.0 copy a folder named fonts from the setup by hand; use the folder of the package instead.

Fonts in a Second Folder Aren't Found

Fonts in a folder that was registered with ServerTextControl.InstallFonts aren't used.

A relative path passed to InstallFonts is resolved against the current directory of the process, which isn't necessarily the folder of the application, and the registration doesn't reach the Document Editor, whose backend runs in processes of its own. Build the path from AppContext.BaseDirectory, and put fonts that the editor needs into the Fonts folder. Register a Second Font Folder shows the code and the project file entry.

A Font Is Available but Still Replaced

The font file is in the Fonts folder, but AdaptFont still reports it as replaced.

The document asks for the font by a name that differs from the name TX Text Control knows, for example DejaVu Sans for a file that is listed as DejaVu Sans Book. List the names with GetSupportedFonts after Create, as Check the Fonts in a Container does, and use these names in your templates or map the requested name to one of them in the AdaptFont event.

A PDF/A Document Can't Be Saved Because of a Font

Saving as PDF/A 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.

PDF/A requires every font to be embedded in the document. Only OpenType and TrueType fonts can be embedded, and a font's license can forbid embedding. The second message comes with a FilterException whose Reason is NonEmbeddableFont.

  1. Set FontSettings.EmbeddableFontsOnly to true before you load the document. Fonts that can't be embedded are then replaced.
  2. To choose the replacements, handle AdaptFont as described above.

Control Which Fonts Replace Others shows the code.

The Document Editor Offers Other Fonts

The Document Editor offers other fonts than you expect, or text in the editor looks different from the document created on the server.

The editor offers the fonts of the Fonts folder of the application that runs its backend, not fonts registered with InstallFonts; a backend in its own container uses the Fonts folder of its own image. Put the fonts the editor needs into that folder, and call TXTextControl.getSupportedFonts in the browser to see the fonts it offers.

Text Looks Different in the Document Viewer

The Document Viewer shows text in another font than the document uses, depending on the device.

With the render mode Font, the viewer renders text with the fonts available on the device of the user. The mode GlyphOutlines draws the text from the outlines of its characters, so the device needs no fonts.

  1. Set DocumentViewerSettings.RenderMode to ComponentRenderMode.GlyphOutlines.

Render Modes compares the modes.