summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/luatex/luaotfload
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-05-06 22:01:04 +0000
committerKarl Berry <karl@freefriends.org>2013-05-06 22:01:04 +0000
commitf5404c03d41c0cf6039679818e8c0e2929c32949 (patch)
tree5c9d6c9a7f6148271d565e403294dedaab7c6129 /Master/texmf-dist/source/luatex/luaotfload
parent849cac0ff436060e322aade5217a2a5f9847fec9 (diff)
luaotfload (6may13)
git-svn-id: svn://tug.org/texlive/trunk@30246 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/luatex/luaotfload')
-rw-r--r--Master/texmf-dist/source/luatex/luaotfload/Makefile81
-rw-r--r--Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx1886
2 files changed, 1494 insertions, 473 deletions
diff --git a/Master/texmf-dist/source/luatex/luaotfload/Makefile b/Master/texmf-dist/source/luatex/luaotfload/Makefile
index c649875203f..98b54911ba0 100644
--- a/Master/texmf-dist/source/luatex/luaotfload/Makefile
+++ b/Master/texmf-dist/source/luatex/luaotfload/Makefile
@@ -1,27 +1,36 @@
# Makefile for luaotfload
-NAME = luaotfload
-DOC = $(NAME).pdf
-DTX = $(NAME).dtx
-OTFL = $(wildcard otfl-*.lua) otfl-blacklist.cnf
-SCRIPT = mkluatexfontdb.lua
+NAME = luaotfload
+DOC = $(NAME).pdf
+DTX = $(NAME).dtx
+OTFL = $(wildcard luaotfload-*.lua) luaotfload-blacklist.cnf $(GLYPHS)
+SCRIPT = luaotfload-tool.lua
+
+GLYPHSCRIPT = mkglyphlist
+GLYPHSOURCE = glyphlist.txt
+
+GRAPH = filegraph
+DOTPDF = $(GRAPH).pdf
+DOT = $(GRAPH).dot
# Files grouped by generation mode
-COMPILED = $(DOC)
-UNPACKED = luaotfload.sty luaotfload.lua
-GENERATED = $(COMPILED) $(UNPACKED)
-SOURCE = $(DTX) $(OTFL) README Makefile NEWS $(SCRIPT)
+GLYPHS = font-age.lua
+GRAPHED = $(DOTPDF)
+COMPILED = $(DOC)
+UNPACKED = luaotfload.sty luaotfload.lua
+GENERATED = $(GRAPHED) $(UNPACKED) $(COMPILED) $(GLYPHS)
+SOURCE = $(DTX) $(OTFL) README Makefile NEWS $(SCRIPT) $(GLYPHSCRIPT)
# test files
-TESTDIR = tests
-TESTFILES = $(wildcard $(TESTDIR)/*.tex)
-TESTFILE_SYS = $(TESTDIR)/systemfonts.tex $(TESTDIR)/fontconfig_conf_reading.tex
-TESTFILES_TL = $(filter-out $(TESTFILE_SYS), $(TESTFILES))
+TESTDIR = tests
+TESTFILES = $(wildcard $(TESTDIR)/*.tex $(TESTDIR)/*.ltx)
+TESTFILES_SYS = $(TESTDIR)/systemfonts.tex $(TESTDIR)/fontconfig_conf_reading.tex
+TESTFILES_TL = $(filter-out $(TESTFILES_SYS), $(TESTFILES))
# Files grouped by installation location
-SCRIPTFILES = $(SCRIPT)
+SCRIPTFILES = $(SCRIPT) $(GLYPHSCRIPT)
RUNFILES = $(UNPACKED) $(OTFL)
-DOCFILES = $(DOC) README NEWS
+DOCFILES = $(DOC) $(DOTPDF) README NEWS
SRCFILES = $(DTX) Makefile
# The following definitions should be equivalent
@@ -34,28 +43,35 @@ SCRIPTDIR = $(TEXMFROOT)/scripts/$(NAME)
RUNDIR = $(TEXMFROOT)/tex/$(FORMAT)/$(NAME)
DOCDIR = $(TEXMFROOT)/doc/$(FORMAT)/$(NAME)
SRCDIR = $(TEXMFROOT)/source/$(FORMAT)/$(NAME)
-TEXMFROOT = ./texmf
+TEXMFROOT = $(shell kpsewhich --var-value TEXMFHOME)
CTAN_ZIP = $(NAME).zip
-TDS_ZIP = $(NAME).tds.zip
-ZIPS = $(CTAN_ZIP) $(TDS_ZIP)
+TDS_ZIP = $(NAME).tds.zip
+ZIPS = $(CTAN_ZIP) $(TDS_ZIP)
-DO_TEX = tex --interaction=batchmode $< >/dev/null
-DO_LATEX = lualatex --interaction=batchmode $< >/dev/null
-DO_MAKEINDEX = makeindex -s gind.ist $(subst .dtx,,$<) >/dev/null 2>&1
+DO_TEX = tex --interaction=batchmode $< >/dev/null
+# (with the next version of latexmk: -pdf -pdflatex=lualatex)
+DO_LATEX = latexmk -pdf -e '$$pdflatex = q(lualatex %O %S)' -silent $< >/dev/null
+DO_GRAPHVIZ = dot -Tpdf -o $@ $< > /dev/null
+DO_GLYPHLIST = texlua ./mkglyphlist > /dev/null
all: $(GENERATED)
-doc: $(COMPILED)
+graph: $(GRAPHED)
+doc: $(GRAPHED) $(COMPILED)
unpack: $(UNPACKED)
+glyphs: $(GLYPHS)
ctan: check $(CTAN_ZIP)
tds: $(TDS_ZIP)
world: all ctan
+$(GLYPHS): /dev/null
+ $(DO_GLYPHLIST)
+
+$(GRAPHED): $(DOT)
+ $(DO_GRAPHVIZ)
+
$(COMPILED): $(DTX)
$(DO_LATEX)
- $(DO_MAKEINDEX)
- $(DO_LATEX)
- $(DO_LATEX)
$(UNPACKED): $(DTX)
$(DO_TEX)
@@ -87,16 +103,19 @@ install: $(ALL_FILES)
$(run-install)
check: $(RUNFILES) $(TESTFILES_TL)
+ @rm -rf var
@for f in $(TESTFILES_TL); do \
echo "check: luatex $$f"; \
- luatex --interaction=batchmode --output-directory $(TESTDIR) $$f \
+ luatex --interaction=batchmode $$f \
> /dev/null || exit $$?; \
done
-check-all: $(TESTFILE_SYS) check
- @echo "check: luatex $<"
- @luatex --interaction=batchmode --output-directory $(TESTDIR) $< \
- >/dev/null
+check-all: $(TESTFILES_SYS) check
+ @cd $(TESTDIR); for f in $(TESTFILES_SYS); do \
+ echo "check: luatex $$f"; \
+ $(TESTENV) luatex --interaction=batchmode ../$$f \
+ > /dev/null || exit $$?; \
+ done
manifest:
@echo "Source files:"
@@ -109,5 +128,5 @@ clean:
@$(RM) -- *.log *.aux *.toc *.idx *.ind *.ilg *.out $(TESTDIR)/*.log
mrproper: clean
- @$(RM) -- $(GENERATED) $(ZIPS) $(TESTDIR)/*.pdf
+ @$(RM) -- $(GENERATED) $(ZIPS) $(GLYPHSOURCE) $(TESTDIR)/*.pdf
diff --git a/Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx b/Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx
index c0489e342f1..2f88225781a 100644
--- a/Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx
+++ b/Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx
@@ -1,10 +1,14 @@
% \iffalse meta-comment
%
-% Copyright (C) 2009-2013 by Elie Roux <elie.roux@telecom-bretagne.eu>
-% and Khaled Hosny <khaledhosny@eglug.org>
-% (Support: <lualatex-dev@tug.org>.)
+% Copyright (C) 2009-2013
+% by Elie Roux <elie.roux@telecom-bretagne.eu>
+% and Khaled Hosny <khaledhosny@eglug.org>
+% and Philipp Gesang <philipp.gesang@alumni.uni-heidelberg.de>
%
-% This work is under the CC0 license.
+% Home: https://github.com/lualatex/luaotfload
+% Support: <lualatex-dev@tug.org>.
+%
+% This work is under the GPL v2.0 license.
%
% This work consists of the main source file luaotfload.dtx
% and the derived files
@@ -14,7 +18,7 @@
% tex luaotfload.dtx
%
% Documentation:
-% pdflatex luaotfload.dtx
+% lualatex luaotfload.dtx
%
% The class ltxdoc loads the configuration file ltxdoc.cfg
% if available. Here you can specify further options, e.g.
@@ -36,7 +40,7 @@
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
-\Msg{* Package: luaotfload v1.29 OpenType layout system}
+\Msg{* Package: luaotfload v2.2 OpenType layout system}
\Msg{************************************************************************}
\keepsilent
@@ -47,11 +51,15 @@
\preamble
This is a generated file.
-Copyright (C) 2009-2013 by by Elie Roux <elie.roux@telecom-bretagne.eu>
- and Khaled Hosny <khaledhosny@eglug.org>
- (Support: <lualatex-dev@tug.org>.)
+Copyright (C) 2009-2013
+ by Elie Roux <elie.roux@telecom-bretagne.eu>
+ and Khaled Hosny <khaledhosny@eglug.org>
+ and Philipp Gesang <philipp.gesang@alumni.uni-heidelberg.de>
+
+ Home: https://github.com/lualatex/luaotfload
+ Support: <lualatex-dev@tug.org>.
-This work is under the CC0 license.
+This work is under the GPL v2.0 license.
This work consists of the main source file luaotfload.dtx
and the derived files
@@ -61,13 +69,12 @@ and the derived files
\let\MetaPrefix\DoubleperCent
-
\generate{%
- \usedir{tex/luatex/luaodfload}%
+ \usedir{tex/luatex/luaotfload}%
\file{luaotfload.sty}{\from{luaotfload.dtx}{package}}%
}
-% The following hacks are to generate a lua file with lua comments starting by
+% The following hacks are to generate a lua file with lua comments starting with
% -- instead of %%
\def\MetaPrefix{-- }
@@ -104,40 +111,94 @@ and the derived files
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{luaotfload.drv}%
- [2013/04/25 v1.29 OpenType layout system]%
+ [2013/04/16 v2.2 OpenType layout system]%
\documentclass{ltxdoc}
-\usepackage{metalogo,multicol,mdwlist,fancyvrb,xcolor,xspace}
+\usepackage{metalogo,multicol,mdwlist,fancyvrb,xspace}
+\usepackage[x11names]{xcolor}
+%
+\def\primarycolor{DodgerBlue4} %%-> rgb 16 78 139 | #104e8b
+\def\secondarycolor{Goldenrod4} %%-> rgb 139 105 200 | #8b6914
+%
\usepackage[
- bookmarks=true,
- colorlinks=true,
- linkcolor=niceblue,
-% urlcolor=niceblue,
- citecolor=niceblue,
- pdftitle={The luaotfload package},
- pdfsubject={OpenType layout system for Plain TeX and LaTeX},
- pdfauthor={Elie Roux & Khaled Hosny},
+ bookmarks=true,
+ colorlinks=true,
+ linkcolor=\primarycolor,
+ urlcolor=\secondarycolor,
+ citecolor=\primarycolor,
+ pdftitle={The luaotfload package},
+ pdfsubject={OpenType layout system for Plain TeX and LaTeX},
+ pdfauthor={Elie Roux & Khaled Hosny & Philipp Gesang},
pdfkeywords={luatex, lualatex, unicode, opentype}
- ]{hyperref}
-
+]{hyperref}
\usepackage{fontspec}
\usepackage{unicode-math}
-\setmainfont[Ligatures=TeX]{Linux Libertine O}
-\setsansfont[Ligatures=TeX]{Linux Biolinum O}
-\setmathfont{XITS Math}
+\setmainfont[
+ Numbers = OldStyle,
+ Ligatures = TeX,
+ BoldFont = {Linux Libertine O Bold},
+ ItalicFont = {Linux Libertine O Italic},
+ SlantedFont = {Linux Libertine O Italic},
+]{Linux Libertine O}
+\setmonofont[Ligatures=TeX,Scale=MatchLowercase]{Liberation Mono}
+%setsansfont[Ligatures=TeX]{Linux Biolinum O}
+\setsansfont[Ligatures=TeX,Scale=MatchLowercase]{Iwona Medium}
+%setmathfont{XITS Math}
+
+\usepackage{hologo}
+
+\newcommand\TEX {\TeX\xspace}
+\newcommand\LUA {Lua\xspace}
+\newcommand\PDFTEX {pdf\TeX\xspace}
+\newcommand\LUATEX {Lua\TeX\xspace}
+\newcommand\XETEX {\XeTeX\xspace}
+\newcommand\LATEX {\LaTeX\xspace}
+\newcommand\CONTEXT {Con\TeX t\xspace}
+\newcommand\OpenType{\identifier{Open\kern-.25ex Type}\xspace}
-\definecolor{niceblue}{rgb}{0.4,0.6,1.000}
+\def\definehighlight[#1][#2]%
+ {\ifcsname #1\endcsname\else
+ \expandafter\def\csname #1\endcsname%
+ {\bgroup#2\csname #1_indeed\endcsname}
+ \expandafter\def\csname #1_indeed\endcsname##1%
+ {##1\egroup}%
+ \fi}
-\newcommand\tex {\TeX\xspace}
-\newcommand\pdftex {PDF\TeX\xspace}
-\newcommand\luatex {Lua\TeX\xspace}
-\newcommand\xetex {\XeTeX\xspace}
-\newcommand\latex {\LaTeX\xspace}
-\newcommand\context{Con\TeX t\xspace}
+\def\restoreunderscore{\catcode`\_=12\relax}
+
+\definehighlight [fileent][\ttfamily\restoreunderscore] %% files, dirs
+\definehighlight [texmacro][\sffamily\itshape\textbackslash] %% cs
+\definehighlight[luafunction][\sffamily\itshape\restoreunderscore] %% lua identifiers
+\definehighlight [identifier][\sffamily] %% names
+\definehighlight [abbrev][\rmfamily\scshape] %% acronyms
+\definehighlight [emphasis][\rmfamily\slshape] %% level 1 emph
\newcommand*\email[1]{\href{mailto:#1}{#1}}
-\EnableCrossrefs
-\CodelineIndex
+\renewcommand\partname{Part}%% gets rid of the stupid “file” heading
+
+\usepackage{syntax}%% bnf for font request syntax
+
+\usepackage{titlesec}
+
+\def\movecountertomargin#1{\llap{\rmfamily\upshape#1\hskip2em}}
+\def\zeropoint{0pt}
+\titleformat \part
+ {\normalsize\rmfamily\bfseries}
+ {\movecountertomargin\thepart} \zeropoint {}
+\titleformat \section
+ {\normalsize\rmfamily\scshape}%% no \word; life is full of disappointments
+ {\movecountertomargin\thesection} \zeropoint {}
+\titleformat \subsection
+ {\small\rmfamily\itshape}
+ {\movecountertomargin\thesubsection} \zeropoint {}
+
+\usepackage{tocloft}
+\renewcommand \cftpartfont {\rmfamily\upshape}
+\renewcommand \cftsecfont {\rmfamily\upshape}
+\renewcommand \cftsubsecfont {\rmfamily\upshape}
+\setlength \cftbeforepartskip {1ex}
+\setlength \cftbeforesecskip {1ex}
+
\VerbatimFootnotes
\begin{document}
\DocInput{luaotfload.dtx}%
@@ -165,595 +226,1536 @@ and the derived files
%
% \GetFileInfo{luaotfload.drv}
%
-% \title{The \textsf{luaotfload} package}
-% \date{2013/04/25 v1.29}
-% \author{Elie Roux and Khaled Hosny\\
-% Support: \email{lualatex-dev@tug.org}}
+% \title{The \identifier{luaotfload} package}
+% \date{2013/05/05 v2.2}
+% \author{Elie Roux · Khaled Hosny · Philipp Gesang\\
+% Home: \url{https://github.com/lualatex/luaotfload}\\
+% Support: \email{lualatex-dev@tug.org}}
%
% \maketitle
%
% \begin{abstract}
-% This package is an adaptation of the \context font loading system,
-% providing the ability to load \textsf{OpenType} fonts with extended font
-% loading syntax supporting a large selection of OpenType font features.
+% This package is an adaptation of the \CONTEXT font loading system.
+% It allows for loading \OpenType fonts with an extended syntax and adds
+% support for a variety of font features.
% \end{abstract}
%
% \tableofcontents
%
+% \part{Package Description}
+%
% \section{Introduction}
%
-% Font management and installation has always been painful with \tex.
-% A lot of files are needed for one font (tfm, pfb, map, fd, vf), and as
-% \tex is 8-bit each font is limited to 256 characters.
-% But the font world has evolved since \tex, and new font technologies have
-% appeared, most notably the so called \emph{smart font} technologies like
-% \textsf{OpenType} fonts. These fonts can contain a lot of characters, and
-% additional functionalities like ligatures, old-style numbers, small capitals,
+% Font management and installation has always been painful with \TEX. A lot of
+% files are needed for one font (\abbrev{tfm}, \abbrev{pfb}, \abbrev{map},
+% \abbrev{fd}, \abbrev{vf}), and due to the 8-Bit encoding each font is limited
+% to 256 characters.
+% But the font world has evolved since the original
+% \TEX, and new typographic systems have appeared, most notably the so
+% called \emphasis{smart font} technologies like \OpenType
+% fonts (\abbrev{otf}).
+% These fonts can contain many more characters than \TEX fonts, as well as additional
+% functionality like ligatures, old-style numbers, small capitals,
% etc., and support more complex writing systems like Arabic and
-% Indic\footnote{Unfortunately, \textsf{luaotfload} doesn't support Indic
-% scripts right now} scripts.
-% They are widely deployed and available for all modern operating systems and
-% are becoming the de facto standard fonts for advanced text layout.
-% Until now the only way to use them directly in the \tex world was by using
-% them with \xetex.
+% Indic\footnote{%
+% Unfortunately, \identifier{luaotfload} doesn't support Indic
+% scripts right now.
+% Assistance in implementing the prerequisites is greatly
+% appreciated.
+% }
+% scripts.
+% \OpenType fonts are widely deployed and available for all
+% modern operating systems.
+% As of 2013 they have become the de facto standard for advanced text
+% layout.
+% However, until recently the only way to use them directly in the \TEX
+% world was with the \XETEX engine.
+%
+% Unlike \XETEX, \LUATEX has no built-in support for
+% \OpenType or technologies other than the original \TEX fonts.
+% Instead, it provides hooks for executing \LUA code during the \TEX run
+% that allow implementing extensions for loading fonts and manipulating
+% how input text is processed without modifying the underlying engine.
+% This is where \identifier{luaotfload} comes into play:
+% Based on code from \CONTEXT, it extends \LUATEX with functionality necessary
+% for handling \OpenType fonts.
+% Additionally, it provides means for accessing fonts known to the operating
+% system conveniently by indexing the metadata.
+%
+% \section{Loading Fonts}
+%
+% \identifier{luaotfload} supports an extended font request syntax:
%
-% Unlike \xetex, \luatex does not provide direct support for using these fonts
-% by default, but it provides a way to hook Lua code in some points of the
-% \tex processing; for instance, we can improve the font loading system, and
-% text procession, which what this package is about.
+% \begin{quote}
+% |\font\foo={|%
+% \meta{prefix}|:|%
+% \meta{font name}|:|%
+% \meta{font features}|}|%
+% \meta{\TEX font features}
+% \end{quote}
%
-% \section{Loading fonts}
+% \noindent
+% The curly brackets are optional and escape the spaces in the enclosed
+% font name.
+% Alternatively, double quotes serve the same purpose.
+% A selection of individual parts of the syntax are discussed below;
+% for a more formal description see figure \ref{font-syntax}.
+%
+% \begin{figure}[b]
+% \setlength\grammarparsep{12pt plus 2pt minus 2pt}
+% \setlength\grammarindent{5cm}
+% \begingroup
+% \small
+% \begin{grammar}
+% <definition> ::= `\\font', {\sc csname}, `=', <font request>, [ <size> ] ;
+%
+% <size> ::= `at', {\sc dimension} ;
+%
+% <font request> ::= `"', <unquoted font request> `"'
+% \alt `{', <unquoted font request> `}'
+% \alt <unquoted font request> ;
+%
+% <unquoted font request> ::= <specification>, [`:', <feature list> ]
+% \alt `[', <path lookup> `]', [ [`:'], <feature list> ] ;
+%
+% <specification> ::= <prefixed spec>, [ <subfont no> ], \{ <modifier> \}
+% \alt <anon lookup>, \{ <modifier> \} ;
+%
+% <prefixed spec> ::= `file:', <file lookup>
+% \alt `name:', <name lookup> ;
+%
+% <file lookup> ::= \{ <name character> \} ;
+%
+% <name lookup> ::= \{ <name character> \} ;
+%
+% <anon lookup> ::= {\sc tfmname} | <name lookup> ;
+%
+% <path lookup> ::= \{ {\sc all_characters} - `]' \} ;
+%
+% <modifier> ::= `/', (`I' | `B' | `BI' | `IB' | `S=', \{ {\sc digit} \} ) ;
+%
+% <subfont no> ::= `(', \{ {\sc digit} \}, `)' ;
+%
+% <feature list> ::= <feature expr>, \{ `;', <feature expr> \} ;
+%
+% <feature expr> ::= {\sc feature_id}, `=', {\sc feature_value}
+% \alt <feature switch>, {\sc feature_id} ;
+%
+% <feature switch> ::= `+' | `-' ;
+%
+% <name character> ::= {\sc all_characters} - ( `(' | `/' | `:' ) ;
+% \end{grammar}
+% \endgroup
+% \caption{Font request syntax.
+% Braces or double quotes around the
+% \emphasis{specification} rule will
+% preserve whitespace in file names.
+% In addition to the font style modifiers
+% (\emphasis{slash-notation}) given above, there
+% are others that are recognized but will be silently
+% ignored: {\ttfamily aat},
+% {\ttfamily icu}, and
+% {\ttfamily gr}.
+% The special terminals are:
+% {\sc feature\textunderscore id} for a valid font
+% feature name and
+% {\sc feature\textunderscore value} for the corresponding
+% value.
+% {\sc tfmname} is the name of a \abbrev{tfm} file.
+% {\sc digit} again refers to bytes 48--57, and
+% {\sc all\textunderscore characters} to all byte values.
+% {\sc csname} and {\sc dimension} are the \TEX concepts.}
+% \label{font-syntax}
+% \end{figure}
+%
+% \subsection{Prefix -- the \identifier{luaotfload}{ }Way}
+%
+% In \identifier{luaotfload}, the canonical syntax for font requests
+% requires a \emphasis{prefix}:
+% \begin{quote}
+% |\font\fontname=|\meta{prefix}|:|\meta{fontname}\dots
+% \end{quote}
+% where \meta{prefix} is either \verb|file:| or \verb|name:|.
+% It determines whether the font loader should interpret the request as
+% a \emphasis{file name} or
+% \emphasis{font name}, respectively,
+% which again influences how it will attempt to locate the font.
+% Examples for font names are
+% “Latin Modern Italic”,
+% “GFS Bodoni Rg”, and
+% “PT Serif Caption”
+% -- they are the human readable identifiers
+% usually listed in drop-down menus and the like.
+% In order for fonts installed both in system locations and in your
+% \fileent{texmf} to be accessible by font name, \identifier{luaotfload} must
+% first collect the metadata included in the files.
+% Please refer to section~\ref{sec:fontdb} below for instructions on how to
+% create the database.
+%
+% File names are whatever your file system allows them to be, except
+% that that they may not contain the characters
+% \verb|(|,
+% \verb|:|, and
+% \verb|/|.
+% As is obvious from the last exception, the \verb|file:| lookup will
+% not process paths to the font location -- only those
+% files found when generating the database are addressable this way.
+% Continue below in the \XETEX section if you need to load your fonts
+% by path.
+% The file names corresponding to the example font names above are
+% \fileent{lmroman12-italic.otf},
+% \fileent{GFSBodoni.otf}, and
+% \fileent{PTZ56F.ttf}.
+%
+% \subsection{\hologo{XeTeX} Compatibility Layer}
+%
+% In addition to the regular prefixed requests, \identifier{luaotfload}
+% accepts loading fonts the \XETEX way.
+% There are again two modes: bracketed and unbracketed.
+% A bracketed request looks as follows.
%
-% \textsf{luaotfload} supports an extended font loading syntax which looks
-% like:
+% \begin{quote}
+% |\font\fontname=[|\meta{path to file}|]|
+% \end{quote}
%
-% \begin{center}
-% |\font\foo={|\meta{prefix}|:|\meta{font name}|:|\meta{font features}|}| \meta{\tex font features}
-% \end{center}
+% \noindent
+% Inside the square brackets, every character except for a closing
+% bracket is permitted, allowing for specifying paths to a font file.
+% Naturally, path-less file names are equally valid and processed the
+% same way as an ordinary \verb|file:| lookup.
+%
+% \begin{quote}
+% |\font\fontname=|\meta{font name} \dots
+% \end{quote}
+%
+% Unbracketed (or, for lack of a better word: \emphasis{anonymous})
+% font requests resemble the conventional \TEX syntax.
+% However, they have a broader spectrum of possible interpretations:
+% before anything else, \identifier{luaotfload} attempts to load a
+% traditional \TEX Font Metric (\abbrev{tfm} or \abbrev{ofm}).
+% If this fails, it performs a \verb|name:| lookup, which itself will
+% fall back to a \verb|file:| lookup if no database entry matches
+% \meta{font name}.
+%
+% Furthermore, \identifier{luaotfload} supports the slashed (shorthand)
+% font style notation from \XETEX.
+%
+% \begin{quote}
+% |\font\fontname=|\meta{font name}|/|\meta{modifier}\dots
+% \end{quote}
%
% \noindent
-% The curly brackets are optional and are used for escaping spaces in font
-% names (double quotes can also used for the same purpose).
+% Currently, four style modifiers are supported:
+% \verb|I| for italic shape,
+% \verb|B| for bold weight,
+% \verb|BI| or \verb|IB| for the combination of both.
+% Other “slashed” modifiers are too specific to the \XETEX engine and
+% have no meaning in \LUATEX.
%
-% \paragraph{Prefix}
+% \subsection{Examples}
%
-% The \meta{prefix} be either |file:| or |name:|, which specify
-% whether to use a select the font from its filename or font name,
-% respectively. If no prefix is specified, then |file:| is assumed.
+% \subsubsection{Loading by File Name}
%
-% For compatibility with \xetex, surrounding the \meta{font name}
-% with square brackets is synonymous to using the |file:| prefix.
+% For example, conventional \abbrev{type1} font can be loaded with a \verb|file:|
+% request like so:
%
-% Accessing fonts by fontname allows loading system installed fonts as well as
-% \textsc{texmf} ones, and requires a font names database; see
-% Section~\ref{sec:fontdb} for more information.
+% \begin{quote}
+% \begin{verbatim}
+% \font\lmromanten={file:ec-lmr10} at 10pt
+% \end{verbatim}
+% \end{quote}
%
-% \paragraph{Font name}
+% The \OpenType version of Janusz Nowacki’s font \emphasis{Antykwa
+% Półtawskiego}\footnote{%
+% \url{http://jmn.pl/antykwa-poltawskiego/}, also available in
+% in \TEX Live.
+% }
+% in its condensed variant can be loaded as follows:
%
-% The \meta{font name} can be either a font filename or actual font name
-% based on the \meta{prefix} as mentioned above.
+% \begin{quote}
+% \begin{verbatim}
+% \font\apcregular=file:antpoltltcond-regular.otf at 42pt
+% \end{verbatim}
+% \end{quote}
%
-% Fonts loaded by filename may either include their absolute path in the
-% filesystem or consist of just the filename with a path.
-% If no path is specified then \textsf{kpathsea} is used to locate the font
-% (which will typically be in the \textsc{texmf} tree or the current
-% directory).
+% The next example shows how to load the \emphasis{Porson} font digitized by
+% the Greek Font Society using \XETEX-style syntax and an absolute path from a
+% non-standard directory:
%
-% For example,
% \begin{quote}
-% \begin{verbatim}
-% \font\1={file:ec-lmr10} at 10pt
-% \font\2={/Users/Shared/Fonts/aldus.otf} at 11pt
-% \font\3={name:TeX Gyre Pagella} at 9pt
-% \end{verbatim}
+% \begin{verbatim}
+% \font\gfsporson="[/tmp/GFSPorson.otf]" at 12pt
+% \end{verbatim}
% \end{quote}
%
+% \subsubsection{Loading by Font Name}
%
-% \paragraph{Font features}
+% The \verb|name:| lookup does not depend on cryptic filenames:
%
-% \meta{font features} are a list of items separated by semi-colons,
-% which are either
-% |key=value| font parameters, or switches to enable/disable certain font
-% features in the form of |+feat|/|-feat|.
-% The supported keys are:
-% \begin{description}
-% \item [mode] \hfill \\
-% \textsf{luaotfload} has two OpenType processing modes; |base| and |node|.
-% |base| mode works by mapping OpenType features to traditional \tex ligature
-% and kerning mechanisms, thus supporting only non-contextual substitutions and
-% kerning pairs, but is slightly faster. |node| works by direct processing of
-% the node list at Lua end and have more wide support of OpenType features but
-% can be slow especially with complex fonts and can't be used in math mode.
+% \begin{quote}
+% \begin{verbatim}
+% \font\pagellaregular={name:TeX Gyre Pagella} at 9pt
+% \end{verbatim}
+% \end{quote}
%
-% By default |node| mode is used, and you have to manually force |base| mode
-% when needed e.g. for math fonts.
+% A bit more specific but essentially the same lookup would be:
%
-% \item [script] \hfill \\
-% OpenType script string, default value is |dflt|. Some fonts don't assign
-% features to the |dflt| script, in which case the script need to be set
-% explicitly.
+% \begin{quote}
+% \begin{verbatim}
+% \font\pagellaregular={name:TeX Gyre Pagella Regular} at 9pt
+% \end{verbatim}
+% \end{quote}
%
-% \item [language] \hfill \\
-% OpenType language string, default value is |latn|.
+% \noindent
+% Which fits nicely with the whole set:
%
-% \item [featurefile] \hfill \\
-% feature files are textual representation of OpenType tables and can be used to
-% extend OpenType features of the font on fly. The file name of the feature file
-% is passed, then features defined in the file can be enabled/disabled like any
-% other feature. The syntax is documented in Adobe's
-% \href{http://www.adobe.com/devnet/opentype/afdko/topic_feature_file_syntax.html}{OpenType Feature File Specification}.
+% \begin{quote}
+% \begin{verbatim}
+% \font\pagellaregular ={name:TeX Gyre Pagella Regular} at 9pt
+% \font\pagellaitalic ={name:TeX Gyre Pagella Italic} at 9pt
+% \font\pagellabold ={name:TeX Gyre Pagella Bold} at 9pt
+% \font\pagellabolditalic={name:TeX Gyre Pagella Bolditalic} at 9pt
+%
+% {\pagellaregular foo bar baz\endgraf}
+% {\pagellaitalic foo bar baz\endgraf}
+% {\pagellabold foo bar baz\endgraf}
+% {\pagellabolditalic foo bar baz\endgraf}
+%
+% ...
+% \end{verbatim}
+% \end{quote}
+%
+% \subsubsection{Modifiers}
+%
+% If the entire \emphasis{Iwona} family\footnote{%
+% \url{http://jmn.pl/kurier-i-iwona/},
+% also in \TEX Live.
+% }
+% is installed in some location accessible by \identifier{luaotfload},
+% the regular shape can be loaded as follows:
+%
+% \begin{quote}
+% \begin{verbatim}
+% \font\iwona=Iwona at 20pt
+% \end{verbatim}
+% \end{quote}
+%
+% \noindent
+% To load the most common of the other styles, the slash notation can
+% be employed as shorthand:
+%
+% \begin{quote}
+% \begin{verbatim}
+% \font\iwonaitalic =Iwona/I at 20pt
+% \font\iwonabold =Iwona/B at 20pt
+% \font\iwonabolditalic=Iwona/BI at 20pt
+% \end{verbatim}
+% \end{quote}
+%
+% \noindent
+% which is equivalent to these full names:
+%
+% \begin{quote}
+% \begin{verbatim}
+% \font\iwonaitalic ="Iwona Italic" at 20pt
+% \font\iwonabold ="Iwona Bold" at 20pt
+% \font\iwonabolditalic="Iwona BoldItalic" at 20pt
+% \end{verbatim}
+% \end{quote}
+%
+% \section{Font features}
%
-% For example, to set a |tkrn| feature from |mykern.fea| file:
+% \emphasis{Font features} are the second to last component in the
+% general scheme for font requests:
%
-% |\font\lmr=Latin Modern Roman:featurefile=mykern.fea;+tkrn|
+% \begin{quote}
+% |\font\foo={|%
+% \meta{prefix}|:|%
+% \meta{font name}|:|%
+% \meta{font features}|}|%
+% \meta{\TEX font features}
+% \end{quote}
+%
+% \noindent
+% If style modifiers are present (\XETEX style), they must precede
+% \meta{font features}.
+%
+% The element \meta{font features} is a semicolon-separated list of feature
+% tags\footnote{%
+% Cf. \url{http://www.microsoft.com/typography/otspec/featurelist.htm}.
+% }
+% and font options.
+% Prepending a font feature with a |+| (plus sign) enables it, whereas
+% a |-| (minus) disables it. For instance, the request
+%
+% \begin{quote}
+% \begin{verbatim}
+% \font\test=LatinModernRoman:+clig;-kern
+% \end{verbatim}
+% \end{quote}
+%
+% \noindent activates contextual ligatures (|clig|) and disables
+% kerning (|kern|).
+% Alternatively the options |true| or |false| can be passed to
+% the feature in a key/value expression.
+% The following request has the same meaning as the last one:
+%
+% \begin{quote}
+% \begin{verbatim}
+% \font\test=LatinModernRoman:clig=true;kern=false
+% \end{verbatim}
+% \end{quote}
+%
+% \noindent
+% Furthermore, this second syntax is required should a font feature
+% accept other options besides a true/false switch.
+% For example, \emphasis{stylistic alternates} (|salt|) are variants of given
+% glyphs.
+% They can be selected either explicitly by supplying the variant
+% index (starting from one), or randomly by setting the value to,
+% obviously, |random|.
+%
+% \iffalse TODO verify that this actually works with a font that supports
+% the salt/random feature!\fi
+% \begin{quote}
+% \begin{verbatim}
+% \font\librmsaltfirst=LatinModernRoman:salt=1
+% \end{verbatim}
+% \end{quote}
+%
+% \noindent Other font options include:
+%
+% \begin{description}
+%
+% \item [mode] \hfill \\
+% \identifier{luaotfload} has two \OpenType processing
+% \emphasis{modes}:
+% \identifier{base} and \identifier{node}.
+%
+% \identifier{base} mode works by mapping \OpenType
+% features to traditional \TEX ligature and kerning mechanisms.
+% Supporting only non-contextual substitutions and kerning
+% pairs, it is the slightly faster, albeit somewhat limited, variant.
+% \identifier{node} mode works by processing \TeX’s internal
+% node list directly at the \LUA end and supports
+% a wider range of \OpenType features.
+% The downside is that the intricate operations required for
+% \identifier{node} mode may slow down typesetting especially
+% with complex fonts and it does not work in math mode.
+%
+% By default \identifier{luaotfload} is in \identifier{node}
+% mode, and \identifier{base} mode has to be requested where needed,
+% e.~g. for math fonts.
+%
+% \item [script] \label{script-tag} \hfill \\
+% An \OpenType script tag;\footnote{%
+% See \url{http://www.microsoft.com/typography/otspec/scripttags.htm}
+% for a list of valid values.
+% For scripts derived from the Latin alphabet the value
+% |latn| is good choice.
+% }
+% the default value is |dlft|.
+% Some fonts, including very popular ones by foundries like Adobe,
+% do not assign features to the |dflt| script, in
+% which case the script needs to be set explicitly.
+%
+% \item [language] \hfill \\
+% An \OpenType language system identifier,\footnote{%
+% Cf. \url{http://www.microsoft.com/typography/otspec/languagetags.htm}.
+% }
+% defaulting to |dflt|.
+%
+% \item [featurefile] \hfill \\
+% A comma-separated list of feature files to be applied to the
+% font.
+% Feature files contain a textual representation of
+% \OpenType tables and extend the features of a font
+% on fly.
+% After they are applied to a font, features defined in a
+% feature file can be enabled or disabled just like any
+% other font feature.
+% The syntax is documented in \identifier{Adobe}’s
+% \OpenType Feature File Specification.\footnote{%
+% Cf. \url{http://www.adobe.com/devnet/opentype/afdko/topic_feature_file_syntax.html}.
+% }
+%
+% For a demonstration of how to set a |tkrn| feature consult
+% the file |tkrn.fea| that is part of \identifier{luaotfload}.
+% It can be read and applied as follows:
+%
+% |\font\test=Latin Modern Roman:featurefile=tkrn.fea;+tkrn|
%
% \item [color] \hfill \\
-% font color, defined as a triplet of two-digit hexadecimal RGB values, with
-% optionally another value for the transparency
-% (where |00| is completely transparent and |FF| is opaque.)
+% A font color, defined as a triplet of two-digit hexadecimal
+% \abbrev{rgb} values, with an optional fourth value for
+% transparency
+% (where |00| is completely transparent and |FF| is opaque).
%
-% For example, to set text in semitransparent red:
+% For example, in order to set text in semitransparent red:
%
-% |\font\lmr=Latin Modern Roman:color=FF0000BB|
+% \begin{quote}
+% \begin{verbatim}
+% \font\test={Latin Modern Roman}:color=FF0000BB
+% \end{verbatim}
+% \end{quote}
%
% \item [protrusion \& expansion] \hfill \\
-% Both keys control microtypographic features of the font, namely glyph
-% protrusion and expansion. The value of the key is the name of predefined
-% Lua tables of protrusion and expansion values; see the end of
-% |otfl-font-dum.lua| file for an example of such tables. The only
-% predefined value is |default|.
+% These keys control microtypographic features of the font,
+% namely \emphasis{character protrusion} and \emphasis{font
+% expansion}.
+% Their arguments are names of \LUA tables that contain
+% values for the respective features.\footnote{%
+% For examples of the table layout please refer to the
+% section of the file \fileent{luaotfload-fonts-ext.lua} where the
+% default values are defined.
+% Alternatively and with loss of information, you can dump
+% those tables into your terminal by issuing
+% \begin{verbatim}
+% \directlua{inspect(fonts.protrusions.setups.default)
+% inspect(fonts.expansions.setups.default)}
+% \end{verbatim}
+% at some point after loading \fileent{luaotfload.sty}.
+% }
+% For both, only the set \identifier{default} is predefined.
+%
+% For example, to enable default protrusion\footnote{%
+% You also need to set
+% \verb|pdfprotrudechars=2| and
+% \verb|pdfadjustspacing=2|
+% to activate protrusion and expansion, respectively.
+% See the
+% \href{http://mirrors.ctan.org/systems/pdftex/manual/pdftex-a.pdf}%
+% {\PDFTEX manual}
+% for details.
+% }:
+%
+% \begin{quote}
+% \begin{verbatim}
+% \font\test=LatinModernRoman:protrusion=default
+% \end{verbatim}
+% \end{quote}
+% \end{description}
%
-% For example, to enable default protrusion\footnote{You also need to set
-% |\pdfprotrudechars2 \pdfadjustspacing2| to activate protrusion and expansion,
-% respectively. See \pdftex manual for details}:
+% \paragraph{Non-standard font features}
+% \identifier{luaotfload} adds a number of features that are not defined
+% in the original \OpenType specification, most of them
+% aiming at emulating the behavior familiar from other \TEX engines.
+% Currently (2013) there are three of them:
%
-% |\font\lmr=Latin Modern Roman:protrusion=default|
+% \begin{description}
%
-% \end{description}
+% \item [anum]
+% Substitutes the glyphs in the \abbrev{ascii} number range
+% with their counterparts from eastern Arabic or Persian,
+% depending on the value of \identifier{language}.
+%
+% \item [tlig]
+% Applies legacy \TEX ligatures:
+%
+% \begin{tabular}{rlrl}
+% `` & \verb|``| & '' & \verb|''| \\
+% ` & \verb|`| & ' & \verb|'| \\
+% " & \verb|"| & -- & \verb|--| \\
+% --- & \verb|---| & !` & \verb|!`| \\
+% ?` & \verb|?`| & & \\
+% \end{tabular}
%
-% \subparagraph{Non-standard font features}
-% \textsf{luaotfload} defines some additional font feature not defined in
-% OpenType, currently three features are defined:
+% \footnote{%
+% These contain the feature set \verb|trep| of earlier
+% versions of \identifier{luaotfload}.
%
-% \begin{itemize*}
-% \item |anum|: replaces European numbers with eastern Arabic numbers or
-% Persian numbers, depending on the value of |language|.
-% \item |itlc|: compute italic correction values (on by default).
-% \item |tlig|: applies legacy \tex ligatures (|``''-- -- !` ?` <<>>|).
-% \item |trep|: applies legacy \tex replacements (|`'"|).
-% \end{itemize*}
+% Note to \XETEX users: this is the equivalent of the
+% assignment \verb|mapping=text-tex| using \XETEX's input
+% remapping feature.
+% }
+%
+% \item [itlc]
+% Computes italic correction values (active by default).
+%
+% \end{description}
%
-% (For \xetex users: these last two are the equivalent of writing
-% |mapping=text-tex| using \xetex's input remapping feature.)
%
%
% \section{Font names database}
% \label{sec:fontdb}
%
-% As introduced in the previous section, \textsf{luaotfload} uses a database
-% to keep track of fonts available to \luatex. Using this database, fonts can
-% be loaded by font name as well as filename.
-%
-% When \textsf{luaotfload} is asked to load a font by font name, it will check
-% if font names database exists and load it, or generate a new database if non
-% exists. This is all done automatically without user intervention. When the
-% asked font is missing from the database, it will attempt to update the
-% database and try to find the font again, so that the user can install new
-% fonts without worrying about manually updating the database.
-%
-% However, it is sometimes desirable to update the database manually, so
-% \textsf{luaotfload} provides a |mkluatexfontdb| utility to manually update
-% the database. |mkluatexfontdb| is a lua script that can be either run
-% directly or as an argument to |texlua|, depending on your system\footnote{
-% On MS Windows it can be run either by calling the wrapper application
-% |mkluatexfontdb.exe| or with |texlua.exe mkluatexfontdb.lua|}.
-%
-% The first time the database is generated may take quite some time to process
-% every font on your computer.
+% As mentioned above, \identifier{luaotfload} keeps track of which
+% fonts are available to \LUATEX by means of a \emphasis{database}.
+% This allows referring to fonts not only by explicit filenames but
+% also by the proper names contained in the metadata which is often
+% more accessible to humans.\footnote{%
+% The tool \href{http://www.lcdf.org/type/}{\fileent{otfinfo}} (comes
+% with \TEX Live), when invoked on a font file with the \verb|-i|
+% option, lists the variety of name fields defined for it.
+% }
+%
+% When \identifier{luaotfload} is asked to load a font by a font name,
+% it will check if the database exists and load it, or else generate a
+% fresh one.
+% Should it then fail to locate the font, an update to the database is
+% performed in case the font has been added to the system only
+% recently. As soon as the database is updated, the resolver will try
+% and look up the font again, all without user intervention.
+% The goal is for \identifier{luaotfload} to act in the background and
+% behave as unobtrusively as possible, while providing a convenient
+% interface to the fonts installed on the system.
+%
+% Generating the database for the first time may take a while since it
+% inspects every font file on your computer.
% This is particularly noticeable if it occurs during a typesetting run.
-% Subsequent runs to update the database will be quite fast, however.
+% In any case, subsequent updates to the database will be quite fast.
+%
+% \subsection[luaotfload-tool / mkluatexfontdb.lua]%
+% {\fileent{luaotfload-tool} /
+% \fileent{mkluatexfontdb.lua}\footnote{%
+% The script may be named just \fileent{mkluatexfontdb} in your
+% distribution.
+% }}
+%
+% It can still be desirable at times to do some of these steps
+% manually, and without having to compile a document.
+% To this end, \identifier{luaotfload} comes with the utility
+% \fileent{luaotfload-tool} that offers an interface to the database
+% functionality.
+% Being a \LUA script, there are two ways to run it:
+% either make it executable (\verb|chmod +x| on unixoid systems) or
+% pass it as an argument to \fileent{texlua}.\footnote{%
+% Tests by the maintainer show only marginal performance gain by
+% running with Luigi Scarso’s
+% \href{https://foundry.supelec.fr/projects/luajittex/}%
+% {\identifier{Luajit\kern-.25ex\TEX}},
+% which is probably due to the fact that most of the time is spent
+% on file system operations.
+%
+% \emphasis{Note}:
+% On \abbrev{MS} \identifier{Windows} systems, the script can be run
+% either by calling the wrapper application
+% \fileent{luaotfload-tool.exe} or as
+% \verb|texlua.exe luaotfload-tool.lua|.
+% }
+% Invoked with the argument \verb|--update| it will perform a database
+% update, scanning for fonts not indexed.
%
-% \textsf{luaotfload} will parse standard places for fonts in your system to
-% build the font database. On Linux, it will read |fontconfig| configuration
-% files to find the font locations;
-% on Windows and Mac~OS~X, it will search in the standard font locations,
-% |%WINDIR%\Fonts| in Windows and |~/Library/Fonts|, |/Library/Fonts|,
-% |/System/Library/Fonts|, and |/Network/Library/Fonts| in Mac~OS~X.
+% \begin{quote}
+% \begin{verbatim}
+% luaotfload-tool --update
+% \end{verbatim}
+% \end{quote}
%
-% If you do not wish the standard font locations be searched by default but
-% would rather specify the exact locations in which to find your fonts, set
-% the |OSFONTDIR| environment variable instead. When this variable is set,
-% only the specified directories will be searched.
+% Adding the \verb|--force| switch will initiate a complete
+% rebuild of the database.
%
-% |mkluatexfontdb.lua --help| provides a brief summary of the functionality of
-% the script and includes some advanced options that we have not mentioned
-% here.
+% \begin{quote}
+% \begin{verbatim}
+% luaotfload-tool --update --force
+% \end{verbatim}
+% \end{quote}
%
-% \subsection{Blacklisting fonts}
+% For sake of backwards compatibility, \fileent{luaotfload-tool} may be
+% renamed or symlinked to \fileent{mkluatexfontdb}.
+% Whenever it is run under this name, it will update the database
+% first, mimicking the behavior of earlier versions of
+% \identifier{luaotfload}.
+%
+% \subsection{Search Paths}
+%
+% \identifier{luaotfload} scans those directories where fonts are
+% expected to be located on a given system.
+% On a Linux machine it follows the paths listed in the
+% \identifier{Fontconfig} configuration files;
+% consult \verb|man 5 fonts.conf| for further information.
+% On \identifier{Windows} systems, the standard location is
+% \verb|Windows\Fonts|,
+% while \identifier{Mac OS~X} requires a multitude of paths to
+% be examined.
+% The complete list is is given in table \ref{table-searchpaths}.
+% Other paths can be specified by setting the environment variable
+% \verb+OSFONTDIR+.
+% If it is non-empty, then search will be extended to the included
+% directories.
+%
+% \begin{table}[t]
+% \hrule
+% \caption{List of paths searched for each supported operating
+% system.}
+% \renewcommand{\arraystretch}{1.2}
+% \begin{center}
+% \begin{tabular}{lp{.5\textwidth}}
+% Windows & \verb|%WINDIR%\Fonts|
+% \\
+% Linux & \fileent{/usr/local/etc/fonts/fonts.conf} and\hfill\break
+% \fileent{/etc/fonts/fonts.conf}
+% \\
+% Mac & \fileent{\textasciitilde/Library/Fonts},\break
+% \fileent{/Library/Fonts},\break
+% \fileent{/System/Library/Fonts}, and\hfill\break
+% \fileent{/Network/Library/Fonts}
+% \\
+% \end{tabular}
+% \end{center}
+% \label{table-searchpaths}
+% \hrule
+% \end{table}
+%
+% \subsection{Querying from Outside}
+%
+% \fileent{luaotfload-tool} also provides rudimentary means of
+% accessing the information collected in the font database.
+% If the option \verb|--find=|\emphasis{name} is given, the script will
+% try and search the fonts indexed by \identifier{luaotfload} for a
+% matching name.
+% For instance, the invocation
%
-% Some fonts are problematic in \luatex, if you found that your document takes
-% too long to compile, or eats all the free memory, you can find the culprit
-% file by running |mkluatexfontdb| utility with |-v| option to see which font
-% file it is stuck with. You can then instruct \textsf{luaotfload} to ignore
-% this font by adding it to the blacklist configuration file.
+% \begin{quote}
+% \begin{verbatim}
+% luaotfload-tool --find="Iwona Regular"
+% \end{verbatim}
+% \end{quote}
%
-% Simply, create a file named |otfl-blacklist.cnf| and added the to be
-% blacklisted files, one per line. Then put the file some where \textsf{kpse}
-% can find. You can either use the base name or the full path. Any thing after
-% a |%| sign is ignored.
+% \noindent
+% will verify if “Iwona Regular” is found in the database and can be
+% readily requested in a document.
%
-% \section{Required \context files}
+% If you are unsure about the actual font name, then add the
+% \verb|-F| (or \verb|--fuzzy|) switch to the command line to enable
+% approximate matching.
+% Suppose you cannot precisely remember if the variant of
+% \identifier{Iwona} you are looking for was “Bright” or “Light”.
+% The query
%
-% This package is a wrapper for several files taken from the \context macro
-% package. The philosophy is to let \context do all the implementation and
-% update these files from time to time. So we try not to modify the files
-% taken from \context as far as possible, but we changed their names to
-% prevent name clashes.
+% \begin{quote}
+% \begin{verbatim}
+% luaotfload-tool -F --find="Iwona Bright"
+% \end{verbatim}
+% \end{quote}
%
-% The \context files are renamed by adding the prefix |otfl-| to them
-% (|otfl| as |OTF L|oad). The files are:
+% \noindent
+% will tell you that indeed the latter name is correct.
%
-% \begin{multicols}{3}
-% \begin{itemize*}
-% \item |luat-dum.lua|
-% \item |data-con.lua|
-% \item |node-inj.lua|
-% \item |node-dum.lua|
-% \item |font-ini.lua|
-% \item |font-tfm.lua|
-% \item |font-cid.lua|
-% \item |font-ott.lua|
-% \item |font-otf.lua|
-% \item |font-otd.lua|
-% \item |font-oti.lua|
-% \item |font-otb.lua|
-% \item |font-otn.lua|
-% \item |font-ota.lua|
-% \item |font-otc.lua|
-% \item |font-def.lua|
-% \item |font-xtx.lua|
-% \item |font-map.lua|
-% \item |font-dum.lua|
-% \end{itemize*}
-% \end{multicols}
+% Basic information about fonts in the database can be displayed
+% using the \verb|-i| option (\verb|--info|).
+% \begin{quote}
+% \begin{verbatim}
+% luaotfload-tool -i --find="Iwona Light Italic"
+% \end{verbatim}
+% \end{quote}
+% \noindent
+% The meaning of the printed values is described in section 4.4 of the
+% \LUATEX reference manual.\footnote{%
+% In \TEX Live: \fileent{texmf-dist/doc/luatex/base/luatexref-t.pdf}.
+% }
%
-% The following files have been written for this package:
-% \begin{multicols}{3}
-% \begin{itemize*}
-% \item |font-clr.lua|
-% \item |font-nms.lua|
-% \item |luat-ovr.lua|
-% \end{itemize*}
-% \end{multicols}
+% \verb|luaotfload-tool --help| will list the available command line
+% switches, including some not discussed in detail here.
+%
+% \subsection{Blacklisting Fonts}
+% \label{font-blacklist}
+%
+% Some fonts are problematic in general, or just in \LUATEX.
+% If you find that compiling your document takes far too long or eats
+% away all your system’s memory, you can track down the culprit by
+% running \verb|luaotfload-tool -v| to increase verbosity.
+% Take a note of the \emphasis{filename} of the font that database
+% creation fails with and append it to the file
+% \fileent{luaotfload-blacklist.cnf}.
+%
+% A blacklist file is a list of font filenames, one per line.
+% Specifying the full path to where the file is located is optional, the
+% plain filename should suffice.
+% File extensions (\fileent{.otf}, \fileent{.ttf}, etc.) may be omitted.
+% Anything after a percent (|%|) character until the end of the line
+% is ignored, so use this to add comments.
+% Place this file to some location where the \identifier{kpse}
+% library can find it, e.~g.
+% \fileent{texmf-local/tex/luatex/luaotfload} if you are running
+% \identifier{\TEX Live},\footnote{%
+% You may have to run \verb|mktexlsr| if you created a new file in
+% your \fileent{texmf} tree.
+% }
+% or just leave it in the working directory of your document.
+% \identifier{luaotfload} reads all files named
+% \fileent{luaotfload-blacklist.cnf} it finds, so the fonts in
+% \fileent{./luaotfload-blacklist.cnf} extend the global blacklist.
+%
+% Furthermore, a filename prepended with a dash character (|-|) is
+% removed from the blacklist, causing it to be temporarily whitelisted
+% without modifying the global file.
+% An example with explicit paths:
+%
+% \begin{verbatim}
+% % example otf-blacklist.cnf
+% /Library/Fonts/GillSans.ttc % Luaotfload ignores this font.
+% -/Library/Fonts/Optima.ttc % This one is usable again, even if
+% % blacklisted somewhere else.
+% \end{verbatim}
+%
+% \section{Files from \CONTEXT and \LUATEX-Fonts}
+%
+% \identifier{luaotfload} relies on code originally written by Hans
+% Hagen\footnote{%
+% The creator of the \href{http://wiki.contextgarden.net}{\CONTEXT}
+% format.
+% }
+% for and tested with \CONTEXT.
+% It integrates the font loader as distributed in
+% the \identifier{\LUATEX-Fonts} package.
+% The original \LUA source files have been combined using the
+% \fileent{mtx-package} script into a single, self-contained blob.
+% In this form the font loader has no further dependencies\footnote{%
+% It covers, however, to some extent the functionality of the
+% \identifier{lualibs} package.
+% }
+% and requires only minor adaptions to integrate into
+% \identifier{luaotfload}.
+% The guiding principle is to let \CONTEXT/\LUATEX-Fonts take care of
+% the implementation, and update the imported code from time to time.
+% As maintainers, we aim at importing files from upstream essentially
+% \emphasis{unmodified}, except for renaming them to prevent name
+% clashes.
+% This job has been greatly alleviated since the advent of
+% \LUATEX-Fonts, prior to which the individual dependencies had to be
+% manually spotted and extracted from the \CONTEXT source code in a
+% complicated and error-prone fashion.
+%
+% Below is a commented list of the files distributed with
+% \identifier{luaotfload} in one way or the other.
+% See figure \ref{file-graph} on page \pageref{file-graph} for a
+% graphical representation of the dependencies.
+% From \LUATEX-Fonts, only the file \fileent{luatex-fonts-merged.lua}
+% has been imported as \fileent{luaotfload-merged.lua}.
+% It is generated by \fileent{mtx-package}, a \LUA source code merging
+% too developed by Hans Hagen.\footnote{%
+% \fileent{mtx-package} is
+% \href
+% {http://repo.or.cz/w/context.git/blob_plain/refs/heads/origin:/scripts/context/lua/mtx-package.lua}
+% {part of \CONTEXT}
+% and requires \fileent{mtxrun}.
+% Run
+% \verb|mtxrun --script package --help|
+% to display further information.
+% For the actual merging code see the file
+% \fileent{util-mrg.lua} that is part of \CONTEXT.
+% }
+% It houses several \LUA files that can be classed in three
+% categories.
+%
+% \begin{itemize}
+% \let\normalitem=\item
+% \def\incitem#1{%
+% \normalitem{\fileent{#1}}
+% }
+% \normalitem \emphasis{\LUA utility libraries}, a subset
+% of what is provided by the \identifier{lualibs}
+% package.
+%
+% \begin{multicols}{2}
+% \begin{itemize}
+% \incitem{l-lua.lua} \incitem{l-lpeg.lua}
+% \incitem{l-function.lua} \incitem{l-string.lua}
+% \incitem{l-table.lua} \incitem{l-io.lua}
+% \incitem{l-file.lua} \incitem{l-boolean.lua}
+% \incitem{l-math.lua} \incitem{util-str.lua}
+% \end{itemize}
+% \end{multicols}
+%
+% \normalitem The \emphasis{font loader} itself.
+% These files have been written for
+% \LUATEX-Fonts and they are distributed along
+% with \identifier{luaotfload}.
+% \begin{multicols}{2}
+% \begin{itemize}
+% \incitem{luatex-basics-gen.lua}
+% \incitem{luatex-basics-nod.lua}
+% \incitem{luatex-fonts-enc.lua}
+% \incitem{luatex-fonts-syn.lua}
+% \incitem{luatex-fonts-tfm.lua}
+% \incitem{luatex-fonts-chr.lua}
+% \incitem{luatex-fonts-lua.lua}
+% \incitem{luatex-fonts-def.lua}
+% \incitem{luatex-fonts-ext.lua}
+% \incitem{luatex-fonts-cbk.lua}
+% \end{itemize}
+% \end{multicols}
+%
+% \normalitem Code related to \emphasis{font handling and
+% node processing}, taken directly from
+% \CONTEXT.
+% \begin{multicols}{2}
+% \begin{itemize}
+% \incitem{data-con.lua} \incitem{font-ini.lua}
+% \incitem{font-con.lua} \incitem{font-cid.lua}
+% \incitem{font-map.lua} \incitem{font-oti.lua}
+% \incitem{font-otf.lua} \incitem{font-otb.lua}
+% \incitem{node-inj.lua} \incitem{font-ota.lua}
+% \incitem{font-otn.lua} \incitem{font-def.lua}
+% \incitem{font-otp.lua}
+% \end{itemize}
+% \end{multicols}
+% \end{itemize}
+%
+% Note that if \identifier{luaotfload} cannot locate the
+% merged file, it will load the individual \LUA libraries
+% instead.
+% Their names remain the same as in \CONTEXT (without the
+% \verb|otfl|-prefix) since we imported the relevant section of
+% \fileent{luatex-fonts.lua} unmodified into \fileent{luaotfload.lua}.
+% Thus if you prefer running bleeding edge code from the
+% \CONTEXT beta, all you have to do is remove
+% \fileent{luaotfload-merged.lua} from the search path.
+%
+% Also, the merged file at some point
+% loads the Adobe Glyph List from a \LUA table that is contained in
+% \fileent{font-age.lua}, which is automatically generated by the
+% script \fileent{mkglyphlist}.\footnote{%
+% See \fileent{luaotfload-font-enc.lua}.
+% The hard-coded file name is why the file lacks the \fileent{luaotfload-}
+% prefix.
+% }
+% There is a make target \identifier{glyphs} that will create a fresh
+% \fileent{font-age.lua} so we don’t need to import it from \CONTEXT
+% any longer.
+%
+% In addition to these, \identifier{luaotfload} requires a number of
+% files not contained in the merge. Some of these have no equivalent in
+% \LUATEX-Fonts or \CONTEXT, some were taken unmodified from the
+% latter.
+%
+% \begin{itemize}
+% \let\normalitem=\item
+% \def\ouritem#1{%
+% \normalitem{\fileent{#1}}%
+% \space--\hskip1em
+% }
+% \ouritem {luaotfload-features.lua} font feature handling;
+% incorporates some of the code from
+% \fileent{font-otc} from \CONTEXT;
+% \ouritem {luaotfload-lib-dir.lua} \fileent{l-dir} from \CONTEXT;
+% contains functionality required
+% by \fileent{luaotfload-font-nms.lua}.
+% \ouritem {luaotfload-override.lua} overrides the \CONTEXT logging
+% functionality.
+% \ouritem {luaotfload-loaders.lua} registers the \OpenType
+% font reader as handler for
+% Postscript fonts
+% (\abbrev{pfa}, \abbrev{pfb}).
+% \ouritem {luaotfload-database.lua} font names database.
+% \ouritem {luaotfload-colors.lua} color handling.
+% \ouritem {luaotfload-auxiliary.lua} access to internal functionality
+% for package authors
+% (proposals for additions welcome).
+% \end{itemize}
+%
+% \begin{figure}[b]
+% \caption{Schematic of the files in \identifier{Luaotfload}}
+% \includegraphics[width=\textwidth]{filegraph.pdf}
+% \label{file-graph}
+% \end{figure}
%
% \section{Troubleshooting}
%
% If you encounter problems with some fonts, please first update to the latest
-% version of this package before reporting a bug, as this package is under
-% active development.
+% version of this package before reporting a bug, as
+% \identifier{luaotfload} is under active development and still a
+% moving target.
+% The development takes place on \identifier{github} at
+% \url{https://github.com/lualatex/luaotfload} where there is an issue
+% tracker for submitting bug reports, feature requests and the likes
+% requests and the likes.
+%
+% Errors during database generation can be traced by increasing
+% verbosity levels and redirecting log output to \fileent{stdout}:
+%
+% \begin{verbatim}
+% luaotfload-tool -fuvvv --log=stdout
+% \end{verbatim}
%
-% A very common problem is the lack of features for some OpenType fonts
-% even when specified. It can be related to the fact that some fonts do not
-% provide features for the |dflt| script, which is the default one in this
-% package, so you may have to specify the script in the command line, for
-% example:
+% If this fails, the font last printed to the terminal is likely to be
+% the culprit.
+% Please specify it when reporting a bug, and blacklist it for the time
+% being (see above, page \pageref{font-blacklist}).
+%
+% A common problem is the lack of features for some
+% \OpenType fonts even when specified.
+% This can be related to the fact that some fonts do not provide
+% features for the \verb|dflt| script (see above on page
+% \pageref{script-tag}),
+% which is the default one in this package.
+% If this happens, assigning a noth script when the font is defined should
+% fix it.
+% For example with \verb|latn|:
%
-% |\font\myfont = MyFont.otf:script=latn;+liga;|
+% \begin{verbatim}
+% \font\test=file:MyFont.otf:script=latn;+liga;
+% \end{verbatim}
+%
+% \part{Implementation}
+%
+% \section{\fileent{luaotfload.lua}}
+%
+% This file initializes the system and loads the font loader.
+% To minimize potential conflicts between other packages and the
+% code imported from \CONTEXT, several precautions are in order.
+% Some of the functionality that the font loader expects to be present,
+% like raw access to callbacks, are assumed to have been disabled by
+% \identifier{luatexbase} when this file is processed.
+% In some cases it is possible to trick it by putting dummies into
+% place and restoring the behavior from \identifier{luatexbase} after
+% initilization.
+% Other cases such as attribute allocation require that we hook the
+% functionality from \identifier{luatexbase} into locations where they
+% normally wouldn’t be.
%
-% \part{\texttt{luaotfload.lua}}
+% Anyways we can import the code base without modifications, which is
+% due mostly to the extra effort by
+% Hans Hagen to make \LUATEX-Fonts self-contained and encapsulate it,
+% and especially due to his willingness to incorporate our suggestions.
%
% \iffalse
%<*lua>
% \fi
-%
-% First some usual initializations.
-%
% \begin{macrocode}
-module("luaotfload", package.seeall)
+luaotfload = luaotfload or {}
+local luaotfload = luaotfload
+
+config = config or { }
+config.luaotfload = config.luaotfload or { }
+------.luaotfload.resolver = config.luaotfload.resolver or "normal"
+config.luaotfload.resolver = config.luaotfload.resolver or "cached"
+config.luaotfload.definer = config.luaotfload.definer or "patch"
+config.luaotfload.loglevel = config.luaotfload.loglevel or 1
+config.luaotfload.color_callback = config.luaotfload.color_callback or "pre_linebreak_filter"
+--luaotfload.prefer_merge = config.luaotfload.prefer_merge or true
luaotfload.module = {
name = "luaotfload",
- version = 1.29,
- date = "2013/04/25",
+ version = 2.2,
+ date = "2013/04/29",
description = "OpenType layout system.",
author = "Elie Roux & Hans Hagen",
copyright = "Elie Roux",
- license = "CC0"
+ license = "GPL v2.0"
}
-local error, warning, info, log = luatexbase.provides_module(luaotfload.module)
+local luatexbase = luatexbase
+
+local type, next = type, next
+local setmetatable = setmetatable
+local find_file = kpse.find_file
+local lfsisfile = lfs.isfile
+local stringfind = string.find
+local stringformat = string.format
+local stringmatch = string.match
+local stringsub = string.sub
+
+local add_to_callback, create_callback =
+ luatexbase.add_to_callback, luatexbase.create_callback
+local reset_callback, call_callback =
+ luatexbase.reset_callback, luatexbase.call_callback
+
+local dummy_function = function () end
+
% \end{macrocode}
-%
-% This is a necessary initalization in order not to rebuild an existing font.
-% Maybe 600 should be replaced by |\pdfpkresolution| or |texconfig.pk_dpi|
-% (and it should be replaced dynamically), but we don't have access (yet) to
-% the |texconfig| table, so we let it be 600. Anyway, it does still work
-% fine even if |\pdfpkresolution| is changed.
+% No final decision has been made on how to handle font definition. At
+% the moment, there are three candidates: The \identifier{generic}
+% callback as hard-coded in the font loader, the \identifier{old}
+% wrapper, and a simplified version of the latter (\identifier{patch})
+% that does nothing besides applying font patches.
%
% \begin{macrocode}
-kpse.init_prog("", 600, "/")
+
+luaotfload.font_definer = "patch" --- | “generic” | “old”
+
+local error, warning, info, log =
+ luatexbase.provides_module(luaotfload.module)
+
+luaotfload.error = error
+luaotfload.warning = warning
+luaotfload.info = info
+luaotfload.log = log
+
% \end{macrocode}
-%
-% The minimal required \luatex version.
+% We set the minimum version requirement for \LUATEX to v0.76,
+% because the font loader requires recent features like direct
+% attribute indexing and \luafunction{node.end_of_math()} that aren’t
+% available in earlier versions.\footnote{%
+% See Taco’s announcement of v0.76:
+% \url{http://comments.gmane.org/gmane.comp.tex.luatex.user/4042}
+% and this commit by Hans that introduced those features.
+% \url{http://repo.or.cz/w/context.git/commitdiff/a51f6cf6ee087046a2ae5927ed4edff0a1acec1b}.
+% }
%
% \begin{macrocode}
-local luatex_version = 60
+
+local luatex_version = 76
if tex.luatexversion < luatex_version then
warning("LuaTeX v%.2f is old, v%.2f is recommended.",
tex.luatexversion/100,
luatex_version /100)
end
+
% \end{macrocode}
-%
% \subsection{Module loading}
-%
-% We load the \context files with this function. It automatically adds the
-% |otfl-| prefix to it, so that we call it with the actual \context
-% name.
+% We load the files imported from \CONTEXT with this function.
+% It automatically prepends the prefix \fileent{luaotfload-} to its
+% argument, so we can refer to the files with their actual \CONTEXT name.
%
% \begin{macrocode}
-function luaotfload.loadmodule(name)
- local tofind = "otfl-"..name
- local found = kpse.find_file(tofind,"tex")
- if found then
- log("loading file %s.", found)
- dofile(found)
- else
- error("file %s not found.", tofind)
- end
+
+local fl_prefix = "luaotfload" -- “luatex” for luatex-plain
+local loadmodule = function (name)
+ require(fl_prefix .."-"..name)
end
+
% \end{macrocode}
-%
-% We start loading some lua files. These two are some code not used by
-% \context at all that allow other modules to be used, it provides some
-% low-level \context functions.
+% Before \TeX Live 2013 version, \LUATEX had a bug that made ofm fonts fail
+% when called with their extension. There was a side-effect making ofm
+% totally unloadable when luaotfload was present. The following lines are
+% a patch for this bug. The utility of these lines is questionable as they
+% are not necessary since \TeX Live 2013. They should be removed in the next
+% version.
%
% \begin{macrocode}
-luaotfload.loadmodule("luat-dum.lua") -- not used in context at all
-luaotfload.loadmodule("luat-ovr.lua") -- override some luat-dum functions
-luaotfload.loadmodule("data-con.lua") -- maybe some day we don't need this one
+local Cs, P, lpegmatch = lpeg.Cs, lpeg.P, lpeg.match
+
+local p_dot, p_slash = P".", P"/"
+local p_suffix = (p_dot * (1 - p_dot - p_slash)^1 * P(-1)) / ""
+local p_removesuffix = Cs((p_suffix + 1)^1)
+
+local find_vf_file = function (name)
+ local fullname = find_file(name, "ovf")
+ if not fullname then
+ --fullname = find_file(file.removesuffix(name), "ovf")
+ fullname = find_file(lpegmatch(p_removesuffix, name), "ovf")
+ end
+ if fullname then
+ log("loading virtual font file %s.", fullname)
+ end
+ return fullname
+end
+
% \end{macrocode}
-%
-% A hack to remove a warning from |node-dum.lua| as it is \context
-% specific.
+% \subsection{Preparing the Font Loader}
+% We treat the fontloader as a black box so behavior is consistent
+% between formats.
+% We do no longer run the intermediate wrapper file
+% \fileent{luaotfload-fonts.lua} which we used to import from
+% \href{http://standalone.contextgarden.net/current/context/experimental/tex/generic/context/luatex/}{\LUATEX-Plain}.
+% Rather, we load the fontloader code directly in the same fashion as
+% \identifier{luatex-fonts}.
+% How this is executed depends on the presence on the \emphasis{merged
+% font loader code}.
+% In \identifier{luaotfload} this is contained in the file
+% \fileent{luaotfload-merged.lua}.
+% If this file cannot be found, the original libraries from \CONTEXT of
+% which the merged code was composed are loaded instead.
+% The imported font loader will call \luafunction{callback.register} once
+% while reading \fileent{font-def.lua}.
+% This is unavoidable unless we modify the imported files, but harmless
+% if we make it call a dummy instead.
+% However, this problem might vanish if we decide to do the merging
+% ourselves, like the \identifier{lualibs} package does.
+% With this step we would obtain the freedom to load our own overrides in
+% the process right where they are needed, at the cost of losing
+% encapsulation.
+% The decision on how to progress is currently on indefinite hold.
%
% \begin{macrocode}
-tex.attribute[0] = 0
+
+local starttime = os.gettimeofday()
+
+local trapped_register = callback.register
+callback.register = dummy_function
+
% \end{macrocode}
-%
-% Node support modules.
+% By default, the fontloader requires a number of \emphasis{private
+% attributes} for internal use.
+% These must be kept consistent with the attribute handling methods as
+% provided by \identifier{luatexbase}.
+% Our strategy is to override the function that allocates new attributes
+% before we initialize the font loader, making it a wrapper around
+% \luafunction{luatexbase.new_attribute}.\footnote{%
+% Many thanks, again, to Hans Hagen for making this part
+% configurable!
+% }
+% The attribute identifiers are prefixed “\fileent{luaotfload@}” to
+% avoid name clashes.
%
% \begin{macrocode}
-luaotfload.loadmodule("font-ini.lua")
-luaotfload.loadmodule("node-dum.lua")
-luaotfload.loadmodule("node-inj.lua")
+
+do
+ local new_attribute = luatexbase.new_attribute
+ local the_attributes = luatexbase.attributes
+
+ attributes = attributes or { }
+
+ attributes.private = function (name)
+ local attr = "luaotfload@" .. name --- used to be: “otfl@”
+ local number = the_attributes[attr]
+ if not number then
+ number = new_attribute(attr)
+ end
+ return number
+ end
+end
+
% \end{macrocode}
-%
-% By default \context takes some private attributes for internal use. To
-% avoide attribute clashes with other packages, we override the function
-% that allocates new attributes, making it a wraper around
-% |luatexbase.new_attribute()|. We also prefix attributes with |otfl@| to
-% avoid possiple name clashes.
+% These next lines replicate the behavior of \fileent{luatex-fonts.lua}.
%
% \begin{macrocode}
-function attributes.private(name)
- local attr = "otfl@" .. name
- local number = luatexbase.attributes[attr]
- if not number then
- number = luatexbase.new_attribute(attr)
+
+local context_environment = { }
+
+local push_namespaces = function ()
+ log("push namespace for font loader")
+ local normalglobal = { }
+ for k, v in next, _G do
+ normalglobal[k] = v
end
- return number
+ return normalglobal
end
+
+local pop_namespaces = function (normalglobal, isolate)
+ if normalglobal then
+ local _G = _G
+ local mode = "non-destructive"
+ if isolate then mode = "destructive" end
+ log("pop namespace from font loader -- " .. mode)
+ for k, v in next, _G do
+ if not normalglobal[k] then
+ context_environment[k] = v
+ if isolate then
+ _G[k] = nil
+ end
+ end
+ end
+ for k, v in next, normalglobal do
+ _G[k] = v
+ end
+ -- just to be sure:
+ setmetatable(context_environment,_G)
+ else
+ log("irrecoverable error during pop_namespace: no globals to restore")
+ os.exit()
+ end
+end
+
+luaotfload.context_environment = context_environment
+luaotfload.push_namespaces = push_namespaces
+luaotfload.pop_namespaces = pop_namespaces
+
+local our_environment = push_namespaces()
+
% \end{macrocode}
-%
-% Font handling modules.
+% The font loader requires that the attribute with index zero be zero.
+% We happily oblige.
+% (Cf. \fileent{luatex-fonts-nod.lua}.)
%
% \begin{macrocode}
-luaotfload.loadmodule("font-tfm.lua")
-luaotfload.loadmodule("font-cid.lua")
-luaotfload.loadmodule("font-ott.lua")
-luaotfload.loadmodule("font-map.lua")
-luaotfload.loadmodule("font-otf.lua")
-luaotfload.loadmodule("font-otd.lua")
-luaotfload.loadmodule("font-oti.lua")
-luaotfload.loadmodule("font-otb.lua")
-luaotfload.loadmodule("font-otn.lua")
-luaotfload.loadmodule("font-ota.lua")
-luaotfload.loadmodule("font-otc.lua")
-luaotfload.loadmodule("font-def.lua")
-luaotfload.loadmodule("font-xtx.lua")
-luaotfload.loadmodule("font-dum.lua")
+
+tex.attribute[0] = 0
+
% \end{macrocode}
-%
-% This is a patch for |otfl-font-def.lua|, that defines a reader for ofm
-% fonts, this is necessary if we set the forced field of the specification
-% to |ofm|.
+% Now that things are sorted out we can finally load the fontloader.
%
% \begin{macrocode}
-if fonts and fonts.tfm and fonts.tfm.readers then
- fonts.tfm.readers.ofm = fonts.tfm.readers.tfm
-end
+
+loadmodule"merged.lua"
+---loadmodule"font-odv.lua" --- <= Devanagari support from Context
+
+if fonts then
+
+ if not fonts._merge_loaded_message_done_ then
+ --- a program talking first person -- HH sure believes in strong AI ...
+ log[[“I am using the merged version of 'luaotfload.lua' here. If]]
+ log[[ you run into problems or experience unexpected behaviour,]]
+ log[[ and if you have ConTeXt installed you can try to delete the]]
+ log[[ file 'luaotfload-font-merged.lua' as I might then use the]]
+ log[[ possibly updated libraries. The merged version is not]]
+ log[[ supported as it is a frozen instance. Problems can be]]
+ log[[ reported to the ConTeXt mailing list.”]]
+ end
+ fonts._merge_loaded_message_done_ = true
+
+else--- the loading sequence is known to change, so this might have to
+ --- be updated with future updates!
+ --- do not modify it though unless there is a change to the merged
+ --- package!
+ loadmodule("l-lua.lua")
+ loadmodule("l-lpeg.lua")
+ loadmodule("l-function.lua")
+ loadmodule("l-string.lua")
+ loadmodule("l-table.lua")
+ loadmodule("l-io.lua")
+ loadmodule("l-file.lua")
+ loadmodule("l-boolean.lua")
+ loadmodule("l-math.lua")
+ loadmodule("util-str.lua")
+ loadmodule('luatex-basics-gen.lua')
+ loadmodule('data-con.lua')
+ loadmodule('luatex-basics-nod.lua')
+ loadmodule('font-ini.lua')
+ loadmodule('font-con.lua')
+ loadmodule('luatex-fonts-enc.lua')
+ loadmodule('font-cid.lua')
+ loadmodule('font-map.lua')
+ loadmodule('luatex-fonts-syn.lua')
+ loadmodule('luatex-fonts-tfm.lua')
+ loadmodule('font-oti.lua')
+ loadmodule('font-otf.lua')
+ loadmodule('font-otb.lua')
+ loadmodule('node-inj.lua')
+ loadmodule('font-ota.lua')
+ loadmodule('font-otn.lua')
+ loadmodule('font-otp.lua')--- since 2013-04-23
+ loadmodule('luatex-fonts-lua.lua')
+ loadmodule('font-def.lua')
+ loadmodule('luatex-fonts-def.lua')
+ loadmodule('luatex-fonts-ext.lua')
+ loadmodule('luatex-fonts-cbk.lua')
+end --- non-merge fallback scope
+
% \end{macrocode}
-%
-% \textsf{luaotfload} specific modules.
+% Here we adjust the globals created during font loader initialization.
+% If the second argument to \luafunction{pop_namespaces()} is \verb|true|
+% this will restore the state of \luafunction{_G}, eliminating every
+% global generated since the last call to \luafunction{push_namespaces()}.
+% At the moment we see no reason to do this, and since the font loader is
+% considered an essential part of \identifier{luatex} as well as a very
+% well organized piece of code, we happily concede it the right to add to
+% \luafunction{_G} if needed.
%
% \begin{macrocode}
-luaotfload.loadmodule("font-nms.lua")
-luaotfload.loadmodule("font-clr.lua")
+
+pop_namespaces(our_environment, false)-- true)
+
+log("fontloader loaded in %0.3f seconds", os.gettimeofday()-starttime)
+
% \end{macrocode}
+% \subsection{Callbacks}
+% After the fontloader is ready we can restore the callback trap from
+% \identifier{luatexbase}.
%
-% \subsection{Post-processing TFM table}
-%
-% Here we do some final touches to the loaded TFM table before passing it
-% to the \tex end.
-%
-% First we create a callback for patching fonts on the fly, to be used by
-% other packages.
% \begin{macrocode}
-luatexbase.create_callback("luaotfload.patch_font", "simple", function() end)
+
+callback.register = trapped_register
+
% \end{macrocode}
-%
-% then define a function where font manipulation will take place.
+% We do our own callback handling with the means provided by luatexbase.
+% Note: \luafunction{pre_linebreak_filter} and \luafunction{hpack_filter}
+% are coupled in \CONTEXT in the concept of \emphasis{node processor}.
%
% \begin{macrocode}
-local function def_font(...)
- local fontdata = fonts.define.read(...)
- if type(fontdata) == "table" and fontdata.shared then
+
+add_to_callback("pre_linebreak_filter",
+ nodes.simple_font_handler,
+ "luaotfload.node_processor",
+ 1)
+add_to_callback("hpack_filter",
+ nodes.simple_font_handler,
+ "luaotfload.node_processor",
+ 1)
+add_to_callback("find_vf_file",
+ find_vf_file, "luaotfload.find_vf_file")
+
+loadmodule"lib-dir.lua" --- required by luaofload-database.lua
+loadmodule"override.lua" --- “luat-ovr”
+
+logs.set_loglevel(config.luaotfload.loglevel)
+
% \end{macrocode}
-%
-% Then we populate |MathConstants| table, which is required for
-% OpenType math.
+% Now we load the modules written for \identifier{luaotfload}.
%
% \begin{macrocode}
- local otfdata = fontdata.shared.otfdata
- if otfdata.metadata.math then
- local mc = { }
- for k,v in next, otfdata.metadata.math do
- if k:find("Percent") then
- -- keep percent values as is
- mc[k] = v
- else
- mc[k] = v / fontdata.units * fontdata.size
- end
- end
- -- for \overwithdelims
- mc.FractionDelimiterSize = 1.01 * fontdata.size
- mc.FractionDelimiterDisplayStyleSize = 2.39 * fontdata.size
+loadmodule"loaders.lua" --- “font-pfb” new in 2.0, added 2011
+loadmodule"database.lua" --- “font-nms”
+loadmodule"colors.lua" --- “font-clr”
- fontdata.MathConstants = mc
- end
% \end{macrocode}
+% Relying on the \verb|name:| resolver for everything has been the source
+% of permanent trouble with the database.
+% With the introduction of the new syntax parser we now have enough
+% granularity to distinguish between the \XETEX emulation layer and the
+% genuine \verb|name:| and \verb|file:| lookups of \LUATEX-Fonts.
+% Another benefit is that we can now easily plug in or replace new lookup
+% behaviors if necessary.
+% The name resolver remains untouched, but it calls
+% \luafunction{fonts.names.resolve()} internally anyways (see
+% \fileent{luaotfload-database.lua}).
%
-% Execute any registered font patching callbacks.
+% \begin{macrocode}
+
+local request_resolvers = fonts.definers.resolvers
+local formats = fonts.formats
+formats.ofm = "type1"
+
+% \end{macrocode}
+% \identifier{luaotfload} promises easy access to system fonts.
+% Without additional precautions, this cannot be achieved by
+% \identifier{kpathsea} alone, because it searches only the
+% \fileent{texmf} directories by default.
+% Although it is possible for \identifier{kpathsea} to include extra
+% paths by adding them to the \verb|OSFONTDIR| environment variable,
+% this is still short of the goal »\emphasis{it just works!}«.
+% When building the font database \identifier{luaotfload} scans
+% system font directories anyways, so we already have all the
+% information for looking sytem fonts.
+% With the release version 2.2 the file names are indexed in the database
+% as well and we are ready to resolve \verb|file:| lookups this way.
+% Thus we no longer need to call the \identifier{kpathsea} library in
+% most cases when looking up font files, only when generating the database.
%
% \begin{macrocode}
- luatexbase.call_callback("luaotfload.patch_font", fontdata)
- end
- return fontdata
+request_resolvers.file = function (specification)
+ local found = fonts.names.crude_file_lookup(specification.name)
+ --local found = fonts.names.crude_file_lookup_verbose(specification.name)
+ specification.name = found[1]
+ --if format then specification.forced = format end
end
+
% \end{macrocode}
-%
-% \subsection{\context override}
-%
-% We have a unified function for both file and name resolver. This line is
-% commented as it makes database reload too often. This means that in some
-% cases, a font in the database will not be found if it's not in the texmf
-% tree. A similar thing will reappear in next version.
+% We classify as \verb|anon:| those requests that have neither a
+% prefix nor brackets. According to Khaled\footnote{%
+% \url{https://github.com/phi-gamma/luaotfload/issues/4#issuecomment-17090553}.
+% }
+% they are the \XETEX equivalent of a \verb|name:| request, so we will be
+% treating them as such.
%
% \begin{macrocode}
---fonts.define.resolvers.file = fonts.define.resolvers.name
+
+--request_resolvers.anon = request_resolvers.name
+
% \end{macrocode}
-%
-% We override the cleanname function as it outputs garbage for exotic font
-% names
+% There is one drawback, though.
+% This syntax is also used for requesting fonts in \identifier{Type1}
+% (\abbrev{tfm}, \abbrev{ofm}) format.
+% These are essentially \verb|file:| lookups and must be caught before
+% the \verb|name:| resolver kicks in, lest they cause the database to
+% update.
+% Even if we were to require the \verb|file:| prefix for all
+% \identifier{Type1} requests, tests have shown that certain fonts still
+% include further fonts (e.~g. \fileent{omlgcb.ofm} will ask for
+% \fileent{omsecob.tfm}) \emphasis{using the old syntax}.
+% For this reason, we introduce an extra check with an early return.
%
% \begin{macrocode}
-containers.cleanname = function (name)
- return (string.gsub(string.lower(name),"[^%w%d\128\255]+","-"))
-end
+local type1_formats = { "tfm", "ofm", }
+
+request_resolvers.anon = function (specification)
+ local name = specification.name
+ for i=1, #type1_formats do
+ local format = type1_formats[i]
+ if resolvers.findfile(name, format) then
+ specification.name = file.addsuffix(name, format)
+ return
+ end
+ end
+ request_resolvers.name(specification)
+end
+
% \end{macrocode}
-%
-% Overriding some defaults set in \context code.
+% Prior to version 2.2, \identifier{luaotfload} did not distinguish
+% \verb|file:| and \verb|path:| lookups, causing complications with the
+% resolver.
+% Now we test if the requested name is an absolute path in the file
+% system, otherwise we fall back to the \verb|file:| lookup.
%
% \begin{macrocode}
-fonts.mode = "node"
+request_resolvers.path = function (specification)
+ local exists, _ = lfsisfile(specification.name)
+ if not exists then -- resort to file: lookup
+ request_resolvers.file(specification)
+ end
+end
+
% \end{macrocode}
-%
-% The following features are useful in math (e.g. in XITS Math font),
-% but \textsf{luaotfload} does not recognize them in |base| mode.
+% We create a callback for patching fonts on the fly, to be used by other
+% packages.
+% It initially contains the empty function that we are going to override
+% below.
%
% \begin{macrocode}
-local register_base_sub = fonts.otf.features.register_base_substitution
-local gsubs = {
- "ss01", "ss02", "ss03", "ss04", "ss05",
- "ss06", "ss07", "ss08", "ss09", "ss10",
- "ss11", "ss12", "ss13", "ss14", "ss15",
- "ss16", "ss17", "ss18", "ss19", "ss20",
-}
-for _,v in next, gsubs do
- register_base_sub(v)
-end
+create_callback("luaotfload.patch_font", "simple", dummy_function)
+
% \end{macrocode}
-%
-% Finally we register the callbacks
+% \subsection{\CONTEXT override}
+% We provide a simplified version of the original font definition
+% callback.
%
% \begin{macrocode}
-luatexbase.add_to_callback("pre_linebreak_filter",
- nodes.simple_font_handler,
- "luaotfload.pre_linebreak_filter")
-luatexbase.add_to_callback("hpack_filter",
- nodes.simple_font_handler,
- "luaotfload.hpack_filter")
-luatexbase.reset_callback("define_font")
-luatexbase.add_to_callback("define_font",
- def_font,
- "luaotfload.define_font", 1)
-luatexbase.add_to_callback("find_vf_file",
- fonts.vf.find,
- "luaotfload.find_vf_file")
+
+local read_font_file = fonts.definers.read
+
+--- spec -> size -> id -> tmfdata
+local patch_defined_font = function (specification, size, id)
+ local tfmdata = read_font_file(specification, size, id)
+ if type(tfmdata) == "table" and tfmdata.shared then
+ --- We need to test for the “shared” field here
+ --- or else the fontspec capheight callback will
+ --- operate on tfm fonts.
+ call_callback("luaotfload.patch_font", tfmdata)
+ end
+ return tfmdata
+end
+
+caches.compilemethod = "both"
+
+reset_callback("define_font")
+
% \end{macrocode}
-% XXX: see https://github.com/wspr/unicode-math/issues/185
-%
-% \luatex does not provide interface to accessing
-% |(Script)ScriptPercentScaleDown| math constants, so we
-% emulate \xetex behaviour by setting |\fontdimen10| and
-% |\fontdimen11|.
+% Finally we register the callbacks.
%
% \begin{macrocode}
-local function set_sscale_diments(fontdata)
- local mc = fontdata.MathConstants
- if mc then
- if mc["ScriptPercentScaleDown"] then
- fontdata.parameters[10] = mc.ScriptPercentScaleDown
- else -- resort to plain TeX default
- fontdata.parameters[10] = 70
- end
- if mc["ScriptScriptPercentScaleDown"] then
- fontdata.parameters[11] = mc.ScriptScriptPercentScaleDown
- else -- resort to plain TeX default
- fontdata.parameters[11] = 50
- end
- end
+
+local font_definer = config.luaotfload.definer
+
+if font_definer == "generic" then
+ add_to_callback("define_font",
+ fonts.definers.read,
+ "luaotfload.define_font",
+ 1)
+elseif font_definer == "patch" then
+ add_to_callback("define_font",
+ patch_defined_font,
+ "luaotfload.define_font",
+ 1)
end
-luatexbase.add_to_callback("luaotfload.patch_font", set_sscale_diments, "unicodemath.set_sscale_diments")
+loadmodule"features.lua" --- contains what was “font-ltx” and “font-otc”
+loadmodule"auxiliary.lua" --- additionaly high-level functionality (new)
+
+-- vim:tw=71:sw=4:ts=4:expandtab
+
+
% \end{macrocode}
%
% \iffalse
%</lua>
% \fi
%
-% \part{\texttt{luaotfload.sty}}
+% \section{\fileent{luaotfload.sty}}
%
% \iffalse
%<*package>
% \fi
%
-% Classical Plain+\latex package initialization.
+% Classical Plain+\LATEX package initialization.
%
% \begin{macrocode}
\csname ifluaotfloadloaded\endcsname
\let\ifluaotfloadloaded\endinput
-
\bgroup\expandafter\expandafter\expandafter\egroup
\expandafter\ifx\csname ProvidesPackage\endcsname\relax
\input luatexbase.sty
\else
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{luaotfload}%
- [2012/05/28 v1.27 OpenType layout system]
+ [2013/04/16 v2.2 OpenType layout system]
\RequirePackage{luatexbase}
\fi
-
-\RequireLuaModule{lualibs}
-% \end{macrocode}
-%
-% Finally we load the |lua| module.
-%
-% \begin{macrocode}
\RequireLuaModule{luaotfload}
+\endinput
% \end{macrocode}
% \iffalse
%</package>
@@ -888,7 +1890,7 @@ luatexbase.add_to_callback("luaotfload.patch_font", set_sscale_diments, "unicode
%
% \begin{enumerate}
%
-% \item
+% \item
% You must cause the modified files to carry prominent notices stating that
% you changed the files and the date of any change.
%