diff options
author | Karl Berry <karl@freefriends.org> | 2013-05-18 22:21:33 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-05-18 22:21:33 +0000 |
commit | 2472c585a2dee03ef4665514cb651e5976fd134a (patch) | |
tree | cb0475ebdca2ed9ee248dd809f6bcce1671a0afb /Master/texmf-dist/source/luatex/luaotfload | |
parent | 542dd7f24e76ac20da26d1c4d7ceb69baa248133 (diff) |
luaotfload (18may13)
git-svn-id: svn://tug.org/texlive/trunk@30561 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/luatex/luaotfload')
-rw-r--r-- | Master/texmf-dist/source/luatex/luaotfload/Makefile | 28 | ||||
-rw-r--r-- | Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx | 267 |
2 files changed, 253 insertions, 42 deletions
diff --git a/Master/texmf-dist/source/luatex/luaotfload/Makefile b/Master/texmf-dist/source/luatex/luaotfload/Makefile index c1e98f652fe..3807ec5e99b 100644 --- a/Master/texmf-dist/source/luatex/luaotfload/Makefile +++ b/Master/texmf-dist/source/luatex/luaotfload/Makefile @@ -7,6 +7,9 @@ OTFL = $(wildcard luaotfload-*.lua) luaotfload-blacklist.cnf GLYPHSCRIPT = mkglyphlist GLYPHSOURCE = glyphlist.txt +CHARSCRIPT = mkcharacters + +RESOURCESCRIPTS = $(GLYPHSCRIPT) $(CHARSCRIPT) SCRIPTNAME = luaotfload-tool SCRIPT = $(SCRIPTNAME).lua @@ -20,12 +23,14 @@ DOT = $(GRAPH).dot # Files grouped by generation mode GLYPHS = luaotfload-glyphlist.lua +CHARS = luaotfload-characters.lua +RESOURCES = $(GLYPHS) $(CHARS) GRAPHED = $(DOTPDF) MAN = $(MANPAGE) COMPILED = $(DOC) UNPACKED = luaotfload.sty luaotfload.lua -GENERATED = $(GRAPHED) $(UNPACKED) $(COMPILED) $(GLYPHS) $(MAN) -SOURCE = $(DTX) $(MANSOURCE) $(OTFL) README Makefile NEWS $(SCRIPT) $(OLDSCRIPT) $(GLYPHSCRIPT) +GENERATED = $(GRAPHED) $(UNPACKED) $(COMPILED) $(RESOURCES) $(MAN) +SOURCE = $(DTX) $(MANSOURCE) $(OTFL) README Makefile NEWS $(RESOURCESCRIPTS) # test files TESTDIR = tests @@ -34,8 +39,8 @@ TESTFILES_SYS = $(TESTDIR)/systemfonts.tex $(TESTDIR)/fontconfig_conf_reading.t TESTFILES_TL = $(filter-out $(TESTFILES_SYS), $(TESTFILES)) # Files grouped by installation location -SCRIPTFILES = $(SCRIPT) $(OLDSCRIPT) $(GLYPHSCRIPT) -RUNFILES = $(UNPACKED) $(OTFL) +SCRIPTFILES = $(SCRIPT) $(OLDSCRIPT) $(RESOURCESCRIPTS) +RUNFILES = $(UNPACKED) $(filter-out $(SCRIPTFILES),$(OTFL)) DOCFILES = $(DOC) $(DOTPDF) README NEWS MANFILES = $(MANPAGE) SRCFILES = $(DTX) Makefile @@ -57,25 +62,32 @@ CTAN_ZIP = $(NAME).zip TDS_ZIP = $(NAME).tds.zip ZIPS = $(CTAN_ZIP) $(TDS_ZIP) +LUA = texlua + DO_TEX = luatex --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 -DO_DOCUTILS = rst2man2 $< >$@ 2>/dev/null +DO_GLYPHS = $(LUA) $(GLYPHSCRIPT) > /dev/null +DO_CHARS = $(LUA) $(CHARSCRIPT) > /dev/null +DO_DOCUTILS = rst2man $< >$@ 2>/dev/null all: $(GENERATED) graph: $(GRAPHED) doc: $(GRAPHED) $(COMPILED) $(MAN) manual: $(MAN) unpack: $(UNPACKED) -glyphs: $(GLYPHS) +resources: $(RESOURCES) +chars: $(CHARS) ctan: $(CTAN_ZIP) tds: $(TDS_ZIP) world: all ctan $(GLYPHS): /dev/null - $(DO_GLYPHLIST) + $(DO_GLYPHS) + +$(CHARS): /dev/null + $(DO_CHARS) $(GRAPHED): $(DOT) $(DO_GRAPHVIZ) diff --git a/Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx b/Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx index 7ccd6e88c65..9ed00b5bd38 100644 --- a/Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx +++ b/Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx @@ -111,7 +111,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{luaotfload.drv}% - [2013/04/16 v2.2 OpenType layout system]% + [2013/05/18 v2.2 OpenType layout system]% \documentclass{ltxdoc} \usepackage{metalogo,multicol,mdwlist,fancyvrb,xspace} \usepackage[x11names]{xcolor} @@ -187,11 +187,14 @@ and the derived files {\normalsize\rmfamily\bfseries} {\movecountertomargin\thepart} \zeropoint {} \titleformat \section - {\normalsize\rmfamily\scshape}%% no \word; life is full of disappointments + {\normalsize\rmfamily\scshape} {\movecountertomargin\thesection} \zeropoint {} \titleformat \subsection {\small\rmfamily\itshape} {\movecountertomargin\thesubsection} \zeropoint {} +\titleformat \subsubsection + {\normalsize\rmfamily\upshape} + {\movecountertomargin\thesubsubsection} \zeropoint {} \usepackage{tocloft} \renewcommand \cftpartfont {\rmfamily\upshape} @@ -228,7 +231,7 @@ and the derived files % \GetFileInfo{luaotfload.drv} % % \title{The \identifier{luaotfload} package} -% \date{2013/05/05 v2.2} +% \date{2013/05/18 v2.2} % \author{Elie Roux · Khaled Hosny · Philipp Gesang\\ % Home: \url{https://github.com/lualatex/luaotfload}\\ % Support: \email{lualatex-dev@tug.org}} @@ -1178,6 +1181,174 @@ and the derived files % \label{file-graph} % \end{figure} % +% \section{Auxiliary Functions} +% +% With release version 2.2, \identifier{luaotfload} received +% additional functions for package authors to call from outside +% (see the file \fileent{luaotfload-auxiliary.lua} for details). +% The purpose of this addition twofold. +% Firstly, \identifier{luaotfload} failed to provide a stable interface +% to internals in the past which resulted in an unmanageable situation +% of different packages abusing the raw access to font objects by means +% of the \luafunction{patch_font} callback. +% When the structure of the font object changed due to an update, all +% of these imploded and several packages had to be fixed while +% simultaneously providing fallbacks for earlier versions. +% Now the patching is done on the \identifier{luaotfload} side and can +% be adapted with future modifications to font objects without touching +% the packages that depend on it. +% Second, some the capabilities of the font loader and the names +% database are not immediately relevant in \identifier{luaotfload} +% itself but might nevertheless be of great value to package authors or +% end users. +% +% Note that the current interface is not yet set in stone and the +% development team is open to suggestions for improvements or +% additions. +% +% \subsection{Callback Functions} +% +% The \luafunction{patch_font} callback is inserted in the wrapper +% \identifier{luaotfload} provides for the font definition callback +% (see below, page \pageref{define-font}). +% At this place it allows manipulating the font object immediately after +% the font loader is done creating it. +% For a short demonstration of its usefulness, here is a snippet that +% writes an entire font object to the file \fileent{fontdump.lua}: +% +% \begin{quote} +% \begin{verbatim} +% \input luaotfload.sty +% \directlua{ +% local dumpfile = "fontdump.lua" +% local dump_font = function (tfmdata) +% local data = table.serialize(tfmdata) +% io.savedata(dumpfile, data) +% end +% +% luatexbase.add_to_callback( +% "luaotfload.patch_font", +% dump_font, +% "my_private_callbacks.dump_font" +% ) +% } +% \font\dumpme=name:Iwona +% \bye +% \end{verbatim} +% \end{quote} +% +% \emphasis{Beware}: this creates a Lua file of around 150,000 lines of +% code, taking up 3~\abbrev{mb} of disk space. +% By inspecting the output you can get a first impression of how a font +% is structured in \LUATEX’s memory, what elements it is composed of, +% and in what ways it can be rearranged. +% +% \subsubsection{Compatibility with Earlier Versions} +% +% As has been touched on in the preface to this section, the structure +% of the object as returned by the fontloader underwent rather drastic +% changes during different stages of its development, and not all +% packages that made use of font patching have kept up with every one +% of it. +% To ensure compatibility with these as well as older versions of +% some packages, \identifier{luaotfload} sets up copies of or references +% to data in the font table where it used to be located. +% For instance, important parameters like the requested point size, the +% units factor, and the font name have again been made accessible from +% the toplevel of the table even though they were migrated to different +% subtables in the meantime. +% +% \subsubsection{Patches} +% +% These are mostly concerned with establishing compatibility with +% \XETEX. +% +% \begin{itemize} +% \let\normalitem=\item +% \def\ouritem#1{% +% \normalitem{\luafunction{#1}}% +% \hfill\break +% } +% +% \ouritem {set_sscale_dimens} +% Calculate \texmacro{fontdimen}s 10 and 11 to emulate \XETEX. +% +% \ouritem {set_capheight} +% Calculates \texmacro{fontdimen} 8 like \XETEX. +% +% \ouritem {patch_cambria_domh} +% Correct some values of the font \emphasis{Cambria Math}. +% +% \end{itemize} +% +% \subsection{Package Author’s Interface} +% +% As \LUATEX release 1.0 is nearing, the demand for a reliable interface +% for package authors increases. +% +% \subsubsection{Font Properties} +% +% Below functions mostly concern querying the different components of a +% font like for instance the glyphs it contains, or what font features +% are defined for which scripts. +% +% \begin{itemize} +% \let\normalitem=\item +% \def\ouritem#1{% +% \normalitem{\luafunction{#1}}% +% \hfill\break +% } +% +% \ouritem {aux.font_has_glyph (id : int, index : int)} +% Predicate that returns true if the font \luafunction{id} +% has glyph \luafunction{index}. +% +% \ouritem {aux.slot_of_name(name : string)} +% Translates an Adobe Glyph name to the corresponding glyph +% slot. +% +% \ouritem {aux.name_of_slot(slot : int)} +% The inverse of \luafunction{slot_of_name}; note that this +% might be incomplete as multiple glyph names may map to the +% same codepoint, only one of which is returned by +% \luafunction{name_of_slot}. +% +% \ouritem {aux.provides_script(id : int, script : string)} +% Test if a font supports \luafunction{script}. +% +% \ouritem {aux.provides_language(id : int, script : string, language : string)} +% Test if a font defines \luafunction{language} for a given +% \luafunction{script}. +% +% \ouritem {aux.provides_feature(id : int, script : string, +% language : string, feature : string)} +% Test if a font defines \luafunction{feature} for +% \luafunction{language} for a given \luafunction{script}. +% +% \ouritem {aux.get_math_dimension(id : int, dimension : string)} +% Get the dimension \luafunction{dimension} of font \luafunction{id}. +% +% \ouritem {aux.sprint_math_dimension(id : int, dimension : string)} +% Same as \luafunction{get_math_dimension()}, but output the value +% in scaled points at the \TEX end. +% +% \end{itemize} +% +% \subsubsection{Database} +% +% \begin{itemize} +% \let\normalitem=\item +% \def\ouritem#1{% +% \normalitem{\luafunction{#1}}% +% \hfill\break +% } +% +% \ouritem {aux.scan_external_dir(dir : string)} +% Include fonts in directory \luafunction{dir} in font lookups without +% adding them to the database. +% +% \end{itemize} +% % \section{Troubleshooting} % % If you encounter problems with some fonts, please first update to the latest @@ -1215,6 +1386,22 @@ and the derived files % \font\test=file:MyFont.otf:script=latn;+liga; % \end{verbatim} % +% Another strategy that helps avoiding problems is to not access raw \LUATEX +% internals directly. +% Some of them, even though they are dangerous to access, have not been +% overridden or disabled. +% Thus, whenever possible prefer the functions in the +% \luafunction{aux} namespace over direct manipulation of font objects. +% For example, raw access to the \luafunction{font.fonts} table like: +% +% \begin{verbatim} +% local somefont = font.fonts[2] +% \end{verbatim} +% +% can render already defined fonts unusable. +% Instead, the function \luafunction{font.getfont()} should be used because +% it has been replaced by a safe variant. +% % \part{Implementation} % % \section{\fileent{luaotfload.lua}} @@ -1257,7 +1444,7 @@ config.luaotfload.color_callback = config.luaotfload.color_callback or "pre_l luaotfload.module = { name = "luaotfload", version = 2.2, - date = "2013/04/29", + date = "2013/05/18", description = "OpenType layout system.", author = "Elie Roux & Hans Hagen", copyright = "Elie Roux", @@ -1312,23 +1499,6 @@ if tex.luatexversion < luatex_version then end % \end{macrocode} -% Prepare directories: the cache function in Luatex-Fonts checks for a -% writable directory only once during startup. If there is no -% \fileent{texmf-var} at this time it will create a subdirectory -% \fileent{./luatex-cache} instead. -% Thus everything has to be laid out before we load the fontloader. -% -% \begin{macrocode} - -local cachepath = kpse.expand_var"$TEXMFVAR" -if not lfs.isdir(cachepath) then - dir.mkdirs(cachepath) - if not lfs.isdir(cachepath) then - error( "ERROR could not create directory %s", cachepath) - end -end - -% \end{macrocode} % \subsection{Module loading} % We load the files imported from \CONTEXT with this function. % It automatically prepends the prefix \fileent{luaotfload-} to its @@ -1592,8 +1762,8 @@ add_to_callback("hpack_filter", 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” +loadmodule"lib-dir.lua" --- required by luaofload-database.lua +loadmodule"override.lua" --- “luat-ovr” logs.set_loglevel(config.luaotfload.loglevel) @@ -1645,14 +1815,14 @@ local resolvefile = fonts.names.crude_file_lookup --local resolvefile = fonts.names.crude_file_lookup_verbose function request_resolvers.file(specification) - local name=resolvefile(specification.name) - local suffix=file.suffix(name) - if formats[suffix] then - specification.forced=suffix - specification.name=file.removesuffix(name) - else - specification.name=name - end + local name = resolvefile(specification.name) + local suffix = file.suffix(name) + if formats[suffix] then + specification.forced = suffix + specification.name = file.removesuffix(name) + else + specification.name = name + end end @@ -1682,6 +1852,7 @@ end % For this reason, we introduce an extra check with an early return. % % \begin{macrocode} + local type1_formats = { "tfm", "ofm", } request_resolvers.anon = function (specification) @@ -1693,6 +1864,20 @@ request_resolvers.anon = function (specification) return end end + --- under some weird circumstances absolute paths get + --- passed to the definer; we have to catch them + --- before the name: resolver misinterprets them. + name = specification.specification + local exists, _ = lfsisfile(name) + if exists then --- garbage; we do this because we are nice, + --- not because it is correct + logs.names_report("log", 1, "load", "file “%s” exists", name) + logs.names_report("log", 1, "load", + "... overriding borked anon: lookup with path: lookup") + specification.name = name + request_resolvers.path(specification) + return + end request_resolvers.name(specification) end @@ -1704,10 +1889,23 @@ end % system, otherwise we fall back to the \verb|file:| lookup. % % \begin{macrocode} + request_resolvers.path = function (specification) - local exists, _ = lfsisfile(specification.name) + local name = specification.name + local exists, _ = lfsisfile(name) if not exists then -- resort to file: lookup + logs.names_report("log", 1, "load", + "path lookup of “%s” unsuccessful, falling back to file:", + name) request_resolvers.file(specification) + else + local suffix = file.suffix(name) + if formats[suffix] then + specification.forced = suffix + specification.name = file.removesuffix(name) + else + specification.name = name + end end end @@ -1723,6 +1921,7 @@ create_callback("luaotfload.patch_font", "simple", dummy_function) % \end{macrocode} % \subsection{\CONTEXT override} +% \label{define-font} % We provide a simplified version of the original font definition % callback. % @@ -1764,11 +1963,11 @@ elseif font_definer == "patch" then end loadmodule"features.lua" --- contains what was “font-ltx” and “font-otc” +loadmodule"extralibs.lua" --- load additional Context libraries loadmodule"auxiliary.lua" --- additionaly high-level functionality (new) -- vim:tw=71:sw=4:ts=4:expandtab - % \end{macrocode} % % \iffalse @@ -1792,7 +1991,7 @@ loadmodule"auxiliary.lua" --- additionaly high-level functionality (new) \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luaotfload}% - [2013/05/10 v2.2 OpenType layout system] + [2013/05/18 v2.2 OpenType layout system] \RequirePackage{luatexbase} \fi \ifnum\luatexversion<76 |