summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2017-01-29 21:01:24 +0100
committerGitHub <noreply@github.com>2017-01-29 21:01:24 +0100
commitc6a32f887d4084f0c3bde51fda4a737b51d1eb06 (patch)
treea01850c3a3562d496bda1675c4f7da6453524597
parent98656f9d5ca25aaea2e977b79e09c9bb661f4cef (diff)
parent616b9077567fd670341696cb6ff2bfc71cf691a9 (diff)
downloadluaotfload-c6a32f887d4084f0c3bde51fda4a737b51d1eb06.tar.gz
Merge pull request #395 from phi-gamma/master
v2.8
-rw-r--r--NEWS8
-rw-r--r--README2
-rw-r--r--doc/luaotfload-main.tex4
-rw-r--r--doc/luaotfload-tool.rst4
-rw-r--r--doc/luaotfload.conf.rst44
-rwxr-xr-xscripts/mkglyphlist21
-rw-r--r--src/fontloader/misc/fontloader-font-dsp.lua57
-rw-r--r--src/fontloader/misc/fontloader-font-oto.lua4
-rw-r--r--src/fontloader/misc/fontloader-font-otr.lua6
-rw-r--r--src/fontloader/misc/fontloader-font-ots.lua4
-rw-r--r--src/fontloader/misc/fontloader-font-oup.lua35
-rw-r--r--src/fontloader/misc/fontloader-l-string.lua12
-rw-r--r--src/fontloader/misc/fontloader-l-table.lua46
-rw-r--r--src/fontloader/runtime/fontloader-reference.lua133
-rw-r--r--src/luaotfload-auxiliary.lua5
-rw-r--r--src/luaotfload-colors.lua2
-rw-r--r--src/luaotfload-configuration.lua37
-rw-r--r--src/luaotfload-database.lua98
-rw-r--r--src/luaotfload-letterspace.lua10
-rw-r--r--src/luaotfload-log.lua32
-rw-r--r--src/luaotfload-main.lua14
-rw-r--r--src/luaotfload-parsers.lua2
-rw-r--r--src/luaotfload.sty4
23 files changed, 435 insertions, 149 deletions
diff --git a/NEWS b/NEWS
index f558e3b..83ac5c2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,13 @@
Change History
--------------
+2017-01-29, luaotfload v2.8:
+ * Latest fontloader code.
+ * Support for Luatex 1.0.
+ * Integration of the extended AFM handler.
+ * Fixes to font family assignment.
+ * Skip initialization if Luaotfload is already loaded.
+ * Optical sizes advertised by fonts treated as big points.
+
2016/04/21, luaotfload v2.7:
* Rework lookup chaining.
* Combining glyphs from different fonts (``combo: ...`` requests).
diff --git a/README b/README
index 01e1fc6..77b2864 100644
--- a/README
+++ b/README
@@ -56,7 +56,7 @@ Here are the recommended installation methods (preferred first).
distribution's manual for details.
3. a. Grab the sources from CTAN or github.
- b. Run 'make install TEXMFROOT=/path/to/texmf'.
+ b. Run 'make install DESTDIR=/path/to/texmf'.
c. See 2c.
4. Try to figure it out by looking at the Makefile and comments in the sources.
diff --git a/doc/luaotfload-main.tex b/doc/luaotfload-main.tex
index 406595a..c26235e 100644
--- a/doc/luaotfload-main.tex
+++ b/doc/luaotfload-main.tex
@@ -1,4 +1,4 @@
-%% Copyright (C) 2009-2016
+%% Copyright (C) 2009-2017
%%
%% by Elie Roux <elie.roux@telecom-bretagne.eu>
%% and Khaled Hosny <khaledhosny@eglug.org>
@@ -32,7 +32,7 @@
\beginfrontmatter
\setdocumenttitle {The \identifier{luaotfload} package}
- \setdocumentdate {2016/06/16 v2.7}
+ \setdocumentdate {2017/01/29 v2.8}
\setdocumentauthor {Elie Roux · Khaled Hosny · Philipp Gesang\\
Home: \hyperlink {https://github.com/lualatex/luaotfload}\\
Support: \email {lualatex-dev@tug.org}}
diff --git a/doc/luaotfload-tool.rst b/doc/luaotfload-tool.rst
index 28f8e00..1eeba11 100644
--- a/doc/luaotfload-tool.rst
+++ b/doc/luaotfload-tool.rst
@@ -6,9 +6,9 @@
generate and query the Luaotfload font names database
-----------------------------------------------------------------------
-:Date: 2016-06-16
+:Date: 2017-01-28
:Copyright: GPL v2.0
-:Version: 2.7
+:Version: 2.8
:Manual section: 1
:Manual group: text processing
diff --git a/doc/luaotfload.conf.rst b/doc/luaotfload.conf.rst
index 2af9cec..fbef8ec 100644
--- a/doc/luaotfload.conf.rst
+++ b/doc/luaotfload.conf.rst
@@ -6,9 +6,9 @@
Luaotfload configuration file
-----------------------------------------------------------------------
-:Date: 2016-06-16
+:Date: 2017-01-29
:Copyright: GPL v2.0
-:Version: 2.7
+:Version: 2.8
:Manual section: 5
:Manual group: text processing
@@ -125,23 +125,25 @@ the variable is unset.
Section ``db``
-----------------------------------------------------------------------
-+-----------------+--------+---------------------------+
-| variable | type | default |
-+-----------------+--------+---------------------------+
-| compress | b | ``true`` |
-+-----------------+--------+---------------------------+
-| formats | s | ``"otf,ttf,ttc"`` |
-+-----------------+--------+---------------------------+
-| max-fonts | n | ``2^51`` |
-+-----------------+--------+---------------------------+
-| scan-local | b | ``false`` |
-+-----------------+--------+---------------------------+
-| skip-read | b | ``false`` |
-+-----------------+--------+---------------------------+
-| strip | b | ``true`` |
-+-----------------+--------+---------------------------+
-| update-live | b | ``true`` |
-+-----------------+--------+---------------------------+
++--------------------+--------+---------------------------+
+| variable | type | default |
++--------------------+--------+---------------------------+
+| compress | b | ``true`` |
++--------------------+--------+---------------------------+
+| designsize-dimen | b | ``bp`` |
++--------------------+--------+---------------------------+
+| formats | s | ``"otf,ttf,ttc"`` |
++--------------------+--------+---------------------------+
+| max-fonts | n | ``2^51`` |
++--------------------+--------+---------------------------+
+| scan-local | b | ``false`` |
++--------------------+--------+---------------------------+
+| skip-read | b | ``false`` |
++--------------------+--------+---------------------------+
+| strip | b | ``true`` |
++--------------------+--------+---------------------------+
+| update-live | b | ``true`` |
++--------------------+--------+---------------------------+
The flag ``compress`` determines whether the font index (usually
``luaotfload-names.lua[.gz]`` will be stored in compressed forms.
@@ -150,6 +152,10 @@ If unset it is equivalent of passing ``--no-compress`` to
and has no effect on the runtime behavior of Luaotfload, the flag
should remain set. Most editors come with zlib support anyways.
+The setting ``designsize-dimen`` applies when looking up fonts from
+families with design sizes. The default of DTP-style “big points”
+can be changed for ``pt`` or even ``dd``.
+
The list of ``formats`` must be a comma separated sequence of strings
containing one or more of these elements:
diff --git a/scripts/mkglyphlist b/scripts/mkglyphlist
index f66a686..b9d5309 100755
--- a/scripts/mkglyphlist
+++ b/scripts/mkglyphlist
@@ -18,7 +18,7 @@
-----------------------------------------------------------------------
local glyphfile = "./build/glyphlist.txt"
local font_age = "./build/luaotfload-glyphlist.lua"
-local glyph_source = "http://partners.adobe.com/public/developer/en/opentype/glyphlist.txt"
+local glyph_source = "https://raw.githubusercontent.com/adobe-type-tools/agl-aglfn/master/glyphlist.txt"
-----------------------------------------------------------------------
-- fallbacks
@@ -67,7 +67,7 @@ local eol = P"\n\r" + P"\r\n" + P"\r" + P"\n"
local space = P" "
local alphanum = R("az", "AZ", "09")
local hexdigit = R("af", "AF", "09")
-local eof_tag = gartenzaun * P"--end"
+local eof_tag = gartenzaun * P"END"
local header_line = gartenzaun * (1-eol)^0 * eol
local codepoint = hexdigit^1
local glyphname = alphanum^1
@@ -140,19 +140,12 @@ local get_raw get_raw = function (retry)
elseif not retry then --- attempt download
print"info: retrieving glyph list from"
print(glyph_source)
- local glyphdata = http.request(glyph_source)
- if glyphdata then
- local fh = io.open(glyphfile, "wb")
- if not fh then
- print (string.format ("error: glyph file (%s) not writable", glyphfile))
- os.exit(-1)
- end
- fh:write(glyphdata)
- fh:close()
- return get_raw(true)
+ local cmd = string.format("wget '%s' -o '%s'", glyph_source, glyphfile)
+ local st = os.execute(string.format("wget '%s' -O '%s'", glyph_source, glyphfile))
+ if st ~= 0 then
+ print(string.format("error: download failed; status: %d, command: %q", st, cmd))
+ os.exit(-1)
end
- print"error: download failed"
- os.exit(-1)
end
print("error: could not obtain glyph data from "..glyphfile)
os.exit(-1)
diff --git a/src/fontloader/misc/fontloader-font-dsp.lua b/src/fontloader/misc/fontloader-font-dsp.lua
index cd28168..14e3a1d 100644
--- a/src/fontloader/misc/fontloader-font-dsp.lua
+++ b/src/fontloader/misc/fontloader-font-dsp.lua
@@ -70,6 +70,7 @@ local readers = fonts.handlers.otf.readers
local streamreader = readers.streamreader
local setposition = streamreader.setposition
+local getposition = streamreader.getposition
local skipshort = streamreader.skipshort
local readushort = streamreader.readcardinal2 -- 16-bit unsigned integer
local readulong = streamreader.readcardinal4 -- 24-bit unsigned integer
@@ -397,7 +398,7 @@ local function readlookuparray(f,noflookups,nofcurrent)
end
end
-- if length > nofcurrent then
- -- report_issue("more lookups than currently matched characters")
+ -- report("more lookups than currently matched characters")
-- end
end
return lookups
@@ -413,7 +414,7 @@ end
-- for i=1,noflookups do
-- local index = readushort(f) + 1
-- if index > nofcurrent then
--- report_issue("more lookups than currently matched characters")
+-- report("more lookups than currently matched characters")
-- for i=nofcurrent+1,index-1 do
-- lookups[i] = false
-- end
@@ -1285,20 +1286,50 @@ do
local plugins = { }
- function plugins.size(f,fontdata,tableoffset,parameters)
- if not fontdata.designsize then
- setposition(f,tableoffset+parameters)
- local designsize = readushort(f)
- if designsize > 0 then
- fontdata.designsize = designsize
- skipshort(f,2)
- fontdata.minsize = readushort(f)
- fontdata.maxsize = readushort(f)
+ function plugins.size(f,fontdata,tableoffset,feature)
+ if fontdata.designsize then
+ -- yes, there are fonts with multiple size entries ... it probably relates
+ -- to the other two fields (menu entries in some language)
+ else
+ local function check(offset)
+ setposition(f,offset)
+ local designsize = readushort(f)
+ if designsize > 0 then -- we could also have a threshold
+ local fontstyle = readushort(f)
+ local guimenuid = readushort(f)
+ local minsize = readushort(f)
+ local maxsize = readushort(f)
+ if minsize == 0 and maxsize == 0 and fontstyleid == 0 and guimenuid == 0 then
+ minsize = designsize
+ maxsize = designsize
+ end
+ if designsize >= minsize and designsize <= maxsize then
+ return minsize, maxsize, designsize
+ end
+ end
+ end
+ local minsize, maxsize, designsize = check(tableoffset+feature.offset+feature.parameters)
+ if not designsize then
+ -- some old adobe fonts have: tableoffset+feature.parameters and we could
+ -- use some heuristic but why bother ... this extra check will be removed
+ -- some day and/or when we run into an issue
+ minsize, maxsize, designsize = check(tableoffset+feature.parameters)
+ if designsize then
+ report("bad size feature in %a, falling back to wrong offset",fontdata.filename or "?")
+ else
+ report("bad size feature in %a,",fontdata.filename or "?")
+ end
+ end
+ if designsize then
+ fontdata.minsize = minsize
+ fontdata.maxsize = maxsize
+ fontdata.designsize = designsize
end
end
end
- -- feature order needs checking ... as we loop over a hash
+ -- feature order needs checking ... as we loop over a hash ... however, in the file
+ -- they are sorted so order is not that relevant
local function reorderfeatures(fontdata,scripts,features)
local scriptlangs = { }
@@ -1440,7 +1471,7 @@ do
feature.parameters = parameters
local plugin = plugins[feature.tag]
if plugin then
- plugin(f,fontdata,offset,parameters)
+ plugin(f,fontdata,featureoffset,feature)
end
end
end
diff --git a/src/fontloader/misc/fontloader-font-oto.lua b/src/fontloader/misc/fontloader-font-oto.lua
index 177382f..1356879 100644
--- a/src/fontloader/misc/fontloader-font-oto.lua
+++ b/src/fontloader/misc/fontloader-font-oto.lua
@@ -237,12 +237,12 @@ local function preparesubstitutions(tfmdata,feature,value,validlookups,lookuplis
if kind == "gsub_single" then
for i=1,#steps do
for unicode, data in next, steps[i].coverage do
- if not changed[unicode] then
+ -- if not changed[unicode] then -- fails for multiple subs in some math fonts
if trace_singles then
report_substitution(feature,sequence,descriptions,unicode,data)
end
changed[unicode] = data
- end
+ -- end
end
end
elseif kind == "gsub_alternate" then
diff --git a/src/fontloader/misc/fontloader-font-otr.lua b/src/fontloader/misc/fontloader-font-otr.lua
index 2b18c1e..a9d3a8b 100644
--- a/src/fontloader/misc/fontloader-font-otr.lua
+++ b/src/fontloader/misc/fontloader-font-otr.lua
@@ -645,7 +645,7 @@ local weights = {
[300] = "light",
[400] = "normal",
[500] = "medium",
- [600] = "semibold",
+ [600] = "semibold", -- demi demibold
[700] = "bold",
[800] = "extrabold",
[900] = "black",
@@ -1843,8 +1843,8 @@ local function getinfo(maindata,sub,platformnames,rawfamilynames,metricstoo)
local fontheader = fontdata.fontheader or { }
local cffinfo = fontdata.cffinfo or { }
local filename = fontdata.filename
- local weight = getname(fontdata,"weight") or cffinfo.weight or metrics.weight
- local width = getname(fontdata,"width") or cffinfo.width or metrics.width
+ local weight = getname(fontdata,"weight") or (cffinfo and cffinfo.weight) or (metrics and metrics.weight)
+ local width = getname(fontdata,"width") or (cffinfo and cffinfo.width ) or (metrics and metrics.width )
local fontname = getname(fontdata,"postscriptname")
local fullname = getname(fontdata,"fullname")
local family = getname(fontdata,"family")
diff --git a/src/fontloader/misc/fontloader-font-ots.lua b/src/fontloader/misc/fontloader-font-ots.lua
index 17e1a3c..1f84214 100644
--- a/src/fontloader/misc/fontloader-font-ots.lua
+++ b/src/fontloader/misc/fontloader-font-ots.lua
@@ -244,6 +244,8 @@ local registerotffeature = otffeatures.register
local onetimemessage = fonts.loggers.onetimemessage or function() end
+local getrandom = utilities and utilities.randomizer and utilities.randomizer.get
+
otf.defaultnodealternate = "none" -- first last
-- We use a few global variables. The handler can be called nested but this assumes that the
@@ -653,7 +655,7 @@ end
local function get_alternative_glyph(start,alternatives,value)
local n = #alternatives
if value == "random" then
- local r = random(1,n)
+ local r = getrandom and getrandom("glyph",1,n) or random(1,n)
return alternatives[r], trace_alternatives and formatters["value %a, taking %a"](value,r)
elseif value == "first" then
return alternatives[1], trace_alternatives and formatters["value %a, taking %a"](value,1)
diff --git a/src/fontloader/misc/fontloader-font-oup.lua b/src/fontloader/misc/fontloader-font-oup.lua
index c494573..cfa90c7 100644
--- a/src/fontloader/misc/fontloader-font-oup.lua
+++ b/src/fontloader/misc/fontloader-font-oup.lua
@@ -29,7 +29,12 @@ local f_index = formatters["I%05X"]
local f_character_y = formatters["%C"]
local f_character_n = formatters["[ %C ]"]
-local doduplicates = true -- can become an option (pseudo feature)
+local check_duplicates = true -- can become an option (pseudo feature) / aways needed anyway
+local check_soft_hyphen = false -- can become an option (pseudo feature) / needed for tagging
+
+directives.register("otf.checksofthyphen",function(v)
+ check_soft_hyphen = v
+end)
local function replaced(list,index,replacement)
if type(list) == "number" then
@@ -106,7 +111,7 @@ local function unifyresources(fontdata,indices)
--
local done = { } -- we need to deal with shared !
--
- local duplicates = doduplicates and resources.duplicates
+ local duplicates = check_duplicates and resources.duplicates
if duplicates and not next(duplicates) then
duplicates = false
end
@@ -359,12 +364,34 @@ local function unifyresources(fontdata,indices)
end
local function copyduplicates(fontdata)
- if doduplicates then
+ if check_duplicates then
local descriptions = fontdata.descriptions
local resources = fontdata.resources
local duplicates = resources.duplicates
+ if check_soft_hyphen then
+ -- ebgaramond has a zero width empty soft hyphen
+ local ds = descriptions[0xAD]
+ if not ds or ds.width == 0 then
+ if ds then
+ descriptions[0xAD] = nil
+ report("patching soft hyphen")
+ else
+ report("adding soft hyphen")
+ end
+ if not duplicates then
+ duplicates = { }
+ resources.duplicates = duplicates
+ end
+ local dh = duplicates[0x2D]
+ if dh then
+ dh[#dh+1] = { [0xAD] = true }
+ else
+ duplicates[0x2D] = { [0xAD] = true }
+ end
+ end
+ end
if duplicates then
- for u, d in next, duplicates do
+ for u, d in next, duplicates do
local du = descriptions[u]
if du then
local t = { f_character_y(u), "@", f_index(du.index), "->" }
diff --git a/src/fontloader/misc/fontloader-l-string.lua b/src/fontloader/misc/fontloader-l-string.lua
index 88297f2..be8f397 100644
--- a/src/fontloader/misc/fontloader-l-string.lua
+++ b/src/fontloader/misc/fontloader-l-string.lua
@@ -75,19 +75,19 @@ local collapser = patterns.collapser
local longtostring = patterns.longtostring
function string.strip(str)
- return lpegmatch(stripper,str) or ""
+ return str and lpegmatch(stripper,str) or ""
end
function string.fullstrip(str)
- return lpegmatch(fullstripper,str) or ""
+ return str and lpegmatch(fullstripper,str) or ""
end
function string.collapsespaces(str)
- return lpegmatch(collapser,str) or ""
+ return str and lpegmatch(collapser,str) or ""
end
function string.longtostring(str)
- return lpegmatch(longtostring,str) or ""
+ return str and lpegmatch(longtostring,str) or ""
end
-- function string.is_empty(str)
@@ -99,7 +99,7 @@ local pattern = P(" ")^0 * P(-1) -- maybe also newlines
-- patterns.onlyspaces = pattern
function string.is_empty(str)
- if str == "" then
+ if not str or str == "" then
return true
else
return lpegmatch(pattern,str) and true or false
@@ -163,7 +163,7 @@ function string.escapedpattern(str,simple)
end
function string.topattern(str,lowercase,strict)
- if str=="" or type(str) ~= "string" then
+ if str == "" or type(str) ~= "string" then
return ".*"
elseif strict then
str = lpegmatch(pattern_c,str)
diff --git a/src/fontloader/misc/fontloader-l-table.lua b/src/fontloader/misc/fontloader-l-table.lua
index 498f518..39357bd 100644
--- a/src/fontloader/misc/fontloader-l-table.lua
+++ b/src/fontloader/misc/fontloader-l-table.lua
@@ -971,6 +971,41 @@ end
table.flattened = flattened
+local function collapsed(t,f,h)
+ if f == nil then
+ f = { }
+ h = { }
+ end
+ for k=1,#t do
+ local v = t[k]
+ if type(v) == "table" then
+ collapsed(v,f,h)
+ elseif not h[v] then
+ f[#f+1] = v
+ h[v] = true
+ end
+ end
+ return f
+end
+
+local function collapsedhash(t,h)
+ if h == nil then
+ h = { }
+ end
+ for k=1,#t do
+ local v = t[k]
+ if type(v) == "table" then
+ collapsedhash(v,h)
+ else
+ h[v] = true
+ end
+ end
+ return h
+end
+
+table.collapsed = collapsed -- 20% faster than unique(collapsed(t))
+table.collapsedhash = collapsedhash
+
local function unnest(t,f) -- only used in mk, for old times sake
if not f then -- and only relevant for token lists
f = { } -- this one can become obsolete
@@ -1077,7 +1112,7 @@ function table.count(t)
return n
end
-function table.swapped(t,s) -- hash
+function table.swapped(t,s) -- hash, we need to make sure we don't mess up next
local n = { }
if s then
for k, v in next, s do
@@ -1090,7 +1125,14 @@ function table.swapped(t,s) -- hash
return n
end
-function table.mirrored(t) -- hash
+function table.hashed(t) -- list, add hash to index (save because we are not yet mixed
+ for i=1,#t do
+ t[t[i]] = i
+ end
+ return t
+end
+
+function table.mirrored(t) -- hash, we need to make sure we don't mess up next
local n = { }
for k, v in next, t do
n[v] = k
diff --git a/src/fontloader/runtime/fontloader-reference.lua b/src/fontloader/runtime/fontloader-reference.lua
index a0b906d..3a4a70c 100644
--- a/src/fontloader/runtime/fontloader-reference.lua
+++ b/src/fontloader/runtime/fontloader-reference.lua
@@ -1,6 +1,6 @@
-- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua
-- parent file : c:/data/develop/context/sources/luatex-fonts.lua
--- merge date : 10/19/16 22:51:32
+-- merge date : 01/27/17 14:39:39
do -- begin closure to overcome local limits and interference
@@ -964,20 +964,20 @@ local fullstripper=patterns.fullstripper
local collapser=patterns.collapser
local longtostring=patterns.longtostring
function string.strip(str)
- return lpegmatch(stripper,str) or ""
+ return str and lpegmatch(stripper,str) or ""
end
function string.fullstrip(str)
- return lpegmatch(fullstripper,str) or ""
+ return str and lpegmatch(fullstripper,str) or ""
end
function string.collapsespaces(str)
- return lpegmatch(collapser,str) or ""
+ return str and lpegmatch(collapser,str) or ""
end
function string.longtostring(str)
- return lpegmatch(longtostring,str) or ""
+ return str and lpegmatch(longtostring,str) or ""
end
local pattern=P(" ")^0*P(-1)
function string.is_empty(str)
- if str=="" then
+ if not str or str=="" then
return true
else
return lpegmatch(pattern,str) and true or false
@@ -1739,6 +1739,38 @@ local function flattened(t,f,depth)
return f
end
table.flattened=flattened
+local function collapsed(t,f,h)
+ if f==nil then
+ f={}
+ h={}
+ end
+ for k=1,#t do
+ local v=t[k]
+ if type(v)=="table" then
+ collapsed(v,f,h)
+ elseif not h[v] then
+ f[#f+1]=v
+ h[v]=true
+ end
+ end
+ return f
+end
+local function collapsedhash(t,h)
+ if h==nil then
+ h={}
+ end
+ for k=1,#t do
+ local v=t[k]
+ if type(v)=="table" then
+ collapsedhash(v,h)
+ else
+ h[v]=true
+ end
+ end
+ return h
+end
+table.collapsed=collapsed
+table.collapsedhash=collapsedhash
local function unnest(t,f)
if not f then
f={}
@@ -1845,6 +1877,12 @@ function table.swapped(t,s)
end
return n
end
+function table.hashed(t)
+ for i=1,#t do
+ t[t[i]]=i
+ end
+ return t
+end
function table.mirrored(t)
local n={}
for k,v in next,t do
@@ -9054,8 +9092,8 @@ local function getinfo(maindata,sub,platformnames,rawfamilynames,metricstoo)
local fontheader=fontdata.fontheader or {}
local cffinfo=fontdata.cffinfo or {}
local filename=fontdata.filename
- local weight=getname(fontdata,"weight") or cffinfo.weight or metrics.weight
- local width=getname(fontdata,"width") or cffinfo.width or metrics.width
+ local weight=getname(fontdata,"weight") or (cffinfo and cffinfo.weight) or (metrics and metrics.weight)
+ local width=getname(fontdata,"width") or (cffinfo and cffinfo.width ) or (metrics and metrics.width )
local fontname=getname(fontdata,"postscriptname")
local fullname=getname(fontdata,"fullname")
local family=getname(fontdata,"family")
@@ -11398,6 +11436,7 @@ local report=logs.reporter("otf reader")
local readers=fonts.handlers.otf.readers
local streamreader=readers.streamreader
local setposition=streamreader.setposition
+local getposition=streamreader.getposition
local skipshort=streamreader.skipshort
local readushort=streamreader.readcardinal2
local readulong=streamreader.readcardinal4
@@ -12453,15 +12492,39 @@ function gposhandlers.extension(f,fontdata,lookupid,lookupoffset,offset,glyphs,n
end
do
local plugins={}
- function plugins.size(f,fontdata,tableoffset,parameters)
- if not fontdata.designsize then
- setposition(f,tableoffset+parameters)
- local designsize=readushort(f)
- if designsize>0 then
+ function plugins.size(f,fontdata,tableoffset,feature)
+ if fontdata.designsize then
+ else
+ local function check(offset)
+ setposition(f,offset)
+ local designsize=readushort(f)
+ if designsize>0 then
+ local fontstyle=readushort(f)
+ local guimenuid=readushort(f)
+ local minsize=readushort(f)
+ local maxsize=readushort(f)
+ if minsize==0 and maxsize==0 and fontstyleid==0 and guimenuid==0 then
+ minsize=designsize
+ maxsize=designsize
+ end
+ if designsize>=minsize and designsize<=maxsize then
+ return minsize,maxsize,designsize
+ end
+ end
+ end
+ local minsize,maxsize,designsize=check(tableoffset+feature.offset+feature.parameters)
+ if not designsize then
+ minsize,maxsize,designsize=check(tableoffset+feature.parameters)
+ if designsize then
+ report("bad size feature in %a, falling back to wrong offset",fontdata.filename or "?")
+ else
+ report("bad size feature in %a,",fontdata.filename or "?")
+ end
+ end
+ if designsize then
+ fontdata.minsize=minsize
+ fontdata.maxsize=maxsize
fontdata.designsize=designsize
- skipshort(f,2)
- fontdata.minsize=readushort(f)
- fontdata.maxsize=readushort(f)
end
end
end
@@ -12598,7 +12661,7 @@ do
feature.parameters=parameters
local plugin=plugins[feature.tag]
if plugin then
- plugin(f,fontdata,offset,parameters)
+ plugin(f,fontdata,featureoffset,feature)
end
end
end
@@ -13509,7 +13572,11 @@ local f_unicode=formatters["U%05X"]
local f_index=formatters["I%05X"]
local f_character_y=formatters["%C"]
local f_character_n=formatters["[ %C ]"]
-local doduplicates=true
+local check_duplicates=true
+local check_soft_hyphen=false
+directives.register("otf.checksofthyphen",function(v)
+ check_soft_hyphen=v
+end)
local function replaced(list,index,replacement)
if type(list)=="number" then
return replacement
@@ -13577,7 +13644,7 @@ local function unifyresources(fontdata,indices)
end
end
local done={}
- local duplicates=doduplicates and resources.duplicates
+ local duplicates=check_duplicates and resources.duplicates
if duplicates and not next(duplicates) then
duplicates=false
end
@@ -13814,10 +13881,31 @@ local function unifyresources(fontdata,indices)
unifythem(resources.sublookups)
end
local function copyduplicates(fontdata)
- if doduplicates then
+ if check_duplicates then
local descriptions=fontdata.descriptions
local resources=fontdata.resources
local duplicates=resources.duplicates
+ if check_soft_hyphen then
+ local ds=descriptions[0xAD]
+ if not ds or ds.width==0 then
+ if ds then
+ descriptions[0xAD]=nil
+ report("patching soft hyphen")
+ else
+ report("adding soft hyphen")
+ end
+ if not duplicates then
+ duplicates={}
+ resources.duplicates=duplicates
+ end
+ local dh=duplicates[0x2D]
+ if dh then
+ dh[#dh+1]={ [0xAD]=true }
+ else
+ duplicates[0x2D]={ [0xAD]=true }
+ end
+ end
+ end
if duplicates then
for u,d in next,duplicates do
local du=descriptions[u]
@@ -16326,12 +16414,10 @@ local function preparesubstitutions(tfmdata,feature,value,validlookups,lookuplis
if kind=="gsub_single" then
for i=1,#steps do
for unicode,data in next,steps[i].coverage do
- if not changed[unicode] then
if trace_singles then
report_substitution(feature,sequence,descriptions,unicode,data)
end
changed[unicode]=data
- end
end
end
elseif kind=="gsub_alternate" then
@@ -18376,6 +18462,7 @@ local fontfeatures=fonthashes.features
local otffeatures=fonts.constructors.features.otf
local registerotffeature=otffeatures.register
local onetimemessage=fonts.loggers.onetimemessage or function() end
+local getrandom=utilities and utilities.randomizer and utilities.randomizer.get
otf.defaultnodealternate="none"
local tfmdata=false
local characters=false
@@ -18721,7 +18808,7 @@ end
local function get_alternative_glyph(start,alternatives,value)
local n=#alternatives
if value=="random" then
- local r=random(1,n)
+ local r=getrandom and getrandom("glyph",1,n) or random(1,n)
return alternatives[r],trace_alternatives and formatters["value %a, taking %a"](value,r)
elseif value=="first" then
return alternatives[1],trace_alternatives and formatters["value %a, taking %a"](value,1)
diff --git a/src/luaotfload-auxiliary.lua b/src/luaotfload-auxiliary.lua
index 1a21405..395f9b5 100644
--- a/src/luaotfload-auxiliary.lua
+++ b/src/luaotfload-auxiliary.lua
@@ -2,14 +2,11 @@
-----------------------------------------------------------------------
-- FILE: luaotfload-auxiliary.lua
-- DESCRIPTION: part of luaotfload
--- REQUIREMENTS: luaotfload 2.7
+-- REQUIREMENTS: luaotfload 2.8
-- AUTHOR: Khaled Hosny, Élie Roux, Philipp Gesang
-----------------------------------------------------------------------
--
---- this file addresses issue #24
---- https://github.com/lualatex/luaotfload/issues/24#
-
luaotfload = luaotfload or { }
local log = luaotfload.log
local logreport = log.report
diff --git a/src/luaotfload-colors.lua b/src/luaotfload-colors.lua
index 12b490e..f2fdceb 100644
--- a/src/luaotfload-colors.lua
+++ b/src/luaotfload-colors.lua
@@ -1,5 +1,5 @@
if not modules then modules = { } end modules ['luaotfload-colors'] = {
- version = "2.7",
+ version = "2.8",
comment = "companion to luaotfload-main.lua (font color)",
author = "Khaled Hosny, Elie Roux, Philipp Gesang, Dohyun Kim, David Carlisle",
copyright = "Luaotfload Development Team",
diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua
index 8484c62..2f4589b 100644
--- a/src/luaotfload-configuration.lua
+++ b/src/luaotfload-configuration.lua
@@ -2,14 +2,14 @@
-------------------------------------------------------------------------------
-- FILE: luaotfload-configuration.lua
-- DESCRIPTION: config file reader
--- REQUIREMENTS: Luaotfload 2.7 or above
+-- REQUIREMENTS: Luaotfload 2.8 or above
-- AUTHOR: Philipp Gesang, <phg@phi-gamma.net>
-- AUTHOR: Dohyun Kim <nomosnomos@gmail.com>
-------------------------------------------------------------------------------
--
if not modules then modules = { } end modules ["luaotfload-configuration"] = {
- version = "2.7",
+ version = "2.8",
comment = "part of Luaotfload",
author = "Philipp Gesang, Dohyun Kim",
copyright = "Luaotfload Development Team",
@@ -203,6 +203,7 @@ local default_config = {
update_live = true,
compress = true,
max_fonts = 2^51,
+ designsize_dimen= "bp",
},
run = {
anon_sequence = default_anon_sequence,
@@ -314,6 +315,18 @@ local set_font_filter = function ()
return true
end
+local set_size_dimension = function ()
+ local names = fonts.names
+ if names and names.set_size_dimension then
+ local dim = config.luaotfload.db.designsize_dimen
+ if not dim or dim == "" then
+ dim = default_config.db.designsize_dimen
+ end
+ names.set_size_dimension (dim)
+ end
+ return true
+end
+
local set_name_resolver = function ()
local names = fonts.names
if names and names.resolve_cached then
@@ -382,6 +395,7 @@ reconf_tasks = {
{ "Build cache paths" , build_cache_paths },
{ "Check terminal dimensions" , check_termwidth },
{ "Set the font filter" , set_font_filter },
+ { "Set design size dimension" , set_size_dimension },
{ "Install font name resolver", set_name_resolver },
{ "Set default features" , set_default_features },
}
@@ -482,6 +496,10 @@ local option_spec = {
out_t = number_t, --- TODO int_t from 5.3.x on
transform = tointeger,
},
+ designsize_dimen = {
+ in_t = string_t,
+ out_t = string_t,
+ },
},
run = {
anon_sequence = {
@@ -698,13 +716,14 @@ local conf_footer = [==[
local formatters = {
db = {
- compress = { false, format_boolean },
- formats = { false, format_string },
- max_fonts = { false, format_integer },
- scan_local = { false, format_boolean },
- skip_read = { false, format_boolean },
- strip = { false, format_boolean },
- update_live = { false, format_boolean },
+ compress = { false, format_boolean },
+ designsize_dimen = { false, format_string },
+ formats = { false, format_string },
+ max_fonts = { false, format_integer },
+ scan_local = { false, format_boolean },
+ skip_read = { false, format_boolean },
+ strip = { false, format_boolean },
+ update_live = { false, format_boolean },
},
default_features = {
__default = { true, format_keyval },
diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua
index c6ccaa6..621a24b 100644
--- a/src/luaotfload-database.lua
+++ b/src/luaotfload-database.lua
@@ -1,5 +1,5 @@
if not modules then modules = { } end modules ['luaotfload-database'] = {
- version = "2.7",
+ version = "2.8",
comment = "companion to luaotfload-main.lua",
author = "Khaled Hosny, Elie Roux, Philipp Gesang",
copyright = "Luaotfload Development Team",
@@ -111,7 +111,7 @@ if not modules then modules = { } end modules ['luaotfload-database'] = {
--doc]]--
local lpeg = require "lpeg"
-local P, Cc, lpegmatch = lpeg.P, lpeg.Cc, lpeg.match
+local P, lpegmatch = lpeg.P, lpeg.match
local log = luaotfload.log
local logreport = log and log.report or print -- overriden later on
@@ -162,7 +162,6 @@ local tablesort = table.sort
local utf8gsub = unicode.utf8.gsub
local utf8lower = unicode.utf8.lower
local utf8len = unicode.utf8.len
-local zlibcompress = zlib.compress
--- these come from Lualibs/Context
local filebasename = file.basename
@@ -520,7 +519,7 @@ load_names = function (dry_run, no_rebuild)
names_version = names.version
if db_version ~= names_version then
logreport ("both", 0, "db",
- [[Version mismatch; expected %4.3f, got %4.3f.]],
+ [[Version mismatch; expected %d, got %d.]],
names_version, db_version)
if not fonts_reloaded then
logreport ("both", 0, "db", [[Force rebuild.]])
@@ -891,8 +890,9 @@ end
--[[doc--
- choose_size -- Pick a font face of appropriate size from the list
- of family members with matching style. There are three categories:
+ choose_size -- Pick a font face of appropriate size (in sp) from
+ the list of family members with matching style. There are three
+ categories:
1. exact matches: if there is a face whose design size equals
the asked size, it is returned immediately and no further
@@ -1042,6 +1042,35 @@ local lookup_fontname = function (specification, name, style)
return nil, nil
end
+local design_size_dimension
+local set_size_dimension
+do
+
+ --- cf. TeXbook p. 57
+ local dimens = {
+ pt = function (v) return v end,
+ bp = function (v) return (v * 7200) / 7227 end,
+ dd = function (v) return (v * 1157) / 1238 end,
+ }
+
+ design_size_dimension = dimens.bp
+
+ set_size_dimension = function (dim)
+ local f = dimens [dim]
+ if f then
+ logreport ("both", 4, "db",
+ "Interpreting design sizes as %q, factor %.6f.",
+ dim, f (1.000000))
+ design_size_dimension = f
+ return
+ end
+ logreport ("both", 0, "db",
+ "Invalid dimension %q requested for design sizes; \z
+ ignoring.")
+ end
+end
+
+
--[[doc--
lookup_font_name -- Perform a name: lookup. This first queries the
@@ -1099,15 +1128,14 @@ lookup_font_name = function (specification)
local askedsize = specification.optsize
if askedsize then
- askedsize = tonumber (askedsize)
+ askedsize = tonumber (askedsize) * 65536
else
askedsize = specification.size
- if askedsize and askedsize >= 0 then
- askedsize = askedsize / 65536
- else
+ if not askedsize or askedsize < 0 then
askedsize = 0
end
end
+ askedsize = design_size_dimension (askedsize)
resolved, subfont = lookup_familyname (specification,
name,
@@ -1322,28 +1350,35 @@ local load_font_file = function (filename, subfont)
return ret
end
---- rawdata -> (int * int * int | bool)
+local get_size_info do --- too many upvalues :/
+ --- rawdata -> (int * int * int | bool)
-local get_size_info = function (rawinfo)
- local design_size = rawinfo.design_size
- local design_range_top = rawinfo.design_range_top
- local design_range_bottom = rawinfo.design_range_bottom
+ get_size_info = function (rawinfo)
+ local design_size = rawinfo.design_size
+ local design_range_top = rawinfo.design_range_top
+ local design_range_bottom = rawinfo.design_range_bottom
- local fallback_size = design_size ~= 0 and design_size
- or design_range_bottom ~= 0 and design_range_bottom
- or design_range_top ~= 0 and design_range_top
+ local fallback_size = design_size ~= 0 and design_size
+ or design_range_bottom ~= 0 and design_range_bottom
+ or design_range_top ~= 0 and design_range_top
- if fallback_size then
- design_size = (design_size or fallback_size) / 10
- design_range_top = (design_range_top or fallback_size) / 10
- design_range_bottom = (design_range_bottom or fallback_size) / 10
- return {
- design_size, design_range_top, design_range_bottom,
- }
- end
+ if fallback_size then
+ design_size = ((design_size or fallback_size) * 2^16) / 10
+ design_range_top = ((design_range_top or fallback_size) * 2^16) / 10
+ design_range_bottom = ((design_range_bottom or fallback_size) * 2^16) / 10
- return false
-end
+ design_size = (design_size * 7200) / 7227
+ design_range_top = (design_range_top * 7200) / 7227
+ design_range_bottom = (design_range_bottom * 7200) / 7227
+
+ return {
+ design_size, design_range_top, design_range_bottom,
+ }
+ end
+
+ return false
+ end
+end ---[local get_size_info]
--[[doc--
map_enlish_names -- Names-table for Lua fontloader objects. This
@@ -1913,7 +1948,7 @@ local create_blacklist = function (blacklist, whitelist)
if p_blacklist == nil then
--- always return false
- p_blacklist = Cc(false)
+ p_blacklist = lpeg.Cc(false)
end
return result
@@ -2605,7 +2640,7 @@ do
polluting the lookup table. What doesn’t work is, e. g.
treating weights > 500 as bold or allowing synonyms like
“heavy”, “black”.
- --]]--
+ --]]--
if width == normal_width then
if pfmweight == bold_weight then
--- bold spectrum matches
@@ -3560,6 +3595,7 @@ local api = {
local export = {
set_font_filter = set_font_filter,
+ set_size_dimension = set_size_dimension,
flush_lookup_cache = flush_lookup_cache,
save_lookups = save_lookups,
load = load_names,
@@ -3599,7 +3635,7 @@ return {
fonts.definers = fonts.definers or { resolvers = { } }
names.blacklist = blacklist
- names.version = 2.9
+ names.version = 4 --- increase monotonically
names.data = nil --- contains the loaded database
names.lookups = nil --- contains the lookup cache
diff --git a/src/luaotfload-letterspace.lua b/src/luaotfload-letterspace.lua
index 78df1d7..fd64c90 100644
--- a/src/luaotfload-letterspace.lua
+++ b/src/luaotfload-letterspace.lua
@@ -1,5 +1,5 @@
if not modules then modules = { } end modules ['letterspace'] = {
- version = "2.7",
+ version = "2.8",
comment = "companion to luaotfload-main.lua",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL; adapted by Philipp Gesang",
copyright = "PRAGMA ADE / ConTeXt Development Team",
@@ -61,7 +61,11 @@ local todirect = nodedirect.tonut
local tonode = nodedirect.tonode
local insert_node_before = nodedirect.insert_before
-local free_node = nodedirect.free
+local free_node = nodedirect.free -- may cause double free
+local free_node = function (n)
+ logreport ("term", 5, "letterspace", "not calling free_node(%d)", n)
+ -- free_node (n)
+end
local copy_node = nodedirect.copy
local new_node = nodedirect.new
@@ -348,7 +352,7 @@ kerncharacters = function (head)
end
start = c
setfield(s, "components", nil)
- --free_node(s) --> double free with multipart components
+ free_node(s) --> double free with multipart components
c = getfield (start, "components")
end
end
diff --git a/src/luaotfload-log.lua b/src/luaotfload-log.lua
index 5b2f1f3..ab38ffa 100644
--- a/src/luaotfload-log.lua
+++ b/src/luaotfload-log.lua
@@ -1,5 +1,5 @@
if not modules then modules = { } end modules ["luaotfload-log"] = {
- version = "2.7",
+ version = "2.8",
comment = "companion to Luaotfload",
author = "Khaled Hosny, Elie Roux, Philipp Gesang",
copyright = "Luaotfload Development Team",
@@ -14,6 +14,7 @@ because we lack a user interface to toggle per-subsystem tracing.
--doc]]--
local module_name = "luaotfload" --- prefix for messages
+local debug = debug
luaotfload = luaotfload or { }
luaotfload.log = luaotfload.log or { }
@@ -132,10 +133,33 @@ end
log.set_logout = set_logout
+local format_error_handler
+if debug then
+ local debugtraceback = debug.traceback
+ format_error_handler = function (err)
+ print ""
+ print (stringformat ("luaotfload error: %q", err))
+ print (stringformat ("Lua interpreter %s", debugtraceback ()))
+ print ""
+ end
+else
+ format_error_handler = function (err)
+ print ""
+ print (stringformat ("luaotfload error: %q", err))
+ print "Lua debug module not available; please enable for a backtrace"
+ print ""
+ end
+end
+
local basic_logger = function (category, fmt, ...)
- local res = { module_name, "|", category, ":" }
+ local res = { module_name, "|", category or "UNKNOWN", ":" }
if fmt then
- res [#res + 1] = stringformat (fmt, ...)
+ local ok, val = xpcall (stringformat, format_error_handler, fmt, ...)
+ if ok then
+ res [#res + 1] = val
+ else
+ res [#res + 1] = stringformat ("ERROR: %q", val)
+ end
end
texiowrite_nl (logout, tableconcat(res, " "))
end
@@ -354,4 +378,4 @@ local texioreporter = function (message)
end
texio.reporter = texioreporter
-
+--- vim:shiftwidth=4:expandtab:ft=lua
diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua
index 83ce5e7..14d5316 100644
--- a/src/luaotfload-main.lua
+++ b/src/luaotfload-main.lua
@@ -52,8 +52,8 @@ local authors = "\z
luaotfload.module = {
name = "luaotfload-main",
- version = 2.70003,
- date = "2016/06/16",
+ version = 2.80001,
+ date = "2017/01/29",
description = "OpenType layout system.",
author = authors,
copyright = authors,
@@ -246,8 +246,18 @@ local install_loaders = function ()
return loaders
end
+local luaotfload_initialized = false --- prevent multiple invocations
+
luaotfload.main = function ()
+ if luaotfload_initialized then
+ logreport ("log", 0, "load",
+ "Luaotfload initialization requested but is already \z
+ loaded, ignoring.")
+ return
+ end
+ luaotfload_initialized = true
+
luaotfload.loaders = install_loaders ()
local loaders = luaotfload.loaders
local loadmodule = loaders.luaotfload
diff --git a/src/luaotfload-parsers.lua b/src/luaotfload-parsers.lua
index e056460..ffb6401 100644
--- a/src/luaotfload-parsers.lua
+++ b/src/luaotfload-parsers.lua
@@ -2,7 +2,7 @@
-------------------------------------------------------------------------------
-- FILE: luaotfload-parsers.lua
-- DESCRIPTION: various lpeg-based parsers used in Luaotfload
--- REQUIREMENTS: Luaotfload >= 2.7
+-- REQUIREMENTS: Luaotfload >= 2.8
-- AUTHOR: Philipp Gesang (Phg), <phg@phi-gamma.net>
-------------------------------------------------------------------------------
--
diff --git a/src/luaotfload.sty b/src/luaotfload.sty
index 112ec23..45744d1 100644
--- a/src/luaotfload.sty
+++ b/src/luaotfload.sty
@@ -1,4 +1,4 @@
-%% Copyright (C) 2009-2016
+%% Copyright (C) 2009-2017
%%
%% by Elie Roux <elie.roux@telecom-bretagne.eu>
%% and Khaled Hosny <khaledhosny@eglug.org>
@@ -41,7 +41,7 @@
\ProvidesPackage{luaotfload}%
%% FIXME The date is meaningless, we need to find a way to
%% use the git revision instead.
- [2016/06/16 v2.7 OpenType layout system]
+ [2017/01/29 v2.8 OpenType layout system]
\fi
\directlua{
require('luaotfload-main')