summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2015-11-26 23:40:23 +0100
committerPhilipp Gesang <phg@phi-gamma.net>2015-11-26 23:40:23 +0100
commit424c5b624b7073e8502a096ab271e422b866e0eb (patch)
tree4bdc31f0321e3bc264e18de89653db60905b3f0d
parent54f5f029605dd3030fcd1d834e447370ddd7823a (diff)
parentf0709824926bf19cf4eb638d9e3c2192bb9131b3 (diff)
downloadluaotfload-424c5b624b7073e8502a096ab271e422b866e0eb.tar.gz
Merge pull request #299 from phi-gamma/master
rc2
-rw-r--r--NEWS1
-rw-r--r--README1
-rw-r--r--doc/luaotfload-main.tex75
-rwxr-xr-xscripts/mkimport11
-rw-r--r--src/luaotfload-colors.lua16
-rw-r--r--src/luaotfload-letterspace.lua94
-rw-r--r--src/luaotfload.sty2
7 files changed, 147 insertions, 53 deletions
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 <mpg@elzevir.fr>
Olof-Joachim Frahm <olof@macrolet.net>
Patrick Gundlach <gundlach@speedata.de>
Philipp Stephani <st_philipp@yahoo.de>
+David Carlisle <d.p.carlisle@gmail.com>
Installation
diff --git a/doc/luaotfload-main.tex b/doc/luaotfload-main.tex
index 5ea70d8..28f92f7 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
@@ -1206,12 +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 via
-\identifier{kpathsea} lookups and use those instead of the fontloader
-%% TODO allow choosing the context path
+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},
@@ -1279,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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/scripts/mkimport b/scripts/mkimport
index 9ea224a..abe1608 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
@@ -693,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
diff --git a/src/luaotfload-colors.lua b/src/luaotfload-colors.lua
index 98549c8..ca5a067 100644
--- a/src/luaotfload-colors.lua
+++ b/src/luaotfload-colors.lua
@@ -313,9 +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 priority_in_callback = luatexbase.priority_in_callback
+
+--- 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 ( )
@@ -327,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
@@ -337,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
@@ -348,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
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
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