From d16a93579dfec03a0dab4281b45f63d877fc4c88 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 26 Apr 2013 22:33:37 +0200 Subject: install the new file: lookup in luaotfload.lua --- luaotfload.dtx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'luaotfload.dtx') diff --git a/luaotfload.dtx b/luaotfload.dtx index 18e01d8..8b3616a 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1328,7 +1328,7 @@ add_to_callback("find_vf_file", loadmodule"lib-dir.lua" --- required by luaofload-database.lua loadmodule"override.lua" --- “luat-ovr” -logs.set_loglevel(0) +logs.set_loglevel(config.luaotfload.loglevel or 2) % \end{macrocode} % \CONTEXT does not support ofm, these lines were added in order to make it @@ -1365,8 +1365,19 @@ loadmodule"colors.lua" --- “font-clr” % % \begin{macrocode} +--- below lines already (2013-04-25) lead to warnings by +--- the font loader +--fonts.definers.resolvers.file = function (specification) +-- specification.name = fonts.names.resolve('', '', specification) +--end + fonts.definers.resolvers.file = function (specification) - specification.name = fonts.names.resolve('', '', specification) + --inspect(specification) + if specification.lookup == "file" then + local found = fonts.names.crude_file_lookup(specification.name) + --local found = fonts.names.crude_file_lookup_verbose(specification.name) + specification.name = found[1] + end end % \end{macrocode} -- cgit v1.2.3 From 996ba6a5014fc546c8e8c769a259b9adaf2090dc Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 28 Apr 2013 13:34:58 +0200 Subject: add prelimiary anon: and path: resolvers --- luaotfload.dtx | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'luaotfload.dtx') diff --git a/luaotfload.dtx b/luaotfload.dtx index 8b3616a..ead0773 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1371,8 +1371,10 @@ loadmodule"colors.lua" --- “font-clr” -- specification.name = fonts.names.resolve('', '', specification) --end -fonts.definers.resolvers.file = function (specification) - --inspect(specification) +local resolvers = fonts.definers.resolvers +local formats = fonts.formats + +resolvers.file = function (specification) if specification.lookup == "file" then local found = fonts.names.crude_file_lookup(specification.name) --local found = fonts.names.crude_file_lookup_verbose(specification.name) @@ -1380,6 +1382,30 @@ fonts.definers.resolvers.file = function (specification) end end +--- TODO rewrite this according to the syntax spec +resolvers.anon = function (specification) + local resolved, subfontno = fonts.names.resolve(nil, nil, specification) + if resolved then --- we follow fonts-def to some extent + specification.resolved = resolved + specification.sub = subfontno + local suffix = file.suffix(resolved) + if formats[suffix] then + specification.forced = suffix + specification.name = file.removesuffix(resolved) + else + specification.name = resolved + end + else + resolvers.file(specification) + end +end + +--- TODO rewrite this according to the syntax spec +resolvers.path = function (specification) + local found = fonts.names.crude_file_lookup(specification.name) + specification.name = found[1] +end + % \end{macrocode} % We create a callback for patching fonts on the fly, to be used by other % packages. -- cgit v1.2.3 From 74ebd14b94432c9de82614627454dfa3bfcb9de0 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 28 Apr 2013 16:39:26 +0200 Subject: add lookups ``file:``, ``path:``, ``name:``, and ``anon:`` --- luaotfload.dtx | 86 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 29 deletions(-) (limited to 'luaotfload.dtx') diff --git a/luaotfload.dtx b/luaotfload.dtx index ead0773..0584f07 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1014,11 +1014,12 @@ 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 stringsub = string.sub -local stringmatch = string.match local stringformat = string.format -local find_file = kpse.find_file +local stringmatch = string.match +local stringsub = string.sub local add_to_callback, create_callback = luatexbase.add_to_callback, luatexbase.create_callback @@ -1363,47 +1364,74 @@ loadmodule"colors.lua" --- “font-clr” % is understood. % Until then it is considered a kludge, like the hack below. % +% 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}). +% % \begin{macrocode} ---- below lines already (2013-04-25) lead to warnings by ---- the font loader ---fonts.definers.resolvers.file = function (specification) --- specification.name = fonts.names.resolve('', '', specification) ---end - local resolvers = fonts.definers.resolvers local formats = fonts.formats +% \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} resolvers.file = function (specification) + --- how would we go about allowing subfonts (ttc)? if specification.lookup == "file" then local found = fonts.names.crude_file_lookup(specification.name) - --local found = fonts.names.crude_file_lookup_verbose(specification.name) specification.name = found[1] end end --- TODO rewrite this according to the syntax spec -resolvers.anon = function (specification) - local resolved, subfontno = fonts.names.resolve(nil, nil, specification) - if resolved then --- we follow fonts-def to some extent - specification.resolved = resolved - specification.sub = subfontno - local suffix = file.suffix(resolved) - if formats[suffix] then - specification.forced = suffix - specification.name = file.removesuffix(resolved) - else - specification.name = resolved - end - else - 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{% +% \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} ---- TODO rewrite this according to the syntax spec +resolvers.anon = resolvers.name + +% \end{macrocode} +% 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} resolvers.path = function (specification) - local found = fonts.names.crude_file_lookup(specification.name) - specification.name = found[1] + local exists, _ = lfsisfile(specification.name) + if not exists then -- resort to file: lookup + resolvers.file(specification) + end end % \end{macrocode} -- cgit v1.2.3 From 189085f9a7212320183d5fed0c4aa31df1602d5f Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 28 Apr 2013 19:08:11 +0200 Subject: catch tfm/ofm before db update; remove ``kpse.lookup()`` as criterion for resolved font --- luaotfload.dtx | 51 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-) (limited to 'luaotfload.dtx') diff --git a/luaotfload.dtx b/luaotfload.dtx index 0584f07..722a8d2 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1378,8 +1378,9 @@ loadmodule"colors.lua" --- “font-clr” % % \begin{macrocode} -local resolvers = fonts.definers.resolvers -local formats = fonts.formats +local request_resolvers = fonts.definers.resolvers +local formats = fonts.formats +formats.ofm = "type1" % \end{macrocode} % \identifier{luaotfload} promises easy access to system fonts. @@ -1398,15 +1399,13 @@ local formats = fonts.formats % most cases when looking up font files, only when generating the database. % % \begin{macrocode} -resolvers.file = function (specification) - --- how would we go about allowing subfonts (ttc)? - if specification.lookup == "file" then - local found = fonts.names.crude_file_lookup(specification.name) - specification.name = found[1] - end +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 ---- TODO rewrite this according to the syntax spec % \end{macrocode} % We classify as \verb|anon:| those requests that have neither a % prefix nor brackets. According to Khaled\footnote{% @@ -1417,7 +1416,35 @@ end % % \begin{macrocode} -resolvers.anon = resolvers.name +--request_resolvers.anon = request_resolvers.name + +% \end{macrocode} +% 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} +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} % Prior to version 2.2, \identifier{luaotfload} did not distinguish @@ -1427,10 +1454,10 @@ resolvers.anon = resolvers.name % system, otherwise we fall back to the \verb|file:| lookup. % % \begin{macrocode} -resolvers.path = function (specification) +request_resolvers.path = function (specification) local exists, _ = lfsisfile(specification.name) if not exists then -- resort to file: lookup - resolvers.file(specification) + request_resolvers.file(specification) end end -- cgit v1.2.3 From 09765c22460ee4aa3e2fbe5cf1af54aa3106e6a5 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 29 Apr 2013 10:55:49 +0200 Subject: [doc] add font request syntax description MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For convenience it’s a notational bastard of BNF and ISO EBNF. I couldn’t find a package for typesetting the latter, and with my limited understanding of LaTeX I couldn’t have written one within an acceptable time. Anyways, I don’t think anybody will be confused by this. --- luaotfload.dtx | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 2 deletions(-) (limited to 'luaotfload.dtx') diff --git a/luaotfload.dtx b/luaotfload.dtx index 722a8d2..957dea1 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -160,6 +160,8 @@ and the derived files \renewcommand\partname{Part}%% gets rid of the stupid “file” heading +\usepackage{syntax}%% bnf for font request syntax + \VerbatimFootnotes \begin{document} \DocInput{luaotfload.dtx}% @@ -256,8 +258,81 @@ and the derived files % % \noindent % The curly brackets are optional and escape the spaces in the enclosed -% font name (alternatively, double quotes serve the same purpose). -% The individual parts of the syntax are: +% 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} +% ::= `\\font', {\sc csname}, `=', , [ ] ; +% +% ::= `at', {\sc dimension} ; +% +% ::= `"', `"' +% \alt `{', `}' +% \alt ; +% +% ::= , [`:', ] +% \alt `[', `]', [ [`:'], ] ; +% +% ::= , [ ], \{ \} +% \alt , \{ \} ; +% +% ::= `file:', +% \alt `name:', ; +% +% ::= \{ \} ; +% +% ::= \{ \} ; +% +% ::= {\sc tfmname} | ; +% +% ::= \{ {\sc all_characters} - `]' \} ; +% +% ::= `/', (`i' | `b' | `bi' | `ib') ; +% +% ::= `(', \{ {\sc digit} \}, `)' ; +% +% ::= , \{ `;', \} ; +% +% ::= {\sc feature_id}, `=', {\sc feature_value} +% \alt , {\sc feature_id} ; +% +% ::= `+' | `-' ; +% +% ::= {\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} +% +% %(* braces around the specification will preserve whitespace *) +% %(* file lookups do not allow paths *) +% %(* others like `aat', `icu', and `gr' are silently ignored *) % % \paragraph{Prefix} % -- cgit v1.2.3 From be7d5713a125033d686d97a38910cb5af62f9093 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 29 Apr 2013 12:51:52 +0200 Subject: [doc] describe the various font requests --- luaotfload.dtx | 184 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 145 insertions(+), 39 deletions(-) (limited to 'luaotfload.dtx') diff --git a/luaotfload.dtx b/luaotfload.dtx index 957dea1..abc737c 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -130,6 +130,8 @@ and the derived files \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} @@ -246,15 +248,15 @@ and the derived files % % \section{Loading Fonts} % -% \identifier{luaotfload} supports an extended font loading syntax: +% \identifier{luaotfload} supports an extended font request syntax: % -% \begin{center} +% \begin{quote} % |\font\foo={|% % \meta{prefix}|:|% % \meta{font name}|:|% % \meta{font features}|}|% % \meta{\TEX font features} -% \end{center} +% \end{quote} % % \noindent % The curly brackets are optional and escape the spaces in the enclosed @@ -330,45 +332,93 @@ and the derived files % \label{font-syntax} % \end{figure} % -% %(* braces around the specification will preserve whitespace *) -% %(* file lookups do not allow paths *) -% %(* others like `aat', `icu', and `gr' are silently ignored *) -% -% \paragraph{Prefix} -% -% The \meta{prefix} is either |file:| or |name:|. -% It determines whether the font loader should interpret the request as a -% file name or font name, respectively, which again influences how it -% will attempt to locate the font. -% The prefix can be omitted, in which case |name:| is assumed. -% -%% \iffalse%% how am i supposed to friggin comment stuff in a dtx??? -%% TODO -%% it would appear that the next paragraph is incorrect; I get -%% name: lookups regardless unless the font file is actually -%% in CWD -%% \fi -%% For compatibility with \XETEX, surrounding the \meta{font name} with -%% square brackets is synonymous to using the |file:| prefix. +% \subsection{Prefix -- the \identifier{luaotfload}\space 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 +% Please refer to section~\ref{sec:fontdb} below for instructions on how to % create the database. % -% \paragraph{Font name} +% 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 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. % -% The \meta{font name} can be either a font filename or actual font -% name based on the \meta{prefix} as mentioned above. +% \begin{quote} +% |\font\fontname=[|\meta{path to file}|]| +% \end{quote} % -% A filename request may optionally include the absolute path to the font file, -% allowing for fonts outside the standard locations to be loaded as well. -% If no path is specified, then \identifier{kpathsea} is used to locate the -% font (which will typically be in the \fileent{texmf} tree or the -% current directory). +% \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. % -% \subparagraph{Examples for loading by file name} +% \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 +% 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. +% +% \subsection{Examples} +% +% \subsubsection{Loading by File Name} % % For example, conventional \abbrev{type1} font can be loaded with a \verb|file:| % request like so: @@ -380,8 +430,11 @@ and the derived files % \end{quote} % % The \OpenType version of Janusz Nowacki’s font \emphasis{Antykwa -% Półtawskiego} (in \TEX Live) in its condensed variant can be loaded as -% follows: +% Półtawskiego}\footnote{% +% \url{http://jmn.pl/antykwa-poltawskiego/}, also available in +% in \TEX Live. +% } +% in its condensed variant can be loaded as follows: % % \begin{quote} % \begin{verbatim} @@ -399,7 +452,7 @@ and the derived files % \end{verbatim} % \end{quote} % -% \subparagraph{Examples for loading by font name} +% \subsubsection{Loading by Font Name} % % The \verb|name:| lookup does not depend on cryptic filenames: % @@ -435,9 +488,62 @@ and the derived files % \end{verbatim} % \end{quote} % -% \paragraph{Font features} +% \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} +% +% \emphasis{Font features} are the second to last component in the +% general scheme for font requests: +% +% \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}. % -% \meta{font features} is semicolon-separated list of feature +% The element \meta{font features} is a semicolon-separated list of feature % tags\footnote{% % Cf. \url{http://www.microsoft.com/typography/otspec/featurelist.htm}. % } @@ -1078,7 +1184,7 @@ luaotfload.prefer_merge = config.luaotfload.prefer_merge or true luaotfload.module = { name = "luaotfload", version = 2.2, - date = "2013/04/15", + date = "2013/04/29", description = "OpenType layout system.", author = "Elie Roux & Hans Hagen", copyright = "Elie Roux", -- cgit v1.2.3 From e79f34d859d48be485589f19fc6905afa5872a53 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 29 Apr 2013 14:52:53 +0200 Subject: only cache ``name:`` lookups --- luaotfload.dtx | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'luaotfload.dtx') diff --git a/luaotfload.dtx b/luaotfload.dtx index abc737c..6392c64 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -540,8 +540,8 @@ and the derived files % \end{quote} % % \noindent -% If style modifiers are present (\XETEX style), they must precede \meta{font -% features}. +% 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{% @@ -1532,19 +1532,6 @@ loadmodule"database.lua" --- “font-nms” loadmodule"colors.lua" --- “font-clr” % \end{macrocode} -% This hack makes fonts called with file method found by fonts.names.resolve -% instead of just trying to find them with \identifier{kpse}. -% It is necessary in cases when font files are not reachable by -% \identifier{kpse} but present in the database, a quite common case -% under Linux. -% -% As of 2013-04-24 we have a workaround in the resolver that handles -% \verb|file:| lookups diverted this way. -% It requires some overhead due to additional extra data saved in the -% names database, and might vanish entirely once the font request syntax -% is understood. -% Until then it is considered a kludge, like the hack below. -% % 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 @@ -1715,7 +1702,6 @@ local patch_defined_font = function (specification, size, id) if type(tfmdata) == "table" then call_callback("luaotfload.patch_font", tfmdata) end - -- inspect(table.keys(tfmdata)) return tfmdata end -- cgit v1.2.3 From dae29b04d0bb7e21bb4d3d19b9781b59e44ec5cb Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 29 Apr 2013 16:26:45 +0200 Subject: use ``fullname`` in status entries This suppresses redundand database updates in the case where a font is found in multiple directories with different timestamps. Also removed references to ``fontdbutil``. --- luaotfload.dtx | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'luaotfload.dtx') diff --git a/luaotfload.dtx b/luaotfload.dtx index 6392c64..9c5d600 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -768,8 +768,8 @@ and the derived files % This is particularly noticeable if it occurs during a typesetting run. % In any case, subsequent updates to the database will be quite fast. % -% \subsection[fontdbutil / mkluatexfontdb.lua]% -% {\fileent{fontdbutil} / +% \subsection[luaotfload-tool / mkluatexfontdb.lua]% +% {\fileent{luaotfload-tool} / % \fileent{mkluatexfontdb.lua}\footnote{% % The script may be named just \fileent{mkluatexfontdb} in your % distribution. @@ -778,7 +778,7 @@ and the derived files % 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{fontdbutil} that offers an interface to the database +% \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 @@ -793,15 +793,15 @@ and the derived files % \emphasis{Note}: % On \abbrev{MS} \identifier{Windows} systems, the script can be run % either by calling the wrapper application -% \fileent{fontdbutil.exe} or as -% \verb|texlua.exe fontdbutil|. +% \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. % % \begin{quote} % \begin{verbatim} -% fontdbutil --update +% luaotfload-tool --update % \end{verbatim} % \end{quote} % @@ -810,11 +810,11 @@ and the derived files % % \begin{quote} % \begin{verbatim} -% fontdbutil --update --force +% luaotfload-tool --update --force % \end{verbatim} % \end{quote} % -% For sake of backwards compatibility, \fileent{fontdbutil} may be +% 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 @@ -862,7 +862,7 @@ and the derived files % % \subsection{Querying from Outside} % -% \fileent{fontdbutil} also provides rudimentary means of +% \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 @@ -871,7 +871,7 @@ and the derived files % % \begin{quote} % \begin{verbatim} -% fontdbutil --find="Iwona Regular" +% luaotfload-tool --find="Iwona Regular" % \end{verbatim} % \end{quote} % @@ -888,7 +888,7 @@ and the derived files % % \begin{quote} % \begin{verbatim} -% fontdbutil -F --find="Iwona Bright" +% luaotfload-tool -F --find="Iwona Bright" % \end{verbatim} % \end{quote} % @@ -899,7 +899,7 @@ and the derived files % using the \verb|-i| option (\verb|--info|). % \begin{quote} % \begin{verbatim} -% fontdbutil -F --find="Iwona Light Italic" +% luaotfload-tool -F --find="Iwona Light Italic" % \end{verbatim} % \end{quote} % \noindent @@ -908,7 +908,7 @@ and the derived files % In \TEX Live: \fileent{texmf-dist/doc/luatex/base/luatexref-t.pdf}. % } % -% \verb|fontdbutil --help| will list the available command line +% \verb|luaotfload-tool --help| will list the available command line % switches, including some not discussed in detail here. % % \subsection{Blacklisting Fonts} @@ -917,7 +917,7 @@ and the derived files % 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|fontdbutil -v| to increase verbosity. +% 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}. @@ -1126,7 +1126,7 @@ and the derived files % verbosity levels and redirecting log output to \fileent{stdout}: % % \begin{verbatim} -% fontdbutil -fuvvv --log=stdout +% luaotfload-tool -fuvvv --log=stdout % \end{verbatim} % % If this fails, the font last printed to the terminal is likely to be -- cgit v1.2.3 From bcf92b745cc583119367810b4a97d4fc91e63fdb Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 29 Apr 2013 16:31:19 +0200 Subject: install uncached name: resolver as default --- luaotfload.dtx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'luaotfload.dtx') diff --git a/luaotfload.dtx b/luaotfload.dtx index 9c5d600..2c9fa77 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1179,7 +1179,8 @@ local luaotfload = luaotfload config = config or { } config.luaotfload = config.luaotfload or { } -luaotfload.prefer_merge = config.luaotfload.prefer_merge or true +config.luaotfload.resolver = config.luaotfload.resolver or "normal" +--luaotfload.prefer_merge = config.luaotfload.prefer_merge or true luaotfload.module = { name = "luaotfload", -- cgit v1.2.3 From 572c0e2de196d2d9551cd205b7f0c69800fb7516 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 29 Apr 2013 22:57:12 +0200 Subject: update NEWS --- luaotfload.dtx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'luaotfload.dtx') diff --git a/luaotfload.dtx b/luaotfload.dtx index 2c9fa77..5b454bc 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -332,7 +332,7 @@ and the derived files % \label{font-syntax} % \end{figure} % -% \subsection{Prefix -- the \identifier{luaotfload}\space Way} +% \subsection{Prefix -- the \identifier{luaotfload}{ }Way} % % In \identifier{luaotfload}, the canonical syntax for font requests % requires a \emphasis{prefix}: -- cgit v1.2.3 From 3e100857c96b4796d009fe8b426e79c54c4b8941 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 29 Apr 2013 23:29:12 +0200 Subject: [doc] fix typos/indenting --- luaotfload.dtx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'luaotfload.dtx') diff --git a/luaotfload.dtx b/luaotfload.dtx index 5b454bc..e18c205 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -361,7 +361,7 @@ and the derived files % \verb|(|, % \verb|:|, and % \verb|/|. -% As obvious from the last exception, the \verb|file:| lookup will +% 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 @@ -470,6 +470,7 @@ and the derived files % \end{verbatim} % \end{quote} % +% \noindent % Which fits nicely with the whole set: % % \begin{quote} -- cgit v1.2.3 From 2d696088aece49853d17f4b2ab3bab0e242071e8 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 30 Apr 2013 19:20:44 +0200 Subject: [doc] fix incorrect statements --- luaotfload.dtx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'luaotfload.dtx') diff --git a/luaotfload.dtx b/luaotfload.dtx index e18c205..36c2a68 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -835,7 +835,7 @@ and the derived files % 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 limited to the included +% If it is non-empty, then search will be extended to the included % directories. % % \begin{table}[t] @@ -900,7 +900,7 @@ and the derived files % using the \verb|-i| option (\verb|--info|). % \begin{quote} % \begin{verbatim} -% luaotfload-tool -F --find="Iwona Light Italic" +% luaotfload-tool -i --find="Iwona Light Italic" % \end{verbatim} % \end{quote} % \noindent -- cgit v1.2.3 From 021dadf3ab211cf76a17b6d0e3e169eafe355e1b Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 30 Apr 2013 19:45:23 +0200 Subject: remove redundant dead code --- luaotfload.dtx | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'luaotfload.dtx') diff --git a/luaotfload.dtx b/luaotfload.dtx index 36c2a68..eb77d46 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1733,38 +1733,6 @@ elseif luaotfload.font_definer == "patch" then 1) end ---[[todo-- ---- The manual promises coercion of the file: lookup if ---- the asked name is enclosed in brackets. ---- A couple things make me doubt that this is the case: ---- ---- 1) there doesn’t appear to be code for these cases ---- 2) the brackets remain part of the file name ---- 3) we still get calls to names.resolve which ---- ignores the “lookup” field of the spec it gets ---- ---- For this reason here is some code that a) coerces ---- file: lookups in these cases and b) strips the brackets ---- from the file name. As we *still* get name: lookups even ---- though this code is active I’ll just leave it here ---- for reference, ineffective as it is. -do - local getspecification, makespecification = - fonts.definers.getspecification, fonts.definers.makespecification - - local analyze = function (specification, size) - local lookup, name, sub, method, detail = getspecification(specification or "") - local filename = stringmatch(name, "^%[(.*)%]$") - if filename then - lookup = "file" --> coerce file: - name = filename --> remove brackets - end - return makespecification(specification, lookup, name, sub, method, detail, size) - end - fonts.definers.analyze = analyze -end ---]]-- - loadmodule"features.lua" --- contains what was “font-ltx” and “font-otc” -- vim:tw=71:sw=4:ts=4:expandtab -- cgit v1.2.3 From be4a4a4df60e475d9d8362cdf31db09969c95d29 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 30 Apr 2013 20:55:37 +0200 Subject: use precalculated scale-factor first step towards a solution for this mystery: https://github.com/lualatex/luaotfload/issues/20 also: config option for the callback --- luaotfload.dtx | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'luaotfload.dtx') diff --git a/luaotfload.dtx b/luaotfload.dtx index eb77d46..77948ac 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1181,6 +1181,7 @@ local luaotfload = luaotfload config = config or { } config.luaotfload = config.luaotfload or { } config.luaotfload.resolver = config.luaotfload.resolver or "normal" +config.luaotfload.definer = config.luaotfload.definer or "patch" --luaotfload.prefer_merge = config.luaotfload.prefer_merge or true luaotfload.module = { @@ -1655,6 +1656,13 @@ create_callback("luaotfload.patch_font", "simple", dummy_function) % How those work remains to be figured out. % % \begin{macrocode} +--- font-con.lua: +--- · constructors.assignmathparameters(target, original) +--- · | .*Percent.* -> value +--- | _ -> value * factor +--- ... where factor = target.parameters.factor +--- · writes new params to target + local define_font_wrapper = function (...) --- we use “tfmdata” (not “fontdata”) for consistency with the --- font loader @@ -1664,17 +1672,13 @@ local define_font_wrapper = function (...) local mathdata = metadata.math --- do all fonts have this field? if mathdata then local mathconstants = { } --- why new hash, not modify in place? - local units_per_em = metadata.units_per_em - local size = tfmdata.size + local factor = tfmdata.parameters.factor for k,v in next, mathdata do - --- afaics this is alread taken care of by - --- definers.read if stringfind(k, "Percent") then -- keep percent values as is - --print(k,v) mathconstants[k] = v else - mathconstants[k] = v / units_per_em * size + mathconstants[k] = v * factor end end --- for \overwithdelims @@ -1716,17 +1720,19 @@ reset_callback("define_font") % % \begin{macrocode} -if luaotfload.font_definer == "old" then +local font_definer = config.luaotfload.definer + +if definer == "old" then add_to_callback("define_font", define_font_wrapper, "luaotfload.define_font", 1) -elseif luaotfload.font_definer == "generic" then +elseif font_definer == "generic" then add_to_callback("define_font", fonts.definers.read, "luaotfload.define_font", 1) -elseif luaotfload.font_definer == "patch" then +elseif font_definer == "patch" then add_to_callback("define_font", patch_defined_font, "luaotfload.define_font", -- cgit v1.2.3 From 700de901361c164652762b0c31b730792ace18d0 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 30 Apr 2013 21:20:58 +0200 Subject: remove old fond definition callback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit everything it did is already been done by ``constructors.assignmathparameters()`` in ``font-con.lua``, so it is save to remove the old code without replacement. There is one subtle difference, however: Context scales the value of ``FractionDelimiterDisplayStyleSize`` by a factor of 2.40, whereas the old luaotfload used 2.39. I’d say whoever takes offense because of this difference please debate Hans for the correct value. kthxbye --- luaotfload.dtx | 58 +--------------------------------------------------------- 1 file changed, 1 insertion(+), 57 deletions(-) (limited to 'luaotfload.dtx') diff --git a/luaotfload.dtx b/luaotfload.dtx index 77948ac..8f7c8a1 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1642,57 +1642,6 @@ end create_callback("luaotfload.patch_font", "simple", dummy_function) -% \end{macrocode} -% This is a wrapper for the imported font loader. -% As of 2013, everything it does appear to be redundand, so we won’t use -% it unless somebody points out a cogent reason. -% Nevertheless, it has been adapted to work with the current structure of -% font data objects and will stay here for reference / until breakage is -% reported. -% \emphasis{TODO} -% This one also enables patching fonts. -% The current fontloader apparently comes with a dedicated mechanism for -% that already: enhancers. -% How those work remains to be figured out. -% -% \begin{macrocode} ---- font-con.lua: ---- · constructors.assignmathparameters(target, original) ---- · | .*Percent.* -> value ---- | _ -> value * factor ---- ... where factor = target.parameters.factor ---- · writes new params to target - -local define_font_wrapper = function (...) - --- we use “tfmdata” (not “fontdata”) for consistency with the - --- font loader - local tfmdata = fonts.definers.read(...) - if type(tfmdata) == "table" and tfmdata.shared then - local metadata = tfmdata.shared.rawdata.metadata - local mathdata = metadata.math --- do all fonts have this field? - if mathdata then - local mathconstants = { } --- why new hash, not modify in place? - local factor = tfmdata.parameters.factor - for k,v in next, mathdata do - if stringfind(k, "Percent") then - -- keep percent values as is - mathconstants[k] = v - else - mathconstants[k] = v * factor - end - end - --- for \overwithdelims - --- done by definers.read as well - mathconstants.FractionDelimiterSize = 1.01 * size - --- fontloader has 2.4 × size - mathconstants.FractionDelimiterDisplayStyleSize = 2.39 * size - tfmdata.MathConstants = mathconstants - end - call_callback("luaotfload.patch_font", tfmdata) - end - return tfmdata -end - % \end{macrocode} % \subsection{\CONTEXT override} % We provide a simplified version of the original font definition @@ -1722,12 +1671,7 @@ reset_callback("define_font") local font_definer = config.luaotfload.definer -if definer == "old" then - add_to_callback("define_font", - define_font_wrapper, - "luaotfload.define_font", - 1) -elseif font_definer == "generic" then +if font_definer == "generic" then add_to_callback("define_font", fonts.definers.read, "luaotfload.define_font", -- cgit v1.2.3 From 4e14b2da1e3675f3877ada80cd77fa6792127fb9 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 1 May 2013 11:24:37 +0200 Subject: [doc] make examples for XeTeX notation uppercase --- luaotfload.dtx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'luaotfload.dtx') diff --git a/luaotfload.dtx b/luaotfload.dtx index 8f7c8a1..dd43990 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -296,7 +296,7 @@ and the derived files % % ::= \{ {\sc all_characters} - `]' \} ; % -% ::= `/', (`i' | `b' | `bi' | `ib') ; +% ::= `/', (`I' | `B' | `BI' | `IB') ; % % ::= `(', \{ {\sc digit} \}, `)' ; % @@ -410,9 +410,9 @@ and the derived files % % \noindent % 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. +% \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. % @@ -510,9 +510,9 @@ and the derived files % % \begin{quote} % \begin{verbatim} -% \font\iwonaitalic =Iwona/i at 20pt -% \font\iwonabold =Iwona/b at 20pt -% \font\iwonabolditalic=Iwona/bi at 20pt +% \font\iwonaitalic =Iwona/I at 20pt +% \font\iwonabold =Iwona/B at 20pt +% \font\iwonabolditalic=Iwona/BI at 20pt % \end{verbatim} % \end{quote} % -- cgit v1.2.3 From 8929aa8fddc54b831cf6400c6553a393f767e0b8 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 1 May 2013 21:09:53 +0200 Subject: merge changes to luaotfload.lua into dtx --- luaotfload.dtx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'luaotfload.dtx') diff --git a/luaotfload.dtx b/luaotfload.dtx index dd43990..fd71485 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1226,6 +1226,11 @@ 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} % We set the minimum version requirement for \LUATEX to v0.76, % because the font loader requires recent features like direct @@ -1542,7 +1547,6 @@ loadmodule"colors.lua" --- “font-clr” % 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}). @@ -1683,10 +1687,12 @@ elseif font_definer == "patch" then 1) end -loadmodule"features.lua" --- contains what was “font-ltx” and “font-otc” +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 -- cgit v1.2.3