GNU TeXmacsUser manualReferenceAboutEnglish
Virtual fonts

A virtual font defines characters as constructions over other characters: a glyph is flipped, cut in two, stacked on another one or drawn a second time a little to the right. TeXmacs uses them to draw the symbols that ordinary text fonts do not have, which is how mathematics can be typeset in a font which was never designed for it.

The virtual fonts live in $TEXMACS_PATH/fonts/virtual, in files with the extension .vfn, and a file of the same name in $TEXMACS_HOME_PATH/fonts/virtual is used in its place, which is how you may extend or correct one without touching the installation.

What a file looks like

A virtual font is a list of definitions, each of them a character name and an expression:

(virtual-font
  (mho (ver-flip (hor-flip omega)))
  (Backsigma (hor-flip Sigma))
  (Exists (join (0 0 exists) (0.25 -0.01 urcorner)
                (0.25 0.02 lrcorner))))

A name of one letter stands for that character, a longer name stands for the character written between angle brackets: the definitions above give <mho>, <Backsigma> and <Exists>. Inside an expression, a name is the glyph of that character, taken from the font the virtual font is built on, or from the virtual font itself when it defines it, so definitions may be built on one another.

The vocabulary

The expressions are a small language of glyph algebra. The operations fall into a few groups:

placing

A triple (x y g) moves the glyph g by x and y, in units of the font size, so (0.25 -0.01 urcorner) puts a corner a quarter of an em to the right and a hundredth of an em down.

assembling

join superposes glyphs, glue and row put them side by side, stack puts one above the other, and add, intersect and exclude combine them as images.

cutting

part takes a rectangular piece of a glyph in relative coordinates, crop removes the white margins, and hor-take and ver-take repeat one column or one row of a glyph over a given length, which is how a stretchable piece is extended.

transforming

hor-flip, ver-flip, rot-left, rot-right and rotate turn a glyph around, magnify, scale, hor-scale and fscale resize it, widen and deepen stretch it while keeping the width of its strokes, unserif removes its serifs, and italic leaves the glyph as it is but declares its slant and italic correction.

spacing

enlarge, unindent and the pretend operations change the box around a glyph without changing the ink, which is how a construction is made to align with the rest of a line.

decorating

bar-left, bar-right, bar-top, bar-bottom add a stroke, negate draws a slash through a glyph, circle draws a circle of a given radius and pen width, and flood-fill fills an outline.

measuring

width, height, xpos and ypos give a length, the arithmetic operations +, -, *, /, min and max compute with them, and with binds the result to a name:

(emu-langle-bis (with sc (/ (height (crop [)) (height emu-langle-pre))
                  (align* (magnify emu-langle-pre * sc) [ * 0.5)))

scales an angle bracket so that its height becomes the height of a square bracket.

A star at the end of the name of an operation, as in glue* or unindent*, means the same operation applied on the other side or with the other reference point.

How a character reaches a virtual font

There are two ways. The first is by name: three virtual fonts, tradi-long, tradi-negate and tradi-misc, are consulted for every character which the current font does not have, and a character defined in one of them is drawn from there. Adding a definition to one of these three, in your home directory, is therefore enough to give a new symbol a shape everywhere.

The second is by a font rule. A compound font may list a virtual font among its members, as the traditional mathematics font does in

fonts-math.scm

:

(virtual tradi-misc $s $d)

and the stretchable characters are built the same way, out of the emu-* virtual fonts: emu-bracket assembles the large brackets, emu-large the large operators, and so on. When a font carries an OpenType MATH table, TeXmacs builds the same kind of construction from the parts the table gives, which is why the assembled delimiters of such a font export as real glyphs.

Adding a symbol

To give a shape to a symbol your font does not have:

  1. copy the virtual font you want to extend, say tradi-misc.vfn, into $TEXMACS_HOME_PATH/fonts/virtual;

  2. add a definition to it, using the glyphs the text fonts do have;

  3. make sure the symbol has a name in

    langs/encoding/tmuniversaltounicode.scm

    , or it will be typed as <#XXXX> and no palette will propose it;

  4. restart TeXmacs; virtual fonts are read once and cached.

A definition which mentions a character the underlying font does not have produces nothing, so it is wise to build on the letters and the punctuation, which every font provides.

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