TX Sheet Control

Font Handling

Topic

Fonts decide more than how the glyphs look. They set the geometry of a document: column widths, line wrapping, row heights, chart labels and the pagination of a PDF. TX Sheet Control therefore renders and exports documents only with fonts it is given, never with the fonts installed on the computer, so that the browser and the server produce the same layout.

Where the Fonts Come From

  • The editor loads a font catalog, catalog.json, and the TrueType files it lists. Every editor package contains the same catalog with 30 families: the browser folder of the download, the npm package and the ASP.NET Core and Blazor packages. Static Assets and Offline Hosting shows how the editor finds the catalog.
  • The server packages read every font file in their font folder: tx-sheet-engine/fonts in the output of a .NET application, dist/fonts in the Node.js package. They contain the same 30 families. GetFontCatalogAsync in .NET and getFontCatalog in Node.js return the families they found and warnings about files they could not read.

Included Fonts and Notices lists the families, and Custom Fonts shows how to add your own.

Fonts That Are Replaced

A workbook often uses fonts that TX Sheet Control does not include, such as the Microsoft Office fonts. When such a font is not deployed, TX Sheet Control uses a Liberation font instead, in the editor and in PDF output:

Font in the workbookUsed instead
Arial, Calibri, Century Gothic, Corbel, Franklin Gothic Book, Franklin Gothic Medium, Quire SansLiberation Sans
Times New Roman, Constantia, Rockwell Nova, Rockwell Nova LightLiberation Serif
Courier New, ConsolasLiberation Mono

The font name stored in the cell stays unchanged, so an XLSX, ODS or TXWB file you save keeps the original name. A deployed original font takes precedence over the replacement: add it as a custom font when the document must match the original typeface. A workbook can also map a font to another family with fonts.substitutions in the load options.

Warning

Fonts Without a Replacement. PDF export, in the editor and on the server, fails when a cell uses a font that is neither deployed nor in the table above, for example Comic Sans MS, with the error "No document font available: Comic Sans MS". Deploy the font, or format the cell with a supplied family.

Characters Missing From a Font

When the font of a cell has no glyph for a character, TX Sheet Control takes the character from a supplied fallback font and keeps the cell's font for the other characters:

  • Chinese, Japanese and Korean from Noto Sans SC, TC, JP and KR.
  • Symbols from Noto Sans Symbols 2.
  • Emoji from Noto Emoji, as monochrome outlines. Color emoji and combined emoji sequences are not supported, and neither is the shaping of complex scripts.

The editor loads the fallback fonts it needs when it shows or edits text, and PDF export in the browser and on the server embeds them. The font name stored in the cell does not change. Keep these families when you build a catalog or a font folder of your own.

Wait for the Fonts

The editor loads the catalog and the fonts of the document when it starts. editor.ready resolves when they are loaded, and rejects when the catalog or a font cannot be loaded. The ready output of Angular, the txsheetcontrolready event of the Tag Helper and the Ready callback of Blazor follow the same initialization. Handle the rejection, and do not treat an editor that is not ready as usable.

Rules for Font Files

These rules apply to the catalog of the editor:

  • TrueType only. Every face must have the format ttf. A WOFF or WOFF2 face makes editor.ready reject with "Invalid deployed font face."
  • Numeric weights. Weights are numbers from 1 to 1000, such as 400 for regular and 700 for bold. Other values are rejected the same way.
  • Each family once. A family listed twice makes editor.ready reject with "Invalid deployed font family."
  • The faces you use. Deploy every weight and style a document uses, such as regular, bold, italic and bold italic. A variable font is used in its default instance, so a variable font with a weight axis does not provide a bold face.

The server font folder accepts the same TrueType files. A file it cannot read appears as a warning in the font catalog, such as "Broken.ttf: Invalid TrueType font size."

Next Steps