From d4cccf105bb508150dc765c93bb47bf6f9a87f81 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Tue, 29 Dec 2009 15:50:46 +0200 Subject: Updating to latest ConTeXt beta (2009.12.26) --- otfl-font-map.lua | 14 ++++---- otfl-font-otf.lua | 33 ++++++++++++++++--- otfl-font-otn.lua | 8 +++-- otfl-font-tfm.lua | 99 +++++++++++++++++++++++++++++-------------------------- 4 files changed, 93 insertions(+), 61 deletions(-) diff --git a/otfl-font-map.lua b/otfl-font-map.lua index 0dc4eca..4cb4976 100644 --- a/otfl-font-map.lua +++ b/otfl-font-map.lua @@ -31,7 +31,7 @@ function fonts.map.line.pdfmapline(tag,str) return "\\loadmapline[" .. tag .. "][" .. str .. "]" end -function fonts.map.line.pdftex(e) -- so far no combination of slant and stretch +function fonts.map.line.pdftex(e) -- so far no combination of slant and extend if e.name and e.fontfile then local fullname = e.fullname or "" if e.slant and e.slant ~= 0 then @@ -40,11 +40,11 @@ function fonts.map.line.pdftex(e) -- so far no combination of slant and stretch else return fonts.map.line.pdfmapline("=",format('%s %s "%g SlantFont" <%s',e.name,fullname,e.slant,e.fontfile)) end - elseif e.stretch and e.stretch ~= 1 and e.stretch ~= 0 then + elseif e.extend and e.extend ~= 1 and e.extend ~= 0 then if e.encoding then - return fonts.map.line.pdfmapline("=",format('%s %s "%g ExtendFont" <%s <%s',e.name,fullname,e.stretch,e.encoding,e.fontfile)) + return fonts.map.line.pdfmapline("=",format('%s %s "%g ExtendFont" <%s <%s',e.name,fullname,e.extend,e.encoding,e.fontfile)) else - return fonts.map.line.pdfmapline("=",format('%s %s "%g ExtendFont" <%s',e.name,fullname,e.stretch,e.fontfile)) + return fonts.map.line.pdfmapline("=",format('%s %s "%g ExtendFont" <%s',e.name,fullname,e.extend,e.fontfile)) end else if e.encoding then @@ -87,9 +87,9 @@ function fonts.map.load_file(filename, entries, encodings) if find(line,"^[%#%%%s]") then -- print(line) else - local stretch, slant, name, fullname, fontfile, encoding + local extend, slant, name, fullname, fontfile, encoding line = line:gsub('"(.+)"', function(s) - stretch = find(s,'"([^"]+) ExtendFont"') + extend = find(s,'"([^"]+) ExtendFont"') slant = find(s,'"([^"]+) SlantFont"') return "" end) @@ -113,7 +113,7 @@ function fonts.map.load_file(filename, entries, encodings) encoding = encoding, fontfile = fontfile, slant = tonumber(slant), - stretch = tonumber(stretch) + extend = tonumber(extend) } encodings[name] = encoding elseif line ~= "" then diff --git a/otfl-font-otf.lua b/otfl-font-otf.lua index 6900b84..e2f0f5b 100644 --- a/otfl-font-otf.lua +++ b/otfl-font-otf.lua @@ -83,7 +83,7 @@ otf.features.default = otf.features.default or { } otf.enhancers = otf.enhancers or { } otf.glists = { "gsub", "gpos" } -otf.version = 2.636 -- beware: also sync font-mis.lua +otf.version = 2.641 -- beware: also sync font-mis.lua otf.pack = true -- beware: also sync font-mis.lua otf.syncspace = true otf.notdef = false @@ -214,6 +214,7 @@ local enhancers = { "share widths", "strip not needed data", "migrate metadata", + "check math parameters", } function otf.load(filename,format,sub,featurefile) @@ -238,8 +239,12 @@ function otf.load(filename,format,sub,featurefile) ff, messages = fontloader.open(filename) end if trace_loading and messages and #messages > 0 then - for m=1,#messages do - logs.report("load otf","warning: %s",messages[m]) + if type(messages) == "string" then + logs.report("load otf","warning: %s",messages) + else + for m=1,#messages do + logs.report("load otf","warning: %s",tostring(messages[m])) + end end end if ff then @@ -1166,6 +1171,26 @@ otf.enhancers["migrate metadata"] = function(data,filename) metadata.charwidth = pfminfo and pfminfo.avgwidth end +local private_math_parameters = { + "FractionDelimiterSize", + "FractionDelimiterDisplayStyleSize", +} + +otf.enhancers["check math parameters"] = function(data,filename) + local mathdata = data.metadata.math + if mathdata then + for m=1,#private_math_parameters do + local pmp = private_math_parameters[m] + if not mathdata[pmp] then + if trace_loading then + logs.report("load otf", "setting math parameter '%s' to 0", pmp) + end + mathdata[pmp] = 0 + end + end + end +end + otf.enhancers["flatten glyph lookups"] = function(data,filename) for k, v in next, data.glyphs do if v.lookups then @@ -1505,8 +1530,6 @@ function otf.copy_to_tfm(data,cache_id) -- we can save a copy when we reorder th tfm.cidinfo = data.cidinfo tfm.cidinfo.registry = tfm.cidinfo.registry or "" tfm.type = "real" - tfm.stretch = 0 -- stretch - tfm.slant = 0 -- slant tfm.direction = 0 tfm.boundarychar_label = 0 tfm.boundarychar = 65536 diff --git a/otfl-font-otn.lua b/otfl-font-otn.lua index fb04b36..e58d773 100644 --- a/otfl-font-otn.lua +++ b/otfl-font-otn.lua @@ -327,6 +327,7 @@ local function toligature(kind,lookupname,start,stop,char,markflag,discfound) -- next.prev = lignode end lignode.next, lignode.prev = next, prev + start = lignode -- print("start->end",nodes.tosequence(start)) else -- start is the ligature local deletemarks = markflag ~= "mark" @@ -456,7 +457,8 @@ end function handlers.gsub_ligature(start,kind,lookupname,ligature,sequence) --or maybe pass lookup ref local s, stop, discfound = start.next, nil, false - if marks[start.char] then + local startchar = start.char + if marks[startchar] then while s do local id = s.id if id == glyph and s.subtype<256 then @@ -479,7 +481,7 @@ function handlers.gsub_ligature(start,kind,lookupname,ligature,sequence) --or ma end if stop and ligature[2] then if trace_ligatures then - local startchar, stopchar = start.char, stop.char + local stopchar = stop.char start = markstoligature(kind,lookupname,start,stop,ligature[2]) logprocess("%s: replacing %s upto %s by ligature %s",pref(kind,lookupname),gref(startchar),gref(stopchar),gref(start.char)) else @@ -518,7 +520,7 @@ function handlers.gsub_ligature(start,kind,lookupname,ligature,sequence) --or ma end if stop and ligature[2] then if trace_ligatures then - local startchar, stopchar = start.char, stop.char + local stopchar = stop.char start = toligature(kind,lookupname,start,stop,ligature[2],skipmark,discfound) logprocess("%s: replacing %s upto %s by ligature %s",pref(kind,lookupname),gref(startchar),gref(stopchar),gref(start.char)) else diff --git a/otfl-font-tfm.lua b/otfl-font-tfm.lua index efea9de..2ab28c7 100644 --- a/otfl-font-tfm.lua +++ b/otfl-font-tfm.lua @@ -234,6 +234,7 @@ function tfm.do_scale(tfmtable, scaledpoints) scaledpoints = (- scaledpoints/1000) * tfmtable.designsize -- already in sp end local delta = scaledpoints/(tfmtable.units or 1000) -- brr, some open type fonts have 2048 + local hdelta, vdelta = delta, delta local t = { } -- unicoded unique descriptions shared cidinfo characters changed parameters indices for k,v in next, tfmtable do @@ -243,6 +244,19 @@ function tfm.do_scale(tfmtable, scaledpoints) t[k] = v end end + local extend_factor = tfmtable.extend_factor or 0 + if extend_factor ~= 0 and extend_factor ~= 1 then + hdelta = hdelta * extend_factor + t.extend = extend_factor * 1000 + else + t.extend = 1000 + end + local slant_factor = tfmtable.slant_factor or 0 + if slant_factor ~= 0 then + t.slant = slant_factor * 1000 + else + t.slant = 0 + end -- status local isvirtual = tfmtable.type == "virtual" or tfmtable.virtualized local hasmath = (tfmtable.math_parameters ~= nil and next(tfmtable.math_parameters) ~= nil) or (tfmtable.MathConstants ~= nil and next(tfmtable.MathConstants) ~= nil) @@ -270,12 +284,12 @@ t.colorscheme = tfmtable.colorscheme local tfmp = tfmtable.parameters -- let's check for indexes -- tp.slant = (tfmp.slant or tfmp[1] or 0) - tp.space = (tfmp.space or tfmp[2] or 0)*delta - tp.space_stretch = (tfmp.space_stretch or tfmp[3] or 0)*delta - tp.space_shrink = (tfmp.space_shrink or tfmp[4] or 0)*delta - tp.x_height = (tfmp.x_height or tfmp[5] or 0)*delta - tp.quad = (tfmp.quad or tfmp[6] or 0)*delta - tp.extra_space = (tfmp.extra_space or tfmp[7] or 0)*delta + tp.space = (tfmp.space or tfmp[2] or 0)*hdelta + tp.space_stretch = (tfmp.space_stretch or tfmp[3] or 0)*hdelta + tp.space_shrink = (tfmp.space_shrink or tfmp[4] or 0)*hdelta + tp.x_height = (tfmp.x_height or tfmp[5] or 0)*vdelta + tp.quad = (tfmp.quad or tfmp[6] or 0)*hdelta + tp.extra_space = (tfmp.extra_space or tfmp[7] or 0)*hdelta local protrusionfactor = (tp.quad ~= 0 and 1000/tp.quad) or 0 local tc = t.characters local characters = tfmtable.characters @@ -292,11 +306,11 @@ t.colorscheme = tfmtable.colorscheme local sharedkerns, basekerns = tfm.check_base_kerns(tfmtable) -- loop over descriptions (afm and otf have descriptions, tfm not) -- there is no need (yet) to assign a value to chr.tonunicode - local scaledwidth = defaultwidth * delta - local scaledheight = defaultheight * delta - local scaleddepth = defaultdepth * delta + local scaledwidth = defaultwidth * hdelta + local scaledheight = defaultheight * vdelta + local scaleddepth = defaultdepth * vdelta local stackmath = tfmtable.ignore_stack_math ~= true -local private = fonts.private + local private = fonts.private for k,v in next, characters do local chr, description, index if ischanged then @@ -317,9 +331,9 @@ local private = fonts.private local width = description.width local height = description.height local depth = description.depth - if width then width = delta*width else width = scaledwidth end - if height then height = delta*height else height = scaledheight end - -- if depth then depth = delta*depth else depth = scaleddepth end + if width then width = hdelta*width else width = scaledwidth end + if height then height = vdelta*height else height = scaledheight end + -- if depth then depth = vdelta*depth else depth = scaleddepth end if depth and depth ~= 0 then depth = delta*depth if nameneeded then @@ -383,7 +397,7 @@ local private = fonts.private if hasitalic then local vi = description.italic or v.italic if vi and vi ~= 0 then - chr.italic = vi*delta + chr.italic = vi*hdelta end end -- to be tested @@ -399,19 +413,19 @@ local private = fonts.private for i=1,#vv do local vvi = vv[i] t[i] = { - ["start"] = (vvi["start"] or 0)*delta, - ["end"] = (vvi["end"] or 0)*delta, - ["advance"] = (vvi["advance"] or 0)*delta, + ["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 ---~ local ic = v.vert_italic_correction ---~ if ic then ---~ chr.italic = ic * delta ---~ print(format("0x%05X -> %s",k,chr.italic)) ---~ end + --~ local ic = v.vert_italic_correction + --~ if ic then + --~ chr.italic = ic * hdelta + --~ print(format("0x%05X -> %s",k,chr.italic)) + --~ end else local hv = v.horiz_variants if hv then @@ -419,9 +433,9 @@ local private = fonts.private for i=1,#hv do local hvi = hv[i] t[i] = { - ["start"] = (hvi["start"] or 0)*delta, - ["end"] = (hvi["end"] or 0)*delta, - ["advance"] = (hvi["advance"] or 0)*delta, + ["start"] = (hvi["start"] or 0)*hdelta, + ["end"] = (hvi["end"] or 0)*hdelta, + ["advance"] = (hvi["advance"] or 0)*hdelta, ["extender"] = hvi["extender"], ["glyph"] = hvi["glyph"], } @@ -432,31 +446,23 @@ local private = fonts.private end local vt = description.top_accent if vt then - chr.top_accent = delta*vt + chr.top_accent = vdelta*vt end if stackmath then local mk = v.mathkerns if mk then local kerns = { } - -- for k, v in next, mk do - -- local kk = { } - -- for i=1,#v do - -- local vi = v[i] - -- kk[i] = { height = delta*vi.height, kern = delta*vi.kern } - -- end - -- kerns[k] = kk - -- end local v = mk.top_right if v then local k = { } for i=1,#v do local vi = v[i] - k[i] = { height = delta*vi.height, kern = delta*vi.kern } + k[i] = { height = vdelta*vi.height, kern = vdelta*vi.kern } end kerns.top_right = k end local v = mk.top_left if v then local k = { } for i=1,#v do local vi = v[i] - k[i] = { height = delta*vi.height, kern = delta*vi.kern } + k[i] = { height = vdelta*vi.height, kern = vdelta*vi.kern } end kerns.top_left = k end local v = mk.bottom_left if v then local k = { } for i=1,#v do local vi = v[i] - k[i] = { height = delta*vi.height, kern = delta*vi.kern } + k[i] = { height = vdelta*vi.height, kern = vdelta*vi.kern } end kerns.bottom_left = k end local v = mk.bottom_right if v then local k = { } for i=1,#v do local vi = v[i] - k[i] = { height = delta*vi.height, kern = delta*vi.kern } + k[i] = { height = vdelta*vi.height, kern = vdelta*vi.kern } end kerns.bottom_right = k end chr.mathkern = kerns -- singular end @@ -469,13 +475,13 @@ local private = fonts.private local base = basekerns[vk] -- hashed by table id, not content if not base then base = {} - for k,v in next, vk do base[k] = v*delta end + for k,v in next, vk do base[k] = v*hdelta end basekerns[vk] = base end chr.kerns = base else local tt = {} - for k,v in next, vk do tt[k] = v*delta end + for k,v in next, vk do tt[k] = v*hdelta end chr.kerns = tt end end @@ -509,8 +515,10 @@ local private = fonts.private for i=1,#vc do local ivc = vc[i] local key = ivc[1] - if key == "right" or key == "down" then - tt[#tt+1] = { key, ivc[2]*delta } + if key == "right" then + tt[#tt+1] = { key, ivc[2]*hdelta } + elseif key == "down" then + tt[#tt+1] = { key, ivc[2]*vdelta } else -- not comment tt[#tt+1] = ivc -- shared since in cache and untouched end @@ -522,13 +530,12 @@ local private = fonts.private end end tc[k] = chr ---~ if k == 0x222B then ---~ print(t.fontname,table.serialize(chr)) ---~ end end -- t.encodingbytes, t.filename, t.fullname, t.name: elsewhere t.size = scaledpoints t.factor = delta + t.hfactor = hdelta + t.vfactor = vdelta if t.fonts then t.fonts = table.fastcopy(t.fonts) -- maybe we virtualize more afterwards end @@ -536,7 +543,7 @@ local private = fonts.private -- mathematics.extras.copy(t) -- can be done elsewhere if needed local ma = tfm.mathactions for i=1,#ma do - ma[i](t,tfmtable,delta) + ma[i](t,tfmtable,delta,hdelta,vdelta) -- what delta? end end -- needed for \high cum suis -- cgit v1.2.3