![]() |
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.
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.
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.
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.
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).
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.
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.
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.
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.