diff options
Diffstat (limited to 'tex')
-rw-r--r-- | tex/context/base/mkii/cont-new.mkii | 2 | ||||
-rw-r--r-- | tex/context/base/mkii/context.mkii | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/cont-new.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/context.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/font-cff.lua | 21 | ||||
-rw-r--r-- | tex/context/base/mkiv/font-dsp.lua | 215 | ||||
-rw-r--r-- | tex/context/base/mkiv/font-otr.lua | 13 | ||||
-rw-r--r-- | tex/context/base/mkiv/l-string.lua | 21 | ||||
-rw-r--r-- | tex/context/base/mkiv/l-table.lua | 80 | ||||
-rw-r--r-- | tex/context/base/mkiv/luat-cnf.lua | 2 | ||||
-rw-r--r-- | tex/context/base/mkiv/status-files.pdf | bin | 25657 -> 25672 bytes | |||
-rw-r--r-- | tex/context/base/mkiv/status-lua.pdf | bin | 421009 -> 420238 bytes | |||
-rw-r--r-- | tex/context/base/mkiv/util-fil.lua | 24 | ||||
-rw-r--r-- | tex/context/base/mkiv/util-sac.lua | 13 | ||||
-rw-r--r-- | tex/context/base/mkiv/util-tab.lua | 141 | ||||
-rw-r--r-- | tex/context/interface/mkiv/i-context.pdf | bin | 804052 -> 804052 bytes | |||
-rw-r--r-- | tex/context/interface/mkiv/i-readme.pdf | bin | 60771 -> 60772 bytes | |||
-rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 258 |
18 files changed, 260 insertions, 536 deletions
diff --git a/tex/context/base/mkii/cont-new.mkii b/tex/context/base/mkii/cont-new.mkii index 49b0f149f..eed45203f 100644 --- a/tex/context/base/mkii/cont-new.mkii +++ b/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2017.03.02 10:05} +\newcontextversion{2017.03.02 22:23} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/mkii/context.mkii b/tex/context/base/mkii/context.mkii index b70b3dbc2..6a5f25120 100644 --- a/tex/context/base/mkii/context.mkii +++ b/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2017.03.02 10:05} +\edef\contextversion{2017.03.02 22:23} %D For those who want to use this: diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 51e03207c..c603af8ba 100644 --- a/tex/context/base/mkiv/cont-new.mkiv +++ b/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2017.03.02 10:05} +\newcontextversion{2017.03.02 22:23} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/mkiv/context.mkiv b/tex/context/base/mkiv/context.mkiv index 8123bc4ed..d12ba09be 100644 --- a/tex/context/base/mkiv/context.mkiv +++ b/tex/context/base/mkiv/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2017.03.02 10:05} +\edef\contextversion{2017.03.02 22:23} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/font-cff.lua b/tex/context/base/mkiv/font-cff.lua index e6f47e40b..37436fbcf 100644 --- a/tex/context/base/mkiv/font-cff.lua +++ b/tex/context/base/mkiv/font-cff.lua @@ -21,12 +21,13 @@ if not modules then modules = { } end modules ['font-cff'] = { -- flush is nicer. local next, type, tonumber = next, type, tonumber -local byte = string.byte +local byte, gmatch = string.byte, string.gmatch local concat, remove = table.concat, table.remove local floor, abs, round, ceil, min, max = math.floor, math.abs, math.round, math.ceil, math.min, math.max local P, C, R, S, C, Cs, Ct = lpeg.P, lpeg.C, lpeg.R, lpeg.S, lpeg.C, lpeg.Cs, lpeg.Ct local lpegmatch = lpeg.match local formatters = string.formatters +local bytetable = string.bytetable local readers = fonts.handlers.otf.readers local streamreader = readers.streamreader @@ -1325,10 +1326,6 @@ do end local tab = list[index] if tab then --- if type(tab) == "string" then --- tab = { byte(tab,1,#tab) } --- list[index] = tab --- end process(tab) else showstate(formatters["unknown %s call %i"](scope,index)) @@ -1516,10 +1513,7 @@ do local defaultwidth = private.data.defaultwidthx or 0 for i=1,#charstrings do - local tab = charstrings[i] --- if type(tab) == "string" then -- no real need as wel nil charstrings[i] at the end - tab = { byte(tab,1,#tab) } --- end + local tab = bytetable(charstrings[i]) local index = i - 1 x = 0 y = 0 @@ -1599,10 +1593,7 @@ do local nominalwidth = private and private.data.nominalwidthx or 0 local defaultwidth = private and private.data.defaultwidthx or 0 -- --- if type(tab) == "string" then - -- a helper is not much faster but might be nicer for the stack - tab = { byte(tab,1,#tab) } --- end + tab = bytetable(tab) -- x = 0 y = 0 @@ -1872,14 +1863,14 @@ local function readfdselect(f,data,glyphs,doshapes,version) end for i=1,#charstrings do parsecharstring(data,dictionaries[fdindex[i]+1],charstrings[i],glyphs,i,doshapes,version) -charstrings[i] = nil + charstrings[i] = nil end resetcharstrings() end end function readers.cff(f,fontdata,specification) --- if specification.glyphs then + -- if specification.glyphs then if specification.details then local datatable = fontdata.tables.cff if datatable then diff --git a/tex/context/base/mkiv/font-dsp.lua b/tex/context/base/mkiv/font-dsp.lua index c336441e3..09c6aea3d 100644 --- a/tex/context/base/mkiv/font-dsp.lua +++ b/tex/context/base/mkiv/font-dsp.lua @@ -50,6 +50,9 @@ if not modules then modules = { } end modules ['font-dsp'] = { local next, type = next, type local bittest = bit32.btest +local band = bit32.band +local bor = bit32.bor +local lshift = bit32.lshift local rshift = bit32.rshift local concat = table.concat local lower = string.lower @@ -83,6 +86,8 @@ local read2dot14 = streamreader.read2dot14 local skipshort = streamreader.skipshort local skipbytes = streamreader.skip local readfword = readshort +local readbytetable = streamreader.readbytetable +local readbyte = streamreader.readbyte local gsubhandlers = { } local gposhandlers = { } @@ -2442,213 +2447,3 @@ function readers.svg(f,fontdata,specification) fontdata.hascolor = true end end - --- This next few are work in progress. I have no fonts that have these tables so it's a --- gamble. I'll pick up this thread some day (if needed at all). See font-tst.tex for a --- possible test. Something for a rainy day and a stack of fresh cd's. - -function readers.fvar(f,fontdata,specification) - local datatable = fontdata.tables.fvar - if datatable then - local tableoffset = datatable.offset - setposition(f,tableoffset) - local majorversion = readushort(f) -- 1 - local minorversion = readushort(f) -- 0 - if majorversion ~= 1 and minorversion ~= 0 then - report("table version %a.%a of %a is not supported (yet), maybe font %s is bad", - majorversion,minorversion,"fvar",fontdata.filename) - return - end - local offsettoaxis = tableoffset + readushort(f) - local nofsizepairs = readushort(f) -- 2 count/size pairs - -- pair 1 - local nofaxis = readushort(f) - local sizeofaxis = readushort(f) - -- pair 2 - local nofinstances = readushort(f) - local sizeofinstances = readushort(f) - -- - local extras = fontdata.extras - local axis = { } - local instances = { } - -- - setposition(f,offsettoaxis) - -- - local function readtuple(f) - local t = { } - for i=1,nofaxis do - t[i] = readfixed(f) - end - return t - end - -- - for i=1,nofaxis do - axis[i] = { - tag = readtag(f), -- ital opsz slnt wdth wght - minimum = readfixed(f), -- we get weird values from a test font ... to be checked - default = readfixed(f), -- idem - maximum = readfixed(f), -- idem - flags = readushort(f), - nameid = extras[readushort(f)], - } - local n = sizeofaxis - 20 - if n > 0 then - skipbytes(f,n) - elseif n < 0 then - -- error - end - end - -- - for i=1,nofinstances do - local subfamid = readushort(f) - local flags = readushort(f) - local tuple = readtuple(f) - local psnameid = false - local nofbytes = 2 + 2 + #tuple * 2 - if nofbytes < sizeofinstances then - psnameid = readushort(f) - nofbytes = nofbytes + 2 - end - instances[i] = { - subfamily = extras[subfamid], - flags = flags, - tuple = tuple, - psname = extras[psnameid] or nil, - } - if nofbytes > 0 then - skipbytes(f,nofbytes) - end - end - -- - fontdata.variable = { - axis = axis, - instances = instances, - } - end -end - --- function readers.gvar(f,fontdata,specification) --- end - --- function readers.hvar(f,fontdata,specification) --- end - --- function readers.vvar(f,fontdata,specification) --- end - --- We don't need all these dimensions so we only mention those that make --- sense. Mapping to some function makes most sense. - -local tags = { - hasc = "", -- horizontal ascender OS/2.sTypoAscender - hdsc = "", -- horizontal descender OS/2.sTypoDescender - -- hlgp = "", -- horizontal line gap OS/2.sTypoLineGap - -- hcla = "", -- horizontal clipping ascent OS/2.usWinAscent - -- hcld = "", -- horizontal clipping descent OS/2.usWinDescent - vasc = "", -- vertical ascender vhea.ascent - vdsc = "", -- vertical descender vhea.descent - vlgp = "", -- vertical line gap vhea.lineGap - xhgt = "", -- x height OS/2.sxHeight - cpht = "", -- cap height OS/2.sCapHeight - -- sbxs = "", -- subscript em x size OS/2.ySubscriptXSize - -- sbys = "", -- subscript em y size OS/2.ySubscriptYSize - -- sbxo = "", -- subscript em x offset OS/2.ySubscriptXOffset - -- sbyo = "", -- subscript em y offset OS/2.ySubscriptYOffset - -- spxs = "", -- superscript em x size OS/2.ySuperscriptXSize - -- spys = "", -- superscript em y size OS/2.ySuperscriptYSize - -- spxo = "", -- superscript em x offset OS/2.ySuperscriptXOffset - -- spyo = "", -- superscript em y offset OS/2.ySuperscriptYOffset - -- strs = "", -- strikeout size OS/2.yStrikeoutSize - -- stro = "", -- strikeout offset OS/2.yStrikeoutPosition - -- unds = "", -- underline size post.underlineThickness - -- undo = "", -- underline offset post.underlinePosition -} - -function readers.mvar(f,fontdata,specification) - local datatable = fontdata.tables.mvar - if datatable then - local tableoffset = datatable.offset - setposition(f,tableoffset) - local majorversion = readushort(f) -- 1 - local minorversion = readushort(f) -- 0 - if majorversion ~= 1 and minorversion ~= 0 then - report("table version %a.%a of %a is not supported (yet), maybe font %s is bad", - majorversion,minorversion,"fvar",fontdata.filename) - return - end - -- - local nofaxis = readushort(f) - local recordsize = readushort(f) - local nofrecords = readushort(f) - local offsettostore = tableoffset + readushort(f) - local records = { } - local dimensions = { } - local store = { } - local regions = { } - -- - for i=1,nofrecords do - local tag = readtag(f) - if tags[tag] then - dimensions[tag] = { - outer = readushort(f), - inner = readushort(f), - } - else - skipshort(f,2) - end - end - -- - setposition(f,offsettostore) - local nofaxis = readushort(f) - local nofregions = readushort(f) - for i=1,nofregions do - local t = { } - for i=1,nofaxis do - t[i] = { - start = read2dot14(f), - peak = read2dot14(f), - stop = read2dot14(f), - } - end - regions[i] = t - end - -- - local format = readushort(f) -- 1 - local offset = offsettostore + readulong(f) - local nofdata = readushort(f) - local data = { } - for i=1,nofdata do - data[i] = readulong(f) + offset - end - for i=1,nofdata do - local offset = data[i] - setposition(f,offset) - local nofdeltas = readushort(f) - local nofshort = readushort(f) - local nofregions = readushort(f) - local deltas = { } - local regions = { } - local length = nofshort + nofregions - for i=1,nofregions do - regions[i] = readushort(f) - end - for i=1,nofdeltas do - local t = { } - for i=1,nofshort do - t[i] = readushort(f) - end - for i=1,nofregions do - t[nofshort+i] = readinteger(f) - end - deltas[i] = t - end - data[i] = { - regions = regions, - deltas = deltas, - } - end - end -end - --- function readers.vorg(f,fontdata,specification) --- end diff --git a/tex/context/base/mkiv/font-otr.lua b/tex/context/base/mkiv/font-otr.lua index 5d3609b35..43a059bb9 100644 --- a/tex/context/base/mkiv/font-otr.lua +++ b/tex/context/base/mkiv/font-otr.lua @@ -2047,11 +2047,11 @@ local function readdata(f,offset,specification) -- -- there are no proper fonts yet: -- - -- readtable("fvar",f,fontdata,specification) -- probably - -- readtable("hvar",f,fontdata,specification) - -- readtable("vvar",f,fontdata,specification) - -- readtable("mvar",f,fontdata,specification) -- probably - -- readtable("vorg",f,fontdata,specification) + readtable("fvar",f,fontdata,specification) -- probably + readtable("hvar",f,fontdata,specification) + readtable("vvar",f,fontdata,specification) + readtable("mvar",f,fontdata,specification) -- probably + readtable("vorg",f,fontdata,specification) -- fontdata.locations = nil fontdata.tables = nil @@ -2141,6 +2141,7 @@ local function loadfont(specification,n) glyphs = true, shapes = true, kerns = true, + variable = true, globalkerns = true, lookups = true, -- true or number: @@ -2207,6 +2208,7 @@ function readers.loadfont(filename,n) glyphs = true, shapes = false, lookups = true, + variable = true, -- kerns = true, -- globalkerns = true, -- only for testing, e.g. cambria has different gpos and kern subfont = n, @@ -2245,6 +2247,7 @@ function readers.loadfont(filename,n) mathconstants = fontdata.mathconstants, colorpalettes = fontdata.colorpalettes, svgshapes = fontdata.svgshapes, + variable = fontdata.variable, }, } end diff --git a/tex/context/base/mkiv/l-string.lua b/tex/context/base/mkiv/l-string.lua index be8f397ae..2e8c61196 100644 --- a/tex/context/base/mkiv/l-string.lua +++ b/tex/context/base/mkiv/l-string.lua @@ -212,3 +212,24 @@ end string.quote = string.quoted string.unquote = string.unquoted + +-- new + +if not string.bytetable then + + local limit = 5000 -- we can go to 8000 in luajit and much higher in lua if needed + + function string.bytetable(str) + local n = #str + if n > limit then + local t = { byte(str,1,limit) } + for i=limit+1,n do + t[i] = byte(str,i) + end + return t + else + return { byte(str,1,n) } + end + end + +end diff --git a/tex/context/base/mkiv/l-table.lua b/tex/context/base/mkiv/l-table.lua index 39357bd25..5deb795d1 100644 --- a/tex/context/base/mkiv/l-table.lua +++ b/tex/context/base/mkiv/l-table.lua @@ -486,7 +486,7 @@ local reserved = table.tohash { -- intercept a language inconvenience: no reserv 'NaN', 'goto', } --- local function simple_table(t) +-- local function is_simple_table(t) -- if #t > 0 then -- local n = 0 -- for _,v in next, t do @@ -520,29 +520,62 @@ local reserved = table.tohash { -- intercept a language inconvenience: no reserv -- return nil -- end -local function simple_table(t) +-- local function is_simple_table(t) +-- local nt = #t +-- if nt > 0 then +-- local n = 0 +-- for _,v in next, t do +-- n = n + 1 +-- -- if type(v) == "table" then +-- -- return nil +-- -- end +-- end +-- if n == nt then +-- local tt = { } +-- for i=1,nt do +-- local v = t[i] +-- local tv = type(v) +-- if tv == "number" then +-- if hexify then +-- tt[i] = format("0x%X",v) +-- else +-- tt[i] = tostring(v) -- tostring not needed +-- end +-- elseif tv == "string" then +-- tt[i] = format("%q",v) +-- elseif tv == "boolean" then +-- tt[i] = v and "true" or "false" +-- else +-- return nil +-- end +-- end +-- return tt +-- end +-- end +-- return nil +-- end + +local function is_simple_table(t) -- also used in util-tab so maybe public local nt = #t if nt > 0 then local n = 0 - for _,v in next, t do + for _, v in next, t do n = n + 1 - -- if type(v) == "table" then - -- return nil - -- end + if type(v) == "table" then + return nil + end end + -- local haszero = t[0] + local haszero = rawget(t,0) -- don't trigger meta if n == nt then local tt = { } for i=1,nt do local v = t[i] local tv = type(v) if tv == "number" then - if hexify then - tt[i] = format("0x%X",v) - else - tt[i] = tostring(v) -- tostring not needed - end + tt[i] = v -- not needed tostring(v) elseif tv == "string" then - tt[i] = format("%q",v) + tt[i] = format("%q",v) -- f_string(v) elseif tv == "boolean" then tt[i] = v and "true" or "false" else @@ -550,11 +583,30 @@ local function simple_table(t) end end return tt + elseif haszero and (n == nt + 1) then + local tt = { } + for i=0,nt do + local v = t[i] + local tv = type(v) + if tv == "number" then + tt[i+1] = v -- not needed tostring(v) + elseif tv == "string" then + tt[i+1] = format("%q",v) -- f_string(v) + elseif tv == "boolean" then + tt[i+1] = v and "true" or "false" + else + return nil + end + end + tt[1] = "[0] = " .. tt[1] + return tt end end return nil end +table.is_simple_table = is_simple_table + -- Because this is a core function of mkiv I moved some function calls -- inline. -- @@ -637,7 +689,7 @@ local function do_serialize(root,name,depth,level,indexed) if next(v) == nil then handle(format("%s {},",depth)) elseif inline then -- and #t > 0 - local st = simple_table(v) + local st = is_simple_table(v) if st then handle(format("%s { %s },",depth,concat(st,", "))) else @@ -723,7 +775,7 @@ local function do_serialize(root,name,depth,level,indexed) handle(format("%s [%q]={},",depth,k)) end elseif inline then - local st = simple_table(v) + local st = is_simple_table(v) if st then if tk == "number" then if hexify then diff --git a/tex/context/base/mkiv/luat-cnf.lua b/tex/context/base/mkiv/luat-cnf.lua index c26b4775b..4f2c6569e 100644 --- a/tex/context/base/mkiv/luat-cnf.lua +++ b/tex/context/base/mkiv/luat-cnf.lua @@ -64,7 +64,7 @@ function texconfig.init() "callback", "font", "img", "lang", "lua", "node", "pdf", "status", "tex", "texconfig", "texio", "token", }, extralua = { - "gzip", "zip", "zlib", "lfs", "ltn12", "mime", "socket", "md5", "profiler", "unicode", "utf", + "gzip", "zip", "zlib", "lfs", "ltn12", "mime", "socket", "md5", "fio", "unicode", "utf", }, extratex = { "epdf", "fontloader", "kpse", "mplib", diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex 81b4701a9..dbcb86a1f 100644 --- a/tex/context/base/mkiv/status-files.pdf +++ b/tex/context/base/mkiv/status-files.pdf diff --git a/tex/context/base/mkiv/status-lua.pdf b/tex/context/base/mkiv/status-lua.pdf Binary files differindex 5e2155247..637ce005e 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/base/mkiv/util-fil.lua b/tex/context/base/mkiv/util-fil.lua index 4e66ba461..d0ffe07c6 100644 --- a/tex/context/base/mkiv/util-fil.lua +++ b/tex/context/base/mkiv/util-fil.lua @@ -218,6 +218,15 @@ function files.readinteger4le(f) end end +function files.readfixed2(f) + local a, b = byte(f:read(2),1,2) + if a >= 0x80 then + return (0x100 * a + b - 0x10000)/256.0 + else + return (0x100 * a + b)/256.0 + end +end + function files.readfixed4(f) local a, b, c, d = byte(f:read(4),1,4) if a >= 0x80 then @@ -230,17 +239,13 @@ end if extract then + local extract = bit32.extract + local band = bit32.band + function files.read2dot14(f) local a, b = byte(f:read(2),1,2) local n = 0x100 * a + b - local m = extract(n,0,30) - if n > 0x7FFF then - n = extract(n,30,2) - return m/0x4000 - 4 - else - n = extract(n,30,2) - return n + m/0x4000 - end + return extract(n,14,2) + (band(n,0x3FFF) / 16384.0) end end @@ -291,12 +296,13 @@ if fio and fio.readcardinal1 then files.readinteger2 = fio.readinteger2 files.readinteger3 = fio.readinteger3 files.readinteger4 = fio.readinteger4 + files.readfixed2 = fio.readfixed2 files.readfixed4 = fio.readfixed4 files.read2dot14 = fio.read2dot14 files.setposition = fio.setposition files.getposition = fio.getposition - files.readbyte = files.readcardinel1 + files.readbyte = files.readcardinal1 files.readsignedbyte = files.readinteger1 files.readcardinal = files.readcardinal1 files.readinteger = files.readinteger1 diff --git a/tex/context/base/mkiv/util-sac.lua b/tex/context/base/mkiv/util-sac.lua index 1a52bfc58..ccdb162d4 100644 --- a/tex/context/base/mkiv/util-sac.lua +++ b/tex/context/base/mkiv/util-sac.lua @@ -190,20 +190,17 @@ end if extract then + + local extract = bit32.extract + local band = bit32.band + function streams.read2dot14(f) local i = f[2] local j = i + 1 f[2] = j + 1 local a, b = byte(f[1],i,j) local n = 0x100 * a + b - local m = extract(n,0,30) - if n > 0x7FFF then - n = extract(n,30,2) - return m/0x4000 - 4 - else - n = extract(n,30,2) - return n + m/0x4000 - end + return extract(n,14,2) + (band(n,0x3FFF) / 16384.0) end end diff --git a/tex/context/base/mkiv/util-tab.lua b/tex/context/base/mkiv/util-tab.lua index 0521a2a4f..fb2702228 100644 --- a/tex/context/base/mkiv/util-tab.lua +++ b/tex/context/base/mkiv/util-tab.lua @@ -564,99 +564,68 @@ local original_serialize = table.serialize -- the extensive one, the one we star -- latest lua for the value of #n (with holes) .. anyway for tracing purposes we want -- indices / keys being sorted, so it will never be real fast -local function serialize(root,name,specification) - - if type(specification) == "table" then - return original_serialize(root,name,specification) -- the original one - end - - local t -- = { } - local n = 1 - local unknown = false - --- local function simple_table(t) --- local ts = #t --- if ts > 0 then --- local n = 0 --- for _, v in next, t do --- n = n + 1 --- if type(v) == "table" then +local is_simple_table = table.is_simple_table + +-- local function is_simple_table(t) +-- local nt = #t +-- if nt > 0 then +-- local n = 0 +-- for _, v in next, t do +-- n = n + 1 +-- if type(v) == "table" then +-- return nil +-- end +-- end +-- -- local haszero = t[0] +-- local haszero = rawget(t,0) -- don't trigger meta +-- if n == nt then +-- local tt = { } +-- for i=1,nt do +-- local v = t[i] +-- local tv = type(v) +-- if tv == "number" then +-- tt[i] = v -- not needed tostring(v) +-- elseif tv == "string" then +-- tt[i] = format("%q",v) -- f_string(v) +-- elseif tv == "boolean" then +-- tt[i] = v and "true" or "false" +-- else -- return nil -- end -- end --- if n == ts then --- local tt = { } --- local nt = 0 --- for i=1,ts do --- local v = t[i] --- local tv = type(v) --- nt = nt + 1 --- if tv == "number" then --- tt[nt] = v --- elseif tv == "string" then --- tt[nt] = format("%q",v) -- f_string(v) --- elseif tv == "boolean" then --- tt[nt] = v and "true" or "false" --- else --- return nil --- end +-- return tt +-- elseif haszero and (n == nt + 1) then +-- local tt = { } +-- for i=0,nt do +-- local v = t[i] +-- local tv = type(v) +-- if tv == "number" then +-- tt[i+1] = v -- not needed tostring(v) +-- elseif tv == "string" then +-- tt[i+1] = format("%q",v) -- f_string(v) +-- elseif tv == "boolean" then +-- tt[i+1] = v and "true" or "false" +-- else +-- return nil -- end --- return tt -- end +-- tt[1] = "[0] = " .. tt[1] +-- return tt -- end --- return nil -- end +-- return nil +-- end - local function simple_table(t) - local nt = #t - if nt > 0 then - local n = 0 - for _, v in next, t do - n = n + 1 - if type(v) == "table" then - return nil - end - end - -- local haszero = t[0] - local haszero = rawget(t,0) -- don't trigger meta - if n == nt then - local tt = { } - for i=1,nt do - local v = t[i] - local tv = type(v) - if tv == "number" then - tt[i] = v -- not needed tostring(v) - elseif tv == "string" then - tt[i] = format("%q",v) -- f_string(v) - elseif tv == "boolean" then - tt[i] = v and "true" or "false" - else - return nil - end - end - return tt - elseif haszero and (n == nt + 1) then - local tt = { } - for i=0,nt do - local v = t[i] - local tv = type(v) - if tv == "number" then - tt[i+1] = v -- not needed tostring(v) - elseif tv == "string" then - tt[i+1] = format("%q",v) -- f_string(v) - elseif tv == "boolean" then - tt[i+1] = v and "true" or "false" - else - return nil - end - end - tt[1] = "[0] = " .. tt[1] - return tt - end - end - return nil +local function serialize(root,name,specification) + + if type(specification) == "table" then + return original_serialize(root,name,specification) -- the original one end + local t -- = { } + local n = 1 + local unknown = false + local function do_serialize(root,name,depth,level,indexed) if level > 0 then n = n + 1 @@ -706,7 +675,7 @@ local function serialize(root,name,specification) if next(v) == nil then -- tricky as next is unpredictable in a hash n = n + 1 t[n] = f_val_not(depth) else - local st = simple_table(v) + local st = is_simple_table(v) if st then n = n + 1 t[n] = f_val_seq(depth,st) else @@ -750,7 +719,7 @@ local function serialize(root,name,specification) n = n + 1 t[n] = f_key_str_value_not(depth,tostring(k)) end else - local st = simple_table(v) + local st = is_simple_table(v) if not st then do_serialize(v,k,depth,level+1) elseif tk == "number" then @@ -821,7 +790,7 @@ local function serialize(root,name,specification) end -- Let's forget about empty tables. if next(root) ~= nil then - local st = simple_table(root) + local st = is_simple_table(root) if st then return t[1] .. f_fin_seq(st) -- todo: move up and in one go else diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex d861de701..ef5687741 100644 --- a/tex/context/interface/mkiv/i-context.pdf +++ b/tex/context/interface/mkiv/i-context.pdf diff --git a/tex/context/interface/mkiv/i-readme.pdf b/tex/context/interface/mkiv/i-readme.pdf Binary files differindex 3ab1ec48f..59eabb096 100644 --- a/tex/context/interface/mkiv/i-readme.pdf +++ b/tex/context/interface/mkiv/i-readme.pdf diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 90077e8f7..2e5aa99c0 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.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 : 03/02/17 10:05:26 +-- merge date : 03/02/17 22:23:29 do -- begin closure to overcome local limits and interference @@ -1015,6 +1015,21 @@ function string.tformat(fmt,...) end string.quote=string.quoted string.unquote=string.unquoted +if not string.bytetable then + local limit=5000 + function string.bytetable(str) + local n=#str + if n>limit then + local t={ byte(str,1,limit) } + for i=limit+1,n do + t[i]=byte(str,i) + end + return t + else + return { byte(str,1,n) } + end + end +end end -- closure @@ -1351,26 +1366,26 @@ local reserved=table.tohash { 'in','local','nil','not','or','repeat','return','then','true','until','while', 'NaN','goto', } -local function simple_table(t) +local function is_simple_table(t) local nt=#t if nt>0 then local n=0 for _,v in next,t do n=n+1 + if type(v)=="table" then + return nil + end end + local haszero=rawget(t,0) if n==nt then local tt={} for i=1,nt do local v=t[i] local tv=type(v) if tv=="number" then - if hexify then - tt[i]=format("0x%X",v) - else - tt[i]=tostring(v) - end + tt[i]=v elseif tv=="string" then - tt[i]=format("%q",v) + tt[i]=format("%q",v) elseif tv=="boolean" then tt[i]=v and "true" or "false" else @@ -1378,10 +1393,28 @@ local function simple_table(t) end end return tt + elseif haszero and (n==nt+1) then + local tt={} + for i=0,nt do + local v=t[i] + local tv=type(v) + if tv=="number" then + tt[i+1]=v + elseif tv=="string" then + tt[i+1]=format("%q",v) + elseif tv=="boolean" then + tt[i+1]=v and "true" or "false" + else + return nil + end + end + tt[1]="[0] = "..tt[1] + return tt end end return nil end +table.is_simple_table=is_simple_table local propername=patterns.propername local function dummy() end local function do_serialize(root,name,depth,level,indexed) @@ -1443,7 +1476,7 @@ local function do_serialize(root,name,depth,level,indexed) if next(v)==nil then handle(format("%s {},",depth)) elseif inline then - local st=simple_table(v) + local st=is_simple_table(v) if st then handle(format("%s { %s },",depth,concat(st,", "))) else @@ -1526,7 +1559,7 @@ local function do_serialize(root,name,depth,level,indexed) handle(format("%s [%q]={},",depth,k)) end elseif inline then - local st=simple_table(v) + local st=is_simple_table(v) if st then if tk=="number" then if hexify then @@ -4402,6 +4435,14 @@ function files.readinteger4le(f) return n end end +function files.readfixed2(f) + local a,b=byte(f:read(2),1,2) + if a>=0x80 then + return (0x100*a+b-0x10000)/256.0 + else + return (0x100*a+b)/256.0 + end +end function files.readfixed4(f) local a,b,c,d=byte(f:read(4),1,4) if a>=0x80 then @@ -4411,17 +4452,12 @@ function files.readfixed4(f) end end if extract then + local extract=bit32.extract + local band=bit32.band function files.read2dot14(f) local a,b=byte(f:read(2),1,2) local n=0x100*a+b - local m=extract(n,0,30) - if n>0x7FFF then - n=extract(n,30,2) - return m/0x4000-4 - else - n=extract(n,30,2) - return n+m/0x4000 - end + return extract(n,14,2)+(band(n,0x3FFF)/16384.0) end end function files.skipshort(f,n) @@ -4461,11 +4497,12 @@ if fio and fio.readcardinal1 then files.readinteger2=fio.readinteger2 files.readinteger3=fio.readinteger3 files.readinteger4=fio.readinteger4 + files.readfixed2=fio.readfixed2 files.readfixed4=fio.readfixed4 files.read2dot14=fio.read2dot14 files.setposition=fio.setposition files.getposition=fio.getposition - files.readbyte=files.readcardinel1 + files.readbyte=files.readcardinal1 files.readsignedbyte=files.readinteger1 files.readcardinal=files.readcardinal1 files.readinteger=files.readinteger1 @@ -9478,6 +9515,11 @@ local function readdata(f,offset,specification) readtable("gsub",f,fontdata,specification) readtable("gpos",f,fontdata,specification) readtable("math",f,fontdata,specification) + readtable("fvar",f,fontdata,specification) + readtable("hvar",f,fontdata,specification) + readtable("vvar",f,fontdata,specification) + readtable("mvar",f,fontdata,specification) + readtable("vorg",f,fontdata,specification) fontdata.locations=nil fontdata.tables=nil fontdata.cidmaps=nil @@ -9563,6 +9605,7 @@ local function loadfont(specification,n) glyphs=true, shapes=true, kerns=true, + variable=true, globalkerns=true, lookups=true, subfont=n or true, @@ -9620,6 +9663,7 @@ function readers.loadfont(filename,n) glyphs=true, shapes=false, lookups=true, + variable=true, subfont=n, } if fontdata then @@ -9654,6 +9698,7 @@ function readers.loadfont(filename,n) mathconstants=fontdata.mathconstants, colorpalettes=fontdata.colorpalettes, svgshapes=fontdata.svgshapes, + variable=fontdata.variable, }, } end @@ -9744,12 +9789,13 @@ if not modules then modules={} end modules ['font-cff']={ license="see context related readme files" } local next,type,tonumber=next,type,tonumber -local byte=string.byte +local byte,gmatch=string.byte,string.gmatch local concat,remove=table.concat,table.remove local floor,abs,round,ceil,min,max=math.floor,math.abs,math.round,math.ceil,math.min,math.max local P,C,R,S,C,Cs,Ct=lpeg.P,lpeg.C,lpeg.R,lpeg.S,lpeg.C,lpeg.Cs,lpeg.Ct local lpegmatch=lpeg.match local formatters=string.formatters +local bytetable=string.bytetable local readers=fonts.handlers.otf.readers local streamreader=readers.streamreader local readstring=streamreader.readstring @@ -10939,8 +10985,7 @@ do local nominalwidth=private.data.nominalwidthx or 0 local defaultwidth=private.data.defaultwidthx or 0 for i=1,#charstrings do - local tab=charstrings[i] - tab={ byte(tab,1,#tab) } + local tab=bytetable(charstrings[i]) local index=i-1 x=0 y=0 @@ -11007,7 +11052,7 @@ do globalbias,localbias=setbias(globals,locals) local nominalwidth=private and private.data.nominalwidthx or 0 local defaultwidth=private and private.data.defaultwidthx or 0 - tab={ byte(tab,1,#tab) } + tab=bytetable(tab) x=0 y=0 width=false @@ -11246,7 +11291,7 @@ local function readfdselect(f,data,glyphs,doshapes,version) end for i=1,#charstrings do parsecharstring(data,dictionaries[fdindex[i]+1],charstrings[i],glyphs,i,doshapes,version) -charstrings[i]=nil + charstrings[i]=nil end resetcharstrings() end @@ -11737,6 +11782,9 @@ if not modules then modules={} end modules ['font-dsp']={ } local next,type=next,type local bittest=bit32.btest +local band=bit32.band +local bor=bit32.bor +local lshift=bit32.lshift local rshift=bit32.rshift local concat=table.concat local lower=string.lower @@ -11766,6 +11814,8 @@ local read2dot14=streamreader.read2dot14 local skipshort=streamreader.skipshort local skipbytes=streamreader.skip local readfword=readshort +local readbytetable=streamreader.readbytetable +local readbyte=streamreader.readbyte local gsubhandlers={} local gposhandlers={} local lookupidoffset=-1 @@ -13869,166 +13919,6 @@ function readers.svg(f,fontdata,specification) fontdata.hascolor=true end end -function readers.fvar(f,fontdata,specification) - local datatable=fontdata.tables.fvar - if datatable then - local tableoffset=datatable.offset - setposition(f,tableoffset) - local majorversion=readushort(f) - local minorversion=readushort(f) - if majorversion~=1 and minorversion~=0 then - report("table version %a.%a of %a is not supported (yet), maybe font %s is bad", - majorversion,minorversion,"fvar",fontdata.filename) - return - end - local offsettoaxis=tableoffset+readushort(f) - local nofsizepairs=readushort(f) - local nofaxis=readushort(f) - local sizeofaxis=readushort(f) - local nofinstances=readushort(f) - local sizeofinstances=readushort(f) - local extras=fontdata.extras - local axis={} - local instances={} - setposition(f,offsettoaxis) - local function readtuple(f) - local t={} - for i=1,nofaxis do - t[i]=readfixed(f) - end - return t - end - for i=1,nofaxis do - axis[i]={ - tag=readtag(f), - minimum=readfixed(f), - default=readfixed(f), - maximum=readfixed(f), - flags=readushort(f), - nameid=extras[readushort(f)], - } - local n=sizeofaxis-20 - if n>0 then - skipbytes(f,n) - elseif n<0 then - end - end - for i=1,nofinstances do - local subfamid=readushort(f) - local flags=readushort(f) - local tuple=readtuple(f) - local psnameid=false - local nofbytes=2+2+#tuple*2 - if nofbytes<sizeofinstances then - psnameid=readushort(f) - nofbytes=nofbytes+2 - end - instances[i]={ - subfamily=extras[subfamid], - flags=flags, - tuple=tuple, - psname=extras[psnameid] or nil, - } - if nofbytes>0 then - skipbytes(f,nofbytes) - end - end - fontdata.variable={ - axis=axis, - instances=instances, - } - end -end -local tags={ - hasc="", - hdsc="", - vasc="", - vdsc="", - vlgp="", - xhgt="", - cpht="", -} -function readers.mvar(f,fontdata,specification) - local datatable=fontdata.tables.mvar - if datatable then - local tableoffset=datatable.offset - setposition(f,tableoffset) - local majorversion=readushort(f) - local minorversion=readushort(f) - if majorversion~=1 and minorversion~=0 then - report("table version %a.%a of %a is not supported (yet), maybe font %s is bad", - majorversion,minorversion,"fvar",fontdata.filename) - return - end - local nofaxis=readushort(f) - local recordsize=readushort(f) - local nofrecords=readushort(f) - local offsettostore=tableoffset+readushort(f) - local records={} - local dimensions={} - local store={} - local regions={} - for i=1,nofrecords do - local tag=readtag(f) - if tags[tag] then - dimensions[tag]={ - outer=readushort(f), - inner=readushort(f), - } - else - skipshort(f,2) - end - end - setposition(f,offsettostore) - local nofaxis=readushort(f) - local nofregions=readushort(f) - for i=1,nofregions do - local t={} - for i=1,nofaxis do - t[i]={ - start=read2dot14(f), - peak=read2dot14(f), - stop=read2dot14(f), - } - end - regions[i]=t - end - local format=readushort(f) - local offset=offsettostore+readulong(f) - local nofdata=readushort(f) - local data={} - for i=1,nofdata do - data[i]=readulong(f)+offset - end - for i=1,nofdata do - local offset=data[i] - setposition(f,offset) - local nofdeltas=readushort(f) - local nofshort=readushort(f) - local nofregions=readushort(f) - local deltas={} - local regions={} - local length=nofshort+nofregions - for i=1,nofregions do - regions[i]=readushort(f) - end - for i=1,nofdeltas do - local t={} - for i=1,nofshort do - t[i]=readushort(f) - end - for i=1,nofregions do - t[nofshort+i]=readinteger(f) - end - deltas[i]=t - end - data[i]={ - regions=regions, - deltas=deltas, - } - end - end -end end -- closure |