GNU TeXmacsUser manualReferenceAboutEnglish
The TeX font classes and their output

This page describes the font classes built on TeX fonts (

Plugins/Metafont/tex_font.cpp

and

tex_rubber_font.cpp

) and how their glyphs end up on the screen, in PDF and in PostScript. The general interface of fonts (font_rep: extents, positions, corrections, index_glyph) is described in TeXmacs fonts.

1.Text fonts

struct tex_font_rep: font_rep
(a TeX text font)

Its own fields are the status (the variant, see below), the family, the resolution dpi, the fall-back design size dsize, the metric tfm, the glyphs pk (from a Type 1 substitute or a PK file), the conversion factor unit from .tfm units to TeXmacs units, and the flag exec, which says whether the ligature and kerning program is run; it is false for typewriter families (whose name ends in tt).

The constructor calls load_tex and fills the generic font parameters of font_rep from the metric: design_size and display_size (in points and in units at the given resolution), slope, the interword space spc with its stretch and shrink, extra, the x-height yx and the derived script positions (ysub_lo_base, ysup_lo_base, …), the fraction bar height yfrac, the rule width wline and the quad wquad. For cmr, ecrm and cmmi, the rule width and the fraction bar position are tuned per size. It also installs the script and accent correction tables of

adjust_cmr.cpp

for the families which have them (ecrm/ecbx, ecss/ecsx, cmr/cmbx, cmmi/cmmib, cmsy/cmbsy, bbm, eufm/eufb, rsfs); these tables, keyed by character, shift sub- and superscripts and wide accents by a fraction of the font size, see mathematical typesetting.

Variants.
The same class implements six kinds of fonts, which differ in how strings of TeXmacs characters are mapped to the 256 character codes of the font. Each has a constructor and a font tree tag recognized by find_font:
tex_font, tree (tex family size dpi [dsize])

Status TEX_ANY: raw character codes; only one-character strings and <less>, <gtr> are supported. Used for symbol fonts such as cmsy, msam or stmary.

tex_ec_font, tree (ec …)

Status TEX_EC: fonts in the Cork (T1) encoding, which is also the internal encoding of TeXmacs strings, so that strings are passed through unchanged.

tex_la_font, tex_gr_font, trees (la …), (gr …)

Status TEX_LA and TEX_GR: Cyrillic (larm, …) and Greek fonts, with sizes in the \(\times 100\) convention. Characters written as entities, such as <#41F>, are translated to font codes through the encodings larm and grmn (a table special_translate built once from these translators, in lower and upper case).

tex_cm_font, tex_adobe_font, trees (cm …), (adobe …)

Status TEX_CM and TEX_ADOBE: fonts in the old TeX text encoding (OT1) or in the encoding of the Adobe clones, which lack the accented letters of the Cork encoding. Such letters are typeset as the base letter with an accent drawn above it, using two tables (CM_unaccented/CM_accents or the Adobe ones) which give, for each Cork code from 128 on, the base letter and the accent character. The position of the accent depends on the height of the letter and on the slant of the font; a few accents which go below or beside the letter, such as the cedilla, are placed by special rules.

For all variants, a string is drawn by running the ligature and kerning program of the metric (tfm->execute) and drawing the resulting character codes one after the other, each followed by its width and kerning. get_extents and get_xpositions compute the same layout without drawing. supports (s) says which strings the font can render; for TEX_ANY, a character is supported if the font has a non-empty glyph for it. magnify (zx, zy) creates the same kind of font at a resolution multiplied by the zoom factor, or a poor_magnify wrapper if the two factors differ.

Glyph access.
get_glyph (s) and index_glyph (s, fnm, fng) map a string to a single glyph: a one-character string is its code, a longer string is accepted if the ligature program reduces it to a single character (get_ligature_code, for instance ffi). index_glyph returns the code together with the metric table tfm_font_metric (tfm, pk, unit) and the glyph table pk, which is what the renderers and the virtual and smart fonts use (see smart fonts). Strings which are not a single glyph fall back to the generic implementations of font_rep.

2.Rubber fonts

struct tex_rubber_font_rep: font_rep
(extensible characters)

Created by tex_rubber_font (trl, family, size, dpi, dsize) from a tree (tex-rubber translator family size dpi [dsize]), for instance (tex-rubber rubber-cmex cmex 10 600) in

progs/fonts/fonts-adobe.scm

. It supports the strings <left-x-n>, <right-…>, <mid-…>, <large-…> and <big-…>, where n is a size number.

To render <left-(-3>, the font looks up the base character <left-(> in the translator (here rubber-cmex), which gives a character code of the font, and follows the chain of successively larger characters of the metric (nth_in_list) n times. If the chain ends in an extensible character (tag 3) before reaching size n, the character is assembled from its top, middle, bottom and repeated pieces, with as many repetitions as needed for the remaining size steps. While drawing, the vertical position is rounded to whole pixels after each piece, and on printers each repeated piece is drawn a second time slightly lower, so that no gaps appear between the pieces. get_extents adds some horizontal space around large delimiters, and corrects the vertical extents of the largest big operators (<big-…-2>).

tex_dummy_rubber_font (fn), for the tree (tex-dummy-rubber …), renders the invisible delimiters <left-.>, <big-.>, and so on: it takes the height of the corresponding parenthesis (or of <big-sum>) in fn, with zero width, and draws nothing.

3.Output

On the screen.
The renderer receives each character as draw (c, fng, x, y), with the glyph table of the font. It shrinks the glyph to the screen resolution and caches the result, see the glyph section and renderer back-ends.
In PDF.
pdf_hummus_renderer_rep::draw (ch, fn, x, y) (
Plugins/Pdf/pdf_hummus_renderer.cpp

) decides once per glyph table how to embed it (make_pdf_font). The part of the glyph table name before the first colon is taken as a font name and looked up with tt_font_find; for a Type 1 substitute the glyph table is called familysize:size.dpitt, so this finds the .pfb file, which is then embedded as a native font, unless its file name is listed in $TEXMACS_PATH/fonts/pdf-font-issues.scm. PK glyph tables (named familysize.dpipk) and fonts which cannot be loaded are embedded as Type 3 fonts made of bitmaps, in chunks of about 255 characters (a TeX font always fits in one chunk), rendered at a conventional size of 100. Two workarounds concern TeX fonts: character 0 of the Computer Modern families is drawn as character 161 (for old PDF viewers), and for native European Computer Modern fonts the ligatures ff to ffl (codes 27 to 31) are mapped to the Unicode ligature code points from U+FB00 on, so that text can be copied from the PDF file.

In PostScript.
printer_rep::draw (
Graphics/Renderer/printer.cpp

) records each character used. When the document is finished, generate_tex_fonts writes, for each glyph table, either the Type 1 font converted from .pfb to .pfa (pfb_to_pfa) together with a re-encoding and scaling, or, for PK glyphs, a bitmap font with one hexadecimal bitmap per character. The Type 1 path is not compiled on Windows.

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".