GNU TeXmacsUser manualReferenceAboutEnglish
OpenType fonts

Most fonts on a modern system are OpenType fonts, and an OpenType font carries much more than outlines and metrics: layout tables which say how glyphs are substituted and positioned and, for the mathematical fonts, a MATH table which declares everything a formula typesetter needs. This chapter describes how TeXmacs reads these tables and puts them to work: the mathematics of any OpenType math font without per-font C++ code, the stretchable delimiters, accents and arrows built from the font's own parts, the features of text fonts such as old style figures, and the profiles which pair each mathematical font with its text companions.

One rule shapes the whole design: the hand-tuned tables win. The tables of adjust_*.cpp and the per-family branches of

unicode_font.cpp

(for the TeX Gyre and the first STIX fonts) were crafted against the layout of TeXmacs and keep precedence wherever they say something; the MATH table fills what they leave open. The tuning can be switched off for comparison with (set-hand-tuned-math-fonts #f).

1.Overview

The support is organized in layers, from the font file to the typesetter:

.otf file
  |  tt_face (tt_face.cpp): MATH, and on demand GSUB and GPOS
  v
parsed tables                       (tt_tools.cpp)
  |  unicode_font: MATH parameters, before the tuned branches
  v
font_rep parameters and hooks        (font.hpp)
  |                                    |  rubber_unicode_font
  v                                     v
typesetter                            variants and assemblies
(fractions, radicals, scripts,       (virtual-font glyph algebra)
 accents, delimiters, operators)

GSUB  -> feature_font: font-features, dtls, flac, ssty
GPOS  -> pair kerning of text
profiles (fonts-opentype.scm) -> smart_font routing and the font menus

The pages of this chapter follow these layers. They describe the implementation; how to choose fonts, how a request is resolved and how the configuration files look is the subject of the reference chapter fonts, from selection to glyph, and the mathematical fonts as seen by users, with a specimen of every shipped font, are described in the section mathematical fonts of the user manual.

2.Source files

All file names are relative to

src/src/

unless stated otherwise.

Plugins/Freetype/tt_tools.hpp
,
tt_tools.cpp

The readers of the MATH, GSUB and GPOS tables.

Plugins/Freetype/tt_face.hpp
,
tt_face.cpp

The parsed tables, cached per face, and the kerning.

Plugins/Freetype/unicode_font.cpp

Activation of the MATH table, the constants and the glyph corrections.

Plugins/Freetype/rubber_unicode_font.cpp

Stretchable glyphs: variants and assemblies.

Graphics/Fonts/font.hpp
,
font.cpp

The mathematical parameters of a font and the height-aware correction hooks.

Graphics/Fonts/smart_font.cpp

Routing: profiles, mathematical italic letters, script-size alternates, and the tables read by the font inspector.

Graphics/Fonts/feature_font.cpp

A font seen through a GSUB feature, and the features a document asks for.

Graphics/Fonts/math_font_profiles.cpp

The table of profiles.

Graphics/Fonts/poor_rubber.cpp

The emulation of stretchable glyphs, now behind the table.

Typeset/Boxes/Composite/math_boxes.cpp
,
script_boxes.cpp
,
Typeset/Concat/concat_math.cpp
,
Typeset/Env/env_semantics.cpp

The typesetter: radicals, bars and wide accents; scripts, limits and stretch stacks; delimiters, big operators and arrows; script sizes.

Plugins/Freetype/tt_file.cpp
,
Graphics/Fonts/font_database.cpp

The order in which font files are looked for, and the merge of the shipped database into the local one.

Typeset/Boxes/Basic/font_debug_boxes.cpp

Glyphs coloured by the route they took.

TeXmacs/progs/fonts/fonts-opentype.scm
,
font-features.scm
,
font-debug.scm
,
font-short-menu.scm

The profiles and the font menus, the features, the font inspector and the font report (relative to

src/

).

3.Further documents

Three documents of the source tree accompany this chapter. They are written in Markdown for the developers of the branch which introduced the support, and are more detailed on its history and status:

src/docs/OPENTYPEMATH.md

A summary of what is implemented, the build and test instructions, and a specimen of every profiled font.

src/docs/opentype-math-design.md

The design and status log: provenance, architecture, the status of each piece, the tests, the known defects, what is still missing, and the correspondence between the hand-made constructions of the typesetter and their MATH counterparts.

src/docs/font-system-review.md
,
src/docs/math-symbol-coverage.md

A review of the font system as a whole, and a count of the mathematical symbols which are still unnamed.

The support goes back to a first MATH reader written in 2021 on the wip-unicode-math branch, which the OSPP 2024 project of Ke Shi for Mogan extended; that work was ported to TeXmacs, hardened, and put to work in the typesetter, under the hand-tuned tables rather than in place of them.

4.Contents of this chapter

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".