diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/font-con.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/font-con.lua | 179 |
1 files changed, 57 insertions, 122 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-con.lua b/Master/texmf-dist/tex/context/base/mkiv/font-con.lua index 354fd4ac393..add646da1ba 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/font-con.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/font-con.lua @@ -46,10 +46,9 @@ constructors.namemode = "fullpath" -- will be a function constructors.version = 1.01 constructors.cache = containers.define("fonts", "constructors", constructors.version, false) -constructors.privateoffset = fonts.privateoffsets.textbase or 0xF0000 -constructors.cacheintex = true -- so we see the original table in fonts.font +constructors.privateoffset = 0xF0000 -- 0x10FFFF | context also uses privates: 0xE000-0xEFFF -constructors.addtounicode = true +constructors.cacheintex = true -- so we see the original table in fonts.font -- This might become an interface: @@ -99,24 +98,6 @@ function constructors.getprivate(tfmdata) return private end -function constructors.setmathparameter(tfmdata,name,value) - local m = tfmdata.mathparameters - local c = tfmdata.MathConstants - if m then - m[name] = value - end - if c and c ~= m then - c[name] = value - end -end - -function constructors.getmathparameter(tfmdata,name) - local p = tfmdata.mathparameters or tfmdata.MathConstants - if p then - return p[name] - end -end - --[[ldx-- <p>Beware, the boundingbox is passed as reference so we may not overwrite it in the process; numbers are of course copies. Here 65536 equals 1pt. (Due to @@ -426,10 +407,7 @@ function constructors.scale(tfmdata,specification) targetparameters.forcedsize = forcedsize -- context specific targetparameters.extrafactor = extrafactor -- context specific -- - local addtounicode = constructors.addtounicode - -- local tounicode = fonts.mappings.tounicode - local unknowncode = tounicode(0xFFFD) -- local defaultwidth = resources.defaultwidth or 0 local defaultheight = resources.defaultheight or 0 @@ -477,8 +455,7 @@ function constructors.scale(tfmdata,specification) local psname = properties.psname or tfmdata.psname local name = properties.name or tfmdata.name -- - -- The psname used in pdf file as well as for selecting subfont in ttc although - -- we don't need that subfont look up here (mapfile stuff). + -- the psname used in pdf file as well as for selecting subfont in ttc -- local psname, psfixed = fixedpsname(psname,fontname or fullname or file.nameonly(filename)) -- @@ -500,28 +477,20 @@ function constructors.scale(tfmdata,specification) target.shrink = expansion.shrink target.step = expansion.step end - -- slanting - local slantfactor = parameters.slantfactor or 0 - if slantfactor ~= 0 then - target.slant = slantfactor * 1000 - else - target.slant = 0 - end -- widening local extendfactor = parameters.extendfactor or 0 if extendfactor ~= 0 and extendfactor ~= 1 then hdelta = hdelta * extendfactor - target.extend = extendfactor * 1000 + target.extend = extendfactor * 1000 -- extent ? else target.extend = 1000 -- extent ? end - -- squeezing - local squeezefactor = parameters.squeezefactor or 0 - if squeezefactor ~= 0 and squeezefactor ~= 1 then - vdelta = vdelta * squeezefactor - target.squeeze = squeezefactor * 1000 + -- slanting + local slantfactor = parameters.slantfactor or 0 + if slantfactor ~= 0 then + target.slant = slantfactor * 1000 else - target.squeeze = 1000 -- extent ? + target.slant = 0 end -- effects local mode = parameters.mode or 0 @@ -530,7 +499,7 @@ function constructors.scale(tfmdata,specification) end local width = parameters.width or 0 if width ~= 0 then - target.width = width * delta * 1000 / 655360 + target.width = width end -- targetparameters.factor = delta @@ -596,7 +565,6 @@ function constructors.scale(tfmdata,specification) targetparameters.descender = delta * descender end -- --- inspect(targetparameters) constructors.enhanceparameters(targetparameters) -- official copies for us, now virtual -- local protrusionfactor = (targetquad ~= 0 and 1000/targetquad) or 0 @@ -740,19 +708,11 @@ function constructors.scale(tfmdata,specification) end end local isunicode = description.unicode - if addtounicode then - if isunicode then - chr.unicode = isunicode - chr.tounicode = tounicode(isunicode) - -- in luatex > 0.85 we can do this: - -- chr.tounicode = isunicode - else - chr.tounicode = unknowncode - end - else - if isunicode then - chr.unicode = isunicode - end + if isunicode then + chr.unicode = isunicode + chr.tounicode = tounicode(isunicode) + -- in luatex > 0.85 we can do this: + -- chr.tounicode = isunicode end if hasquality then -- we could move these calculations elsewhere (saves calculations) @@ -782,15 +742,12 @@ function constructors.scale(tfmdata,specification) local t = { } for i=1,#vv do local vvi = vv[i] - local s = vvi["start"] or 0 - local e = vvi["end"] or 0 - local a = vvi["advance"] or 0 - t[i] = { -- zero check nicer for 5.3 - ["start"] = s == 0 and 0 or s * vdelta, - ["end"] = e == 0 and 0 or e * vdelta, - ["advance"] = a == 0 and 0 or a * vdelta, - ["extender"] = vvi["extender"], - ["glyph"] = vvi["glyph"], + t[i] = { + ["start"] = (vvi["start"] or 0)*vdelta, + ["end"] = (vvi["end"] or 0)*vdelta, + ["advance"] = (vvi["advance"] or 0)*vdelta, + ["extender"] = vvi["extender"], + ["glyph"] = vvi["glyph"], } end chr.vert_variants = t @@ -800,15 +757,12 @@ function constructors.scale(tfmdata,specification) local t = { } for i=1,#hv do local hvi = hv[i] - local s = hvi["start"] or 0 - local e = hvi["end"] or 0 - local a = hvi["advance"] or 0 - t[i] = { -- zero check nicer for 5.3 - ["start"] = s == 0 and 0 or s * hdelta, - ["end"] = e == 0 and 0 or e * hdelta, - ["advance"] = a == 0 and 0 or a * hdelta, - ["extender"] = hvi["extender"], - ["glyph"] = hvi["glyph"], + t[i] = { + ["start"] = (hvi["start"] or 0)*hdelta, + ["end"] = (hvi["end"] or 0)*hdelta, + ["advance"] = (hvi["advance"] or 0)*hdelta, + ["extender"] = hvi["extender"], + ["glyph"] = hvi["glyph"], } end chr.horiz_variants = t @@ -827,10 +781,7 @@ function constructors.scale(tfmdata,specification) if stackmath then local mk = character.mathkerns if mk then - local tr = mk.topright - local tl = mk.topleft - local br = mk.bottomright - local bl = mk.bottomleft + local tr, tl, br, bl = mk.topright, mk.topleft, mk.bottomright, mk.bottomleft chr.mathkern = { -- singular -> should be patched in luatex ! top_right = tr and mathkerns(tr,vdelta) or nil, top_left = tl and mathkerns(tl,vdelta) or nil, @@ -925,7 +876,7 @@ function constructors.scale(tfmdata,specification) else chr.commands = vc end - -- chr.index = nil + chr.index = nil end end targetcharacters[unicode] = chr @@ -935,14 +886,15 @@ function constructors.scale(tfmdata,specification) -- constructors.aftercopyingcharacters(target,tfmdata) -- - constructors.trytosharefont(target,tfmdata) + constructors.trytosharefont(target,tfmdata) -- -- catch inconsistencies -- local vfonts = target.fonts - if isvirtual or target.type == "virtual" or properties.virtualized then +-- if isvirtual then +if isvirtual or target.type == "virtual" or properties.virtualized then properties.virtualized = true - target.type = "virtual" +target.type = "virtual" if not vfonts or #vfonts == 0 then target.fonts = { { id = 0 } } end @@ -995,16 +947,12 @@ function constructors.finalize(tfmdata) parameters.width = 0 end -- - if not parameters.slantfactor then - parameters.slantfactor = tfmdata.slant or 0 - end - -- if not parameters.extendfactor then parameters.extendfactor = tfmdata.extend or 0 end -- - if not parameters.squeezefactor then - parameters.squeezefactor = tfmdata.squeeze or 0 + if not parameters.slantfactor then + parameters.slantfactor = tfmdata.slant or 0 end -- local designsize = parameters.designsize @@ -1040,22 +988,24 @@ function constructors.finalize(tfmdata) properties.virtualized = tfmdata.type == "virtual" end -- - properties.fontname = tfmdata.fontname - properties.filename = tfmdata.filename - properties.fullname = tfmdata.fullname - properties.name = tfmdata.name - properties.psname = tfmdata.psname - -- - properties.encodingbytes = tfmdata.encodingbytes or 1 - properties.embedding = tfmdata.embedding or "subset" - properties.tounicode = tfmdata.tounicode or 1 - properties.cidinfo = tfmdata.cidinfo or nil - properties.format = tfmdata.format or "type1" - properties.direction = tfmdata.direction or 0 - properties.writingmode = tfmdata.writingmode or "horizontal" - properties.identity = tfmdata.identity or "horizontal" - properties.usedbitmap = tfmdata.usedbitmap - -- + if not tfmdata.properties then + tfmdata.properties = { + fontname = tfmdata.fontname, + filename = tfmdata.filename, + fullname = tfmdata.fullname, + name = tfmdata.name, + psname = tfmdata.psname, + -- + encodingbytes = tfmdata.encodingbytes or 1, + embedding = tfmdata.embedding or "subset", + tounicode = tfmdata.tounicode or 1, + cidinfo = tfmdata.cidinfo or nil, + format = tfmdata.format or "type1", + direction = tfmdata.direction or 0, + writingmode = tfmdata.writingmode or "horizontal", + identity = tfmdata.identity or "horizontal", + } + end if not tfmdata.resources then tfmdata.resources = { } end @@ -1093,9 +1043,8 @@ function constructors.finalize(tfmdata) tfmdata.stretch = nil tfmdata.shrink = nil tfmdata.step = nil - tfmdata.slant = nil tfmdata.extend = nil - tfmdata.squeeze = nil + tfmdata.slant = nil tfmdata.mode = nil tfmdata.width = nil tfmdata.units = nil @@ -1148,18 +1097,7 @@ hashmethods.normal = function(list) -- no need to add to hash (maybe we need a skip list) else n = n + 1 - if type(v) == "table" then - -- table.sequenced - local t = { } - local m = 0 - for k, v in next, v do - m = m + 1 - t[m] = k .. '=' .. tostring(v) - end - s[n] = k .. '={' .. concat(t,",") .. "}" - else - s[n] = k .. '=' .. tostring(v) - end + s[n] = k .. '=' .. tostring(v) end end if n > 0 then @@ -1177,9 +1115,7 @@ loose our testcases for <l n='luatex'/>.</p> --ldx]]-- function constructors.hashinstance(specification,force) - local hash = specification.hash - local size = specification.size - local fallbacks = specification.fallbacks + local hash, size, fallbacks = specification.hash, specification.size, specification.fallbacks if force or not hash then hash = constructors.hashfeatures(specification) specification.hash = hash @@ -1617,8 +1553,7 @@ end -- while typesetting function constructors.collectprocessors(what,tfmdata,features,trace,report) - local processes = { } - local nofprocesses = 0 + local processes, nofprocesses = { }, 0 if features and next(features) then local properties = tfmdata.properties local whathandler = handlers[what] |