diff options
Diffstat (limited to 'tex')
-rw-r--r-- | tex/context/base/context-version.pdf | bin | 4254 -> 4254 bytes | |||
-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-afm.lua | 57 | ||||
-rw-r--r-- | tex/context/base/mkiv/font-onr.lua | 44 | ||||
-rw-r--r-- | tex/context/base/mkiv/font-tfm.lua | 166 | ||||
-rw-r--r-- | tex/context/base/mkiv/status-files.pdf | bin | 9202 -> 9091 bytes | |||
-rw-r--r-- | tex/context/base/mkiv/status-lua.pdf | bin | 366280 -> 366358 bytes | |||
-rw-r--r-- | tex/context/interface/mkiv/i-context.pdf | bin | 821323 -> 821180 bytes | |||
-rw-r--r-- | tex/context/interface/mkiv/i-readme.pdf | bin | 60791 -> 60786 bytes | |||
-rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 160 | ||||
-rw-r--r-- | tex/generic/context/luatex/luatex-plain-tfm.lua | 63 | ||||
-rw-r--r-- | tex/generic/context/luatex/luatex-test.tex | 8 |
13 files changed, 430 insertions, 72 deletions
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex f6f778254..54e343a8c 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/mkiv/cont-new.mkiv b/tex/context/base/mkiv/cont-new.mkiv index 3f90812a0..79bb68bd3 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{2016.06.25 14:38} +\newcontextversion{2016.06.26 19:00} %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 a59a31463..425a152fa 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{2016.06.25 14:38} +\edef\contextversion{2016.06.26 19:00} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/mkiv/font-afm.lua b/tex/context/base/mkiv/font-afm.lua index 9b63095a3..b2e942c8c 100644 --- a/tex/context/base/mkiv/font-afm.lua +++ b/tex/context/base/mkiv/font-afm.lua @@ -41,6 +41,7 @@ local trace_loading = false trackers.register("afm.loading", function(v local trace_defining = false trackers.register("fonts.defining", function(v) trace_defining = v end) local report_afm = logs.reporter("fonts","afm loading") +local report_pfb = logs.reporter("fonts","pfb loading") local setmetatableindex = table.setmetatableindex @@ -293,20 +294,36 @@ do local initialize = function(str,position,size) n = 0 - m = tonumber(size) + m = size -- % tonumber(size) return position + 1 end - local charstrings = P("/CharStrings") - local name = P("/") * C((R("az")+R("AZ")+R("09")+S("-_."))^1) - local size = C(R("09")^1) - local spaces = P(" ")^1 + local charstrings = P("/CharStrings") + local encoding = P("/Encoding") + local dup = P("dup") + local put = P("put") + local array = P("array") + local name = P("/") * C((R("az")+R("AZ")+R("09")+S("-_."))^1) + local digits = R("09")^1 + local cardinal = digits / tonumber + local spaces = P(" ")^1 + local spacing = patterns.whitespace^0 local p_filternames = Ct ( - (1-charstrings)^0 * charstrings * spaces * Cmt(size,initialize) - * (Cmt(name * P(" ")^1 * C(R("09")^1), progress) + P(1))^1 + (1-charstrings)^0 * charstrings * spaces * Cmt(cardinal,initialize) + * (Cmt(name * spaces * cardinal, progress) + P(1))^1 ) + -- /Encoding 256 array + -- 0 1 255 {1 index exch /.notdef put} for + -- dup 0 /Foo put + + local p_filterencoding = + (1-encoding)^0 * encoding * spaces * digits * spaces * array * (1-dup)^0 + * Cf( + Ct("") * Cg(spacing * dup * spaces * cardinal * spaces * name * spaces * put)^1 + ,rawset) + -- if one of first 4 not 0-9A-F then binary else hex local decrypt @@ -343,20 +360,20 @@ do local data = io.loaddata(resolvers.findfile(filename)) - if not find(data,"!PS%-AdobeFont%-") then - print("no font",filename) + if not data then + report_pfb("no data in %a",filename) return end - if not data then - print("no data",filename) + if not (find(data,"!PS%-AdobeFont%-") or find(data,"%%!FontType1")) then + report_pfb("no font in %a",filename) return end local ascii, binary = match(data,"(.*)eexec%s+......(.*)") if not binary then - print("no binary",filename) + report_pfb("no binary data in %a",filename) return end @@ -364,17 +381,26 @@ do local vector = lpegmatch(p_filternames,binary) - vector[0] = table.remove(vector,1) + if vector[1] == ".notdef" then + -- tricky + vector[0] = table.remove(vector,1) + end if not vector then - print("no vector",filename) + report_pfb("no vector in %a",filename) return end - return vector + local encoding = lpegmatch(p_filterencoding,ascii) + + return vector, encoding end + local pfb = handlers.pfb or { } + handlers.pfb = pfb + pfb.loadvector = loadpfbvector + get_indexes = function(data,pfbname) local vector = loadpfbvector(pfbname) if vector then @@ -410,6 +436,7 @@ do end + end local function readafm(filename) diff --git a/tex/context/base/mkiv/font-onr.lua b/tex/context/base/mkiv/font-onr.lua index a4969ad73..d03a9df89 100644 --- a/tex/context/base/mkiv/font-onr.lua +++ b/tex/context/base/mkiv/font-onr.lua @@ -21,19 +21,19 @@ add features.</p> local fonts, logs, trackers, resolvers = fonts, logs, trackers, resolvers -local next, type, tonumber, rawget = next, type, tonumber, rawget +local next, type, tonumber, rawget, rawset = next, type, tonumber, rawget, rawset local match, lower, gsub, strip, find = string.match, string.lower, string.gsub, string.strip, string.find local char, byte, sub = string.char, string.byte, string.sub local abs = math.abs local bxor, rshift = bit32.bxor, bit32.rshift -local P, S, R, Cmt, C, Ct, Cs, Carg = lpeg.P, lpeg.S, lpeg.R, lpeg.Cmt, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg +local P, S, R, Cmt, C, Ct, Cs, Carg, Cf, Cg = lpeg.P, lpeg.S, lpeg.R, lpeg.Cmt, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Carg, lpeg.Cf, lpeg.Cg local lpegmatch, patterns = lpeg.match, lpeg.patterns local trace_indexing = false trackers.register("afm.indexing", function(v) trace_indexing = v end) local trace_loading = false trackers.register("afm.loading", function(v) trace_loading = v end) local report_afm = logs.reporter("fonts","afm loading") -local report_afm = logs.reporter("fonts","pfb loading") +local report_pfb = logs.reporter("fonts","pfb loading") fonts = fonts or { } local handlers = fonts.handlers or { } @@ -72,20 +72,36 @@ do local initialize = function(str,position,size) n = 0 - m = tonumber(size) + m = size -- % tonumber(size) return position + 1 end - local charstrings = P("/CharStrings") - local name = P("/") * C((R("az")+R("AZ")+R("09")+S("-_."))^1) - local size = C(R("09")^1) - local spaces = P(" ")^1 + local charstrings = P("/CharStrings") + local encoding = P("/Encoding") + local dup = P("dup") + local put = P("put") + local array = P("array") + local name = P("/") * C((R("az")+R("AZ")+R("09")+S("-_."))^1) + local digits = R("09")^1 + local cardinal = digits / tonumber + local spaces = P(" ")^1 + local spacing = patterns.whitespace^0 local p_filternames = Ct ( - (1-charstrings)^0 * charstrings * spaces * Cmt(size,initialize) - * (Cmt(name * P(" ")^1 * C(R("09")^1), progress) + P(1))^1 + (1-charstrings)^0 * charstrings * spaces * Cmt(cardinal,initialize) + * (Cmt(name * spaces * cardinal, progress) + P(1))^1 ) + -- /Encoding 256 array + -- 0 1 255 {1 index exch /.notdef put} for + -- dup 0 /Foo put + + local p_filterencoding = + (1-encoding)^0 * encoding * spaces * digits * spaces * array * (1-dup)^0 + * Cf( + Ct("") * Cg(spacing * dup * spaces * cardinal * spaces * name * spaces * put)^1 + ,rawset) + -- if one of first 4 not 0-9A-F then binary else hex local decrypt @@ -153,10 +169,16 @@ do return end - return vector + local encoding = lpegmatch(p_filterencoding,ascii) + + return vector, encoding end + local pfb = handlers.pfb or { } + handlers.pfb = pfb + pfb.loadvector = loadpfbvector + get_indexes = function(data,pfbname) local vector = loadpfbvector(pfbname) if vector then diff --git a/tex/context/base/mkiv/font-tfm.lua b/tex/context/base/mkiv/font-tfm.lua index ab6d795bb..3aee1bf53 100644 --- a/tex/context/base/mkiv/font-tfm.lua +++ b/tex/context/base/mkiv/font-tfm.lua @@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['font-tfm'] = { license = "see context related readme files" } -local next = next +local next, type = next, type local match = string.match local trace_defining = false trackers.register("fonts.defining", function(v) trace_defining = v end) @@ -69,6 +69,10 @@ function tfm.setfeatures(tfmdata,features) end end +function tfm.reencode(tfmdata,specification) + return tfmdata +end + local depth = { } -- table.setmetatableindex("number") local function read_from_tfm(specification) @@ -80,17 +84,20 @@ local function read_from_tfm(specification) end local tfmdata = font.read_tfm(filename,size) -- not cached, fast enough if tfmdata then + + tfmdata = tfm.reencode(tfmdata,specification) -- not a manipulator, has to come earlier + local features = specification.features and specification.features.normal or { } local resources = tfmdata.resources or { } local properties = tfmdata.properties or { } local parameters = tfmdata.parameters or { } local shared = tfmdata.shared or { } + -- properties.name = tfmdata.name properties.fontname = tfmdata.fontname properties.psname = tfmdata.psname properties.filename = specification.filename properties.format = fonts.formats.tfm -- better than nothing - parameters.size = size -- tfmdata.properties = properties tfmdata.resources = resources @@ -100,6 +107,8 @@ local function read_from_tfm(specification) shared.rawdata = { } shared.features = features shared.processes = next(features) and tfm.setfeatures(tfmdata,features) or nil + -- + parameters.size = size parameters.slant = parameters.slant or parameters[1] or 0 parameters.space = parameters.space or parameters[2] or 0 parameters.space_stretch = parameters.space_stretch or parameters[3] or 0 @@ -146,7 +155,7 @@ local function read_from_tfm(specification) end -- local allfeatures = tfmdata.shared.features or specification.features.normal - constructors.applymanipulators("tfm",tfmdata,allfeatures.normal,trace_features,report_tfm) + constructors.applymanipulators("tfm",tfmdata,allfeatures,trace_features,report_tfm) if not features.encoding then local encoding, filename = match(properties.filename,"^(.-)%-(.*)$") -- context: encoding-name.* if filename and encoding and encodings.known and encodings.known[encoding] then @@ -199,3 +208,154 @@ function readers.tfm(specification) end readers.ofm = readers.tfm + +-- bonus for old times sake: + +do + + local outfiles = { } + + local tfmcache = table.setmetatableindex(function(t,tfmdata) + local id = font.define(tfmdata) + t[tfmdata] = id + return id + end) + + local encdone = table.setmetatableindex("table") + + function tfm.reencode(tfmdata,specification) + + local features = specification.features + + if not features then + return tfmdata + end + + local features = features.normal + + if not features then + return tfmdata + end + + local tfmfile = file.basename(tfmdata.name) + local encfile = features.reencode -- or features.enc + local pfbfile = features.pfbfile -- or features.pfb + local bitmap = features.bitmap -- or features.pk + + if not encfile then + return tfmdata + end + + local pfbfile = outfiles[tfmfile] + + if pfbfile == nil then + if bitmap then + pfbfile = false + elseif type(pfbfile) ~= "string" then + pfbfile = tfmfile + end + if type(pfbfile) == "string" then + pfbfile = file.addsuffix(pfbfile,"pfb") + pdf.mapline(tfmfile .. "<" .. pfbfile) + report_tfm("using type1 shapes from %a for %a",pfbfile,tfmfile) + else + report_tfm("using bitmap shapes for %a",tfmfile) + pfbfile = false -- use bitmap + end + outfiles[tfmfile] = pfbfile + end + + local encoding = false + + if type(encfile) == "string" and encfile ~= "auto" then + encoding = fonts.encodings.load(file.addsuffix(encfile,"enc")) + if encoding then + encoding = encoding.vector + end + elseif type(pfbfile) == "string" then + local pfb = fonts.constructors.handlers.pfb + -- report_tfm("using encoding from %a",pfbfile) + if pfb and pfb.loadvector then + local v, e = pfb.loadvector(pfbfile) + if e then + encoding = e + end + end + end + + if not encoding then + report_tfm("bad encoding for %a, quitting",tfmfile) + return tfmdata + end + + local unicoding = fonts.encodings.agl and fonts.encodings.agl.unicodes + local virtualid = tfmcache[tfmdata] + local tfmdata = table.copy(tfmdata) -- good enough for small fonts + local characters = { } + local originals = tfmdata.characters + local indices = { } + local parentfont = { "font", 1 } + local private = fonts.constructors.privateoffset + local reported = encdone[tfmfile][encfile] + + -- create characters table + + for index, name in table.sortedhash(encoding) do -- predictable order + local unicode = unicoding[name] + local original = originals[index] + if original then + if not unicode then + unicode = private + private = private + 1 + if not reported then + report_tfm("glyph %a in font %a with encoding %a gets unicode %U",name,tfmfile,encfile,unicode) + end + end + characters[unicode] = original + indices[index] = unicode + original.name = name -- so one can lookup weird names + original.commands = { parentfont, { "char", index } } + else + report_tfm("bad index %a in font %a with name %a",index,tfmfile,name) + end + end + + encdone[tfmfile][encfile] = true + + -- redo kerns and ligatures + + for k, v in next, characters do + local kerns = v.kerns + if kerns then + local t = { } + for k, v in next, kerns do + local i = indices[k] + if i then + t[i] = v + end + end + v.kerns = next(t) and t or nil + end + local ligatures = v.ligatures + if ligatures then + local t = { } + for k, v in next, ligatures do + local i = indices[k] + if i then + t[i] = v + v.char = indices[v.char] + end + end + v.ligatures = next(t) and t or nil + end + end + + -- wrap up + + tfmdata.fonts = { { id = virtualid } } + tfmdata.characters = characters + + return tfmdata + end + +end diff --git a/tex/context/base/mkiv/status-files.pdf b/tex/context/base/mkiv/status-files.pdf Binary files differindex ef99b2374..03376e020 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 8f5ffceab..4c697e37e 100644 --- a/tex/context/base/mkiv/status-lua.pdf +++ b/tex/context/base/mkiv/status-lua.pdf diff --git a/tex/context/interface/mkiv/i-context.pdf b/tex/context/interface/mkiv/i-context.pdf Binary files differindex bffa5e999..3d6d1b217 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 42e9490d6..e2209a67b 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 3c21f19c8..362aec0c3 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 : 06/25/16 14:38:07 +-- merge date : 06/26/16 19:00:04 do -- begin closure to overcome local limits and interference @@ -7440,7 +7440,7 @@ if not modules then modules={} end modules ['font-tfm']={ copyright="PRAGMA ADE / ConTeXt Development Team", license="see context related readme files" } -local next=next +local next,type=next,type local match=string.match local trace_defining=false trackers.register("fonts.defining",function(v) trace_defining=v end) local trace_features=false trackers.register("tfm.features",function(v) trace_features=v end) @@ -7468,6 +7468,9 @@ function tfm.setfeatures(tfmdata,features) return {} end end +function tfm.reencode(tfmdata,specification) + return tfmdata +end local depth={} local function read_from_tfm(specification) local filename=specification.filename @@ -7478,6 +7481,7 @@ local function read_from_tfm(specification) end local tfmdata=font.read_tfm(filename,size) if tfmdata then + tfmdata=tfm.reencode(tfmdata,specification) local features=specification.features and specification.features.normal or {} local resources=tfmdata.resources or {} local properties=tfmdata.properties or {} @@ -7487,8 +7491,7 @@ local function read_from_tfm(specification) properties.fontname=tfmdata.fontname properties.psname=tfmdata.psname properties.filename=specification.filename - properties.format=fonts.formats.tfm - parameters.size=size + properties.format=fonts.formats.tfm tfmdata.properties=properties tfmdata.resources=resources tfmdata.parameters=parameters @@ -7496,6 +7499,7 @@ local function read_from_tfm(specification) shared.rawdata={} shared.features=features shared.processes=next(features) and tfm.setfeatures(tfmdata,features) or nil + parameters.size=size parameters.slant=parameters.slant or parameters[1] or 0 parameters.space=parameters.space or parameters[2] or 0 parameters.space_stretch=parameters.space_stretch or parameters[3] or 0 @@ -7539,7 +7543,7 @@ local function read_from_tfm(specification) end end local allfeatures=tfmdata.shared.features or specification.features.normal - constructors.applymanipulators("tfm",tfmdata,allfeatures.normal,trace_features,report_tfm) + constructors.applymanipulators("tfm",tfmdata,allfeatures,trace_features,report_tfm) if not features.encoding then local encoding,filename=match(properties.filename,"^(.-)%-(.*)$") if filename and encoding and encodings.known and encodings.known[encoding] then @@ -7586,6 +7590,125 @@ function readers.tfm(specification) return check_tfm(specification,fullname) end readers.ofm=readers.tfm +do + local outfiles={} + local tfmcache=table.setmetatableindex(function(t,tfmdata) + local id=font.define(tfmdata) + t[tfmdata]=id + return id + end) + local encdone=table.setmetatableindex("table") + function tfm.reencode(tfmdata,specification) + local features=specification.features + if not features then + return tfmdata + end + local features=features.normal + if not features then + return tfmdata + end + local tfmfile=file.basename(tfmdata.name) + local encfile=features.reencode + local pfbfile=features.pfbfile + local bitmap=features.bitmap + if not encfile then + return tfmdata + end + local pfbfile=outfiles[tfmfile] + if pfbfile==nil then + if bitmap then + pfbfile=false + elseif type(pfbfile)~="string" then + pfbfile=tfmfile + end + if type(pfbfile)=="string" then + pfbfile=file.addsuffix(pfbfile,"pfb") + pdf.mapline(tfmfile.."<"..pfbfile) + report_tfm("using type1 shapes from %a for %a",pfbfile,tfmfile) + else + report_tfm("using bitmap shapes for %a",tfmfile) + pfbfile=false + end + outfiles[tfmfile]=pfbfile + end + local encoding=false + if type(encfile)=="string" and encfile~="auto" then + encoding=fonts.encodings.load(file.addsuffix(encfile,"enc")) + if encoding then + encoding=encoding.vector + end + elseif type(pfbfile)=="string" then + local pfb=fonts.constructors.handlers.pfb + if pfb and pfb.loadvector then + local v,e=pfb.loadvector(pfbfile) + if e then + encoding=e + end + end + end + if not encoding then + report_tfm("bad encoding for %a, quitting",tfmfile) + return tfmdata + end + local unicoding=fonts.encodings.agl and fonts.encodings.agl.unicodes + local virtualid=tfmcache[tfmdata] + local tfmdata=table.copy(tfmdata) + local characters={} + local originals=tfmdata.characters + local indices={} + local parentfont={ "font",1 } + local private=fonts.constructors.privateoffset + local reported=encdone[tfmfile][encfile] + for index,name in table.sortedhash(encoding) do + local unicode=unicoding[name] + local original=originals[index] + if original then + if not unicode then + unicode=private + private=private+1 + if not reported then + report_tfm("glyph %a in font %a with encoding %a gets unicode %U",name,tfmfile,encfile,unicode) + end + end + characters[unicode]=original + indices[index]=unicode + original.name=name + original.commands={ parentfont,{ "char",index } } + else + report_tfm("bad index %a in font %a with name %a",index,tfmfile,name) + end + end + encdone[tfmfile][encfile]=true + for k,v in next,characters do + local kerns=v.kerns + if kerns then + local t={} + for k,v in next,kerns do + local i=indices[k] + if i then + t[i]=v + end + end + v.kerns=next(t) and t or nil + end + local ligatures=v.ligatures + if ligatures then + local t={} + for k,v in next,ligatures do + local i=indices[k] + if i then + t[i]=v + v.char=indices[v.char] + end + end + v.ligatures=next(t) and t or nil + end + end + tfmdata.fonts={ { id=virtualid } } + tfmdata.characters=characters + return tfmdata + end +end end -- closure @@ -23376,17 +23499,17 @@ if not modules then modules={} end modules ['font-onr']={ license="see context related readme files" } local fonts,logs,trackers,resolvers=fonts,logs,trackers,resolvers -local next,type,tonumber,rawget=next,type,tonumber,rawget +local next,type,tonumber,rawget,rawset=next,type,tonumber,rawget,rawset local match,lower,gsub,strip,find=string.match,string.lower,string.gsub,string.strip,string.find local char,byte,sub=string.char,string.byte,string.sub local abs=math.abs local bxor,rshift=bit32.bxor,bit32.rshift -local P,S,R,Cmt,C,Ct,Cs,Carg=lpeg.P,lpeg.S,lpeg.R,lpeg.Cmt,lpeg.C,lpeg.Ct,lpeg.Cs,lpeg.Carg +local P,S,R,Cmt,C,Ct,Cs,Carg,Cf,Cg=lpeg.P,lpeg.S,lpeg.R,lpeg.Cmt,lpeg.C,lpeg.Ct,lpeg.Cs,lpeg.Carg,lpeg.Cf,lpeg.Cg local lpegmatch,patterns=lpeg.match,lpeg.patterns local trace_indexing=false trackers.register("afm.indexing",function(v) trace_indexing=v end) local trace_loading=false trackers.register("afm.loading",function(v) trace_loading=v end) local report_afm=logs.reporter("fonts","afm loading") -local report_afm=logs.reporter("fonts","pfb loading") +local report_pfb=logs.reporter("fonts","pfb loading") fonts=fonts or {} local handlers=fonts.handlers or {} fonts.handlers=handlers @@ -23411,16 +23534,25 @@ do end local initialize=function(str,position,size) n=0 - m=tonumber(size) + m=size return position+1 end local charstrings=P("/CharStrings") + local encoding=P("/Encoding") + local dup=P("dup") + local put=P("put") + local array=P("array") local name=P("/")*C((R("az")+R("AZ")+R("09")+S("-_."))^1) - local size=C(R("09")^1) + local digits=R("09")^1 + local cardinal=digits/tonumber local spaces=P(" ")^1 + local spacing=patterns.whitespace^0 local p_filternames=Ct ( - (1-charstrings)^0*charstrings*spaces*Cmt(size,initialize)*(Cmt(name*P(" ")^1*C(R("09")^1),progress)+P(1))^1 + (1-charstrings)^0*charstrings*spaces*Cmt(cardinal,initialize)*(Cmt(name*spaces*cardinal,progress)+P(1))^1 ) + local p_filterencoding=(1-encoding)^0*encoding*spaces*digits*spaces*array*(1-dup)^0*Cf( + Ct("")*Cg(spacing*dup*spaces*cardinal*spaces*name*spaces*put)^1 +,rawset) local decrypt do local r,c1,c2,n=0,0,0,0 @@ -23460,8 +23592,12 @@ do report_pfb("no vector in %a",filename) return end - return vector + local encoding=lpegmatch(p_filterencoding,ascii) + return vector,encoding end + local pfb=handlers.pfb or {} + handlers.pfb=pfb + pfb.loadvector=loadpfbvector get_indexes=function(data,pfbname) local vector=loadpfbvector(pfbname) if vector then diff --git a/tex/generic/context/luatex/luatex-plain-tfm.lua b/tex/generic/context/luatex/luatex-plain-tfm.lua index 87b453689..4a08fb4c7 100644 --- a/tex/generic/context/luatex/luatex-plain-tfm.lua +++ b/tex/generic/context/luatex/luatex-plain-tfm.lua @@ -7,12 +7,17 @@ if not modules then modules = { } end modules ['luatex-plain-tfm'] = { } -- \font\foo=file:luatex-plain-tfm.lua:tfm=csr10;enc=csr;pfb=csr10 at 12pt +-- \font\bar=file:luatex-plain-tfm.lua:tfm=csr10;enc=csr at 12pt -- --- \foo áäčďěíĺľňóôŕřšťúýž ff ffi \input tufte +-- \foo áäčďěíĺľňóôŕřšťúýž ff ffi \input tufte\par +-- \bar áäčďěíĺľňóôŕřšťúýž ff ffi \input tufte\par + +local outfiles = { } return function(specification) local size = specification.size + local name = specification.name local feat = specification.features and specification.features.normal if not feat then @@ -21,7 +26,7 @@ return function(specification) local tfm = feat.tfm local enc = feat.enc or tfm - local pfb = feat.pfb or tfm + local pfb = feat.pfb if not tfm then return @@ -29,7 +34,6 @@ return function(specification) local tfmfile = tfm .. ".tfm" local encfile = enc .. ".enc" - local pfbfile = pfb .. ".pfb" local tfmdata, id = fonts.constructors.readanddefine("file:"..tfmfile,size) @@ -44,38 +48,28 @@ return function(specification) if tfmdata and encoding and unicoding then + tfmdata = table.copy(tfmdata) -- good enough for small fonts + local characters = { } local originals = tfmdata.characters local indices = { } local parentfont = { "font", 1 } - local mapline = tfm .. "<" .. pfbfile -- .."<"..encfile - - local dummy = unicoding.foo -- foo forces loading + local private = fonts.constructors.privateoffset -- create characters table - for name, index in next, encoding do - local unicode = unicoding[name] - if unicode then - local original = originals[index] - original.name = name -- so one can lookup weird names - original.commands = { parentfont, { "char", index } } - characters[unicode] = original - indices[index] = unicode - else - -- unknown name - end - end - - -- also include ligatures and whatever left - - local p = fonts.constructors.privateoffset - for k, v in next, originals do - if not indices[k] then - characters[p] = v - indices[k] = p - p = p + 1 + for name, index in table.sortedhash(encoding) do -- predictable order + local unicode = unicoding[name] + local original = originals[index] + if not unicode then + unicode = private + private = private + 1 + report_tfm("glyph %a in font %a gets private unicode %U",name,tfmfile,private) end + characters[unicode] = original + indices[index] = unicode + original.name = name -- so one can lookup weird names + original.commands = { parentfont, { "char", index } } end -- redo kerns and ligatures @@ -106,8 +100,21 @@ return function(specification) tfmdata.fonts = { { id = id } } tfmdata.characters = characters - pdf.mapline(mapline) + -- resources + + local outfile = outfiles[tfmfile] + + if outfile == nil then + if pfb then + outfile = pfb .. ".pfb" + pdf.mapline(tfm .. "<" .. outfile) + else + outfile = false + end + outfiles[tfmfile] = outfile + end end + return tfmdata end diff --git a/tex/generic/context/luatex/luatex-test.tex b/tex/generic/context/luatex/luatex-test.tex index 9dc7c3113..2aa4f22d9 100644 --- a/tex/generic/context/luatex/luatex-test.tex +++ b/tex/generic/context/luatex/luatex-test.tex @@ -159,9 +159,15 @@ $\sin{x}$ % \egroup % assumes csr10.tfm csr10.pfb csr.enc to be present -% + % \font\foo=file:luatex-plain-tfm.lua:tfm=csr10;enc=csr;pfb=csr10 at 12pt % % \foo áäčďěíĺľňóôŕřšťúýž ff ffi +% \font\foo=file:csr10.tfm:reencode=csr +% \font\foo=file:csr10.tfm:reencode=csr;bitmap=yes % use map file +% \font\foo=file:csr10.tfm:reencode=auto +% +% \foo áäčďěíĺľňóôŕřšťúýž ff ffi \input tufte\par + \end |