summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/luatex/luaotfload
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-07-05 23:54:33 +0000
committerKarl Berry <karl@freefriends.org>2013-07-05 23:54:33 +0000
commit3a7fd63f467d90781d764fbded8b377343d25522 (patch)
treecdedc2a8efb1115d3b9a6743f70a77781600b452 /Master/texmf-dist/source/luatex/luaotfload
parent6ae06b1532def77d3f173bf682d34a85ad5bc687 (diff)
luaotfload (4jul13)
git-svn-id: svn://tug.org/texlive/trunk@31106 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/luatex/luaotfload')
-rw-r--r--Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx123
1 files changed, 92 insertions, 31 deletions
diff --git a/Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx b/Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx
index 4abe0631867..b8bee750ed7 100644
--- a/Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx
+++ b/Master/texmf-dist/source/luatex/luaotfload/luaotfload.dtx
@@ -40,7 +40,7 @@
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
-\Msg{* Package: luaotfload v2.2 OpenType layout system}
+\Msg{* Package: luaotfload v2.3 OpenType layout system}
\Msg{************************************************************************}
\keepsilent
@@ -111,7 +111,7 @@ and the derived files
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{luaotfload.drv}%
- [2013/05/23 v2.2d OpenType layout system]%
+ [2013/05/23 v2.3d OpenType layout system]%
\documentclass{ltxdoc}
\usepackage{metalogo,multicol,mdwlist,fancyvrb,xspace}
\usepackage[x11names]{xcolor}
@@ -231,7 +231,7 @@ and the derived files
% \GetFileInfo{luaotfload.drv}
%
% \title{The \identifier{luaotfload} package}
-% \date{2013/05/23 v2.2d}
+% \date{2013/05/23 v2.3d}
% \author{Elie Roux · Khaled Hosny · Philipp Gesang\\
% Home: \url{https://github.com/lualatex/luaotfload}\\
% Support: \email{lualatex-dev@tug.org}}
@@ -400,7 +400,23 @@ and the derived files
% \begin{quote}
% |\font\fontname=|\meta{prefix}|:|\meta{fontname}\dots
% \end{quote}
-% where \meta{prefix} is either \verb|file:| or \verb|name:|.
+% where \meta{prefix} is either \verb|file:| or \verb|name:|.\footnote{%
+% The development version also knows two further prefixes,
+% \verb|kpse:| and \verb|my:|.
+% A \verb|kpse| lookup is restricted to files that can be found by
+% \identifier{kpathsea} and
+% will not attempt to locate system fonts.
+% This behavior can be of value when an extra degree of encapsulation is
+% needed, for instance when supplying a customized tex distribution.
+%
+% The \verb|my| lookup takes this a step further: it lets you define
+% a custom resolver function and hook it into the \luafunction{resolve_font}
+% callback.
+% This ensures full control over how a file is located.
+% For a working example see the
+% \href{https://bitbucket.org/phg/lua-la-tex-tests/src/5f6a535d/pln-lookup-callback-1.tex}
+% {test repo}.
+% }
% It determines whether the font loader should interpret the request as
% a \emphasis{file name} or
% \emphasis{font name}, respectively,
@@ -410,7 +426,26 @@ and the derived files
% “GFS Bodoni Rg”, and
% “PT Serif Caption”
% -- they are the human readable identifiers
-% usually listed in drop-down menus and the like.
+% usually listed in drop-down menus and the like.\footnote{%
+% Font names may appear like a great choice at first because they
+% offer seemingly more intuitive identifiers in comparison to arguably
+% cryptic file names:
+% “PT Sans Bold” is a lot more descriptive than \fileent{PTS75F.ttf}.
+% On the other hand, font names are quite arbitrary and there is no
+% universal method to determine their meaning.
+% While \identifier{luaotfload} provides fairly sophisticated heuristic
+% to figure out a matching font style, weight, and optical size, it
+% cannot be relied upon to work satisfactorily for all font files.
+% For an in-depth analysis of the situation and how broken font names
+% are, please refer to
+% \href{http://www.ntg.nl/pipermail/ntg-context/2013/073889.html}
+% {this post}
+% by Hans Hagen, the author of the font loader.
+% If in doubt, use filenames.
+% \fileent{luaotfload-tool} can perform the matching for you with the
+% option \verb|--find=<name>|, and you can use the file name it returns
+% in your font definition.
+% }
% 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.
@@ -1159,9 +1194,6 @@ and the derived files
% \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
@@ -1428,8 +1460,8 @@ and the derived files
%<*lua>
% \fi
% \begin{macrocode}
-luaotfload = luaotfload or {}
-local luaotfload = luaotfload
+luaotfload = luaotfload or {}
+local luaotfload = luaotfload
config = config or { }
config.luaotfload = config.luaotfload or { }
@@ -1437,14 +1469,17 @@ config.luaotfload = config.luaotfload or { }
config.luaotfload.resolver = config.luaotfload.resolver or "cached"
config.luaotfload.definer = config.luaotfload.definer or "patch"
config.luaotfload.compatibility = config.luaotfload.compatibility or false
-config.luaotfload.loglevel = config.luaotfload.loglevel or 1
+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
+config.luaotfload.prioritize = config.luaotfload.prioritize or "sys"
+config.luaotfload.names_dir = config.luaotfload.names_dir or "names"
+config.luaotfload.cache_dir = config.luaotfload.cache_dir or "fonts"
+config.luaotfload.names_file = config.luaotfload.names_file or "luaotfload-names.lua"
luaotfload.module = {
name = "luaotfload",
- version = 2.2,
- date = "2013/05/23",
+ version = 2.3,
+ date = "2013/06/02",
description = "OpenType layout system.",
author = "Elie Roux & Hans Hagen",
copyright = "Elie Roux",
@@ -1743,16 +1778,6 @@ pop_namespaces(our_environment, false)-- true)
log("fontloader loaded in %0.3f seconds", os.gettimeofday()-starttime)
% \end{macrocode}
-% Restore original \luafunction{kpse.expand_path} function.
-%
-% \begin{macrocode}
-
-if normal_expand_path ~= nil then
- kpse.expand_path = normal_expand_path
- phantom_kpse = nil
-end
-
-% \end{macrocode}
% \subsection{Callbacks}
% After the fontloader is ready we can restore the callback trap from
% \identifier{luatexbase}.
@@ -1779,7 +1804,6 @@ 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”
logs.set_loglevel(config.luaotfload.loglevel)
@@ -1807,7 +1831,7 @@ loadmodule"colors.lua" --- “font-clr”
% \begin{macrocode}
local request_resolvers = fonts.definers.resolvers
-local formats = fonts.formats
+local formats = fonts.formats -- nice table; does lowercasing ...
formats.ofm = "type1"
% \end{macrocode}
@@ -1831,7 +1855,7 @@ formats.ofm = "type1"
local resolvefile = fonts.names.crude_file_lookup
--local resolvefile = fonts.names.crude_file_lookup_verbose
-function request_resolvers.file(specification)
+request_resolvers.file = function (specification)
local name = resolvefile(specification.name)
local suffix = file.suffix(name)
if formats[suffix] then
@@ -1842,7 +1866,6 @@ function request_resolvers.file(specification)
end
end
-
% \end{macrocode}
% We classify as \verb|anon:| those requests that have neither a
% prefix nor brackets. According to Khaled\footnote{%
@@ -1927,6 +1950,44 @@ request_resolvers.path = function (specification)
end
% \end{macrocode}
+% {\bfseries EXPERIMENTAL}:
+% \identifier{kpse}-only resolver, for those who can do without system
+% fonts.
+%
+% \begin{macrocode}
+
+request_resolvers.kpse = function (specification)
+ local name = specification.name
+ local suffix = file.suffix(name)
+ if suffix and formats[suffix] then
+ name = file.removesuffix(name)
+ if resolvers.findfile(name, suffix) then
+ specification.forced = suffix
+ specification.name = name
+ return
+ end
+ end
+ for t, format in next, formats do --- brute force
+ if kpse.find_file (name, format) then
+ specification.forced = t
+ specification.name = name
+ return
+ end
+ end
+end
+
+% \end{macrocode}
+% Also {\bfseries EXPERIMENTAL}:
+% custom file resolvers via callback.
+%
+% \begin{macrocode}
+create_callback("luaotfload.resolve_font", "simple", dummy_function)
+
+request_resolvers.my = function (specification)
+ call_callback("luaotfload.resolve_font", specification)
+end
+
+% \end{macrocode}
% 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
@@ -1953,12 +2014,12 @@ local patch_defined_font = function (specification, size, id)
--- 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)
+ call_callback("luaotfload.patch_font", tfmdata, specification)
end
return tfmdata
end
-reset_callback("define_font")
+reset_callback "define_font"
% \end{macrocode}
% Finally we register the callbacks.
@@ -2008,7 +2069,7 @@ loadmodule"auxiliary.lua" --- additionaly high-level functionality (new)
\else
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{luaotfload}%
- [2013/05/23 v2.2d OpenType layout system]
+ [2013/05/23 v2.3d OpenType layout system]
\RequirePackage{luatexbase}
\fi
\ifnum\luatexversion<76