Luatex Reference: Beta 0.60.1
Luatex Reference: Beta 0.60.1
Reference
beta 0.60.1
LuaTEX
Reference
Manual
3 Lua general 23
3.1 Initialization 23
3.1.1 LuaTEX as a Lua interpreter 23
3.1.2 LuaTEX as a Lua byte compiler 23
3.1.3 Other commandline processing 23
3.2 Lua changes 25
3.3 Lua modules 29
4 LuaTEX Lua Libraries 31
4.1 The callback library 31
4.1.1 File discovery callbacks 32
4.1.1.1 find_read_file and find_write_file 32
4.1.1.2 find_font_file 32
4.1.1.3 find_output_file 32
4.1.1.4 find_format_file 33
4.1.1.5 find_vf_file 33
4.1.1.6 find_ocp_file 33
4.1.1.7 find_map_file 33
4.1.1.8 find_enc_file 33
4.1.1.9 find_sfd_file 33
4.1.1.10 find_pk_file 33
4.1.1.11 find_data_file 34
4.1.1.12 find_opentype_file 34
4.1.1.13 find_truetype_file and find_type1_file 34
4.1.1.14 find_image_file 34
4.1.2 File reading callbacks 34
4.1.2.1 open_read_file 34
4.1.2.1.1 reader 35
4.1.2.1.2 close 35
4.1.2.2 General file readers 35
4.1.3 Data processing callbacks 36
4.1.3.1 process_input_buffer 36
4.1.3.2 process_output_buffer (0.43) 37
4.1.3.3 token_filter 37
4.1.4 Node list processing callbacks 37
4.1.4.1 buildpage_filter 37
4.1.4.2 pre_linebreak_filter 38
4.1.4.3 linebreak_filter 39
4.1.4.4 post_linebreak_filter 39
4.1.4.5 hpack_filter 39
4.1.4.6 vpack_filter 40
4.1.4.7 pre_output_filter 40
4.1.4.8 hyphenate 40
4.1.4.9 ligaturing 41
4.1.4.10 kerning 41
4.1.4.11 mlist_to_hlist 41
4.1.5 Information reporting callbacks 42
4.1.5.1 start_run 42
4.1.5.2 stop_run 42
4.1.5.3 start_page_number 42
4.1.5.4 stop_page_number 42
4.1.5.5 show_error_hook 42
4.1.6 Font-related callbacks 43
4.1.6.1 define_font 43
4.2 The font library 43
4.2.1 Loading a tfm file 43
4.2.2 Loading a vf file 44
4.2.3 The fonts array 44
4.2.4 Checking a font's status 44
4.2.5 Defining a font directly 45
4.2.6 Projected next font id 45
4.2.7 Font id (0.47) 45
4.2.8 Currently active font 45
4.2.9 Maximum font id 45
4.2.10 Iterating over all fonts 45
4.3 The fontloader library (0.36) 46
4.3.1 Getting quick information on a font 46
4.3.2 Loading an OpenType or TrueType file 46
4.3.3 Applying a ‘feature file' 47
4.3.4 Applying an ‘afm file' 48
4.3.5 Fontloader font tables 48
4.3.5.1 Table types 48
4.3.5.1.1 Top-level 48
4.3.5.1.2 Glyph items 50
4.3.5.1.3 map table 52
4.3.5.1.4 private table 54
4.3.5.1.5 cidinfo table 54
4.3.5.1.6 pfminfo table 54
4.3.5.1.7 names table 55
4.3.5.1.8 anchor_classes table 56
4.3.5.1.9 gpos table 56
4.3.5.1.10 gsub table 58
4.3.5.1.11 ttf_tables and ttf_tab_saved tables 58
4.3.5.1.12 sm table 58
4.3.5.1.13 features table 58
4.3.5.1.14 mm table 59
4.3.5.1.15 mark_classes table (0.44) 60
4.3.5.1.16 math table 60
4.3.5.1.17 validation_state table 61
4.3.5.1.18 horiz_base and vert_base table 62
4.3.5.1.19 altuni table 62
4.3.5.1.20 vert_variants and horiz_variants table 62
4.3.5.1.21 mathkern table 63
4.3.5.1.22 kerns table 63
4.3.5.1.23 vkerns table 63
4.3.5.1.24 texdata table 63
4.3.5.1.25 lookups table 63
4.4 The img library 65
4.5 The kpse library 69
4.5.1 kpse.set_program_name and kpse.new 69
4.5.2 find_file 70
4.5.3 lookup 71
4.5.4 init_prog 72
4.5.5 readable_file 72
4.5.6 expand_path 72
4.5.7 expand_var 72
4.5.8 expand_braces 73
4.5.9 show_path 73
4.5.10 var_value 73
4.5.11 version 73
4.6 The lang library 73
4.7 The lua library 75
4.7.1 Lua bytecode registers 75
4.7.2 Lua chunk name registers 76
4.8 The mplib library 76
4.8.1 mplib.new 76
4.8.2 mp:statistics 77
4.8.3 mp:execute 77
4.8.4 mp:finish 78
4.8.5 Result table 78
4.8.5.1 fill 79
4.8.5.2 outline 80
4.8.5.3 text 80
4.8.5.4 special 81
4.8.5.5 start_bounds, start_clip 81
4.8.5.6 stop_bounds, stop_clip 81
4.8.6 Subsidiary table formats 81
4.8.6.1 Paths and pens 81
4.8.6.2 Colors 81
4.8.6.3 Transforms 82
4.8.6.4 Dashes 82
4.8.7 Character size information 82
4.8.7.1 mp.char_width 82
4.8.7.2 mp.char_height 82
4.8.7.3 mp.char_depth 82
4.9 The node library 83
4.9.1 Node handling functions 83
4.9.1.1 node.types 83
4.9.1.2 node.whatsits 84
4.9.1.3 node.id 84
4.9.1.4 node.subtype 84
4.9.1.5 node.type 84
4.9.1.6 node.fields 84
4.9.1.7 node.has_field 84
4.9.1.8 node.new 85
4.9.1.9 node.free 85
4.9.1.10 node.flush_list 85
4.9.1.11 node.copy 85
4.9.1.12 node.copy_list 85
4.9.1.13 node.hpack 86
4.9.1.14 node.vpack (since 0.36) 86
4.9.1.15 node.dimensions (0.43) 86
4.9.1.16 node.mlist_to_hlist 87
4.9.1.17 node.slide 87
4.9.1.18 node.tail 88
4.9.1.19 node.length 88
4.9.1.20 node.count 88
4.9.1.21 node.traverse 88
4.9.1.22 node.traverse_id 88
4.9.1.23 node.remove 88
4.9.1.24 node.insert_before 89
4.9.1.25 node.insert_after 89
4.9.1.26 node.first_character 89
4.9.1.27 node.ligaturing 89
4.9.1.28 node.kerning 89
4.9.1.29 node.unprotect_glyphs 90
4.9.1.30 node.protect_glyphs 90
4.9.1.31 node.last_node 90
4.9.1.32 node.write 90
4.9.1.33 node.protrusion_skippable (0.60.1) 90
4.9.1.34 node.protrusion_skipable (0.53) 91
4.9.2 Attribute handling 91
4.9.2.1 node.has_attribute 91
4.9.2.2 node.set_attribute 91
4.9.2.3 node.unset_attribute 91
4.10 The pdf library 92
4.11 The status library 95
4.12 The tex library 96
4.12.1 Internal parameter values 97
4.12.1.1 Integer parameters 97
4.12.1.2 Dimension parameters 98
4.12.1.3 Direction parameters 99
4.12.1.4 Glue parameters 99
4.12.1.5 Muglue parameters 99
4.12.1.6 Tokenlist parameters 99
4.12.2 Convert commands 100
4.12.3 Last item commands 100
4.12.4 Attribute, count, dimension, skip and token registers 101
4.12.5 Box registers 101
4.12.6 Math parameters 102
4.12.7 Special list heads 103
4.12.8 Semantic nest levels (0.51) 104
4.12.9 Print functions 105
4.12.9.1 tex.print 105
4.12.9.2 tex.sprint 105
4.12.9.3 tex.tprint 106
4.12.9.4 tex.write 106
4.12.10 Helper functions 106
4.12.10.1 tex.round 106
4.12.10.2 tex.scale 107
4.12.10.3 tex.sp (0.51) 107
4.12.10.4 tex.definefont 107
4.12.11 Functions for dealing with primitives 108
4.12.11.1 tex.enableprimitives 108
4.12.11.2 tex.extraprimitives 109
4.12.11.3 tex.primitives 112
4.12.12 Core functionality interfaces 112
4.12.12.1 tex.badness (0.53) 112
4.12.12.2 tex.linebreak (0.53) 112
4.12.12.3 tex.shipout (0.51) 114
4.13 The texconfig table 114
4.14 The texio library 115
4.14.1 Printing functions 115
4.14.1.1 texio.write 115
4.14.1.2 texio.write_nl 115
4.15 The token library 116
4.15.1 token.get_next 116
4.15.2 token.is_expandable 116
4.15.3 token.expand 116
4.15.4 token.is_activechar 116
4.15.5 token.create 117
4.15.6 token.command_name 117
4.15.7 token.command_id 117
4.15.8 token.csname_name 117
4.15.9 token.csname_id 118
5 Math 119
5.1 The current math style 119
5.1.1 \mathstyle 119
5.1.2 \Ustack 119
5.2 Unicode math characters 120
5.3 Cramped math styles 122
5.4 Math parameter settings 122
5.5 Font-based Math Parameters 123
5.6 Math spacing setting 126
5.7 Math accent handling 127
5.8 Math root extension 127
5.9 Math kerning in super- and subscripts 128
5.10 Scripts on horizontally extensible items like arrows 128
5.11 Extensible delimiters 129
5.12 Other Math changes 129
5.12.1 Verbose versions of single-character math commands 129
5.12.2 Allowed math commands in non-math modes 129
5.13 Math todo 129
8 Nodes 151
8.1 Lua node representation 151
8.1.1 Auxiliary items 151
8.1.1.1 glue_spec items 151
8.1.1.2 attribute_list and attribute items 152
8.1.1.3 action item 152
8.1.2 Main text nodes 153
8.1.2.1 hlist nodes 153
8.1.2.2 vlist nodes 154
8.1.2.3 rule nodes 154
8.1.2.4 ins nodes 154
8.1.2.5 mark nodes 154
8.1.2.6 adjust nodes 155
8.1.2.7 disc nodes 155
8.1.2.8 math nodes 155
8.1.2.9 glue nodes 156
8.1.2.10 kern nodes 156
8.1.2.11 penalty nodes 157
8.1.2.12 glyph nodes 157
8.1.2.13 margin_kern nodes 158
8.1.3 Math nodes 158
8.1.3.1 Math kernel subnodes 158
8.1.3.1.1 math_char and math_text_char subnodes 158
8.1.3.1.2 sub_box and sub_mlist subnodes 158
8.1.3.2 Math delimiter subnode 159
8.1.3.2.1 delim subnodes 159
8.1.3.3 Math core nodes 159
8.1.3.3.1 simple nodes 159
8.1.3.3.2 accent nodes 160
8.1.3.3.3 style nodes 160
8.1.3.3.4 choice nodes 160
8.1.3.3.5 radical nodes 161
8.1.3.3.6 fraction nodes 161
8.1.3.3.7 fence nodes 161
8.1.4 whatsit nodes 162
8.1.4.1 open nodes 162
8.1.4.2 write nodes 162
8.1.4.3 close nodes 162
8.1.4.4 special nodes 163
8.1.4.5 language nodes 163
8.1.4.6 local_par nodes 163
8.1.4.7 dir nodes 163
8.1.4.8 pdf_literal nodes 164
8.1.4.9 pdf_refobj nodes 164
8.1.4.10 pdf_refxform nodes 164
8.1.4.11 pdf_refximage nodes 164
8.1.4.12 pdf_annot nodes 165
8.1.4.13 pdf_start_link nodes 165
8.1.4.14 pdf_end_link nodes 165
8.1.4.15 pdf_dest nodes 166
8.1.4.16 pdf_thread nodes 166
8.1.4.17 pdf_start_thread nodes 166
8.1.4.18 pdf_end_thread nodes 166
8.1.4.19 pdf_save_pos nodes 167
8.1.4.20 late_lua nodes 167
8.1.4.21 pdf_colorstack nodes 167
8.1.4.22 pdf_setmatrix nodes 167
8.1.4.23 pdf_save nodes 167
8.1.4.24 pdf_restore nodes 168
8.1.4.25 user_defined nodes 168
9 Modifications 169
9.1 Changes from TEX 3.1415926 169
9.2 Changes from ε-TEX 2.2 169
9.3 Changes from pdfTEX 1.40 169
9.4 Changes from Aleph RC4 170
9.5 Changes from standard web2c 171
This book will eventually become the reference manual of LuaTEX. At the moment,
it simply reports the behaviour of the executable matching the snapshot or beta
release date in the title page.
Features may come and go. The current version of LuaTEX is not meant for produc-
tion and users cannot depend on stability, nor on functionality staying the same.
Nothing is considered stable just yet. This manual therefore simply reflects the
current state of the executable. Absolutely nothing on the following pages is set
in stone. When the need arises, anything can (and will) be changed without prior
notice.
If you are not willing to deal with this situation, you should wait for the stable
version. Currently we expect the 1.0 release to happen in spring 2012. Full
stabilization will not happen soon, the TODO list is still large.
Neither Aleph's I/O translation processes, nor tcx files, nor encTEX can be used, these encoding-related
functions are superseded by a Lua-based solution (reader callbacks). Also, some experimental pdfTEX
features are removed. These can be implemented in Lua instead.
2 Basic TEX enhancements
2.1 Introduction
From day one, LuaTEX has offered extra functionality when compared to the superset of pdfTEX and
Aleph. That has not been limited to the possibility to execute lua code via \directlua, but LuaTEX
also adds functionality via new TEX-side primitives.
However, starting with beta 0.39.0, most of that functionality is hidden by default. When LuaTEX
0.40.0 starts up in ‘iniluatex' mode (luatex -ini), it defines only the primitive commands known by
TEX82 and the one extra command \directlua.
As is fitting, a lua function has to be called to add the extra primitives to the user environment. The
simplest method to get access to all of the new primitive commands is by adding this line to the format
generation file:
\directlua { tex.enableprimitives('',tex.extraprimitives()) }
But be aware, that the curly braces may not have the proper \catcode assigned to them at this early
time (giving a 'Missing number' error), so it may be needed to put these assignments
\catcode `\{=1
\catcode `\}=2
before the above line. More fine-grained primitives control is possible, you can look the details in
section 4.12.11. For simplicity's sake, this manual assumes that you have executed the \directlua
command as given above.
The startup behavior documented above is considered stable in the sense that there will not be back-
ward-incompatible changes any more.
primitive explanation
\luatexversion a combination of major and minor number, as in pdfTEX; the current current value
is 60
\luatexrevision the revision number, as in pdfTEX; the current value is 1
\luatexdatestamp a combination of the local date and hour when the current executable was com-
piled, the syntax is identical to \luatexrevision; the value for the executable
that generated this document is 2010042610.
Note that the \luatexdatestamp depends on both the compilation time and compilation place of the
current executable; it is defined in terms of the local time. The purpose of this primitive is solely to be
an aid in the development process, do not use it for anything besides debugging.
\attribute2=5
\setbox0=\hbox {Hello}
\setbox2=\hbox attr1=12 attr2=-1{Hello}
This will set the attribute list of box 2 to 1 = 12, and the attributes of box 0 will be 2 = 5. As you can
see, assigning a negative value causes an attribute to be ignored.
The attr keyword(s) should come before a to or spread, if that is also specified.
2.6.1 \directlua
The primitive \directlua is used to execute Lua code immediately. The syntax is
\directlua general text
\directlua name general text general text
\directlua 16-bit number general text
The last general text is expanded fully, and then fed into the Lua interpreter. After reading and expansion
has been applied to the general text, the resulting token list is converted to a string as if it was displayed
using \the\toks. On the Lua side, each \directlua block is treated as a separate chunk. In such
a chunk you can use the local directive to keep your variables from interfering with those used by the
macro package.
The conversion to and from a token list means that you normally can not use Lua line comments (starting
with --) within the argument. As there typically will be only one ‘line' the first line comment will run
on until the end of the input. You will either need to use TEX-style line comments (starting with %), or
change the TEX category codes locally. Another possibility is to say:
\begingroup
\endlinechar=10
\directlua ...
\endgroup
Then Lua line comments can be used, since TEX does not replace line endings with spaces.
The name general text specifies the name of the Lua chunk, mainly shown in the stack backtrace of
error messages created by Lua code. The general text is expanded fully, thus macros can be used to
generate the chunk name, i.e.
$\pi = \directlua{tex.print(math.pi)}$
will result in
π = 3.1415926535898
Because the general text is a chunk, the normal Lua error handling is triggered if there is a problem in
the included code. The Lua error messages should be clear enough, but the contextual information is
still pretty bad. Often, you will only see the line number of the right brace at the end of the code.
While on the subject of errors: some of the things you can do inside Lua code can break up LuaTEX
pretty bad. If you are not careful while working with the node list interface, you may even end up with
assertion errors from within the TEX portion of the executable.
The behavior documented in the above subsection is considered stable in the sense that there will not
be backward-incompatible changes any more.
2.6.2 \latelua
\latelua stores Lua code in a whatsit that will be processed inside the output routine. Its intended
use is a cross between \pdfliteral and \write. Within the Lua code you can print pdf statements
directly to the pdf file via pdf.print, or you can write to other output streams via texio.write or
simply using lua's I/O routines.
\latelua general text
\latelua name general text general text
\latelua 16-bit number general text
Expansion of macros etcetera in the final <general text> is delayed until just before the what-
sit is executed (like in \write). With regard to PDF output stream \latelua behaves as
\pdfliteral page.
The name general text and 16-bit number behave in the same way as they do for \directlua
2.6.3 \luaescapestring
This primitive converts a TEX token sequence so that it can be safely used as the contents of a Lua string:
embedded backslashes, double and single quotes, and newlines and carriage returns are escaped. This
is done by prepending an extra token consisting of a backslash with category code 12, and for the line
endings, converting them to n and r respectively. The token sequence is fully expanded.
\luaescapestring general text
Most often, this command is not actually the best way to deal with the differences between the TEX and
Lua. In very short bits of Lua code it is often not needed, and for longer stretches of Lua code it is easier
to keep the code in a separate file and load it using Lua's dofile:
\directlua { dofile('mysetups.lua')}
2.7.1 \clearmarks
This primitive clears a marks class completely, resetting all three connected mark texts to empty.
\clearmarks 16-bit number
2.7.3 \formatname
\formatname's syntax is identical to \jobname.
In iniTEX, the expansion is empty. Otherwise, the expansion is the value that \jobname had during the
iniTEX run that dumped the currently loaded format.
2.7.4 \scantextokens
The syntax of \scantextokens is identical to \scantokens. This primitive is a slightly adapted
version of ε-TEX's \scantokens. The differences are:
• The last (and usually only) line does not have a \endlinechar appended
• \scantextokens never raises an EOF error, and it does not execute \everyeof tokens.
• The ‘ . . . while end of file . . . ' error tests are not executed, allowing the expansion to end on a
different grouping level or while a conditional is still incomplete.
primitive explanation
\alignmark Duplicates the functionality of # inside alignment preambles
\aligntab Duplicates the functionality of & inside alignments (and preambles)
2.7.6.1 \catcodetable
\catcodetable 16-bit number
The \catcodetable switches to a different catcode table. Such a table has to be previously created
using one of the two primitives below, or it has to be zero. Table zero is initialized by iniTEX.
2.7.6.2 \initcatcodetable
\initcatcodetable 16-bit number
The \initcatcodetable creates a new table with catcodes identical to those defined by iniTEX:
0 _ escape
5 ^^M car_ret
return (this name may change)
9 ^^@ null ignore
10 <space> spacespacer
11 a -- z letter
11 A -- Z letter
12 everything else other
14 % comment
15 ^^? delete invalid_char
The new catcode table is allocated globally: it will not go away after the current group has ended. If
the supplied number is identical to the currently active table, an error is raised.
2.7.6.3 \savecatcodetable
\savecatcodetable 16-bit number
\savecatcodetable copies the current set of catcodes to a new table with the requested number.
The definitions in this new table are all treated as if they were made in the outermost level.
The new table is allocated globally: it will not go away after the current group has ended. If the supplied
number is the currently active table, an error is raised.
\font\myfont = {cmr10}
This allows for embedded spaces, without the need for double quotes. Macro expansion takes place
inside the argument.
This allows for embedded spaces, without the need for double quotes. Macro expansion takes place
inside the argument.
2.8 Debugging
If \tracingonline is larger than 2, the node list display will also print the node number of the nodes.
3.1 Initialization
In this mode, it will set Lua's arg[0] to the found script name, pushing preceding options in negative
values and the rest of the commandline in the positive values, just like the Lua interpreter.
LuaTEX will exit immediately after executing the specified Lua script and is, in effect, a somewhat bulky
standalone Lua interpreter with a bunch of extra preloaded libraries.
In this mode, LuaTEX is exactly like luac from the standalone Lua distribution, except that it does not
have the -l switch, and that it accepts (but ignores) the --luaconly switch.
But if the option is present, LuaTEX will enter an alternative mode of commandline processing in com-
parison to the standard web2c programs.
In this mode, a small series of actions is taken in order. First, it will parse the commandline as
usual, but it will only interpret a small subset of the options immediately: --safer, --nosocket,
--[no-]shell-escape, --enable-write18, --disable-write18, --shell-restricted,
--help, --version, and --credits.
Now it searches for the requested Lua initialization script. If it can not be found using the actual name
given on the commandline, a second attempt is made by prepending the value of the environment variable
LUATEXDIR, if that variable is defined.
Then it checks the various safety switches. You can use those to disable some Lua commands that can
easily be abused by a malicious document. At the moment, --safer nils the following functions:
library functions
os execute exec setenv rename remove tmpdir
io popen output tmpfile
lfs rmdir mkdir chdir lock touch
Furthermore, it disables loading of compiled Lua libraries (support for these was added in 0.46.0), and
it makes io.open() fail on files that are opened for anything besides reading.
--nosocket makes the socket library unavailable, so that Lua cannot use networking.
The switches --[no-]shell-escape, --[enable|disable]-write18, and --shell-restricted
have the same effects as in pdfTEX, and additionally make io.popen(), os.execute, os.exec and
os.spawn adhere to the requested option.
Next the initialization script is loaded and executed. From within the script, the entire commandline is
available in the Lua table arg, beginning with arg[0], containing the name of the executable.
Commandline processing happens very early on. So early, in fact, that none of TEX's initializations have
taken place yet. For that reason, the tables that deal with typesetting, like tex, token, node and
pdf, are off-limits during the execution of the startup file (they are nilled). Special care is taken that
texio.write and texio.write_nl function properly, so that you can at least report your actions to
the log file when (and if) it eventually becomes opened (note that TEX does not even know its \jobname
yet at this point). See chapter 4 for more information about the LuaTEX-specific Lua extension tables.
Everything you do in the Lua initialization script will remain visible during the rest of the run, with the
exception of the aforementioned tex, token, node and pdf tables: those will be initialized to their
documented state after the execution of the script. You should not store anything in variables or within
tables with these four global names, as they will be overwritten completely.
We recommend you use the startup file only for your own TEX-independent initializations (if you need
any), to parse the commandline, set values in the texconfig table, and register the callbacks you need.
LuaTEX allows some of the commandline opiotns to be overridden by reading values from the texconfig
table at the end of script execution (see the description of the texconfig table later on in this document
for more details on which ones exactly).
Unless the texconfig table tells LuaTEX not to initialize kpathsea at all (set texconfig.kpse_init
to false for that), LuaTEX acts on three more commandline options after the initialization script is
finished:
in order to initialize the built-in kpathsea library properly, LuaTEX needs to know the correct program
name to use, and for that it needs to check --progname, or --ini and --fmt, if --progname is
missing.
CLUAINPUTS=.:$SELFAUTOLOC/lib/{$progname,$engine,}/lua//
This path is imperfect (it requires a TDS subtree below the binaries directory), but the architecture
has to be in the path somewhere, and the currently simplest way to do that is to search below
the binary directory only.
One level up (a lib directory parallel to bin) would have been nicer, but that is not doable
because texlive uses a bin/<arch> structure.
In keeping with the other TEX-like programs in TEXLive, the two Lua functions os.execute and
io.popen (as well as the two new functions os.exec and os.spawn that are explained below) take
the value of shell_escape and/or shell_escape_commands in account. Whenever LuaTEX is run
with the assumed intention to typeset a document (and by that I mean that it is called as luatex,
as opposed to texlua, and that the commandline option --luaonly was not given), it will only run
the four functions above if the matching texmf.cnf variable(s) or their texconfig (see section 4.13)
counterparts allow execution of the requested system command. In ‘script interpreter' runs of LuaTEX,
these settings have no effect, and all four functions function as normal. This change is new in 0.37.0.
The read("*line") function from the io library has been adjusted so that it is line-ending neutral:
any of LF, CR or CR+LF are acceptable line endings.
The tostring() printer for numbers has been changed so that it returns 0.00000000000001 instead
of 1e-14 (which confused TEX enormously). Even values with an even smaller exponent print simply
as 0.
luafilesystem has been extended: there are two extra boolean functions (lfs.isdir(filename)
and lfs.isfile(filename)) and one extra string field in its attributes table (permissions). There
is an additional function (added in 0.51) lfs.shortname() which takes a file name and returns its short
name on WIN32 platforms. On other platforms, it just returns the given argument. The file name is not
tested for existence. Finally, for non-WIN32 platforms only, there is the new function lfs.readlink()
(added in 0.51) that takes an existing symbolic link as argument and returns its content. It returns an
error on WIN32.
The string library has an extra function: string.explode(s[,m]). This function returns an array
containing the string argument s split into sub-strings based on the value of the string argument m. The
second argument is a string that is either empty (this splits the string into characters), a single character
(this splits on each occurrence of that character, possibly introducing empty strings), or a single character
followed by the plus sign + (this special version does not create empty sub-strings). The default value
for m is + (multiple spaces).
Note: m is not hidden by surrounding braces (as it would be if this function was written in TEX macros).
The string library also has six extra iterators that return strings piecemeal:
• os.selfdir is a variable that holds the directory path of argv[0]. For example:
/opt/tex/texmf-linux-64/bin (present since 0.27.0).
• os.exec(commandline) is a variation on os.execute.
The commandline can be either a single string or a single table.
If the argument is a table: LuaTEX first checks if there is a value at integer index zero. If there is,
this is the command to be executed. Otherwise, it will use the value at integer index one. (if neither
are present, nothing at all happens).
The set of consecutive values starting at integer 1 in the table are the arguments that are passed
on to the command (the value at index 1 becomes argv[0]). The command is searched for in the
execution path, so there is normally no need to pass on a fully qualified pathname.
If the argument is a string, then it is automatically converted into a table by splitting on whitespace.
In this case, it is impossible for the command and first argument to differ from each other.
In the string argument format, whitespace can be protected by putting (part of) an argument inside
single or double quotes. One layer of quotes is interpreted by LuaTEX, and all occurrences of \", \'
or \\ within the quoted text are un-escaped. In the table format, there is no string handling taking
place.
This function normally does not return control back to the Lua script: the command will replace the
current process. However, it will return the two values nil and 'error' if there was a problem
while attempting to execute the command.
On windows, the current process is actually kept in memory until after the execution of the command
has finished. This prevents crashes in situations where TEXLua scripts are run inside integrated TEX
environments.
The original reason for this command is that it cleans out the current process before starting the new
one, making it especially useful for use in TEXLua.
• os.spawn(commandline) is a returning version of os.exec, with otherwise identical calling
conventions.
If the command ran ok, then the return value is the exit status of the command. Otherwise, it will
return the two values nil and 'error'.
• os.setenv('key','value') This sets a variable in the environment. Passing nil instead of a
value string will remove the variable.
• os.env This is a hash table containing a dump of the variables and values in the process environment
at the start of the run. It is writeable, but the actual environment is not updated automatically.
• os.gettimeofday() Returns the current ‘Unix time', but as a float. This function is not available
on the SunOS platforms, so do not use this function for portable documents.
• os.times() Returns the current process times cf. the Unix C library ‘times' call in seconds. This
function is not available on the MS Windows and SunOS platforms, so do not use this function for
portable documents.
• os.tmpdir() This will create a directory in the ‘current directory' with the name luatex.XXXXXX
where the X-es are replaced by a unique string. The function also returns this string, so you can
lfs.chdir() into it, or nil if it failed to create the directory. The user is responsible for cleaning
up at the end of the run, it does not happen automatically.
• os.type This is a string that gives a global indication of the class of operating system. The possible
values are currently windows, unix, and msdos (you are unlikely to find this value ‘in the wild').
• os.name This is a string that gives a more precise indication of the operating system. These possible
values are not yet fixed, and for os.type values windows and msdos, the os.name values are
simply windows and msdos
The list for the type unix is more precise: linux, freebsd, kfreebsd (since 0.51), cygwin (since
0.53), openbsd, solaris, sunos (pre-solaris), hpux, irix, macosx, gnu (hurd), bsd (unknown,
but bsd-like), sysv (unknown, but sysv-like), generic (unknown).
(os.version is planned as a future extension)
• os.uname() This function returns a table with specific operating system information acquired at
runtime. The keys in the returned table are all string valued, and their names are: sysname,
machine, release, version, and nodename.
In stock Lua, many things depend on the current locale. In LuaTEX, we can't do that, because it makes
documents unportable. While LuaTEX is running if forces the following locale settings:
LC_CTYPE=C
LC_COLLATE=C
LC_NUMERIC=C
where the callback_name is a predefined callback name, see below. The function returns the internal
id of the callback or nil, if the callback could not be registered. In the latter case, error contains an
error message, otherwise it is nil.
LuaTEX internalizes the callback function in such a way that it does not matter if you redefine a function
accidentally.
Callback assignments are always global. You can use the special value nil instead of a function for
clearing the callback.
For some minor speed gain, you can assign the boolean false to the non-file related callbacks, doing
so will prevent LuaTEX from executing whatever it would execute by default (when no callback function
is registered at all). Be warned: this may cause all sorts of grief unless you know exactly what you are
doing! This functionality is present since version 0.38.
Currently, callbacks are not dumped into the format file.
The keys in the table are the known callback names, the value is a boolean where true means that the
callback is currently set (active).
function f = callback.find(callback_name)
If the callback is not set, callback.find returns nil.
Arguments:
id_number
This number is zero for the log or \input files. For TEX's \read or \write the number is incre-
mented by one, so \read0 becomes 1.
asked_name
This is the user-supplied filename, as found by \input, \openin or \openout.
Return value:
actual_name
This is the filename used. For the very first file that is read in by TEX, you have to make sure you
return an actual_name that has an extension and that is suitable for use as jobname. If you don't,
you will have to manually fix the name of the log file and output file after LuaTEX is finished, and
an eventual format filename will become mangled. That is because these file names depend on the
jobname.
You have to return nil if the file cannot be found.
4.1.1.2 find_font_file
Your callback function should have the following conventions:
4.1.1.3 find_output_file
Your callback function should have the following conventions:
<string> actual_name = function (<string> asked_name)
4.1.1.4 find_format_file
Your callback function should have the following conventions:
The asked_name is a format file for reading (the format file for writing is always opened in the current
directory).
4.1.1.5 find_vf_file
Like find_font_file, but for virtual fonts. This applies to both Aleph's ovf files and traditional
Knuthian vf files.
4.1.1.6 find_ocp_file
Like find_font_file, but for ocp files.
4.1.1.7 find_map_file
Like find_font_file, but for map files.
4.1.1.8 find_enc_file
Like find_font_file, but for enc files.
4.1.1.9 find_sfd_file
Like find_font_file, but for subfont definition files.
4.1.1.10 find_pk_file
Like find_font_file, but for pk bitmap files. The argument name is a bit special in this case. Its
form is
4.1.1.11 find_data_file
Like find_font_file, but for embedded files (\pdfobj file '...').
4.1.1.12 find_opentype_file
Like find_font_file, but for OpenType font files.
The asked_name is a font file. This callback is called while LuaTEX is building its internal list of
needed font files, so the actual timing may surprise you. Your return value is later fed back into the
matching read_file callback.
Strangely enough, find_type1_file is also used for OpenType (otf) fonts.
4.1.1.14 find_image_file
Your callback function should have the following conventions:
The asked_name is an image file. Your return value is used to open a file from the harddisk, so make
sure you return something that is considered the name of a valid file by your operating system.
4.1.2.1 open_read_file
Your callback function should have the following conventions:
file_name
The filename returned by a previous find_read_file or the return value of kpse.find_file()
if there was no such callback defined.
Return value:
env
This is a table containing at least one required and one optional callback function for this file. The
required field is reader and the associated function will be called once for each new line to be read,
the optional one is close that will be called once when LuaTEX is done with the file.
LuaTEX never looks at the rest of the table, so you can use it to store your private per-file data. Both
the callback functions will receive the table as their only argument.
4.1.2.1.1 reader
LuaTEX will run this function whenever it needs a new input line from the file.
function(<table> env)
return <string> line
end
Your function should return either a string or nil. The value nil signals that the end of file has
occurred, and will make TEX call the optional close function next.
4.1.2.1.2 close
LuaTEX will run this optional function when it decides to close the file.
function(<table> env)
return
end
function(<string> name)
return <boolean> success, <string> data, <number> data_size
end
The name will normally be a full path name as it is returned by either one of the file discovery callbacks
or the internal version of kpse.find_file().
success
Return false when a fatal error occurred (e. g. when the file cannot be found, after all).
data
The bytes comprising the file.
data_size
The length of the data, in bytes.
Return an empty string and zero if the file was found but there was a reading problem.
The list of functions is as follows:
4.1.3.1 process_input_buffer
This callback allows you to change the contents of the line input buffer just before LuaTEX actually starts
looking at it.
function(<string> buffer)
return <string> adjusted_buffer
end
If you return nil, LuaTEX will pretend like your callback never happened. You can gain a small amount
of processing time from that.
This callback does not replace any internal code.
function(<string> buffer)
return <string> adjusted_buffer
end
If you return nil, LuaTEX will pretend like your callback never happened. You can gain a small amount
of processing time from that.
This callback does not replace any internal code.
4.1.3.3 token_filter
This callback allows you to replace the way LuaTEX fetches lexical tokens.
function()
return <table> token
end
The calling convention for this callback is a bit more complicated than for most other callbacks. The
function should either return a Lua table representing a valid to-be-processed token or tokenlist, or
something else like nil or an empty table.
If your Lua function does not return a table representing a valid token, it will be immediately called
again, until it eventually does return a useful token or tokenlist (or until you reset the callback value to
nil). See the description of token for some handy functions to be used in conjunction with this callback.
If your function returns a single usable token, then that token will be processed by LuaTEX immediately.
If the function returns a token list (a table consisting of a list of consecutive token tables), then that
list will be pushed to the input stack at a completely new token list level, with its token type set to
‘inserted'. In either case, the returned token(s) will not be fed back into the callback function.
Setting this callback to false has no effect (because otherwise nothing would happen, forever).
4.1.4.1 buildpage_filter
This callback is called whenever LuaTEX is ready to move stuff to the main vertical list. You can use this
callback to do specialized manipulation of the page building stage like imposition or column balancing.
function(<string> extrainfo)
end
The string extrainfo gives some additional information about what TEX's state is with respect to the
‘current page'. The possible values are:
value explanation
alignment a (partial) alignment is being added
after_output an output routine has just finished
box a typeset box is being added
new_graf the beginning of a new paragraph
vmode_par \par was found in vertical mode
hmode_par \par was found in horizontal mode
insert an insert is added
penalty a penalty (in vertical mode)
before_display immediately before a display starts
after_display a display is finished
end LuaTEX is terminating (it's all over)
4.1.4.2 pre_linebreak_filter
This callback is called just before LuaTEX starts converting a list of nodes into a stack of \hboxes. The
removal of a possible final skip and the subsequent insertion of \parfillskip has not happened yet
at that moment.
The string called groupcode identifies the nodelist's context within TEX's processing. The
range of possibilities is given in the table below, but not all of those can actually appear in
pre_linebreak_filter, some are for the hpack_filter and vpack_filter callbacks that will
be explained in the next two paragraphs.
value explanation
<empty> main vertical list
hbox \hbox in horizontal mode
adjusted_hbox \hbox in vertical mode
vbox \vbox
vtop \vtop
align \halign or \valign
disc discretionaries
insert packaging an insert
vcenter \vcenter
local_box \localleftbox or \localrightbox
split_off top of a \vsplit
split_keep remainder of a \vsplit
align_set alignment cell
fin_row alignment row
4.1.4.3 linebreak_filter
This callback replaces LuaTEX's line breaking algorithm.
The returned node is the head of the list that will be added to the main vertical list, the boolean argument
is true if this paragraph is interrupted by a following math display.
If you return something that is not a <node>, LuaTEX will apply the internal linebreak algorithm on the
list that starts at <head>. Otherwise, the <node> you return is supposed to be the head of a list of
nodes that are all allowed in vertical mode, and the last of those has to represent a hbox. Failure to do
so will result in a fatal error.
Setting this callback to false is possible, but dangerous, because it is possible you will end up in an
unfixable ‘deadcycles loop'.
4.1.4.4 post_linebreak_filter
This callback is called just after LuaTEX has converted a list of nodes into a stack of \hboxes.
4.1.4.5 hpack_filter
This callback is called when TEX is ready to start boxing some horizontal mode material. Math items
and line boxes are ignored at the moment.
function(<node> head, <string> groupcode, <number> size,
<string> packtype [, <string> direction])
return true | false | <node> newhead
end
4.1.4.6 vpack_filter
This callback is called when TEX is ready to start boxing some vertical mode material. Math displays
are ignored at the moment.
This function is very similar to the hpack_filter. Besides the fact that it is called at different moments,
there is an extra variable that matches TEX's \maxdepth setting.
4.1.4.7 pre_output_filter
This callback is called when TEX is ready to start boxing the box 255 for \output.
4.1.4.8 hyphenate
No return values. This callback has to insert discretionary nodes in the node list it receives.
Setting this callback to false will prevent the internal discretionary insertion pass.
4.1.4.9 ligaturing
No return values. This callback has to apply ligaturing to the node list it receives.
You don't have to worry about return values because the head node that is passed on to the callback is
guaranteed not to be a glyph_node (if need be, a temporary node will be prepended), and therefore it
cannot be affected by the mutations that take place. After the callback, the internal value of the ‘tail of
the list' will be recalculated.
The next of head is guaranteed to be non-nil.
The next of tail is guaranteed be nil, and therefore the second callback argument can often be ignored.
It is provided for orthogonality, and because it can sometimes be handy when special processing has to
take place.
Setting this callback to false will prevent the internal ligature creation pass.
4.1.4.10 kerning
No return values. This callback has to apply kerning between the nodes in the node list it receives. See
ligaturing for calling conventions.
Setting this callback to false will prevent the internal kern insertion pass.
4.1.4.11 mlist_to_hlist
This callback replaces LuaTEX's math list to node list conversion algorithm.
The returned node is the head of the list that will be added to the vertical or horizontal list, the string
argument is either ‘text' or ‘display' depending on the current math mode, the boolean argument is true
if penalties have to be inserted in this list, false otherwise.
Setting this callback to false is bad, it will almost certainly result in an endless loop.
4.1.5.1 start_run
function()
This callback replaces the code that prints LuaTEX's banner. Note that for successful use, this callback
has to be set in the lua initialization file, otherwise it will be seen only after the run has already started.
4.1.5.2 stop_run
function()
This callback replaces the code that prints LuaTEX's statistics and ‘output written to' messages.
4.1.5.3 start_page_number
function()
Replaces the code that prints the [ and the page number at the begin of \shipout. This callback
will also override the printing of box information that normally takes place when \tracingoutput is
positive.
4.1.5.4 stop_page_number
function()
4.1.5.5 show_error_hook
function()
return
end
This callback is run from inside the TEX error function, and the idea is to allow you to do some extra
reporting on top of what TEX already does (none of the normal actions are removed). You may find some
of the values in the status table useful.
This callback does not replace any internal code.
message
is the formal error message TEX has given to the user. (the line after the '!').
indicator
is either a filename (when it is a string) or a location indicator (a number) that can mean lots of
different things like a token list id or a \read number.
lineno
is the current line number.
This is an investigative item for 'testing the water' only. The final goal is the total replacement of TEX's
error handling routines, but that needs lots of adjustments in the web source because TEX deals with
errors in a somewhat haphazard fashion. This is why the exact definition of indicator is not given
here.
4.1.6.1 define_font
function(<string> name, <number> size, <number> id) return <table> font end
The string name is the filename part of the font specification, as given by the user.
The number size is a bit special:
The internal structure of the font table that is to be returned is explained in chapter 7. That table is
saved internally, so you can put extra fields in the table for your later Lua code to use.
Setting this callback to false is pointless as it will prevent font loading completely but will nevertheless
generate errors.
The internal structure of the metrics font table that is returned is explained in chapter 7.
The meaning of the number s, and the format of the returned table is similar to the one returned by the
read_tfm() function.
font.fonts[n] = { ... }
<table> f = font.fonts[n]
See chapter 7 for the structure of the tables. Because this is a virtual array, you cannot call pairs on
it, but see below for the font.each iterator.
The two metatable functions implementing the virtual array are:
<table> f = font.getfont(<number> n)
font.setfont(<number> n, <table> f)
Also note the following: assignments can only be made to fonts that have already been defined in TEX,
but have not been accessed at all since that definition. This limits the usability of the write access to
font.fonts quite a lot, a less stringent ruleset will likely be implemented later.
<boolean> f = font.frozen(<number> n)
The return value is one of true (unassignable), false (can be changed) or nil (not a valid font at all).
<number> i = font.define(<table> f)
The return value is the internal id number of the defined font (the index into font.fonts). If the font
creation fails, an error is raised. The table is a font structure, as explained in chapter 7.
This returns the font id number that would be returned by a font.define call if it was executed at
this spot in the code flow. This is useful for virtual fonts that need to reference themselves.
This returns the font id associated with csname string, or −1 if csname is not defined, new in 0.47.
This is an iterator over each of the defined TEX fonts. The first returned value is the index in font.fonts,
the second the font itself, as a Lua table. The indices are listed incrementally, but they do not always
form an array of consecutive numbers: in some cases there can be holes in the sequence.
This function returns either nil, or a table, or an array of small tables (in the case of a TrueType
collection). The returned table(s) will contain six fairly interesting information items from the font(s)
defined by the file:
Getting information through this function is (sometimes much) more efficient than loading the font prop-
erly, and is therefore handy when you want to create a dictionary of available fonts based on a directory
contents.
myfont = load_font('/opt/tex/texmf/fonts/data/arial.ttf')
f, w = fontloader.open('filename')
The first return value is a table representation of the font. The second return value is a table containing
any warnings and errors reported by fontloader while opening the font. In normal typesetting, you would
probably ignore the second argument, but it can be useful for debugging purposes.
For TrueType collections (when filename ends in 'ttc') and dfont collections, you have to use a second
string argument to specify which font you want from the collection. Use the fontname strings that are
returned by fontloader.info for that.
f, w = fontloader.open('filename','fontname')
Do not forget to store the fontname value in the psname field of the metrics table to be returned to
LuaTEX, otherwise the font inclusion backend will not be able to find the correct font in the collection.
The font file is parsed and partially interpreted by the font loading routines from FontForge. The file
format can be OpenType, TrueType, TrueType Collection, cff, or Type1.
There are a few advantages to this approach compared to reading the actual font file ourselves:
• The font is automatically re-encoded, so that the metrics table for TrueType and OpenType fonts
is using Unicode for the character indices.
• Many features are pre-processed into a format that is easier to handle than just the bare tables
would be.
• PostScript-based OpenType fonts do not store the character height and depth in the font file, so the
character boundingbox has to be calculated in some way.
• In the future, it may be interesting to allow Lua scripts access to the font program itself, perhaps
even creating or changing the font.
fontloader.apply_featurefile(f,'filename')
A ‘feature file' is a textual representation of the features in an OpenType font. See http:
//www.adobe.com/devnet/opentype/afdko/topic_feature_file_syntax.html and http://fontforge.sourceforge
.net/featurefile.html for a more detailed description of feature files.
fontloader.apply_afmfile(f,'filename')
An afm file is a textual representation of (some of) the meta information in a Type1 font. See http://www
.adobe.com/devnet/font/pdfs/5004.AFM_Spec.pdf for more information about afm files.
Note: If you fontloader.open() a Type1 file named font.pfb, the library will automatically search
for and apply font.afm if it exists in the same directory as the file font.pfb. In that case, there is
no need for an explicit call to apply_afmfile().
4.3.5.1.1 Top-level
The top-level keys in the returned table are (the explanations in this part of the documentation are not
yet finished):
The lookups is a hash, based on lookup subtable names, with the value of each key inside that a linear
array of small hashes:
For the first seven values of type, there can be additional sub-information, stored in the sub-table
specification:
Tables for offset_specs contain up to four number-valued fields: x (a horizontal offset), y (a vertical
offset), h (an advance width correction) and v (an advance height correction).
The ligatures is a linear array of small hashes:
The anchor table is indexed by a string signifying the anchor type, which is one of
The content of these is an short array of defined anchors, with the entry keys being the anchor names.
For all except baselig, the value is a single table with this definition:
For baselig, the value is a small array of such anchor sets sets, one for each constituent item of the
ligature.
For clarification, an anchor table could for example look like this :
['anchor'] = {
['basemark'] = {
['Anchor-7'] = { ['x']=170, ['y']=1080 }
},
['mark'] ={
['Anchor-1'] = { ['x']=160, ['y']=810 },
['Anchor-4'] = { ['x']=160, ['y']=800 }
},
['baselig'] = {
[1] = { ['Anchor-2'] = { ['x']=160, ['y']=650 } },
[2] = { ['Anchor-2'] = { ['x']=460, ['y']=640 } }
}
}
key explanation
copyright
family
subfamily
uniqueid
fullname
version
postscriptname
trademark
manufacturer
designer
descriptor
venderurl
designerurl
license
licenseurl
idontknow
preffamilyname
prefmodifiers
compatfull
sampletext
cidfindfontname
wwsfamily
wwssubfamily
The flags table has a true value for each of the lookup flags that is actually set:
4.3.5.1.12 sm table
4.3.5.1.14 mm table
The axismaps:
ScriptPercentScaleDown
ScriptScriptPercentScaleDown
DelimitedSubFormulaMinHeight
DisplayOperatorMinHeight
MathLeading
AxisHeight
AccentBaseHeight
FlattenedAccentBaseHeight
SubscriptShiftDown
SubscriptTopMax
SubscriptBaselineDropMin
SuperscriptShiftUp
SuperscriptShiftUpCramped
SuperscriptBottomMin
SuperscriptBaselineDropMax
SubSuperscriptGapMin
SuperscriptBottomMaxWithSubscript
SpaceAfterScript
UpperLimitGapMin
UpperLimitBaselineRiseMin
LowerLimitGapMin
LowerLimitBaselineDropMin
StackTopShiftUp
StackTopDisplayStyleShiftUp
StackBottomShiftDown
StackBottomDisplayStyleShiftDown
StackGapMin
StackDisplayStyleGapMin
StretchStackTopShiftUp
StretchStackBottomShiftDown
StretchStackGapAboveMin
StretchStackGapBelowMin
FractionNumeratorShiftUp
FractionNumeratorDisplayStyleShiftUp
FractionDenominatorShiftDown
FractionDenominatorDisplayStyleShiftDown
FractionNumeratorGapMin
FractionNumeratorDisplayStyleGapMin
FractionRuleThickness
FractionDenominatorGapMin
FractionDenominatorDisplayStyleGapMin
SkewedFractionHorizontalGap
SkewedFractionVerticalGap
OverbarVerticalGap
OverbarRuleThickness
OverbarExtraAscender
UnderbarVerticalGap
UnderbarRuleThickness
UnderbarExtraDescender
RadicalVerticalGap
RadicalDisplayStyleVerticalGap
RadicalRuleThickness
RadicalExtraAscender
RadicalKernBeforeDegree
RadicalKernAfterDegree
RadicalDegreeBottomRaisePercent
MinConnectorOverlap
FractionDelimiterSize (new in 0.47.0)
FractionDelimiterDisplayStyleSize (new in 0.47.0)
key explanation
bad_ps_fontname
bad_glyph_table
bad_cff_table
bad_metrics_table
bad_cmap_table
bad_bitmaps_table
bad_gx_table
bad_ot_table
bad_os2_version
bad_sfnt_header
4.3.5.1.18 horiz_base and vert_base table
The features points to an array of tables with the same layout except that in those nested tables, the
tag represents a language.
Rule items have one common item and one specialized item:
coverage:
reversecoverage:
img.new
<image> var = img.new()
<image> var = img.new(image_spec)
This function creates a userdata object of type ‘image'. The image_spec argument is optional. If it is
given, it must be a table, and that table must contain a filename key. A number of other keys can also
be useful, these are explained below.
You can either say
a=img.new()
followed by
a.filename="foo.png"
or you can put the file name (and some or all of the other keys) into a table directly, like so:
a=img.new{filename='foo.pdf',page=1}
The generated <image> userdata object allows access to a set of user-specified values as well as a
set of values that are normally filled in and updated automatically by LuaTEX itself. Some of those are
derived from the actual image file, others are updated to reflect the pdf output status of the object.
There is one required user-specified field: the file name (filename). It can optionally be augmented
by the requested image dimensions (width, depth, height), user-specified image attributes (attr),
the requested pdf page identifier (page), the requested boundingbox (pagebox) for pdf inclusion, the
requested color space object (colorspace).
The function img.new does not access the actual image file, it just creates the <image> userdata object
and initializes some memory structures. The <image> object and its internal structures are automatically
garbage collected.
Once the image is scanned, all the values in the <image> become frozen, and you cannot change them
any more.
img.keys
<table> keys = img.keys()
This function returns a list of all the possible image_spec keys, both user-supplied and automatic ones.
A running (undefined) dimension in width, height, or depth is represented as nil in Lua, so if you
want to load an image at its ‘natural' size, you do not have to specify any of those three fields.
The stream parameter allows to fabricate an /XObject /Form object from a string giving the stream
contents, e. g., for a filled rectangle:
When writing the image, an /Xobject /Form object is created, like with embedded pdf file writing.
The object is written out only once. The stream key requires that also the bbox table is given. The
stream key conflicts with the filename key. The transform key works as usual also with stream.
The bbox key needs a table with four boundingbox values, e. g.:
This replaces and overrules any given pagebox value; with given bbox the box dimensions coming with
an embedded pdf file are ignored. The xsize and ysize dimensions are set accordingly, when the
image is scaled. The bbox parameter is ignored for non-pdf images.
The transform allows to mirror and rotate the image in steps of 90 deg. The default value 0 gives
an unmirrored, unrotated image. Values 1--3 give counterclockwise rotation by 90, 180, or 270 degrees,
whereas with values 4--7 the image is first mirrored and then rotated counterclockwise by 90, 180,
or 270 degrees. The transform operation gives the same visual result as if you would externally
preprocess the image by a graphics tool and then use it by LuaTEX. If a pdf file to be embedded already
contains a /Rotate specification, the rotation result is the combination of the /Rotate rotation followed
by the transform operation.
img.scan
<image> var = img.scan(<image> var)
<image> var = img.scan(image_spec)
When you say img.scan(a) for a new image, the file is scanned, and variables such as xsize, ysize,
image type, number of pages, and the resolution are extracted. Each of the width, height, depth
fields are set up according to the image dimensions, if they were not given an explicit value already.
An image file will never be scanned more than once for a given image variable. With all subsequent
img.scan(a) calls only the dimensions are again set up (if they have been changed by the user in the
meantime).
For ease of use, you can do right-away a
img.copy
<image> var = img.copy(<image> var)
<image> var = img.copy(image_spec)
If you say a = b, then both variables point to the same <image> object. if you want to write out an
image with different sizes, you can do a b=img.copy(a).
Afterwards, a and b still reference the same actual image dictionary, but the dimensions for b can now
be changed from their initial values that were just copies from a.
img.write
<image> var = img.write(<image> var)
<image> var = img.write(image_spec)
By img.write(a) a pdf object number is allocated, and a whatsit node of subtype pdf_refximage
is generated and put into the output list. By this the image a is placed into the page stream, and the
image file is written out into an image stream object after the shipping of the current page is finished.
Again you can do a terse call like
The <image> variable is returned in case you want it for later processing.
img.immediatewrite
<image> var = img.immediatewrite(<image> var)
<image> var = img.immediatewrite(image_spec)
By img.immediatewrite(a) a pdf object number is allocated, and the image file for image a is written
out immediately into the pdf file as an image stream object (like with \immediate\pdfximage). The
object number of the image stream dictionary is then available by the objnum key. No pdf_refximage
whatsit node is generated. You will need an img.write(a) or img.node(a) call to let the image
appear on the page, or reference it by another trick; else you will have a dangling image object in the
pdf file.
Also here you can do a terse call like
The <image> variable is returned and you will most likely need it.
img.node
<node> n = img.node(<image> var)
<node> n = img.node(image_spec)
This function allocates a pdf object number and returns a whatsit node of subtype pdf_refximage,
filled with the image parameters width, height, depth, and objnum. Also here you can do a terse
call like:
node.write(img.node{filename="foo.png"})
img.types
<table> types = img.types()
This function returns a list with the supported image file type names, currently these are pdf, png, jpg,
and jbig2.
img.boxes
<table> boxes = img.boxes()
This function returns a list with the supported pdf page box names, currently these are media, crop,
bleed, trim, and art (all in lowercase letters).
kpse.set_program_name(<string> name)
kpse.set_program_name(<string> name, <string> progname)
The second argument controls the use of the ‘dotted' values in the texmf.cnf configuration file, and
defaults to the first argument.
Third, if you prefer the object oriented interface, you have to call a different function. It has the same
arguments, but it returns a userdata variable.
4.5.2 find_file
The most often used function in the library is find_file:
Arguments:
filename
the name of the file you want to find, with or without extension.
ftype
maps to the -format argument of kpsewhich. The supported ftype values are the same as the
ones supported by the standalone kpsewhich program:
'gf' 'TeX system sources'
'pk' 'PostScript header'
'bitmap font' 'Troff fonts'
'tfm' 'type1 fonts'
'afm' 'vf'
'base' 'dvips config'
'bib' 'ist'
'bst' 'truetype fonts'
'cnf' 'type42 fonts'
'ls-R' 'web2c files'
'fmt' 'other text files'
'map' 'other binary files'
'mem' 'misc fonts'
'mf' 'web'
'mfpool' 'cweb'
'mft' 'enc files'
'mp' 'cmap files'
'mppool' 'subfont definition files'
'MetaPost support' 'opentype fonts'
'ocp' 'pdftex config'
'ofm' 'lig files'
'opl' 'texmfscripts'
'otp' 'lua',
'ovf' 'font feature files',
'ovp' 'cid maps',
'graphic/figure' 'mlbib',
'tex' 'mlbst',
'TeX system documentation' 'clua',
'texpool'
The default type is tex. Note: this is different from kpsewhich, which tries to deduce the file type
itself from looking at the supplied extension. The last four types: 'font feature files', 'cid maps',
'mlbib', 'mlbst' were new additions in LuaTEX 0.40.2.
mustexist
is similar to kpsewhich's -must-exist, and the default is false. If you specify true (or a non-
zero integer), then the kpse library will search the disk as well as the ls-R databases.
dpi
This is used for the size argument of the formats pk, gf, and bitmap font.
4.5.3 lookup
A more powerful (but slower) generic method for finding files is also available (since 0.51).
4.5.4 init_prog
Extra initialization for programs that need to generate bitmap fonts.
4.5.5 readable_file
Test if an (absolute) file name is a readable file
The return value is the actual absolute filename you should use, because the disk name is not always
the same as the requested name, due to aliases and system-specific handling under e. g. msdos.
Returns nil if the file does not exist or is not readable.
4.5.6 expand_path
Like kpsewhich's -expand-path:
<string> r = kpse.expand_path(<string> s)
4.5.7 expand_var
Like kpsewhich's -expand-var:
<string> r = kpse.expand_var(<string> s)
4.5.8 expand_braces
Like kpsewhich's -expand-braces:
<string> r = kpse.expand_braces(<string> s)
4.5.9 show_path
Like kpsewhich's -show-path:
4.5.10 var_value
Like kpsewhich's -var-value:
<string> r = kpse.var_value(<string> s)
4.5.11 version
Returns the kpathsea version string (new in 0.51)
<string> r = kpse.version()
<language> l = lang.new()
<language> l = lang.new(<number> id)
This function creates a new userdata object. An object of type <language> is the first argument to
most of the other functions in the lang library. These functions can also be used as if they were object
methods, using the colon syntax.
Without an argument, the next available internal id number will be assigned to this object. With argument,
an object will be created that links to the internal language with that id number.
<number> n = lang.id(<language> l)
<string> n = lang.hyphenation(<language> l)
lang.hyphenation(<language> l, <string> n)
Either returns the current hyphenation exceptions for this language, or adds new ones. The syntax of
the string is explained in the next chapter, section 6.3.
lang.clear_hyphenation(<language> l)
<string> n = lang.clean(<string> o)
Creates a hyphenation key from the supplied hyphenation value. The syntax of the argument string is
explained section 6.3. This function is useful if you want to do something else based on the words in a
dictionary file, like spell-checking.
<string> n = lang.patterns(<language> l)
lang.patterns(<language> l, <string> n)
Adds additional patterns for this language object, or returns the current set. The syntax of this string is
explained in section 6.3.
lang.clear_patterns(<language> l)
<number> n = lang.prehyphenchar(<language> l)
lang.prehyphenchar(<language> l, <number> n)
Gets or sets the ‘pre-break' hyphen character for implicit hyphenation in this language (initially the
hyphen, decimal 45).
<number> n = lang.posthyphenchar(<language> l)
lang.posthyphenchar(<language> l, <number> n)
Gets or sets the ‘post-break' hyphen character for implicit hyphenation in this language (initially null,
decimal 0, indicating emptiness).
<number> n = lang.preexhyphenchar(<language> l)
lang.preexhyphenchar(<language> l, <number> n)
Gets or sets the ‘pre-break' hyphen character for explicit hyphenation in this language (initially null,
decimal 0, indicating emptiness).
<number> n = lang.postexhyphenchar(<language> l)
lang.postexhyphenchar(<language> l, <number> n)
Gets or sets the ‘post-break' hyphen character for explicit hyphenation in this language (initially null,
decimal 0, indicating emptiness).
Inserts hyphenation points (discretionary nodes) in a node list. If tail is given as argument, processing
stops on that node. Currently, success is always true if head (and tail, if specified) are proper nodes,
regardless of possible other errors.
Hyphenation works only on ‘characters', a special subtype of all the glyph nodes with the node subtype
having the value 1. Glyph modes with different subtypes are not processed. See section 6.1 for more
details.
<string> s = lua.version
This returns the Lua version identifier string. The value is currently lua.version.
The contents of the lua.bytecode array is stored inside the format file as actual Lua bytecode, so it
can also be used to preload Lua code.
Note: The function must not contain any upvalues. Currently, functions containing upvalues can be
stored (and their upvalues are set to nil), but this is an artifact of the current Lua implementation and
thus subject to change.
The associated function calls are
function f = lua.getbytecode(<number> n)
lua.setbytecode(<number> n, <function> f)
Note: Since a Lua file loaded using loadfile(filename) is essentially an anonymous function, a
complete file can be stored in a bytecode register like this:
lua.bytecode[n] = loadfile(filename)
Now all definitions (functions, variables) contained in the file can be created by executing this bytecode
register:
lua.bytecode[n]()
Note that the path of the file is stored in the Lua bytecode to be used in stack backtraces and therefore
dumped into the format file if above code is used in iniTEX. If it contains private information, i.e. the user
name, this information is then contained in the format file as well. This should be kept in mind when
preloading files into a bytecode register in iniTEX.
lua.name[<number> n] = <string> s
<string> s = lua.name[<number n>]
If you want to unset a lua name, you can assign nil to it.
4.8.1 mplib.new
To create a new METAPOST instance, call
<mpinstance> mp = mplib.new({...})
This creates the mp instance object. The argument hash can have a number of different fields, as follows:
with:
type the kind of file, one of: mp, mem, tfm, map, pfb, enc
Return either the full pathname of the found file, or nil if the file cannot be found.
4.8.2 mp:statistics
You can request statistics with:
This function returns the vital statistics for an MPlib instance. There are four fields, giving the maximum
number of used items in each of the four statically allocated object classes:
4.8.3 mp:execute
You can ask the METAPOST interpreter to run a chunk of code by calling
4.8.4 mp:finish
local rettable = mp:finish()
If for some reason you want to stop using an MPlib instance while processing is not yet actually done,
you can call mp:finish. Eventually, used memory will be freed and open files will be closed by the
Lua garbage collector, but an explicit mp:finish is the only way to capture the final part of the output
streams.
When status equals 3, you should stop using this MPlib instance immediately, it is no longer capable
of processing input.
If it is present, each of the entries in the fig array is a userdata representing a figure object, and each
of those has a number of object methods you can call:
NOTE: you can call fig:objects() only once for any one fig object!
When the boundingbox represents a ‘negated rectangle', i.e. when the first set of coordinates is larger
than the second set, the picture is empty.
Graphical objects come in various types that each have a different list of accessible values. The types
are: fill, outline, text, start_clip, stop_clip, start_bounds, stop_bounds, special.
There is helper function (mplib.fields(obj)) to get the list of accessible values for a particular
object, but you can just as easily use the tables given below).
All graphical objects have a field type that gives the object type as a string value, that not explicit
mentioned in the tables. In the following, numbers are PostScript points represented as a floating point
number, unless stated otherwise. Field values that are of table are explained in the next section.
4.8.5.1 fill
4.8.5.3 text
There is one special case: pens that are (possibly transformed) ellipses have an extra string-valued key
type with value elliptical besides the array part containing the knot list.
4.8.6.2 Colors
A color is an integer array with 0, 1, 3 or 4 values:
4.8.6.3 Transforms
Each transform is a six-item array.
1 number represents x
2 number represents y
3 number represents xx
4 number represents yx
5 number represents xy
6 number represents yy
Note that the translation (index 1 and 2) comes first. This differs from the ordering in PostScript, where
the translation comes last.
4.8.6.4 Dashes
Each dash is two-item hash, using the same model as PostScript for the representation of the dashlist.
dashes is an array of ‘on' and ‘off', values, and offset is the phase of the pattern.
4.8.7.1 mp.char_width
4.8.7.2 mp.char_height
4.8.7.3 mp.char_depth
<number> w = mp.char_depth(<string> fontname, <number> char)
• The next field returns the userdata object for the next node in a linked list of nodes, or nil, if there
is no next node.
• The id indicates TEX's ‘node type'. The field id has a numeric value for efficiency reasons, but some
of the library functions also accept a string value instead of id.
• The subtype is another number. It often gives further information about a node of a particular id,
but it is most important when dealing with ‘whatsits', because they are differentiated solely based
on their subtype.
The other available fields depend on the id (and for ‘whatsits', the subtype) of the node. Further
details on the various fields and their meanings are given in chapter 8.
Support for unset (alignment) nodes is partial: they can be queried and modified from Lua code, but
not created.
Nodes can be compared to each other, but: you are actually comparing indices into the node memory.
This means that equality tests can only be trusted under very limited conditions. It will not work correctly
in any situation where one of the two nodes has been freed and/or reallocated: in that case, there will
be false positives.
At the moment, memory management of nodes should still be done explicitly by the user. Nodes are not
‘seen' by the Lua garbage collector, so you have to call the node freeing functions yourself when you
are no longer in need of a node (list). Nodes form linked lists without reference counting, so you have
to be careful that when control returns back to LuaTEX itself, you have not deleted nodes that are still
referenced from a next pointer elsewhere, and that you did not create nodes that are referenced more
than once.
There are statistics available with regards to the allocated node memory, which can be handy for tracing.
4.9.1.1 node.types
table t = node.types()
This function returns an array that maps node id numbers to node type strings, providing an overview of
the possible top-level id types.
4.9.1.2 node.whatsits
table t = node.whatsits()
TEX's ‘whatsits' all have the same id. The various subtypes are defined by their subtype. The function
is much like node.types, except that it provides an array of subtype mappings.
4.9.1.3 node.id
4.9.1.4 node.subtype
This converts a single whatsit name to its internal numeric representation (subtype).
4.9.1.5 node.type
4.9.1.6 node.fields
This function returns an array of valid field names for a particular type of node. If you want to get the
valid fields for a ‘whatsit', you have to supply the second argument also. In other cases, any given second
argument will be silently ignored.
This function accepts string id and subtype values as well.
4.9.1.7 node.has_field
4.9.1.8 node.new
Creates a new node. All of the new node's fields are initialized to either zero or nil except for id and
subtype (if supplied). If you want to create a new whatsit, then the second argument is required,
otherwise it need not be present. As with all node functions, this function creates a node on the TEX
level.
This function accepts string id and subtype values as well.
4.9.1.9 node.free
node.free(<node> n)
Removes the node n from TEX's memory. Be careful: no checks are done on whether this node is still
pointed to from a register or some next field: it is up to you to make sure that the internal data
structures remain correct.
4.9.1.10 node.flush_list
node.flush_list(<node> n)
Removes the node list n and the complete node list following n from TEX's memory. Be careful: no
checks are done on whether any of these nodes is still pointed to from a register or some next field: it
is up to you to make sure that the internal data structures remain correct.
4.9.1.11 node.copy
<node> m = node.copy(<node> n)
Creates a deep copy of node n, including all nested lists as in the case of a hlist or vlist node. Only the
next field is not copied.
4.9.1.12 node.copy_list
<node> m = node.copy_list(<node> n)
<node> m = node.copy_list(<node> n, <node> m)
Creates a deep copy of the node list that starts at n. If m is also given, the copy stops just before node
m.
4.9.1.13 node.hpack
This function creates a new hlist by packaging the list that begins at node n into a horizontal box.
With only a single argument, this box is created using the natural width of its components. In the three
argument form, info must be either additional or exactly, and w is the additional (\hbox spread)
or exact (\hbox to) width to be used.
Direction support added in LuaTEX 0.45.
The second return value is the badness of the generated box, this extension was added in 0.51.
Caveat: at this moment, there can be unexpected side-effects to this function, like updating some of
the \marks and \inserts. Also note that the content of h is the original node list n: if you call
node.free(h) you will also free the node list itself, unless you explicitly set the list field to nil
beforehand. And in a similar way, calling node.free(n) will invalidate h as well!
This function creates a new vlist by packaging the list that begins at node n into a vertical box. With only
a single argument, this box is created using the natural width of its components. In the three argument
form, info must be either additional or exactly, and w is the additional (\vbox spread) or exact
(\vbox to) height to be used.
Direction support added in LuaTEX 0.45.
The second return value is the badness of the generated box, this extension was added in 0.51.
See the description of node.hpack() for a few memory allocation caveats.
This calling method takes glue settings into account and is especially useful for finding the actual width
of a sublist of nodes that are already boxed, for example in code like this, which prints the width of the
space inbetween the a and b as it would be if \box0 was used as-is:
\directlua{print (node.dimensions(tex.box[0].glue_set,
tex.box[0].glue_sign,
tex.box[0].glue_order,
tex.box[0].list.next,
node.tail(tex.box[0].list))) }
4.9.1.16 node.mlist_to_hlist
<node> h = node.mlist_to_hlist(<node> n,
<string> displaytype, <boolean> penalties)
This runs the internal mlist to hlist conversion, converting the math list in n into the horizontal list h.
The interface is exactly the same as for the callback mlist_to_hlist.)
4.9.1.17 node.slide
<node> m = node.slide(<node> n)
Returns the last node of the node list that starts at n. As a side-effect, it also creates a reverse chain
of prev pointers between nodes.
4.9.1.18 node.tail
<node> m = node.tail(<node> n)
4.9.1.19 node.length
<number> i = node.length(<node> n)
<number> i = node.length(<node> n, <node> m)
Returns the number of nodes contained in the node list that starts at n. If m is also supplied it stops at
m instead of at the end of the list. The node m is not counted.
4.9.1.20 node.count
Returns the number of nodes contained in the node list that starts at n that have an matching id field.
If m is also supplied, counting stops at m instead of at the end of the list. The node m is not counted.
This function also accept string id's.
4.9.1.21 node.traverse
<node> t = node.traverse(<node> n)
This is an iterator that loops over the node list that starts at n.
4.9.1.22 node.traverse_id
This is an iterator that loops over all the nodes in the list that starts at n that have a matching id field.
4.9.1.23 node.remove
4.9.1.24 node.insert_before
This function inserts the node new before current into the list following head. It is your responsibility
to make sure that current is really part of that list. The return values are the (potentially mutated)
head and the new, set up to be part of the list (with correct next field). If head is initially nil, it will
become new.
4.9.1.25 node.insert_after
This function inserts the node new after current into the list following head. It is your responsibility
to make sure that current is really part of that list. The return values are the head and the new, set
up to be part of the list (with correct next field). If head is initially nil, it will become new.
4.9.1.26 node.first_character
<node> n = node.first_character(<node> n)
<node> n = node.first_character(<node> n, <node> m)
Returns the first node that is a glyph node with a subtype indicating it is a character, or nil.
4.9.1.27 node.ligaturing
Apply TEX-style ligaturing to the specified nodelist. The tail node m is optional. The two returned nodes
h and t are the new head and tail (both n and m can change into a new ligature).
4.9.1.28 node.kerning
<node> h, <node> t, <boolean> success = node.kerning(<node> n)
<node> h, <node> t, <boolean> success = node.kerning(<node> n, <node> m)
Apply TEX-style kerning to the specified nodelist. The tail node m is optional. The two returned nodes h
and t are the head and tail (either one of these can be an inserted kern node, because special kernings
with word boundaries are possible).
4.9.1.29 node.unprotect_glyphs
node.unprotect_glyphs(<node> n)
Subtracts 256 from all glyph node subtypes. This and the next function are helpers to convert from
characters to glyphs during node processing.
4.9.1.30 node.protect_glyphs
node.protect_glyphs(<node> n)
Adds 256 to all glyph node subtypes in the node list starting at n, except that if the value is 1, it adds
only 255. The special handling of 1 means that characters will become glyphs after subtraction of
256.
4.9.1.31 node.last_node
<node> n = node.last_node()
This function pops the last node from TEX's ‘current list'. It returns that node, or nil if the current list
is empty.
4.9.1.32 node.write
node.write(<node> n)
This is an experimental function that will append a node list to TEX's ‘current list' (the node list is not
deep-copied any more since version 0.38). There is no error checking yet!
4.9.2.1 node.has_attribute
Tests if a node has the attribute with number id set. If val is also supplied, also tests if the value
matches val. It returns the value, or, if no match is found, nil.
4.9.2.2 node.set_attribute
Sets the attribute with number id to the value val. Duplicate assignments are ignored. [needs expla-
nation]
4.9.2.3 node.unset_attribute
Unsets the attribute with number id. If val is also supplied, it will only perform this operation if the
value matches val. Missing attributes or attribute-value pairs are ignored.
If the attribute was actually deleted, returns its old value. Otherwise, returns nil.
pdf.h, pdf.v
These are the h and v values that define the current location on the output page, measured from its
lower left corner. The values can be queried using scaled points as units.
pdf.h
pdf.v
Note: this interface will almost certainly change in the future.
pdf.print()
A print function to write stuff to the pdf document that can be used from within a \latelua argument.
This function is not to be used inside \directlua unless you know exactly what you are doing.
pdf.print(<string> s)
pdf.print(<string> type, <string> s)
The optional parameter can be used to mimic the behavior of \pdfliteral: the type is direct or
page.
pdf.immediateobj()
This function creates a pdf object and immediately write it to the pdf file. It is modelled after pdfTEX's
\immediate\pdfobj primitives. All function variants return the object number of the newly generated
object.
n = pdf.immediateobj(<string> objtext)
n = pdf.immediateobj("file", <string> filename)
n = pdf.immediateobj("stream", <string> streamtext {, <string> attrtext})
n = pdf.immediateobj("streamfile", <string> filename, {, <string> attrtext})
The 1st version puts the objtext raw into an object. Only the object wrapper is automatically generated,
but any internal structure (like << >> dictionary markers) needs to provided by the user. The 2nd version
with keyword "file" as 1st argument puts the contents of the file with name filename raw into the
object. The 3rd version with keyword "stream" creates a stream object and puts the streamtext raw
into the stream. The stream length is automatically calculated. The optional attrtext goes into the
dictionary of that object. The 4th version with keyword "streamfile" does the same as the 3rd one,
it just reads the stream data raw from a file.
An optional first argument can be given to make the function use a previously reserved pdf object.
pdf.obj()
This function creates a pdf object, which is written to the pdf file only when referenced.
All function variants return the object number of the newly generated object, and there are two separate
calling modes.
The first mode is modelled after pdfTEX's \pdfobj primitive.
n = pdf.obj(<string> objtext)
n = pdf.obj("file", <string> filename)
n = pdf.obj("stream", <string> streamtext {, <string> attrtext})
n = pdf.obj("streamfile", <string> filename, {, <string> attrtext})
An optional first argument can be given to make the function use a previously reserved pdf object.
The second mode accepts a single argument table with key--value pairs.
The string field can have the values raw and stream, this field is required, the others are optional
(within constraints).
Note: this mode makes pdf.obj look more flexible than it actually is: the constraints from the separate
parameter version still apply, so for example you can't have both string and file at the same time.
pdf.reserveobj()
This function creates an empty pdf object and returns its number.
n = pdf.reserveobj()
n = pdf.reserveobj("annot")
The keys in the table are the known items, the value is the current value. Almost all of the values in
status are fetched through a metatable at run-time whenever they are accessed, so you cannot use
pairs on status, but you can use pairs on info, of course. If you do not need the full list, you can
also ask for a single item by using its name as an index into status.
The current list is:
key explanation
pdf_gone written pdf bytes
pdf_ptr not yet written pdf bytes
dvi_gone written dvi bytes
dvi_ptr not yet written dvi bytes
total_pages number of written pages
output_file_name name of the pdf or dvi file
log_name name of the log file
banner terminal display banner
var_used variable (one-word) memory in use
dyn_used token (multi-word) memory in use
str_ptr number of strings
init_str_ptr number of iniTEX strings
max_strings maximum allowed strings
pool_ptr string pool index
init_pool_ptr iniTEX string pool index
pool_size current size allocated for string characters
node_mem_usage a string giving insight into currently used nodes
var_mem_max number of allocated words for nodes
fix_mem_max number of allocated words for tokens
fix_mem_end maximum number of used tokens
cs_count number of control sequences
hash_size size of hash
hash_extra extra allowed hash
font_ptr number of active fonts
max_in_stack max used input stack entries
max_nest_stack max used nesting stack entries
max_param_stack max used parameter stack entries
max_buf_stack max used buffer position
max_save_stack max used save stack entries
stack_size input stack size
nest_size nesting stack size
param_size parameter stack size
buf_size current allocated size of the line buffer
save_size save stack size
obj_ptr max pdf object pointer
obj_tab_size pdf object table size
pdf_os_cntr max pdf object stream pointer
pdf_os_objidx pdf object stream index
pdf_dest_names_ptr max pdf destination pointer
dest_names_size pdf destination table size
pdf_mem_ptr max pdf memory used
pdf_mem_size pdf memory size
largest_used_mark max referenced marks class
filename name of the current input file
inputid numeric id of the current input
linenumber location in the current input file
lasterrorstring last error string
luabytecodes number of active Lua bytecode registers
luabytecode_bytes number of bytes in Lua bytecode registers
luastate_bytes number of bytes in use by Lua interpreters
output_active true if the \output routine is active
callbacks total number of executed callbacks so far
indirect_callbacks number of those that were themselves a result of other callbacks (e.g. file
readers)
luatex_svn the luatex repository id (added in 0.51)
luatex_version the luatex version number (added in 0.38)
luatex_revision the luatex revision string (added in 0.38)
ini_version true if this is an iniTEX run (added in 0.38)
Read-only:
tex.pagedepth tex.pagefilstretch tex.pagestretch
tex.pagefilllstretch tex.pagegoal tex.pagetotal
tex.pagefillstretch tex.pageshrink tex.prevdepth
tex.count.scratchcounter = 0
enormous = tex.dimen['maxdimen']
In this case, LuaTEX looks up the value for you on the fly. You have to use a valid \countdef (or
\attributedef, or \dimendef, or \skipdef, or \toksdef), anything else will generate an error
(the intent is to eventually also allow <chardef tokens> and even macros that expand into a number).
The attribute and count registers accept and return Lua numbers.
The dimension registers accept Lua numbers (in scaled points) or strings (with an included absolute
dimension; em and ex and px are forbidden). The result is always a number in scaled points.
The token registers accept and return Lua strings. Lua strings are converted to and from token lists
using \the\toks style expansion: all category codes are either space (10) or other (12).
The skip registers accept and return glue_spec userdata node objects (see the description of the node
interface elsewhere in this manual).
As an alternative to array addressing, there are also accessor functions defined for all cases, for example,
here is the set of possibilities for \skip registers:
In the function-based interface, it is possible to define values globally by using the string 'global' as
the first function argument.
note: these three virtual tables are deprecated and will be removed in luatex 0.70. You should switch
to using tex.box[].width etc. instead, see below.
It is also possible to set and query actual boxes, using the node interface as defined in the node library:
tex.box
tex.setbox(<number> n, <node> s)
tex.setbox('global', <number> n, <node> s)
<node> n = tex.getbox(<number> n)
for function-based access. In the function-based interface, it is possible to define values globally by
using the string 'global' as the first function argument.
Be warned that an assignment like
tex.box[0] = tex.box[2]
does not copy the node list, it just duplicates a node pointer. If \box2 will be cleared by TEX commands
later on, the contents of \box0 becomes invalid as well. To prevent this from happening, always use
node.copy_list() unless you are assigning to a temporary variable:
tex.box[0] = node.copy_list(tex.box[2])
display crampeddisplay
text crampedtext
script crampedscript
scriptscript crampedscriptscript
4.12.9.1 tex.print
tex.print(<string> s, ...)
tex.print(<number> n, <string> s, ...)
tex.print(<table> t)
tex.print(<number> n, <table> t)
Each string argument is treated by TEX as a separate input line. If there is a table argument instead of
a list of strings, this has to be a consecutive array of strings to print (the first non-string value will stop
the printing process). This syntax was added in 0.36.
The optional parameter can be used to print the strings using the catcode regime defined by
\catcodetable n. If n is −1, the currently active catcode regime is used. If n is −2, the result-
ing catcodes are in the result of \the: all category codes are 12 (other) except for the space character,
that has category code 10 (space). Otherwise, if n is not a valid catcode table, then it is ignored, and
the currently active catcode regime is used instead.
The very last string of the very last tex.print() command in a \directlua will not have the
\endlinechar appended, all others do.
4.12.9.2 tex.sprint
tex.sprint(<string> s, ...)
tex.sprint(<number> n, <string> s, ...)
tex.sprint(<table> t)
tex.sprint(<number> n, <table> t)
Each string argument is treated by TEX as a special kind of input line that makes it suitable for use as
a partial line input mechanism:
• TEX does not switch to the ‘new line' state, so that leading spaces are not ignored.
• No \endlinechar is inserted.
• Trailing spaces are not removed.
Note that this does not prevent TEX itself from eating spaces as result of interpreting the line. For
example, in
before\directlua{tex.sprint("\\relax")tex.sprint(" inbetween")}after
the space before inbetween will be gobbled as a result of the ‘normal' scanning of \relax.
If there is a table argument instead of a list of strings, this has to be a consecutive array of strings to
print (the first non-string value will stop the printing process). This syntax was added in 0.36.
4.12.9.3 tex.tprint
4.12.9.4 tex.write
tex.write(<string> s, ...)
tex.write(<table> t)
Each string argument is treated by TEX as a special kind of input line that makes is suitable for use as
a quick way to dump information:
• All catcodes on that line are either ‘space' (for ' ') or ‘character' (for all others).
• There is no \endlinechar appended.
If there is a table argument instead of a list of strings, this has to be a consecutive array of strings to
print (the first non-string value will stop the printing process). This syntax was added in 0.36.
4.12.10.1 tex.round
<number> n = tex.round(<number> o)
Rounds Lua number o, and returns a number that is in the range of a valid TEX register value. If the
number starts out of range, it generates a ‘number to big' error as well.
4.12.10.2 tex.scale
Multiplies the Lua numbers o and delta, and returns a rounded number that is in the range of a valid
TEX register value. In the table version, it creates a copy of the table with all numeric top--level values
scaled in that manner. If the multiplied number(s) are of range, it generates ‘number to big' error(s) as
well.
Note: the precision of the output of this function will depend on your computer's architecture and
operating system, so use with care! An interface to LuaTEX's internal, 100% portable scale function will
be added at a later date.
<number> n = tex.sp(<number> o)
<number> n = tex.sp(<string> s)
Converts the number o or a string s that represents an explicit dimension into an integer number of
scaled points.
For parsing the string, the same scanning and conversion rules are used that LuaTEX would use if it was
scanning a dimension specifier in its TEX-like input language (this includes generating errors for bad
values), expect for the following:
1. only explicit values are allowed, control sequences are not handled
2. infinite dimension units (fil...) are forbidden
3. mu units do not generate an error (but may not be useful either)
4.12.10.4 tex.definefont
4.12.11.1 tex.enableprimitives
tex.enableprimitives('LuaTeX', {'formatname'})
will define \LuaTeXformatname with the same intrinsic meaning as the documented primitive
\formatname, provided that the control sequences \LuaTeXformatname is currently undefined.
Second example:
tex.enableprimitives('Omega',tex.extraprimitives ('omega'))
will define a whole series of csnames like \Omegatextdir, \Omegapardir, etc., but it will stick with
\OmegaVersion instead of creating the doubly-prefixed \OmegaOmegaVersion.
Starting with version 0.39.0 (and this is why the above two functions are needed), LuaTEX in --ini
mode contains only the TEX82 primitives and \directlua, no extra primitives at all.
So, if you want to have all the new functionality available using their default names, as it is now, you
will have to add
4.12.11.2 tex.extraprimitives
This function returns a list of the primitives that originate from the engine(s) given by the requested
string value(s). The possible values and their (current) return values are:
name values
tex vskip write vsize unhcopy output - / unskip unvbox boxmaxdepth muskipdef
string toksdef floatingpenalty righthyphenmin voffset escapechar topmark splitfirstmark
vsplit everydisplay badness xleaders textfont showlists language mathchoice topskip
abovedisplayshortskip underline tracinglostchars pagefillstretch unvcopy splitbotmark
finalhyphendemerits atopwithdelims pretolerance fi dp setlanguage ht nulldelimiterspace or
wd pagegoal advance chardef catcode mathchar scriptscriptfont mathcode leftskip
pagefilstretch delcode fontname lastkern belowdisplayshortskip tolerance mathopen
exhyphenpenalty maxdepth futurelet abovewithdelims hangindent lastskip linepenalty
everyjob xspaceskip globaldefs everypar scriptfont delimiter afterassignment firstmark
lineskiplimit lineskip def fam day iffalse textstyle end mag box belowdisplayskip ifx
errmessage exhyphenchar hss expandafter hfilneg the displaywidth mathsurround
pagedepth looseness leaders vss ifhmode botmark ifinner displaystyle accent immediate
ifmmode parshape meaning abovedisplayskip medmuskip emergencystretch rightskip
mathclose hangafter hoffset aftergroup cleaders romannumeral hbadness mathbin
showboxbreadth jobname vbadness patterns nonstopmode errhelp predisplaypenalty
endlinechar mathinner lastbox showboxdepth postdisplaypenalty mathrel holdinginserts
radical mathord pagetotal everycr adjdemerits halign defaultskewchar errorcontextlines
splitmaxdepth ifcase tracingmacros moveright predisplaysize tracingrestores message ifhbox
deadcycles interlinepenalty mathpunct lccode noboundary displayindent nonscript everyhbox
global penalty tracingcommands everymath nolimits noalign inputlineno pagestretch parskip
indent dimendef widowpenalty ifvbox above spaceskip middle displaylimits pausing everyvbox
iftrue moveleft mathop endcsname dimen ifcat clubpenalty splittopskip doublehyphendemerits
ifdim limits ifeof insert delimitershortfall ifodd insertpenalties tracingpages vadjust
tracingonline count ifnum edef char begingroup tracingparagraphs hyphenation uccode hfuzz
openout leqno hyphenpenalty vcenter hfil thickmuskip maxdeadcycles mkern hbox overfullrule
else hsize raise thinmuskip spacefactor input hrule left eqno parfillskip font valign dump
relax prevdepth read shipout batchmode right skipdef setbox baselineskip special mskip
endgroup uchyph binoppenalty endinput omit pagefilllstretch overwithdelims newlinechar
vfilneg time vfill span prevgraf over show vbox tracingstats year defaulthyphenchar nullfont
muskip closeout toks outer multiply tracingoutput parindent displaywidowpenalty unhbox
lefthyphenmin vtop mathaccent discretionary vfuzz overline unkern showthe showbox
uppercase lowercase closein openin errorstopmode scrollmode skewchar hyphenchar sfcode
countdef mathchardef let xdef gdef long atop scriptscriptstyle scriptstyle unpenalty noindent
copy lower kern vfil hfill hskip pageshrink crcr cr ifvoid ifvmode if number lastpenalty skip
par vrule noexpand mark ignorespaces fontdimen divide csname scriptspace outputpenalty
month delimiterfactor relpenalty brokenpenalty tabskip
core directlua
etex unless botmarks currentiftype pagediscards mutoglue displaywidowpenalties fontcharic
fontchardp fontcharwd iffontchar eTeXVersion protected topmarks showgroups glueexpr
splitfirstmarks predisplaydirection gluetomu everyeof eTeXversion scantokens clubpenalties
savingvdiscards splitbotmarks showtokens tracingassigns dimexpr parshapedimen readline
eTeXminorversion glueshrinkorder ifdefined currentifbranch firstmarks lastnodetype marks
currentgrouplevel interlinepenalties muexpr unexpanded ifcsname parshapeindent
showifs parshapelength currentgrouptype widowpenalties splitdiscards glueshrink
gluestretch gluestretchorder numexpr interactionmode detokenize fontcharht currentiflevel
savinghyphcodes lastlinefit tracingnesting tracingscantokens tracingifs tracinggroups
eTeXrevision
pdftex pdfximage pdfpxdimen pdftrailer pdfuniqueresname pdfoutput pdfgentounicode pdfoutline
pdfsetrandomseed pdfprimitive pdfoptionpdfminorversion pdfendthread pdfimagehicolor
pdflastximagecolordepth pdfpkresolution pdfthreadmargin pdfimageapplygamma
pdfobjcompresslevel pdfpageheight pdfreplacefont pdfxformresources pdffirstlineheight
pdfcopyfont pdfvorigin ifincsname pdfnormaldeviate letterspacefont pdflastximagepages
ifpdfprimitive pdfcatalog pdfignoreddimen pdfpageattr pdfgamma pdffontname pdfannot
pdfnoligatures rightmarginkern pdflastlink pdfuniformdeviate pdfstartthread pdffontsize
expanded pdflastxpos pdflastypos pdfrandomseed pdfimagegamma ifpdfabsdim
pdfglyphtounicode pdffontobjnum pdftexrevision pdfcolorstack pdfxform pdfprotrudechars
ifpdfabsnum pdfcompresslevel pdfinsertht pdfstartlink quitvmode pdfmapfile pdftracingfonts
pdfpagebox pdfcreationdate pdfcolorstackinit pdfdest pdflastlinedepth pdfinclusionerrorlevel
pdfinfo pdfxformattr pdfxformname pdfpagesattr pdflastannot pdfsave pdfhorigin pdfpagewidth
pdfrefxform tagcode pdfeachlineheight pdfliteral pdflastximage pdfimageresolution
pdfdestmargin pdfobj pdfminorversion pdfeachlinedepth pdftexversion pdflastxform
pdfximagebbox pdfincludechars pdfsavepos pdfpkmode rpcode pdfretval pdfdecimaldigits
pdfadjustspacing pdftexbanner pdflinkmargin pdfdraftmode pdffontexpand pdfmapline
pdffontattr pdfnames pdfthread pdfendlink pdfrefximage pdfrefobj pdfrestore pdfsetmatrix
efcode lpcode leftmarginkern pdfpageref pdflastobj pdfinclusioncopyfonts pdfpageresources
omega textdir popocplist rightghost omathchardef nullocplist localrightbox addbeforeocplist
omathchar omathcode localleftbox addafterocplist bodydir localinterlinepenalty pagedir
chardp mathdir charht charit charwd pagewidth oradical externalocp OmegaVersion ocplist
clearocplists pardir localbrokenpenalty nullocp pageheight ocptracelevel removeafterocplist
removebeforeocplist pushocplist ocp odelcode omathaccent leftghost odelimiter
aleph pagebottomoffset Omegaminorversion Omegarevision Alephrevision boxdir AlephVersion
Alephminorversion Omegaversion Alephversion pagerightoffset
luatex Umathcloseopspacing Umathordpunctspacing Udelimiterunder luastartup
Umathopenpunctspacing Umathordinnerspacing Umathbinclosespacing Umathlimitbelowbgap
Umathopeninnerspacing Uoverdelimiter Umathpunctpunctspacing Umathclosepunctspacing
Umathrelordspacing Umathsupbottommin Umathlimitbelowkern Umathstackdenomdown
Umathfractionrule Umathpunctinnerspacing Umathcloseinnerspacing Umathopenrelspacing
Umathsupsubbottommax Umathcloserelspacing Umathcharnum Umathinnerordspacing
synctex formatname Umathrelinnerspacing Umathsubtopmax suppressoutererror
Umathsubsupshiftdown Umathopbinspacing Umathordbinspacing Umathrelopspacing
Umathopenbinspacing Umathoverdelimiterbgap alignmark Uunderdelimiter
Umathclosebinspacing Umathcodenum Umathpunctopenspacing Umathconnectoroverlapmin
crampedscriptscriptstyle Umathradicaldegreeafter luatexversion Umathfractionnumup
Umathopclosespacing Umathordclosespacing Umathoverdelimitervgap Udelcode
Umathopenclosespacing attribute Umathsubshiftdrop Umathsubshiftdown
Umathpunctrelspacing Umathradicaldegreeraise Umathsupshiftdrop Umathpunctclosespacing
Umathcloseclosespacing luatexrevision Umathchar Udelimiterover Ustack Umathcode
Udelcodenum suppresslongerror Umathbotaccent Umathaxis Umathfractionnumvgap
Umathrelclosespacing Umathpunctbinspacing luatexdatestamp Ustopdisplaymath
crampedscriptstyle latelua crampedtextstyle Umathbinrelspacing Umathopordspacing
attributedef Umathordordspacing Umathopenordspacing outputbox Ustopmath aligntab
Umathpunctopspacing Umathsubsupvgap luaescapestring Umathfractiondenomvgap
Umathradicalrule Umathunderbarrule postexhyphenchar Umathradicaldegreebefore
Umathstacknumup Umathbinopspacing Ustartdisplaymath savecatcodetable
Umathbinpunctspacing Uroot Umathoverbarkern Umathoperatorsize Uradical mathstyle
Umathopopenspacing Umathordopenspacing Umathbininnerspacing Umathinnerrelspacing
clearmarks Umathoverbarvgap Umathopenopenspacing Umathunderdelimiterbgap
Umathoverbarrule crampeddisplaystyle ifabsdim Umathlimitabovebgap Umathstackvgap
Umathinneropspacing Umathrelbinspacing Umathcloseopenspacing initcatcodetable nokerns
Umathlimitabovekern Udelimiter Umathfractiondelsize gleaders Umathunderdelimitervgap
Umathinnerbinspacing noligs Ustartmath Usubscript Umathaccent pagetopoffset
catcodetable Umathspaceafterscript primitive Umathinneropenspacing Umathaccents
Umathordopspacing Umathopenopspacing ifabsnum scantextokens suppressifcsnameerror
suppressfontnotfounderror pageleftoffset preexhyphenchar posthyphenchar
prehyphenchar Umathinnerinnerspacing Umathinnerpunctspacing Umathinnerclosespacing
Umathpunctordspacing Umathcloseordspacing Umathrelpunctspacing Umathrelopenspacing
Umathrelrelspacing Umathbinopenspacing Umathbinbinspacing Umathbinordspacing
Umathopinnerspacing Umathoppunctspacing Umathoprelspacing Umathopopspacing
Umathordrelspacing Umathsupshiftup Umathlimitbelowvgap Umathlimitabovevgap
Umathfractiondenomdown Umathradicalvgap Umathradicalkern Umathunderbarvgap
Umathunderbarkern Umathquad Umathchardef Usuperscript ifprimitive
Note that 'luatex' does not contain directlua, as that is considered to be a core primitive, along
with all the TEX82 primitives, so it is part of the list that is returned from 'core'.
Running tex.extraprimitives() will give you the complete list of primitives that are not de-
fined at LuaTEX 0.39.0 -ini startup. It is exactly equivalent to tex.extraprimitives('etex',
'pdftex', 'omega', 'aleph', 'luatex')
4.12.11.3 tex.primitives
<table> t = tex.primitives()
This function returns a hash table listing all primitives that LuaTEX knows about. The keys in the hash
are primitives names, the values are tables representing tokens (see section 4.15). The third value is
always zero.
This helper function is useful during linebreak calculations. f and s are scaled values; the function
returns the badness for when total f is supposed to be made from amounts that sum to s. The returned
number is a reasonable approximation of 100(t/s)3 ;
Note that there is no interface for \displaywidowpenalties, you have to pass the right choice for
widowpenalties yourself.
The meaning of the various keys should be fairly obvious from the table (the names match the TEX and
pdfTEX primitives) except for the last 5 entries. The four pdf...line... keys are ignored if their
value equals pdfignoreddimen.
It is your own job to make sure that listhead is a proper paragraph list: this function does not add
any nodes to it. To be exact, if you want to replace the core line breaking, you may have to do the
following (when you are not actually working in the pre_line_break or line_break callback, or
when the original list starting at listhead was generated in horizontal mode):
• add an ‘indent box' and perhaps a local_par node at the start (only if you need them)
• replace any found final glue by an infinite penalty (or add such a penalty, if the last node is not a
glue)
• add a glue node for the \parfillskip after that penalty node
• make sure all the prev pointers are OK
The result is a node list, it still needs to be vpacked if you want to assign it to a box.
The returned info table contains four values that are all numbers:
tex.shipout(<number> n)
Ships out box number n to the output file, and clears the box register.
Note: the numeric values that match web2c parameters are only used if kpse_init is explicitly set to
false. In all other cases, the normal values from texmf.cnf are used.
4.14.1.1 texio.write
Without the target argument, writes all given strings to the same location(s) TEX writes messages to
at this moment. If \batchmode is in effect, it writes only to the log, otherwise it writes to the log and
the terminal. The optional target can be one of three possibilities: term, log or term and log.
Note: If several strings are given, and if the first of these strings is or might be one of the targets above,
the target must be specified explicitly to prevent Lua from interpreting the first string as the target.
4.14.1.2 texio.write_nl
4.15.1 token.get_next
token t = token.get_next()
This fetches the next input token from the current input source, without expansion.
4.15.2 token.is_expandable
<boolean> b = token.is_expandable(token t)
4.15.3 token.expand
token.expand()
If a token is expandable, this will expand one level of it, so that the first token of the expansion will now
be the next token to be read by token.get_next().
4.15.4 token.is_activechar
<boolean> b = token.is_activechar(token t)
This is a special test that is sometimes handy. Discovering whether some control sequence is the result
of an active character turned out to be very hard otherwise.
4.15.5 token.create
token t = token.create(<string> csname)
token t = token.create(<number> charcode)
token t = token.create(<number> charcode, <number> catcode)
This is the token factory. If you feed it a string, then it is the name of a control sequence (without
leading backslash), and it will be looked up in the equivalence table.
If you feed it number, then this is assumed to be an input character, and an optional second number
gives its category code. This means it is possible to overrule a character's category code, with a few
exceptions: the category codes 0 (escape), 9 (ignored), 13 (active), 14 (comment), and 15 (invalid) cannot
occur inside a token. The values 0, 9, 14 and 15 are therefore illegal as input to token.create(), and
active characters will be resolved immediately.
Note: unknown string sequences and never defined active characters will result in a token representing
an ‘undefined control sequence' with a near-random name. It is not possible to define brand new control
sequences using token.create!
4.15.6 token.command_name
<string> commandname = token.command_name(<token> t)
This returns the name associated with the ‘command' value of the token in LuaTEX. There is not always
a direct connection between these names and primitives. For instance, all \ifxxx tests are grouped
under if_fest, and the ‘command modifier' defines which test is to be run.
4.15.7 token.command_id
<number> i = token.command_id(<string> commandname)
This returns a number that is the inverse operation of the previous command, to be used as the first item
in a token table.
4.15.8 token.csname_name
<string> csname = token.csname_name(<token> t)
This returns the name associated with the ‘equivalence table' value of the token in LuaTEX. It returns the
string value of the command used to create the current token, or an empty string if there is no associated
control sequence.
Keep in mind that there are potentially two control sequences that return the same csname string: single
character control sequences and active characters have the same ‘name'.
4.15.9 token.csname_id
<number> i = token.csname_id(<string> csname)
This returns a number that is the inverse operation of the previous command, to be used as the third
item in a token table.
5 Math
The handling of mathematics in LuaTEX differs quite a bit from how TEX82 (and therefore pdfTEX)
handles math. First, LuaTEX adds primitives and extends some others so that Unicode input can be used
easily. Second, all of TEX82's internal special values (for example for operator spacing) have been made
accessible and changeable via control sequences. Third, there are extensions that make it easier to use
OpenType math fonts. And finally, there are some extensions that have been proposed in the past that
are now added to the engine.
5.1.1 \mathstyle
The returned value is between 0 and 7 (in math mode), or −1 (all other modes). For easy testing, the
eight math style commands have been altered so that the can be used as numeric values, so you can
write code like this:
\ifnum\mathstyle=\textstyle
\message{normal text style}
\else \ifnum\mathstyle=\crampedtextstyle
\message{cramped text style}
\fi \fi
5.1.2 \Ustack
There are a few math commands in TEX where the style that will be used is not known straight from
the start. These commands (\over, \atop, \overwithdelims, \atopwithdelims) would therefore
normally return wrong values for \mathstyle. To fix this, LuaTEX introduces a special prefix command:
\Ustack:
Unaltered:
Unaltered:
\crampeddisplaystyle
\crampedtextstyle
\crampedscriptstyle
\crampedscriptscriptstyle
These additional commands are not all that valuable on their own, but they come in handy as arguments
to the math parameter settings that will be added shortly.
Each of the parameters in this section can be set by a command like this:
\Umathquad\displaystyle=1em
Note 1: OpenType fonts set \Umathlimitabovekern and \Umathlimitbelowkern to zero and set
\Umathquad to the font size of the used font, because these are not supported in the MATH table,
Note 2: tfm fonts do not set \Umathradicalrule because TEX82 uses the height of the rad-
ical instead. When this parameter is indeed not set when LuaTEX has to typeset a rad-
ical, a backward compatibility mode will kick in that assumes that an oldstyle TEX font is
used. Also, they do not set \Umathradicaldegreebefore, \Umathradicaldegreeafter, and
\Umathradicaldegreeraise. These are then automatically initialized to 5/18quad, −10/18quad,
and 60.
Note 3: If tfm fonts are used, then the \Umathradicalvgap is not set until the first time LuaTEX
has to typeset a formula because this needs parameters from both family2 and family3. This pro-
vides a partial backward compatibility with TEX82, but that compatibility is only partial: once the
\Umathradicalvgap is set, it will not be recalculated any more.
Note 4: (also if tfm fonts are used) A similar situation arises wrt. \Umathspaceafterscript: it is
not set until the first time LuaTEX has to typeset a formula. This provides some backward compatibility
with TEX82. But once the \Umathspaceafterscript is set, \scriptspace will never be looked at
again.
Note 5: Tfm fonts set \Umathconnectoroverlapmin to zero because TEX82 always stacks extensibles
without any overlap.
Note 6: The \Umathoperatorsize is only used in \displaystyle, and is only set in OpenType
fonts. In tfm font mode, it is artificially set to one scaled point more than the initial attempt's size, so
that always the ‘first next' will be tried, just like in TEX82.
Note 7: The \Umathradicaldegreeraise is a special case because it is the only parameter that is
expressed in a percentage instead of as a number of scaled points.
Note 8: SubscriptShiftDownWithSuperscript does not actually exist in the ‘standard' Opentype
Math font Cambria, but it is useful enough to be added. New in version 0.38.
Note 9: FractionDelimiterDisplaySize and FractionDelimiterSize do not actually exist in
the ‘standard' Opentype Math font Cambria, but were useful enough to be added. New in version 0.47.
They are all initialized by initex to the values mentioned in the table in Chapter 18 of the TEXbook.
Note 1: for ease of use as well as for backward compatibility, \thinmuskip, \medmuskip and
\thickmuskip are treated especially. In their case a pointer to the corresponding internal para-
meter is saved, not the actual \muskip value. This means that any later changes to one of these three
parameters will be taken into account.
Note 2: Careful readers will realise that there are also primitives for the items marked * in the TEXbook.
These will not actually be used as those combinations of atoms cannot actually happen, but it seemed
better not to break orthogonality. They are initialized to zero.
The mathkern value at a specific height is the kern value that is specified by the next higher height
and kern pair, or the highest one in the character (if there is no value high enough in the character), or
simply zero (if the character has no mathkern pairs at all).
primitive explanation
\Usuperscript Duplicates the functionality of ^
\Usubscript Duplicates the functionality of _
\Ustartmath Duplicates the functionality of $, when used in non-math mode.
\Ustopmath Duplicates the functionality of $, when used in inline math mode.
\Ustartdisplaymath Duplicates the functionality of $$, when used in non-math mode.
\Ustopdisplaymath Duplicates the functionality of $$, when used in display math mode.
All are new in version 0.38. The \Ustopmath and \Ustopdisplaymath primitives check if the current
math mode is the correct one (inline vs. displayed), but you can freely intermix the four mathon/mathoff
commands with explicit dollar sign(s).
• Pre-scripts.
• Multi-story stacks.
• Flattened accents for high characters (?).
• Better control over the spacing around displays and handling of equation numbers.
• Support for multi-line displays using MathML style alignment points.
6 Languages and characters, fonts and glyphs
LuaTEX's internal handling of the characters and glyphs that eventually become typeset is quite different
from the way TEX82 handles those same objects. The easiest way to explain the difference is to focus
on unrestricted horizontal mode (i. e. paragraphs) and hyphenation first. Later on, it will be easy to deal
with the differences that occur in horizontal and math modes.
In TEX82, the characters you type are converted into char_node records when they are encountered
by the main control loop. TEX attaches and processes the font information while creating those records,
so that the resulting ‘horizontal list' contains the final forms of ligatures and implicit kerning. This
packaging is needed because we may want to get the effective width of for instance a horizontal box.
When it becomes necessary to hyphenate words in a paragraph, TEX converts (one word at time) the
char_node records into a string array by replacing ligatures with their components and ignoring the
kerning. Then it runs the hyphenation algorithm on this string, and converts the hyphenated result back
into a ‘horizontal list' that is consecutively spliced back into the paragraph stream. Keep in mind that
the paragraph may contain unboxed horizontal material, which then already contains ligatures and kerns
and the words therein are part of the hyphenation process.
The char_node records are somewhat misnamed, as they are glyph positions in specific fonts, and
therefore not really ‘characters' in the linguistic sense. There is no language information inside the
char_node records. Instead, language information is passed along using language whatsit records
inside the horizontal list.
In LuaTEX, the situation is quite different. The characters you type are always converted into
glyph_node records with a special subtype to identify them as being intended as linguistic char-
acters. LuaTEX stores the needed language information in those records, but does not do any font-
related processing at the time of node creation. It only stores the index of the font.
When it becomes necessary to typeset a paragraph, LuaTEX first inserts all hyphenation points right
into the whole node list. Next, it processes all the font information in the whole list (creating ligatures
and adjusting kerning), and finally it adjusts all the subtype identifiers so that the records are ‘glyph
nodes' from now on.
That was the broad overview. The rest of this chapter will deal with the minutiae of the new process.
Incidentally, LuaTEX allows 32768 separate languages, and words can be 256 characters long.
Because the \uchyph value is saved in the actual nodes, its handling is subtly different from TEX82:
changes to \uchyph become effective immediately, not at the end of the current partial paragraph.
Typeset boxes now always have their language information embedded in the nodes themselves, so there
is no longer a possible dependency on the surrounding language settings. In TEX82, a mid-paragraph
statement like \unhbox0 would process the box using the current paragraph language unless there was
a \setlanguage issued inside the box. In LuaTEX, all language variables are already frozen.
1. three sets of arguments in curly braces ({}{}{}) indicates a desired complex discretionary, with
arguments as in \discretionary's command in normal document input.
2. - indicates a desired simple discretionary, cf. \- and \discretionary- in normal document input.
3. Internal command names are ignored. This rule is provided especially for \discretionary, but it
also helps to deal with \relax commands that may sneak in.
4. = indicates a hyphen in the document input (but that is only useful in documents where
\exhyphenchar is not equal to the hyphen).
The expanded argument is first converted back to a space-separated string while dropping the internal
command names. This string is then converted into a dictionary by a routine that creates key--value
pairs by converting the other listed items. It is important to note that the keys in an exception dictionary
can always be generated from the values. Here are a few examples:
The resultant patterns and exception dictionary will be stored under the language code that is the
present value of \language.
In the last line of the table, you see there is no \discretionary command in the value: the command
is optional in the TEX-based input syntax. The underlying reason for that is that it is conceivable that a
whole dictionary of words is stored as a plain text file and loaded into LuaTEX using one of the functions
in the Lua lang library. This loading method is quite a bit faster than going through the TEX language
primitives, but some (most?) of that speed gain would be lost if it had to interpret command sequences
while doing so.
The motivation behind the ε-TEX extension \savinghyphcodes was that hyphenation heavily depended
on font encodings. This is no longer true in LuaTEX, and the corresponding primitive is ignored pending
complete removal. The future semantics of \uppercase and \lowercase are still under consideration,
no changes have taken place yet.
Inserted characters and ligatures inherit their attributes from the nearest glyph node item (usually the
preceding one, but the following one for the items inserted at the left-hand side of a word).
Word boundaries are no longer implied by font switches, but by language switches. One word can have
two separate fonts and still be hyphenated correctly (but it can not have two different languages, the
\setlanguage command forces a word boundary).
All languages start out with \prehyphenchar=`\-, \posthyphenchar=0, \preexhyphenchar=0
and \postexhyphenchar=0. When you assign the values of one of these four parameters, you are
actually changing the settings for the current \language, this behavior is compatible with \patterns
and \hyphenation.
LuaTEX also hyphenates the first word in a paragraph.
Words can be up to 256 characters long (up from 64 in TEX82). Longer words generate an error right now,
but eventually either the limitation will be removed or perhaps it will become possible to silently ignore
the excess characters (this is what happens in TEX82, but there the behaviour cannot be controlled).
If you are using the Lua function lang.hyphenate, you should be aware that this function expects to
receive a list of ‘character' nodes. It will not operate properly in the presence of ‘glyph', ‘ligature', or
‘ghost' nodes, nor does it know how to deal with kerning. In the near future, it will be able to skip over
‘ghost' nodes, and we may add a less fuzzy function you can call as well.
The hyphenation exception dictionary is maintained as key-value hash, and that is also dynamic, so the
hyph_size setting is not used either.
A technical paper detailing the new algorithm will be released as a separate document.
Initial: {o}{f}{f}{i}{c}{e}
After hyphenation: {o}{f}{{-},{},{}}{f}{i}{c}{e}
First ligature stage: {o}{{f}{-},{f},{ff}}{i}{c}{e}
Final result: {o}{{f}{-},{fi},{ffi}}{c}{e}
That's bad enough, but if there was a hyphenation point between the f and the i: of-f-ice, the final
result should be:
{o}{{f}{-},
{{f}{-},
{i},
{fi}},
{{ff}{-},
{i},
{ffi}}}{c}{e}
with discretionaries in the post-break text as well as in the replacement text of the top-level discretionary
that resulted from the first hyphenation point. And this is only a simple case.
As of 0.39.0, the solution in LuaTEX is not as smart as all this. It essentially creates the following set of
items for of-f-ice:
{o}{{f}{-},
{fi},
{ffi}},
{{f}{-},
{i},
{fi}}{c}{e}
This is not perfect (because the off-ice hyphenation will never be chosen), but luckily three-item
ligatures with multiple embedded hyphenation points are extremely rare indeed: even this example was
artificially created. A full, perfect solution is possible, but is low on the agenda now that at least office
can be hyphenated properly again.
The key name is always required. The keys stretch, shrink, step and optionally auto_expand
only have meaning when used together: they can be used to replace a post-loading \pdffontexpand
command. The expansion_factor is value that can be present inside a font in font.fonts. It is
the actual expansion factor (a value between -shrink and stretch, with step step) of a font that
was automatically generated by the font expansion algorithm. The key attributes can be used to
replace \pdffontattr. The key used is set by the engine when a font is actively in use, this makes
sure that the font's definition is written to the output file (dvi or pdf). The tfm reader sets it to false. The
direction is a number signalling the ‘normal' direction for this font. There are sixteen possibilities:
number meaning number meaning
0 LT 8 TT
1 LL 9 TL
2 LB 10 TB
3 LR 11 TR
4 RT 12 BT
5 RL 13 BL
6 RB 14 BB
7 RR 15 BR
These are Omega-style direction abbreviations: the first character indicates the ‘first' edge of the char-
acter glyphs (the edge that is seen first in the writing direction), the second the ‘top' side.
The parameters is a hash with mixed key types. There are seven possible string keys, as well as a
number of integer indices (these start from 8 up). The seven strings are actually used instead of the
bottom seven indices, because that gives a nicer user interface.
The names and their internal remapping are:
The keys type, format, embedding, fullname and filename are used to embed OpenType fonts
in the result pdf.
The characters table is a list of character hashes indexed by an integer number. The number is the
‘internal code' TEX knows this character by.
Two very special string indexes can be used also: left_boundary is a virtual character whose ligatures
and kerns are used to handle word boundary processing. right_boundary is similar but not actually
used for anything (yet!).
Other index keys are ignored.
Each character hash itself is a hash. For example, here is the character ‘f' (decimal 102) in the font
cmr10 at 10 points:
[102] = {
['width'] = 200250,
['height'] = 455111,
['depth'] = 0,
['italic'] = 50973,
['kerns'] = {
[63] = 50973,
[93] = 50973,
[39] = 50973,
[33] = 50973,
[41] = 50973
},
['ligatures'] = {
[102] = {
['char'] = 11,
['type'] = 0
},
[108] = {
['char'] = 13,
['type'] = 0
},
[105] = {
['char'] = 12,
['type'] = 0
}
}
}
Of course a more compact is also possible, but keep in mind that reserved words cannot be used compact
and in LuaTEX we often have a type key.
[102] = {
...
ligatures = {
[102] = {
char = 11,
['type'] = 0
},
...
}
}
The values of top_accent, bot_accent and mathkern are used only for math accent and superscript
placement, see the 119math chapter in this manual for details.
The values of left_protruding and right_protruding are used only when \pdfprotrudechars
is non-zero.
Whether or not expansion_factor is used depends on the font's global expansion settings, as well
as on the value of \pdfadjustspacing.
The usage of tounicode is this: if this font specifies a tounicode=1 at the top level, then LuaTEX will
construct a /ToUnicode entry for the pdf font (or font subset) based on the character-level tounicode
strings, where they are available. If a character does not have a sensible Unicode equivalent, do not
provide a string either (no empty strings).
If the font-level tounicode is not set, then LuaTEX will build up /ToUnicode based on the TEX code
points you used, and any character-level tounicodes will be ignored. At the moment, the string format
is exactly the format that is expected by Adobe CMap files (utf-16BE in hexadecimal encoding), minus
the enclosing angle brackets. This may change in the future. Small example: the tounicode for a fi
ligature would be 00660069.
The presence of extensible will overrule next, if that is also present. It in in turn can be overruled
by vert_variants.
The extensible table is very simple:
key type description
top number ‘top' character index
mid number ‘middle' character index
bot number ‘bottom' character index
rep number ‘repeatable' character index
The horiz_variants and vert_variants are arrays of components. Each of those components is
itself a hash of up to five keys:
The kerns table is a hash indexed by character index (and ‘character index' is defined as either a non-
negative integer or the string value right_boundary), with the values the kerning to be applied, in
scaled points.
The ligatures table is a hash indexed by character index (and ‘character index' is defined as either
a non-negative integer or the string value right_boundary), with the values being yet another small
hash, with two fields:
value description
real this is a base font
virtual this is a virtual font
A font that uses anything other than an 8-bit encoding vector has to be written to the pdf in a different
way.
The rule is: if the font table has encodingbytes set to 2, then this is a wide font, in all other cases it
isn't. The value 2 is the default for OpenType and TrueType fonts loaded via Lua. For Type1 fonts, you
have to set encodingbytes to 2 explicitly. For pk bitmap fonts, wide font encoding is not supported
at all.
If no special care is needed, LuaTEX currently falls back to the mapfile-based solution used by pdfTEX
and dvips. This behaviour will be removed in the future, when the existing code becomes integrated in
the new subsystem.
But if this is a ‘wide' font, then the new subsystem kicks in, and some extra fields have to be present in
the font structure. In this case, LuaTEX does not use a map file at all.
The extra fields are: format, embedding, fullname, cidinfo (as explained above), filename, and
the index key in the separate characters.
Values for format are:
value description
type1 this is a PostScript Type1 font
type3 this is a bitmapped (pk) font
truetype this is a TrueType or TrueType-based OpenType font
opentype this is a PostScript-based OpenType font
(type3 fonts are provided for backward compatibility only, and do not support the new wide encoding
options.)
Values for embedding are:
value description
no don't embed the font at all
subset include and atttempt to subset the font
full include this font in its entirety
It is not possible to artificially modify the transformation matrix for the font at the moment.
The other fields are used as follows: The fullname will be the PostScript/pdf font name. The cidinfo
will be used as the character set (the CID /Ordering and /Registry keys). The filename points
to the actual font file. If you include the full path in the filename or if the file is in the local directory,
LuaTEX will run a little bit more efficient because it will not have to re-run the find_xxx_file callback
in that case.
Be careful: when mixing old and new fonts in one document, it is possible to create PostScript name
clashes that can result in printing errors. When this happens, you have to change the fullname of the
font.
Typeset strings are written out in a wide format using 2 bytes per glyph, using the index key in the
character information as value. The overall effect is like having an encoding based on numbers instead of
traditional (PostScript) name-based reencoding. The way to get the correct index numbers for Type1
fonts is by loading the font via fontloader.open; use the table indices as index fields.
This type of reencoding means that there is no longer a clear connection between the text in your input
file and the strings in the output pdf file. Dealing with this is high on the agenda.
The presence of the toplevel type key with the specific value virtual will trigger handling of the rest
of the special virtual font fields in the table, but the mere existence of 'type' is enough to prevent LuaTEX
from looking for a virtual font on its own.
Therefore, this also works ‘in reverse': if you are absolutely certain that a font is not a virtual font,
assigning the value base or real to type will inhibit LuaTEX from looking for a virtual font file,
thereby saving you a disk search.
The fonts is another Lua array. The values are one- or two-key hashes themselves, each entry indi-
cating one of the base fonts in a virtual font. In case your font is referring to itself, you can use the
font.nextid() function which returns the index of the next to be defined font which is probably the
currently defined one.
An example makes this easy to understand
fonts = {
{ name = 'ptmr8a', size = 655360 },
{ name = 'psyr', size = 600000 },
{ id = 38 }
}
says that the first referenced font (index 1) in this virtual font is ptrmr8a loaded at 10pt, and the second
is psyr loaded at a little over 9pt. The third one is previously defined font that is known to LuaTEX as
fontid ‘38'.
The array index numbers are used by the character command definitions that are part of each character.
The commands array is a hash where each item is another small array, with the first entry representing
a command and the extra items being the parameters to that command. The allowed commands and their
arguments are:
...
commands = {
{'push'}, -- remember where we are
{'right', 5000}, -- move right about 0.08pt
{'font', 3}, -- select the fonts[3] entry
{'char', 97}, -- place character 97 (ASCII 'a')
{'pop'}, -- go all the way back
{'down', -200000}, -- move upwards by about 3pt
{'special', 'pdf: 1 0 0 rg'} -- switch to red color
{'rule', 500000, 20000} -- draw a bar
{'special','pdf: 0 g'} -- back to black
}
...
The default value for font is always 1 at the start of the commands array. Therefore, if the virtual font
is essentially only a re-encoding, then you do usually not have create an explicit ‘font' command in the
array.
Rules inside of commands arrays are built up using only two dimensions: they do not have depth. For
correct vertical placement, an extra down command may be needed.
Regardless of the amount of movement you create within the commands, the output pointer will always
move by exactly the width that was given in the width key of the character hash. Any movements that
take place inside the commands array are ignored on the upper level.
\directlua {
callback.register('define_font',
function (name,size)
if name == 'cmr10-red' then
f = font.read_tfm('cmr10',size)
f.name = 'cmr10-red'
f.type = 'virtual'
f.fonts = {{ name = 'cmr10', size = size }}
for i,v in pairs(f.characters) do
if (string.char(i)):find('[tacohanshartmut]') then
v.commands = {
{'special','pdf: 1 0 0 rg'},
{'char',i},
{'special','pdf: 0 g'},
}
else
v.commands = {{'char',i}}
end
end
else
f = font.read_tfm(name,size)
end
return f
end
)
}
These objects are reference counted, so there is actually an extra field named ref_count as well. This
item type will likely disappear in the future, and the glue fields themselves will become part of the nodes
referencing glue items.
A normal node's attribute field will point to an item of type attribute_list, and the next field in
that item will point to the first defined ‘attribute' item, whose next will point to the second ‘attribute'
item, etc.
Valid fields in attribute items:
The subtype is sometimes just a stub entry. Not all nodes actually use the subtype, but this way you
can be sure that all nodes accept it as a valid field name, and that is often handy in node list traversal.
In the following tables next and id are not explicitly mentioned.
Besides these three fields, almost all nodes also have an attr field, and there is a also a field called
prev. That last field is always present, but only initialized on explicit request: when the function
node.slide() is called, it will set up the prev fields to be a backwards pointer in the argument node
list.
Valid fields: As for hlist, except that ‘shift' is a displacement perpendicular to the line progression
direction.
A warning: never assign a node list to the list field unless you are sure its internal link structure is
correct, otherwise an error may be result.
A warning: never assign a node list to the list field unless you are sure its internal link structure is
correct, otherwise an error may be result.
The subtype numbers 4 and 5 belong to the ‘of-f-ice' explanation given elsewhere.
A warning: never assign a node list to the pre, post or replace field unless you are sure its internal link
structure is correct, otherwise an error may be result.
1 \lineskip
2 \baselineskip
3 \parskip
4 \abovedisplayskip
5 \belowdisplayskip
6 \abovedisplayshortskip
7 \belowdisplayshortskip
8 \leftskip
9 \rightskip
10 \topskip
11 \splittopskip
12 \tabskip
13 \spaceskip
14 \xspaceskip
15 \parfillskip
16 \thinmuskip
17 \medmuskip
18 \thickmuskip
100 \leaders
101 \cleaders
102 \xleaders
103 \aleaders
A warning: never assign a node list to the components field unless you are sure its internal link structure
is correct, otherwise an error may be result.
Valid bits for the subtype field are:
bit meaning
0 character
1 glyph
2 ligature
3 ghost
4 left
5 right
See section 6.1 for a detailed description of the subtype field.
The math_char is the simplest subnode field, it contains the character and family for a single glyph ob-
ject. The math_text_char is a special case that you will not normally encounter, it arises temporarily
during math list conversion (its sole function is to suppress a following italic correction).
These two subnode types are used for subsidiary list items. For sub_box, the list points to a ‘normal'
vbox or hbox. For sub_mlist, the list points to a math list that is yet to be converted.
A warning: never assign a node list to the components field unless you are sure its internal link structure
is correct, otherwise an error may be result.
The fields large_char and large_fam can be zero, in that case the font that is sed for the small_fam
is expected to provide the large version as an extension to the small_char.
First, there are the objects (the TEXbook calls then ‘atoms') that are associated with the simple math
objects: Ord, Op, Bin, Rel, Open, Close, Punct, Inner, Over, Under, Vcent. These all have the same
fields, and they are combined into a single node type with separate subtypes for differentiation.
A warning: never assign a node list to the display, text, script, or scriptscript field unless you are sure
its internal link structure is correct, otherwise an error may be result.
A warning: never assign a node list to the nucleus, sub, sup, left, or degree field unless you are sure its
internal link structure is correct, otherwise an error may be result.
A warning: never assign a node list to the num, or denom field unless you are sure its internal link
structure is correct, otherwise an error may be result.
A warning: never assign a node list to the box_left or box_right field unless you are sure its internal
link structure is correct, otherwise an error may be result.
However, only four combinations are accepted: TLT, TRT, RTT, and LTL.
Inside actual dir whatsit nodes, the representation of dir is not a three-letter but a four-letter combi-
nation. The first character in this case is always either + or -, indicating whether the value is pushed
or popped from the direction stack.
Be aware that pdf_refxform nodes have dimensions that are used by LuaTEX.
Be aware that pdf_refximage nodes have dimensions that are used by LuaTEX.
value explanation
97 the value is an attribute node list
100 the value is a number
110 the value is a node list
115 the value is a string
116 the value is a token list in Lua table form
9 Modifications
Besides the expected changes caused by new functionality, there are a number of not-so-expected
changes. These are sometimes a side-effect of a new (conflicting) feature, or, more often than not, a
change necessary to clean up the internal interfaces.
\TeXXeTstate
\beginR
\beginL
\endR
\endL
are missing.
• Some of the tracing information that is output by ε-TEX's \tracingassigns and
\tracingrestores is not there.
• Register management in LuaTEX uses the Aleph model, so the maximum value is 65535 and the
implementation uses a flat array instead of the mixed flat&sparse model from ε-TEX.
• savinghyphcodes is a no-op. See chapter 6 for details.
• When kpathsea is used to find files, LuaTEX uses the ofm file format to search for font metrics. In
turn, this means that LuaTEX looks at the OFMFONTS configuration variable (like Omega and Aleph)
instead of TFMFONTS (like TEX and pdfTEX). Likewise for virtual fonts (LuaTEX uses the variable
OVFFONTS instead of VFFONTS).
• A few other experimental primitives are also provided without the extra pdf prefix, so they can also
be called like this:
\primitive \ifabsnum
\ifprimitive \ifabsdim
• The \pdftexversion is set to 200.
• The PNG transparency fix from 1.40.6 is not applied (high-level support is pending)
• LFS (pdf Files larger than 2GiB) support is not working yet.
• LuaTEX 0.45.0 introduces two extra token lists, \pdfxformresources and \pdfxformattr, as
an alternative to \pdfxform keywords.
• As of LuaTEX 0.50.0 is no longer possible for fonts from embedded pdf files to be replaced by /
merged with the document fonts of the enveloping pdf document. This regression may be temporary,
depending on how the rewritten font backend will look after beta 0.60.
-8bit
-translate-file=TCXNAME
-mltex
-enc
-etex
\pdfpagewidth \pagewidth
\pdfpageheight \pageheight
\fontcharwd \charwd
\fontcharht \charht
\fontchardp \chardp
\fontcharic \charit