diff options
author | Karl Berry <karl@freefriends.org> | 2017-05-10 17:56:24 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-05-10 17:56:24 +0000 |
commit | 347d616d3cb26d19d9c79f8b0439712cf5f9012b (patch) | |
tree | 7e7766f16f342eb6a8fb4824d3c9e8376a65f2f1 /Master/texmf-dist/tex/context/base | |
parent | b74dd6fa976d54286d0465def3cbd3a725770307 (diff) |
context (May 9 10:39)
git-svn-id: svn://tug.org/texlive/trunk@44279 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkii/cont-new.mkii | 2 | ||||
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkii/context.mkii | 2 | ||||
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/cont-new.mkiv | 2 | ||||
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/context.mkiv | 2 | ||||
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/font-dsp.lua | 37 | ||||
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/font-otr.lua | 43 | ||||
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/font-sym.mkvi | 2 | ||||
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/font-ttf.lua | 112 | ||||
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/status-files.pdf | bin | 25664 -> 25656 bytes | |||
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/status-lua.pdf | bin | 424881 -> 424881 bytes | |||
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/util-fil.lua | 30 | ||||
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/util-sac.lua | 30 |
12 files changed, 166 insertions, 96 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkii/cont-new.mkii b/Master/texmf-dist/tex/context/base/mkii/cont-new.mkii index d75587f5661..293a87f1957 100644 --- a/Master/texmf-dist/tex/context/base/mkii/cont-new.mkii +++ b/Master/texmf-dist/tex/context/base/mkii/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2017.05.06 23:06} +\newcontextversion{2017.05.09 10:14} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/Master/texmf-dist/tex/context/base/mkii/context.mkii b/Master/texmf-dist/tex/context/base/mkii/context.mkii index dfbd7e33a06..ee0cb8adf20 100644 --- a/Master/texmf-dist/tex/context/base/mkii/context.mkii +++ b/Master/texmf-dist/tex/context/base/mkii/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2017.05.06 23:06} +\edef\contextversion{2017.05.09 10:14} %D For those who want to use this: diff --git a/Master/texmf-dist/tex/context/base/mkiv/cont-new.mkiv b/Master/texmf-dist/tex/context/base/mkiv/cont-new.mkiv index c539cac7e4e..8412a0bce13 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/cont-new.mkiv +++ b/Master/texmf-dist/tex/context/base/mkiv/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2017.05.06 23:06} +\newcontextversion{2017.05.09 10:14} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/Master/texmf-dist/tex/context/base/mkiv/context.mkiv b/Master/texmf-dist/tex/context/base/mkiv/context.mkiv index bc713993f04..be0623bd439 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/context.mkiv +++ b/Master/texmf-dist/tex/context/base/mkiv/context.mkiv @@ -39,7 +39,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2017.05.06 23:06} +\edef\contextversion{2017.05.09 10:14} \edef\contextkind {beta} %D For those who want to use this: diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-dsp.lua b/Master/texmf-dist/tex/context/base/mkiv/font-dsp.lua index d43348cdfb1..b46e1b82cd2 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/font-dsp.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/font-dsp.lua @@ -307,11 +307,13 @@ end) -- italic = "ital", -- }, "self") +-- todo: spaces in name but not before : + local pattern = lpeg.Cf ( lpeg.Ct("") * lpeg.Cg ( --(lpeg.R("az")^1/names) * lpeg.S(" :") * - lpeg.C(lpeg.R("az")^1) * lpeg.S(" :=") * + lpeg.C((lpeg.R("az","09")+lpeg.P(" "))^1) * lpeg.S(" :=") * (lpeg.patterns.number/tonumber) * lpeg.S(" ,")^0 )^1, rawset ) @@ -371,7 +373,10 @@ local function getaxisscale(segments,minimum,default,maximum,user) local e for i=1,#segments do local s = segments[i] - if s[1] >= default then + if type(s) ~= "number" then + report("using default axis scale") + return default + elseif s[1] >= default then if s[2] == default then return default else @@ -3329,7 +3334,7 @@ function readers.stat(f,fontdata,specification) end -- The avar table is optional and used in combination with fvar. Given the --- detailed explanation about bad valeus we expect the worst and do some +-- detailed explanation about bad values we expect the worst and do some -- checking. function readers.avar(f,fontdata,specification) @@ -3337,7 +3342,7 @@ function readers.avar(f,fontdata,specification) if tableoffset then local function collect() - local nofvalues = readulong(f) + local nofvalues = readushort(f) local values = { } local lastfrom = false local lastto = false @@ -3349,7 +3354,7 @@ function readers.avar(f,fontdata,specification) -- ignore else values[#values+1] = { f, t } - lasfrom, lastto = f, t + lastfrom, lastto = f, t end end nofvalues = #values @@ -3358,7 +3363,7 @@ function readers.avar(f,fontdata,specification) if some[1] == -1 and some[2] == -1 then some = values[nofvalues] if some[1] == 1 and some[2] == 1 then - for i=2,size-1 do + for i=2,nofvalues-1 do some = values[i] if some[1] == 0 and some[2] == 0 then return values @@ -3370,10 +3375,11 @@ function readers.avar(f,fontdata,specification) return false end - local version = readulong(f) -- 1.0 - local reserved = readulong(f) - local nofaxis = readulong(f) - local segments = { } + local majorversion = readushort(f) -- 1 + local minorversion = readushort(f) -- 0 + local reserved = readushort(f) + local nofaxis = readushort(f) + local segments = { } for i=1,nofaxis do segments[i] = collect() end @@ -3403,9 +3409,9 @@ function readers.fvar(f,fontdata,specification) 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 + minimum = readfixed(f), + default = readfixed(f), + maximum = readfixed(f), flags = readushort(f), name = lower(extras[readushort(f)] or "bad name"), } @@ -3425,10 +3431,6 @@ function readers.fvar(f,fontdata,specification) local flags = readushort(f) -- 0, not used yet local values = { } for i=1,nofaxis do - -- depends on what we want to see: - -- - -- values[axis[i].tag] = readfixed(f) - -- values[i] = { axis = axis[i].tag, value = readfixed(f), @@ -3516,6 +3518,7 @@ function readers.hvar(f,fontdata,specification) innerindex[i] = band(mapdata,innermask) end -- use last entry when no match i + setvariabledata(fontdata,"hvarwidths",true) local glyphs = fontdata.glyphs for i=0,fontdata.nofglyphs-1 do local glyph = glyphs[i] diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-otr.lua b/Master/texmf-dist/tex/context/base/mkiv/font-otr.lua index 977be70a6a5..3addf332493 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/font-otr.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/font-otr.lua @@ -2075,6 +2075,39 @@ local function readdata(f,offset,specification) if variablefonts_supported then + local variabledata = fontdata.variabledata + + if variabledata then + local instances = variabledata.instances + local axis = variabledata.axis + if axis and (not instances or #instances == 0) then + instances = { } + variabledata.instances = instances + local function add(n,subfamily,value) + local values = { } + for i=1,#axis do + local a = axis[i] + values[i] = { + axis = a.tag, + value = i == n and value or a.default, + } + end + instances[#instances+1] = { + subfamily = subfamily, + values = values, + } + end + for i=1,#axis do + local a = axis[i] + local tag = a.tag + add(i,"default"..tag,a.default) + add(i,"minimum"..tag,a.minimum) + add(i,"maximum"..tag,a.maximum) + end + -- report("%i fake instances added",#instances) + end + end + if not specification.factors then local instance = specification.instance if type(instance) == "string" then @@ -2089,19 +2122,19 @@ local function readdata(f,offset,specification) end end end + if not fontdata.factors then if fontdata.variabledata then local factors = helpers.getfactors(fontdata,true) if factors then specification.factors = factors - fontdata.factors = factors - fontdata.instance = instance - report("font instance: %s, factors: % t",instance,factors) + fontdata.factors = factors + report("factors: % t",factors) else - report("user instance: %s, bad factors",instance) + report("bad factors") end else - report("unknown instance") + -- report("unknown instance") end end diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-sym.mkvi b/Master/texmf-dist/tex/context/base/mkiv/font-sym.mkvi index c1ffd6361ae..0e709f161a7 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/font-sym.mkvi +++ b/Master/texmf-dist/tex/context/base/mkiv/font-sym.mkvi @@ -173,6 +173,8 @@ \unexpanded\def\getnamedglyphdirect#fontname#character{{\setdirectsymbolicfont{#fontname}\clf_fontchar{#character}}} \unexpanded\def\getglyphstyled #fontname#character{{\setstyledsymbolicfont{#fontname}\doifelsenumber{#character}\char\donothing#character}} \unexpanded\def\getglyphdirect #fontname#character{{\setdirectsymbolicfont{#fontname}\doifelsenumber{#character}\char\donothing#character}} +\unexpanded\def\resolvedglyphstyled#fontname#character{{\setstyledsymbolicfont{#fontname}\clf_tochar{#character}}} +\unexpanded\def\resolvedglyphdirect#fontname#character{{\setdirectsymbolicfont{#fontname}\clf_tochar{#character}}} % this one is wrong: diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-ttf.lua b/Master/texmf-dist/tex/context/base/mkiv/font-ttf.lua index 290a3dfe879..37b30f31448 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/font-ttf.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/font-ttf.lua @@ -40,6 +40,8 @@ local concat = table.concat local report = logs.reporter("otf reader","ttf") +local trace_deltas = false + local readers = fonts.handlers.otf.readers local streamreader = readers.streamreader @@ -154,14 +156,15 @@ end -- We had two loops (going backward) but can do it in one loop .. but maybe we -- should only accept fonts with proper hvar tables. -local function applyaxis(glyph,shape,points,deltas) +local function applyaxis(glyph,shape,deltas,dowidth) + local points = shape.points if points then local nofpoints = #points --- local h = nofpoints + 2 -- weird, the example font seems to have left first --- ----- l = nofpoints + 2 --- ----- v = nofpoints + 3 --- ----- t = nofpoints + 4 --- local width = glyph.width + local h = nofpoints + 1 -- weird, the example font seems to have left first + ----- l = nofpoints + 2 + ----- v = nofpoints + 3 + ----- t = nofpoints + 4 + local width = dowidth and glyph.width -- what if hvar for i=1,#deltas do local deltaset = deltas[i] local xvalues = deltaset.xvalues @@ -176,30 +179,22 @@ local function applyaxis(glyph,shape,points,deltas) local p = points[d] if p then if xvalues then - local x = xvalues[d] + local x = xvalues[i] if x and x ~= 0 then p[1] = p[1] + factor * x end end if yvalues then - local y = yvalues[d] + local y = yvalues[i] if y and y ~= 0 then p[2] = p[2] + factor * y end end - elseif width then --- weird one-off and bad values --- --- if d == h then --- print("index",d) --- inspect(dpoints) --- inspect(xvalues) --- local x = xvalues[i] --- if x then --- print("phantom h advance",width,factor*x) --- width = width + factor * x --- end --- end + elseif width then -- and p == h then + local x = xvalues[d+1] + if x then + width = width + factor * x + end end end else @@ -218,10 +213,24 @@ local function applyaxis(glyph,shape,points,deltas) end end end --- todo : phantom point hadvance + if width then + local x = xvalues[h] + if x then + width = width + factor * x + end + end end end --- glyph.width = width + -- for i=1,nofpoints do + -- local p = points[i] + -- p[1] = round(p[1]) + -- p[2] = round(p[2]) + -- end + if width then + glyph.width = width + end + else + report("no points for glyph %a",glyph.name) end end @@ -935,8 +944,10 @@ local function readpoints(f) else if count < 128 then -- no second byte, use count + elseif bittest(count,0x80) then + count = band(count,0x7F) * 256 + readbyte(f) else - count = band(count,0x80) * 256 + readbyte(f) + -- bad news end local points = { } local p = 0 @@ -1055,15 +1066,16 @@ function readers.gvar(f,fontdata,specification,glyphdata,shapedata) local data = { } local tuples = { } local glyphdata = fontdata.glyphs + local dowidth = fontdata.variabledata.hvarwidths -- there is one more offset (so that one can calculate the size i suppose) -- so we could test for overflows but we simply assume sane font files if bittest(flags,0x0001) then - for i=1,nofglyphs do - data[i] = readulong(f) + for i=1,nofglyphs+1 do + data[i] = dataoffset + readulong(f) end else - for i=1,nofglyphs do - data[i] = 2*readushort(f) + for i=1,nofglyphs+1 do + data[i] = dataoffset + 2*readushort(f) end end -- @@ -1073,15 +1085,22 @@ function readers.gvar(f,fontdata,specification,glyphdata,shapedata) tuples[i] = readtuplerecord(f,nofaxis) end end - local lastoffset = false + local nextoffset = false + local startoffset = data[1] for i=1,nofglyphs do -- hm one more cf spec - local startoffset = dataoffset + data[i] - if startoffset == lastoffset then - -- no deltas + nextoffset = data[i+1] + local glyph = glyphdata[i-1] + local name = trace_deltas and glyph.name + if startoffset == nextoffset then + if name then + report("no deltas for glyph %a",name) + end else local shape = shapedata[i-1] -- todo 0 if not shape then - -- no shape + if name then + report("no shape for glyph %a",name) + end else lastoffset = startoffset setposition(f,startoffset) @@ -1121,7 +1140,7 @@ function readers.gvar(f,fontdata,specification,glyphdata,shapedata) -- advance = advance + 2*nofaxis else if index+1 > #tuples then - print("error, bad index",index) + report("error, bad tuple index",index) end peak = tuples[index+1] -- hm, needs checking, only peak? end @@ -1182,7 +1201,11 @@ function readers.gvar(f,fontdata,specification,glyphdata,shapedata) -- * 1 end end - if s ~= 0 then + if s == 0 then + if name then + report("no deltas applied for glyph %a",name) + end + else deltas[#deltas+1] = { factor = s, points = points, @@ -1192,21 +1215,11 @@ function readers.gvar(f,fontdata,specification,glyphdata,shapedata) end end if shape.type == "glyph" then --- if fontdata.glyphs[i-1].name == "X" then --- if deltas then --- for i=1,#deltas do --- local d = deltas[i] --- local x = d.xvalues --- local y = d.yvalues --- if x and y then --- for i=1,#x do --- print(i-1,x[i],y[i]) --- end --- end --- end --- end +-- if glyph.name == "u1f31d" then +-- if glyph.unicode == 127773 then +-- inspect(deltas) -- end - applyaxis(glyphdata[i],shape,shape.points,deltas) + applyaxis(glyph,shape,deltas,dowidth) else -- todo: args_are_xy_values mess .. i have to be really bored -- and motivated to deal with it @@ -1214,6 +1227,7 @@ function readers.gvar(f,fontdata,specification,glyphdata,shapedata) end end end + startoffset = nextoffset end end end diff --git a/Master/texmf-dist/tex/context/base/mkiv/status-files.pdf b/Master/texmf-dist/tex/context/base/mkiv/status-files.pdf Binary files differindex 0440c4cd837..c6da00b9129 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/status-files.pdf +++ b/Master/texmf-dist/tex/context/base/mkiv/status-files.pdf diff --git a/Master/texmf-dist/tex/context/base/mkiv/status-lua.pdf b/Master/texmf-dist/tex/context/base/mkiv/status-lua.pdf Binary files differindex db8b36d2f05..89f2632f33a 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/status-lua.pdf +++ b/Master/texmf-dist/tex/context/base/mkiv/status-lua.pdf diff --git a/Master/texmf-dist/tex/context/base/mkiv/util-fil.lua b/Master/texmf-dist/tex/context/base/mkiv/util-fil.lua index de3c999b72e..01bcd571e9a 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/util-fil.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/util-fil.lua @@ -195,23 +195,41 @@ 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.readfixed2(f) local a, b = byte(f:read(2),1,2) if a >= 0x80 then - return (0x100 * a + b - 0x10000)/256.0 + return (a - 0x100) + b/0x100 else - return (0x100 * a + b)/256.0 + return (a ) + b/0x100 end end -- (real) (n>>16) + ((n&0xffff)/65536.0)) +-- function files.readfixed4(f) +-- local a, b, c, d = byte(f:read(4),1,4) +-- if a >= 0x80 then +-- return (0x1000000 * a + 0x10000 * b + 0x100 * c + d - 0x100000000)/65536.0 +-- else +-- return (0x1000000 * a + 0x10000 * b + 0x100 * c + d)/65536.0 +-- end +-- end + function files.readfixed4(f) local a, b, c, d = byte(f:read(4),1,4) if a >= 0x80 then - return (0x1000000 * a + 0x10000 * b + 0x100 * c + d - 0x100000000)/65536.0 + return (0x100 * a + b - 0x10000) + (0x100 * c + d)/0x10000 else - return (0x1000000 * a + 0x10000 * b + 0x100 * c + d)/65536.0 + return (0x100 * a + b ) + (0x100 * c + d)/0x10000 end end @@ -281,8 +299,8 @@ 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.readfixed2 = fio.readfixed2 -- needs recent luatex + -- files.readfixed4 = fio.readfixed4 -- needs recent luatex files.read2dot14 = fio.read2dot14 files.setposition = fio.setposition files.getposition = fio.getposition diff --git a/Master/texmf-dist/tex/context/base/mkiv/util-sac.lua b/Master/texmf-dist/tex/context/base/mkiv/util-sac.lua index 50bb14d3557..b509d9a9b7c 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/util-sac.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/util-sac.lua @@ -239,9 +239,9 @@ function streams.readfixed4(f) f[2] = j + 1 local a, b, c, d = byte(f[1],i,j) if a >= 0x80 then - return (0x1000000 * a + 0x10000 * b + 0x100 * c + d - 0x100000000)/65536.0 + return (0x100 * a + b - 0x10000) + (0x100 * c + d)/0x10000 else - return (0x1000000 * a + 0x10000 * b + 0x100 * c + d)/65536.0 + return (0x100 * a + b ) + (0x100 * c + d)/0x10000 end end @@ -251,9 +251,9 @@ function streams.readfixed2(f) f[2] = j + 1 local a, b = byte(f[1],i,j) if a >= 0x80 then - return (0x100 * a + b - 0x10000)/256.0 + return (a - 0x100) + b/0x100 else - return (0x100 * a + b)/256.0 + return (a ) + b/0x100 end end @@ -300,7 +300,7 @@ if sio and sio.readcardinal2 then local readfixed4 = sio.readfixed4 local read2dot14 = sio.read2dot14 local readbytes = sio.readbytes - local readbytetable = sio.readbytetable + local readbytetable = sio.readbytetable function streams.readcardinal1(f) local i = f[2] @@ -342,16 +342,16 @@ if sio and sio.readcardinal2 then f[2] = i + 4 return readinteger4(f[1],i) end - function streams.readfixed2(f) - local i = f[2] - f[2] = i + 2 - return readfixed2(f[1],i) - end - function streams.readfixed4(f) - local i = f[2] - f[2] = i + 4 - return readfixed4(f[1],i) - end + -- function streams.readfixed2(f) -- needs recent luatex + -- local i = f[2] + -- f[2] = i + 2 + -- return readfixed2(f[1],i) + -- end + -- function streams.readfixed4(f) -- needs recent luatex + -- local i = f[2] + -- f[2] = i + 4 + -- return readfixed4(f[1],i) + -- end function streams.read2dot4(f) local i = f[2] f[2] = i + 2 |