From c3bf9af66a89a22281db67252f918c81929dee14 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 23 Nov 2015 23:57:13 +0100 Subject: [doc] document setting the Context path --- doc/luaotfload-main.tex | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/luaotfload-main.tex b/doc/luaotfload-main.tex index 5ea70d8..4a4ada6 100644 --- a/doc/luaotfload-main.tex +++ b/doc/luaotfload-main.tex @@ -1209,9 +1209,21 @@ Thus if you prefer running bleeding edge code from the \CONTEXT beta, all you have to do is to choose the \inlinecode {context} fontloader via the configuration file (see section \ref{sec:conf} below). % -This will make \identifier {Luaotfload} locate the \CONTEXT source via -\identifier{kpathsea} lookups and use those instead of the fontloader -%% TODO allow choosing the context path +This will make \identifier {Luaotfload} locate the \CONTEXT source by +means of \identifier{kpathsea} lookups and use those instead of the +merged package. +% +The parameter may be extended with a path to the \CONTEXT +\fileent{texmf}, separated with a colon: + +\beginlisting +[run] + fontloader = context:~/context/tex/texmf-context +\endlisting + +This setting allows accessing an installation -- e. g. the standalone +distribution or a source repository -- outside the current \TEX +distribution. Also, the merged file at some point loads the Adobe Glyph List from a \LUA table that is contained in \fileent{luaotfload-glyphlist.lua}, -- cgit v1.2.3 From 4bdf24de7d3b5178caa5a38d306c4bee1fe53668 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 24 Nov 2015 00:03:34 +0100 Subject: [doc] fix several listings --- doc/luaotfload-main.tex | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/luaotfload-main.tex b/doc/luaotfload-main.tex index 4a4ada6..a9971e8 100644 --- a/doc/luaotfload-main.tex +++ b/doc/luaotfload-main.tex @@ -611,7 +611,9 @@ obviously, \inlinecode{random}. the file \inlinecode{tkrn.fea} that is part of \identifier{luaotfload}. It can be read and applied as follows: - \inlinecode{\\font \\test = Latin Modern Roman:featurefile=tkrn.fea;+tkrn} + \beginlisting + \font \test = Latin Modern Roman:featurefile=tkrn.fea;+tkrn + \endlisting \endaltitem \beginaltitem {color} @@ -624,7 +626,7 @@ obviously, \inlinecode{random}. For example, in order to set text in semitransparent red: \beginlisting -\font \test = "Latin Modern Roman:color=FF0000BB" + \font \test = "Latin Modern Roman:color=FF0000BB" \endlisting \endaltitem @@ -663,8 +665,8 @@ obviously, \inlinecode{random}. letterspacing width: \beginlisting -\font \iwonakernedA = "file:Iwona-Regular.otf:kernfactor=0.125" -\font \iwonakernedB = "file:Iwona-Regular.otf:letterspace=12.5" + \font \iwonakernedA = "file:Iwona-Regular.otf:kernfactor=0.125" + \font \iwonakernedB = "file:Iwona-Regular.otf:letterspace=12.5" \endlisting Specific pairs of letters and ligatures may be exempt from @@ -736,7 +738,7 @@ obviously, \inlinecode{random}. }: \beginlisting -\font \test = LatinModernRoman:protrusion=default + \font \test = LatinModernRoman:protrusion=default \endlisting \endaltitem \enddescriptions -- cgit v1.2.3 From a5693d7b6f8109c09b231c2ac92c08aef7bd442d Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 24 Nov 2015 00:42:35 +0100 Subject: [mkimport] remove code obstructing user-specified import path --- scripts/mkimport | 9 --------- 1 file changed, 9 deletions(-) diff --git a/scripts/mkimport b/scripts/mkimport index 9ea224a..0be0847 100755 --- a/scripts/mkimport +++ b/scripts/mkimport @@ -480,15 +480,6 @@ local import_file = function (name, kind, def, cat) end --[[ [local import_file = function (name, kind)] ]] local import = function (arg) - if #arg > 1 then - local tgt = parms.target - local name = tgt or die ("invalid filename " .. tostring (tgt)) - local stat = import_file (name) - if stat == import_failed then - die ("failed to import file " .. name) - end - status ("import status for file %s: %s", name, import_status[stat]) - end --- Multiple files local statcount = { } -- import status codes -> size_t for cat, defs in next, imports do -- cgit v1.2.3 From f3737e68ca8b39ecf0368ac9781fb6b32c57c560 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 24 Nov 2015 00:50:32 +0100 Subject: [mkimport] allow output in pwd --- scripts/mkimport | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mkimport b/scripts/mkimport index 0be0847..abe1608 100755 --- a/scripts/mkimport +++ b/scripts/mkimport @@ -684,7 +684,7 @@ local build_paths = function (argv) --- also set the target name local fname = argv[3] local dir = filedirname (fname) - if not lfsisdir (dir) then + if not string.is_empty (dir) and not lfsisdir (dir) then die ("third argument must be point into writable directory, not “%s”", argv[3]) end -- cgit v1.2.3 From faa2f91a150bf3b0b9fc1cc95c36b23d91cc3a93 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 24 Nov 2015 00:52:32 +0100 Subject: [doc] document mkimport usage --- doc/luaotfload-main.tex | 75 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 21 deletions(-) diff --git a/doc/luaotfload-main.tex b/doc/luaotfload-main.tex index a9971e8..28f92f7 100644 --- a/doc/luaotfload-main.tex +++ b/doc/luaotfload-main.tex @@ -1208,24 +1208,8 @@ individual unpackaged \LUA libraries that come with the source, or even use the files from Context directly. % Thus if you prefer running bleeding edge code from the \CONTEXT beta, -all you have to do is to choose the \inlinecode {context} fontloader -via the configuration file (see section \ref{sec:conf} below). -% -This will make \identifier {Luaotfload} locate the \CONTEXT source by -means of \identifier{kpathsea} lookups and use those instead of the -merged package. -% -The parameter may be extended with a path to the \CONTEXT -\fileent{texmf}, separated with a colon: - -\beginlisting -[run] - fontloader = context:~/context/tex/texmf-context -\endlisting - -This setting allows accessing an installation -- e. g. the standalone -distribution or a source repository -- outside the current \TEX -distribution. +choose the \inlinecode {context} fontloader via the configuration file +(see sections \ref{sec:conf} and \ref{sec:pkg} below). Also, the merged file at some point loads the Adobe Glyph List from a \LUA table that is contained in \fileent{luaotfload-glyphlist.lua}, @@ -1293,11 +1277,60 @@ The fontloader code is integrated as an isolated component that can be switched out on demand. To specify the fontloader you wish to use, the configuration file (described in section \ref{sec:conf}) provides the option -\inlinecode{fontloader}. Its value can be one of the identifiers -\inlinecode{default} or \inlinecode{reference} or the name of a file -somewhere in the search path of \LUATEX. +\inlinecode{fontloader}. +Its value can be one of the identifiers \inlinecode{default} or +\inlinecode{reference} or the name of a file somewhere in the search +path of \LUATEX. +% +This will make \identifier {Luaotfload} locate the \CONTEXT source by +means of \identifier{kpathsea} lookups and use those instead of the +merged package. +% +The parameter may be extended with a path to the \CONTEXT +\fileent{texmf}, separated with a colon: + +\beginlisting +[run] + fontloader = context:~/context/tex/texmf-context +\endlisting + +\noindent This setting allows accessing an installation -- e. g. the +standalone distribution or a source repository -- outside the current +\TEX distribution. + +Like the \identifier{Lualibs} package, the reference fontloader is +deployed as a \emphasis{merged package} containing a series of \LUA +files joined together in their expected order and stripped of +non-significant parts. +% +The \fileent{mkimport} utility assists in pulling the files from a +\CONTEXT tree and packaging them for use with \identifier{Luaotfload}.% +\footnote{% + These tasks are performed, respectively, by the build targets + \inlinecode{import} and \inlinecode{package} of the + \identifier{Luaotfload} makefile. +} +% +The state of the files currently in \identifier{Luaotfload}’s +repository can be queried: +\beginlisting +./scripts/mkimport news +\endlisting +% +The subcommand for importing takes the prefix of the desired \CONTEXT +\identifier{texmf} as an optional argument: +\beginlisting +./scripts/mkimport import ~/context/tex/texmf-context +\endlisting +% +Whereas the command for packaging requires a path to the +\emphasis{package description file} and the output name to be passed. +\beginlisting +./scripts/mkimport package ./src/fontloader/luaotfload-package.lua fontloader-custom.lua +\endlisting \endsubsection + \endsection %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- cgit v1.2.3 From f4204c1ea5fcc0368392c119530687681ab733c9 Mon Sep 17 00:00:00 2001 From: David Carlisle Date: Mon, 23 Nov 2015 18:50:00 +0000 Subject: define priority_in_callback (from luatexbase) --- src/luaotfload-colors.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/luaotfload-colors.lua b/src/luaotfload-colors.lua index 98549c8..576a432 100644 --- a/src/luaotfload-colors.lua +++ b/src/luaotfload-colors.lua @@ -315,7 +315,16 @@ end local color_callback_activated = 0 local add_to_callback = luatexbase.add_to_callback -local priority_in_callback = luatexbase.priority_in_callback +local function priority_in_callback (name,description) + for i,v in ipairs(luatexbase.callback_descriptions(name)) + do + if v == description then + return i + end + end + return false +end + --- unit -> unit add_color_callback = function ( ) -- cgit v1.2.3 From 54654688c8aa643ec9cc068eb25464d40ead84a0 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 26 Nov 2015 08:19:49 +0100 Subject: [colors] remove workaround for deprecated interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Luatexbase API was consolidated. Since the priority_in_callback functionality wasn’t used for anything but determining whether we need to convert to an hlist first, there’s not really any gain in keeping it around in the generic form. --- src/luaotfload-colors.lua | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/luaotfload-colors.lua b/src/luaotfload-colors.lua index 576a432..ca5a067 100644 --- a/src/luaotfload-colors.lua +++ b/src/luaotfload-colors.lua @@ -313,18 +313,15 @@ local color_handler = function (head) return head end +local color_callback_name = "luaotfload.color_handler" local color_callback_activated = 0 local add_to_callback = luatexbase.add_to_callback -local function priority_in_callback (name,description) - for i,v in ipairs(luatexbase.callback_descriptions(name)) - do - if v == description then - return i - end - end - return false -end +--- unit -> bool +local mlist_to_hlist_initial = function () + local cdesc = luatexbase.callback_descriptions "mlist_to_hlist" + return cdesc and cdesc[1] == color_callback_name +end --- unit -> unit add_color_callback = function ( ) @@ -336,7 +333,7 @@ add_color_callback = function ( ) if color_callback_activated == 0 then add_to_callback(color_callback, color_handler, - "luaotfload.color_handler") + color_callback_name) add_to_callback("hpack_filter", function (head, groupcode) if groupcode == "hbox" or @@ -346,10 +343,10 @@ add_color_callback = function ( ) end return head end, - "luaotfload.color_handler") + color_callback_name) add_to_callback("mlist_to_hlist", function (head, display_type, need_penalties) - if priority_in_callback("mlist_to_hlist","luaotfload.color_handler") == 1 then + if mlist_to_hlist_initial () then head = mlist_to_hlist(head, display_type, need_penalties) end if display_type == "text" then @@ -357,7 +354,7 @@ add_color_callback = function ( ) end return color_handler(head) end, - "luaotfload.color_handler") + color_callback_name) color_callback_activated = 1 end end -- cgit v1.2.3 From fec6aa52281f689c7cfdd7b379f5dccbc2ce7cef Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 26 Nov 2015 23:12:49 +0100 Subject: [letterspace] fix handling of interword space MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix https://github.com/lualatex/luaotfload/issues/297 Interword glue hasn’t been considered yet. This again adapts the relevant logic from Context to our letterspacing method. The code is deliberately simplistic and will most likely not address all constellations of a glue preceding a character. --- src/luaotfload-letterspace.lua | 94 +++++++++++++++++++++++++++++++----------- 1 file changed, 71 insertions(+), 23 deletions(-) diff --git a/src/luaotfload-letterspace.lua b/src/luaotfload-letterspace.lua index ab81881..5fa25f9 100644 --- a/src/luaotfload-letterspace.lua +++ b/src/luaotfload-letterspace.lua @@ -6,6 +6,9 @@ if not modules then modules = { } end modules ['letterspace'] = { license = "see context related readme files" } +--- This code diverged quite a bit from its origin in Context. Please +--- do *not* report bugs on the Context list. + local log = luaotfload.log local logreport = log.report @@ -39,7 +42,6 @@ local new_node = nodedirect.new local nodepool = nodedirect.pool local new_kern = nodepool.kern -local new_glue = nodepool.glue local nodecodes = nodes.nodecodes @@ -47,6 +49,7 @@ local glyph_code = nodecodes.glyph local kern_code = nodecodes.kern local disc_code = nodecodes.disc local math_code = nodecodes.math +local glue_code = nodecodes.glue local fonthashes = fonts.hashes local chardata = fonthashes.characters @@ -81,11 +84,17 @@ local kerncodes = bothways { [0] = "fontkern" , [1] = "userkern" , [2] = "accentkern" } +local skipcodes = bothways { [0] = "userskip" + , [13] = "spaceskip" + , [14] = "xspaceskip" + } -kerncodes.kerning = kerncodes.fontkern --- idiosyncrasy -local kerning_code = kerncodes.kerning -local userkern_code = kerncodes.userkern - +kerncodes.kerning = kerncodes.fontkern --- idiosyncrasy +local kerning_code = kerncodes.kerning +local userkern_code = kerncodes.userkern +local userskip_code = skipcodes.userskip +local spaceskip_code = skipcodes.spaceskip +local xspaceskip_code = skipcodes.xspaceskip ----------------------------------------------------------------------- --- node-res @@ -93,19 +102,30 @@ local userkern_code = kerncodes.userkern local glue_spec = new_node "glue_spec" -nodepool.glue = function (width, stretch, shrink, - stretch_order, shrink_order) +local new_gluespec = function (width, + stretch, shrink, + stretch_order, shrink_order) + local spec = copy_node(glue_spec) + if width then setfield(spec, "width" , width ) end + if stretch then setfield(spec, "stretch" , stretch ) end + if shrink then setfield(spec, "shrink" , shrink ) end + if stretch_order then setfield(spec, "stretch_order", stretch_order) end + if shrink_order then setfield(spec, "shrink_order" , shrink_order ) end + return spec +end + +local new_glue = function (width, stretch, shrink, + stretch_order, shrink_order) local n = new_node "glue" - if not width then + if not width then return n end -- no spec - elseif width == false or tonumber(width) then - local s = copy_node(glue_spec) - if width then setfield(s, "width" , width ) end - if stretch then setfield(s, "stretch" , stretch ) end - if shrink then setfield(s, "shrink" , shrink ) end - if stretch_order then setfield(s, "stretch_order", stretch_order) end - if shrink_order then setfield(s, "shrink_order" , shrink_order ) end - setfield(n, "spec", s) + if width == false then + local width = tonumber(width) + if width then + setfield(n, "spec", + new_gluespec(width, stretch, shrink, + stretch_order, shrink_order)) + end else -- shared setfield(n, "spec", copy_node(width)) @@ -198,6 +218,22 @@ local kern_injector = function (fillup, kern) return new_kern(kern) end +local kernable_skip = function (n) + local st = getsubtype (n) + return st == userskip_code + or st == spaceskip_code + or st == xspaceskip_code +end + +local function spec_injector (fillup, width, stretch, shrink) + if fillup then + local spec = new_gluespec(width, 2 * stretch, 2 * shrink) + setfield(spec, "stretch_order", 1) + return spec + end + return new_gluespec(width,stretch,shrink) +end + --[[doc-- Caveat lector. @@ -221,13 +257,11 @@ kerncharacters = function (head) local identifiers = fonthashes.identifiers local kernfactors = kernfactors - local firstkern = true while start do local id = getid(start) if id == glyph_code then - --- 1) look up kern factor (slow, but cached rudimentarily) local krn local fontid = getfont(start) @@ -304,6 +338,21 @@ kerncharacters = function (head) if not pid then -- nothing + elseif pid == glue_code and kernable_skip(prev) then + local spec = getfield(prev, "spec") + local wd = getfield(spec, "width") + if wd > 0 then + --- formula taken from Context + --- existing_width extended by four times the + --- width times the font’s kernfactor + local newwd = wd + --[[two en to a quad]] 4 * wd * krn + local stretched = (getfield(spec,"stretch") * newwd) / wd + local shrunk = (getfield(spec,"shrink") * newwd) / wd + setfield(prev, "spec", + spec_injector(fillup, newwd, stretched, shrunk)) + done = true + end + elseif pid == kern_code then local prev_subtype = getsubtype(prev) if prev_subtype == kerning_code --- context does this by means of an @@ -412,11 +461,10 @@ kerncharacters = function (head) krn = quaddata[lastfont]*krn -- here end setfield(disc, "replace", kern_injector(false, krn)) - end - - end - end - end + end --[[if replace and prv and nxt]] + end --[[if not pid]] + end --[[if prev]] + end --[[if id == glyph_code]] ::nextnode:: if start then -- cgit v1.2.3 From e9035474083a1d1e3892873f72d972754fbb11d6 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 26 Nov 2015 23:26:26 +0100 Subject: [*] update news and readme --- NEWS | 1 + README | 1 + 2 files changed, 2 insertions(+) diff --git a/NEWS b/NEWS index d5688b6..4ed320a 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,7 @@ Change History * Separate module loading from initialization * Custom fontloader package with the files from Lualibs removed * Lualibs are now a dependency when used in a TeX run as well + * Respect interword spaces when letterspacing 2014/07/13, luaotfload v2.5 * Remove legacy code. diff --git a/README b/README index 19c3bd1..71490b8 100644 --- a/README +++ b/README @@ -38,6 +38,7 @@ Manuel Pégourié-Gonnard Olof-Joachim Frahm Patrick Gundlach Philipp Stephani +David Carlisle Installation -- cgit v1.2.3 From f0709824926bf19cf4eb638d9e3c2192bb9131b3 Mon Sep 17 00:00:00 2001 From: David Carlisle Date: Thu, 26 Nov 2015 22:24:52 +0000 Subject: @ may not be catcode 11 in plain --- src/luaotfload.sty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/luaotfload.sty b/src/luaotfload.sty index 1b31b1d..ad4ef2d 100644 --- a/src/luaotfload.sty +++ b/src/luaotfload.sty @@ -33,7 +33,7 @@ %% \csname ifluaotfloadloaded\endcsname \let\ifluaotfloadloaded\endinput -\ifx\newluafunction\@undefined +\ifx\newluafunction\undefined \input ltluatex \fi \ifdefined\ProvidesPackage -- cgit v1.2.3