From 407d9151f5473b20e9072473b80d0f591a3580a1 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Tue, 12 Oct 2010 17:13:00 +0200 Subject: beta 2010.10.12 17:13 --- tex/context/base/buff-ini.lua | 6 +++- tex/context/base/buff-ver.mkiv | 2 +- tex/context/base/cont-new.tex | 2 +- tex/context/base/context.tex | 2 +- tex/context/base/font-afm.lua | 13 ++++--- tex/context/base/font-ctx.lua | 53 +++++++++++++++++++++++++++++ tex/context/base/font-def.lua | 8 +++-- tex/context/base/font-ini.lua | 1 + tex/context/base/font-tfm.lua | 2 +- tex/context/base/mult-cld.lua | 13 +++++++ tex/context/base/page-flt.lua | 6 ++-- tex/context/base/page-flt.mkiv | 28 ++++++++++----- tex/context/base/s-fnt-29.tex | 12 ------- tex/generic/context/luatex-fonts-merged.lua | 13 ++++--- 14 files changed, 122 insertions(+), 39 deletions(-) diff --git a/tex/context/base/buff-ini.lua b/tex/context/base/buff-ini.lua index a590cf81a..0564c70cf 100644 --- a/tex/context/base/buff-ini.lua +++ b/tex/context/base/buff-ini.lua @@ -242,8 +242,12 @@ function buffers.loaddata(filename) -- this one might go away end end -function buffers.typefile(name,realign,range) -- still somewhat messy, since name can be be suffixless +function buffers.typefile(name,realign,range,regime) -- still somewhat messy, since name can be be suffixless local str = buffers.loaddata(name) + if regime and regime ~= "" then + regimes.load(regime) + str = regimes.translate(str,regime) + end if str and str~= "" then local lines = str:splitlines() if realign then diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv index d20c5a2a5..155872a10 100644 --- a/tex/context/base/buff-ver.mkiv +++ b/tex/context/base/buff-ver.mkiv @@ -634,7 +634,7 @@ {\doinitializeverbatim \beginofverbatimlines \dostarttagged\t!verbatimblock\currenttyping - \ctxlua{buffers.typefile("\readfilename","\typingparameter\c!strip","\typingparameter\c!range")}% + \ctxlua{buffers.typefile("\readfilename","\typingparameter\c!strip","\typingparameter\c!range","\currentregime")}% \dostoptagged \endofverbatimlines} diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index eaec0cc5c..0fe4d2057 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2010.10.12 01:03} +\newcontextversion{2010.10.12 17:13} %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/context.tex b/tex/context/base/context.tex index 218dba703..8412ea74e 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2010.10.12 01:03} +\edef\contextversion{2010.10.12 17:13} %D For those who want to use this: diff --git a/tex/context/base/font-afm.lua b/tex/context/base/font-afm.lua index 5897904b2..ff2078e73 100644 --- a/tex/context/base/font-afm.lua +++ b/tex/context/base/font-afm.lua @@ -24,7 +24,7 @@ local trace_loading = false trackers.register("afm.loading", function(v) trac local report_afm = logs.new("load afm") local next, type = next, type -local format, match, gmatch, lower, gsub = string.format, string.match, string.gmatch, string.lower, string.gsub +local format, match, gmatch, lower, gsub, strip = string.format, string.match, string.gmatch, string.lower, string.gsub, string.strip local lpegmatch = lpeg.match local abs = math.abs @@ -107,11 +107,13 @@ local function scan_comment(str) return fd end --- On a rainy day I will rewrite this in lpeg ... +-- On a rainy day I will rewrite this in lpeg ... or we can use the (slower) fontloader +-- as in now supports afm/pfb loading. local keys = { } -function keys.FontName (data,line) data.metadata.fullname = line:strip() end +function keys.FontName (data,line) data.metadata.fontname = strip (line) -- get rid of spaces + data.metadata.fullname = strip (line) end function keys.ItalicAngle (data,line) data.metadata.italicangle = tonumber (line) end function keys.IsFixedPitch(data,line) data.metadata.isfixedpitch = toboolean(line,true) end function keys.CharWidth (data,line) data.metadata.charwidth = tonumber (line) end @@ -840,14 +842,15 @@ local function kerns (tfmdata,value) prepare_kerns (tfmdata,'kerns', local function extrakerns (tfmdata,value) prepare_kerns (tfmdata,'extrakerns', value) end register_feature('liga',true) -register_feature('kerns',true) +register_feature('kern',true) +--~ register_feature('kerns',true) -- kerns? register_feature('extrakerns') -- needed? base_initializers.ligatures = ligatures node_initializers.ligatures = ligatures base_initializers.texligatures = texligatures node_initializers.texligatures = texligatures -base_initializers.kerns = kerns +base_initializers.kern = kerns node_initializers.kerns = kerns node_initializers.extrakerns = extrakerns base_initializers.extrakerns = extrakerns diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua index c9a51f0ba..e5da6e868 100644 --- a/tex/context/base/font-ctx.lua +++ b/tex/context/base/font-ctx.lua @@ -407,6 +407,8 @@ function definers.stage_two(global,cs,str,size,classfeatures,fontfeatures,classf specification.mathsize = mathsize specification.textsize = textsize specification.goodies = goodies + specification.cs = cs + specification.global = global if detail and detail ~= "" then specification.method, specification.detail = method or "*", detail elseif specification.detail and specification.detail ~= "" then @@ -458,6 +460,57 @@ function definers.stage_two(global,cs,str,size,classfeatures,fontfeatures,classf statistics.stoptiming(fonts) end +function definers.define(specification) + -- + local name = specification.name + if not name or name == "" then + return -1 + else + statistics.starttiming(fonts) + -- + -- following calls expect a few properties to be set: + -- + specification.lookup = specification.lookup or "file" + specification.specification = "" -- not used + specification.size = specification.size or 655260 + specification.sub = specification.sub or "" + specification.method = specification.method or "*" + specification.detail = specification.detail or "" + specification.resolved = "" + specification.forced = "" + specification.features = { } -- via detail + -- + -- we don't care about mathsize textsize goodies fallbacks + -- + if specification.cs == "" then + specification.cs = nil + specification.global = false + elseif specification.global == nil then + specification.global = false + end + -- + local tfmdata = definers.read(specification,specification.size) + if not tfmdata then + return -1, nil + elseif type(tfmdata) == "number" then + if specification.cs then + tex.definefont(specification.global,specification.cs,tfmdata) + end + return tfmdata, fontdata[tfmdata] + else + local id = font.define(tfmdata) + tfmdata.id = id + definers.register(tfmdata,id) + if specification.cs then + tex.definefont(specification.global,specification.cs,id) + end + tfm.cleanuptable(tfmdata) + return id, tfmdata + end + statistics.stoptiming(fonts) + end +end + local enable_auto_r_scale = false experiments.register("fonts.autorscale", function(v) diff --git a/tex/context/base/font-def.lua b/tex/context/base/font-def.lua index 3f585b908..713e5b68d 100644 --- a/tex/context/base/font-def.lua +++ b/tex/context/base/font-def.lua @@ -29,7 +29,7 @@ default loader that only handles .

local fonts = fonts local tfm = fonts.tfm local vf = fonts.vf -local fontids = fonts.ids +local fontcsnames = fonts.csnames fonts.used = allocate() @@ -646,7 +646,7 @@ function definers.read(specification,size,id) -- id can be optional, name can al end end lastdefined = fontdata or id -- todo ! ! ! ! ! - if not fontdata then + if not fontdata then -- or id? report_define( "unknown font %s, loading aborted",specification.name) elseif trace_defining and type(fontdata) == "table" then report_define("using %s font with id %s, name:%s size:%s bytes:%s encoding:%s fullname:%s filename:%s", @@ -659,6 +659,10 @@ function definers.read(specification,size,id) -- id can be optional, name can al fontdata.fullname or "?", file.basename(fontdata.filename or "?")) end + local cs = specification.cs + if cs then + fontcsnames[cs] = fontdata -- new (beware: locals can be forgotten) + end statistics.stoptiming(fonts) return fontdata end diff --git a/tex/context/base/font-ini.lua b/tex/context/base/font-ini.lua index 04d30a31d..8209f483e 100644 --- a/tex/context/base/font-ini.lua +++ b/tex/context/base/font-ini.lua @@ -32,6 +32,7 @@ fonts = fonts or { } fonts.ids = mark(fonts.ids or { }) fonts.identifiers = fonts.ids -- aka fontdata fonts.chr = mark(fonts.chr or { }) fonts.characters = fonts.chr -- aka chardata fonts.qua = mark(fonts.qua or { }) fonts.quads = fonts.qua -- aka quaddata +fonts.css = mark(fonts.css or { }) fonts.csnames = fonts.css -- aka namedata fonts.tfm = fonts.tfm or { } fonts.vf = fonts.vf or { } diff --git a/tex/context/base/font-tfm.lua b/tex/context/base/font-tfm.lua index d887e45d3..266bc7406 100644 --- a/tex/context/base/font-tfm.lua +++ b/tex/context/base/font-tfm.lua @@ -627,7 +627,7 @@ function tfm.scale(tfmtable, scaledpoints, relativeid) t.psname = t.fontname or (t.fullname and fonts.names.cleanname(t.fullname)) end if trace_defining then - report_define("used for accesing subfont: '%s'",t.psname or "nopsname") + report_define("used for accessing (sub)font: '%s'",t.psname or "nopsname") report_define("used for subsetting: '%s'",t.fontname or "nofontname") end -- this will move up (side effect of merging split call) diff --git a/tex/context/base/mult-cld.lua b/tex/context/base/mult-cld.lua index edc4253a9..382370dea 100644 --- a/tex/context/base/mult-cld.lua +++ b/tex/context/base/mult-cld.lua @@ -350,3 +350,16 @@ function context.disabletrackers(str) trackers.disable(str) end --~ end --~ --~ context.direct(something) + +-- this might be generalized: register some primitives as: accepting this or that +-- we can also speed this up + +function context.char(k) + if type(k) == "table" then + for i=1,#k do + context(format([[\char%s\relax]],k[i])) + end + elseif k then + context(format([[\char%s\relax]],k)) + end +end diff --git a/tex/context/base/page-flt.lua b/tex/context/base/page-flt.lua index a1798adc9..282ca0cc5 100644 --- a/tex/context/base/page-flt.lua +++ b/tex/context/base/page-flt.lua @@ -8,8 +8,9 @@ if not modules then modules = { } end modules ['page-flt'] = { -- floats -> managers.floats -local setdimen, setbox, setcount, texbox = tex.setdimen, tex.setbox, tex.setcount, tex.box local insert, remove = table.insert, table.remove +local find = string.find +local setdimen, setbox, setcount, texbox = tex.setdimen, tex.setbox, tex.setcount, tex.box local texwrite, texsprint, ctxcatcodes = tex.write, tex.sprint, tex.ctxcatcodes local copy_node_list = node.copy_list @@ -83,7 +84,8 @@ local function get(stack,n,bylabel) if bylabel then for i=1,#stack do local s = stack[i] - if s.data.label == n then + local n = string.topattern(tostring(n)) -- to be sure + if find(s.data.label,n) then return s, s.box, i end end diff --git a/tex/context/base/page-flt.mkiv b/tex/context/base/page-flt.mkiv index 9857bb0ea..21662f30e 100644 --- a/tex/context/base/page-flt.mkiv +++ b/tex/context/base/page-flt.mkiv @@ -123,23 +123,33 @@ %D %D \starttyping %D test \placefigure{}{} -%D test \placefigure[somewhere:123][whatever]{}{} -%D test \placefigure[somewhere:456][whatever]{}{} +%D test \placefigure[somewhere:alpha][whatever]{}{} +%D test \placefigure[somewhere:beta] [whatever]{}{} +%D test \placefigure[somewhere:gamma][whatever]{}{} +%D test \placefigure[somewhere:delta][whatever]{}{} %D test \placefigure{}{} %D -%D \placenamedfloat[figure][456] -%D \placenamedfloat[figure][123] +%D in \in{figure}[whatever] bla bla +%D +%D \placenamedfloat[figure][*l*] +%D \placenamedfloat[figure][gamma] +%D \placenamedfloat[figure][beta] %D \stoptyping \def\placenamedfloat {\dodoubleargument\doplacenamedfloat} \def\doplacenamedfloat[#1][#2]% - {\def\currentfloat{#1}% - \blank[\@@bkspacebefore]% - \dofloatsflushbylabel\s!somewhere{#2}% - \box\floatbox - \blank[\@@bkspaceafter]} + {\doloop + {\dofloatsflushbylabel\s!somewhere{#2}% + \ifvoid\floatbox + \exitloop + \else + \def\currentfloat{#1}% + \blank[\@@bkspacebefore]% + \box\floatbox + \blank[\@@bkspaceafter] + \fi}} %D The following code is in transition as we don't want to break the %D current single column, multi column, and columnset mechanism. diff --git a/tex/context/base/s-fnt-29.tex b/tex/context/base/s-fnt-29.tex index bdff5d087..857591085 100644 --- a/tex/context/base/s-fnt-29.tex +++ b/tex/context/base/s-fnt-29.tex @@ -13,18 +13,6 @@ \startluacode - local function char(k) - if type(k) == "table" then - for i=1,#k do - context([[\char%s\relax]],k[i]) - end - elseif k then - context([[\char%s\relax]],k) - end - end - - -- context.char = char -- to be considered - function fonts.tracers.shapes() -- todo: ranges local NC, NR = context.NC, context.NR local chrs = fonts.ids[font.current()].characters diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index 415fff8dd..aee369864 100644 --- a/tex/generic/context/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 10/12/10 01:03:01 +-- merge date : 10/12/10 17:13:41 do -- begin closure to overcome local limits and interference @@ -3123,6 +3123,7 @@ fonts = fonts or { } fonts.ids = mark(fonts.ids or { }) fonts.identifiers = fonts.ids -- aka fontdata fonts.chr = mark(fonts.chr or { }) fonts.characters = fonts.chr -- aka chardata fonts.qua = mark(fonts.qua or { }) fonts.quads = fonts.qua -- aka quaddata +fonts.css = mark(fonts.css or { }) fonts.csnames = fonts.css -- aka namedata fonts.tfm = fonts.tfm or { } fonts.vf = fonts.vf or { } @@ -3833,7 +3834,7 @@ function tfm.scale(tfmtable, scaledpoints, relativeid) t.psname = t.fontname or (t.fullname and fonts.names.cleanname(t.fullname)) end if trace_defining then - report_define("used for accesing subfont: '%s'",t.psname or "nopsname") + report_define("used for accessing (sub)font: '%s'",t.psname or "nopsname") report_define("used for subsetting: '%s'",t.fontname or "nofontname") end -- this will move up (side effect of merging split call) @@ -14859,7 +14860,7 @@ default loader that only handles .

local fonts = fonts local tfm = fonts.tfm local vf = fonts.vf -local fontids = fonts.ids +local fontcsnames = fonts.csnames fonts.used = allocate() @@ -15476,7 +15477,7 @@ function definers.read(specification,size,id) -- id can be optional, name can al end end lastdefined = fontdata or id -- todo ! ! ! ! ! - if not fontdata then + if not fontdata then -- or id? report_define( "unknown font %s, loading aborted",specification.name) elseif trace_defining and type(fontdata) == "table" then report_define("using %s font with id %s, name:%s size:%s bytes:%s encoding:%s fullname:%s filename:%s", @@ -15489,6 +15490,10 @@ function definers.read(specification,size,id) -- id can be optional, name can al fontdata.fullname or "?", file.basename(fontdata.filename or "?")) end + local cs = specification.cs + if cs then + fontcsnames[cs] = fontdata -- new (beware: locals can be forgotten) + end statistics.stoptiming(fonts) return fontdata end -- cgit v1.2.3