From 882238ac1ea6d9563ea4e1add879f82ee8e6d9d0 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Sun, 23 May 2010 15:03:00 +0200 Subject: beta 2010.05.23 15:03 --- tex/context/base/cont-new.tex | 2 +- tex/context/base/context.tex | 2 +- tex/context/base/font-afm.lua | 5 +- tex/context/base/font-ctx.lua | 57 ++++++++++++++++++++++- tex/context/base/font-ini.lua | 60 +++++++----------------- tex/context/base/font-ini.mkiv | 2 +- tex/context/base/font-otf.lua | 12 ++++- tex/context/base/strc-bkm.lua | 12 +++-- tex/context/base/strc-lst.lua | 14 +++--- tex/context/base/tabl-tab.mkiv | 37 +++++++-------- tex/generic/context/luatex-fonts-merged.lua | 72 +++++++++++------------------ 11 files changed, 149 insertions(+), 126 deletions(-) (limited to 'tex') diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 974ec917d..65318a8ce 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.05.22 12:06} +\newcontextversion{2010.05.23 15:03} %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 1d4891f20..09404ab48 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.05.22 12:06} +\edef\contextversion{2010.05.23 15:03} %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 a6891826d..6aa3ef45a 100644 --- a/tex/context/base/font-afm.lua +++ b/tex/context/base/font-afm.lua @@ -456,6 +456,9 @@ function afm.add_dimensions(data) -- we need to normalize afm to otf i.e. indexe end end +fonts.formats.afm = "type1" +fonts.formats.pfb = "type1" + function afm.copy_to_tfm(data) if data then local glyphs = data.glyphs @@ -482,7 +485,7 @@ function afm.copy_to_tfm(data) tfm.fullname = metadata.fullname or metadata.fontname tfm.psname = tfm.fullname -- in otf: tfm.fontname or tfm.fullname tfm.name = tfm.filename or tfm.fullname or tfm.fontname - tfm.format = 'type1' + tfm.format = fonts.fontformat(tfm.filename,"type1") tfm.type = 'real' tfm.units = 1000 tfm.direction = 0 diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua index 50283fccb..76e9f095a 100644 --- a/tex/context/base/font-ctx.lua +++ b/tex/context/base/font-ctx.lua @@ -560,10 +560,65 @@ function fonts.char(n) -- todo: afm en tfm end end --- thsi will become obsolete: +-- moved from ini: + +fonts.color = { } -- dummy in ini + +local attribute = attributes.private('color') +local mapping = (attributes and attributes.list[attribute]) or { } + +local set_attribute = node.set_attribute +local unset_attribute = node.unset_attribute + +function fonts.color.set(n,c) + local mc = mapping[c] + if not mc then + unset_attribute(n,attribute) + else + set_attribute(n,attribute,mc) + end +end + +function fonts.color.reset(n) + unset_attribute(n,attribute) +end + +-- this will become obsolete: fonts.otf.name_to_slot = name_to_slot fonts.afm.name_to_slot = name_to_slot fonts.otf.char = fonts.char fonts.afm.char = fonts.char + +-- this will change ... + +function fonts.show_char_data(n) + local tfmdata = fonts.ids[font.current()] + if tfmdata then + if type(n) == "string" then + n = utf.byte(n) + end + local chr = tfmdata.characters[n] + if chr then + write_nl(format("%s @ %s => U%04X => %s => ",tfmdata.fullname,tfmdata.size,n,utf.char(n)) .. serialize(chr,false)) + end + end +end + +function fonts.show_font_parameters() + local tfmdata = fonts.ids[font.current()] + if tfmdata then + local parameters, mathconstants = tfmdata.parameters, tfmdata.MathConstants + local hasparameters, hasmathconstants = parameters and next(parameters), mathconstants and next(mathconstants) + if hasparameters then + write_nl(format("%s @ %s => parameters => ",tfmdata.fullname,tfmdata.size) .. serialize(parameters,false)) + end + if hasmathconstants then + write_nl(format("%s @ %s => math constants => ",tfmdata.fullname,tfmdata.size) .. serialize(mathconstants,false)) + end + if not hasparameters and not hasmathconstants then + write_nl(format("%s @ %s => no parameters and/or mathconstants",tfmdata.fullname,tfmdata.size)) + end + end +end diff --git a/tex/context/base/font-ini.lua b/tex/context/base/font-ini.lua index b9988687d..e45149781 100644 --- a/tex/context/base/font-ini.lua +++ b/tex/context/base/font-ini.lua @@ -70,54 +70,26 @@ fonts.define.specify.synonyms = fonts.define.specify.synonyms or { } -- tracing -fonts.color = fonts.color or { } +if not fonts.color then -local attribute = attributes.private('color') -local mapping = (attributes and attributes.list[attribute]) or { } + fonts.color = { + set = function() end, + reset = function() end, + } -local set_attribute = node.set_attribute -local unset_attribute = node.unset_attribute - -function fonts.color.set(n,c) - local mc = mapping[c] - if not mc then - unset_attribute(n,attribute) - else - set_attribute(n,attribute,mc) - end -end -function fonts.color.reset(n) - unset_attribute(n,attribute) end --- this will change ... - -function fonts.show_char_data(n) - local tfmdata = fonts.ids[font.current()] - if tfmdata then - if type(n) == "string" then - n = utf.byte(n) - end - local chr = tfmdata.characters[n] - if chr then - write_nl(format("%s @ %s => U%04X => %s => ",tfmdata.fullname,tfmdata.size,n,utf.char(n)) .. serialize(chr,false)) - end - end -end +-- format identification -function fonts.show_font_parameters() - local tfmdata = fonts.ids[font.current()] - if tfmdata then - local parameters, mathconstants = tfmdata.parameters, tfmdata.MathConstants - local hasparameters, hasmathconstants = parameters and next(parameters), mathconstants and next(mathconstants) - if hasparameters then - write_nl(format("%s @ %s => parameters => ",tfmdata.fullname,tfmdata.size) .. serialize(parameters,false)) - end - if hasmathconstants then - write_nl(format("%s @ %s => math constants => ",tfmdata.fullname,tfmdata.size) .. serialize(mathconstants,false)) - end - if not hasparameters and not hasmathconstants then - write_nl(format("%s @ %s => no parameters and/or mathconstants",tfmdata.fullname,tfmdata.size)) - end +fonts.formats = { } + +function fonts.fontformat(filename,default) + local extname = file.extname(filename) + local format = fonts.formats[extname] + if format then + return format + else + logs.report("fonts define","unable to detemine font format for '%s'",filename) + return default end end diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv index b5cae7b8b..2eb790d5e 100644 --- a/tex/context/base/font-ini.mkiv +++ b/tex/context/base/font-ini.mkiv @@ -1434,7 +1434,7 @@ % this one already catches both define/setup -\unexpanded\def\setupbodyfontenvironment{\definebodyfontenvironment} +\let\setupbodyfontenvironment\definebodyfontenvironment %D Just a couple of interface macros: diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua index 2ccdc4598..d68137c96 100644 --- a/tex/context/base/font-otf.lua +++ b/tex/context/base/font-otf.lua @@ -576,7 +576,10 @@ end otf.enhancers["merge cid fonts"] = function(data,filename) -- we can also move the names to data.luatex.names which might -- save us some more memory (at the cost of harder tracing) - if data.subfonts and data.glyphs and next(data.glyphs) then + if data.subfonts then + if data.glyphs and next(data.glyphs) then + logs.report("load otf","replacing existing glyph table due to subfonts") + end local cidinfo = data.cidinfo local verbose = fonts.verbose if cidinfo.registry then @@ -1490,6 +1493,11 @@ end -- we cannot share descriptions as virtual fonts might extend them (ok, we could -- use a cache with a hash +fonts.formats.dfont = "truetype" +fonts.formats.ttc = "truetype" +fonts.formats.ttf = "truetype" +fonts.formats.otf = "opentype" + function otf.copy_to_tfm(data,cache_id) -- we can save a copy when we reorder the tma to unicode (nasty due to one->many) if data then local glyphs, pfminfo, metadata = data.glyphs or { }, data.pfminfo or { }, data.metadata or { } @@ -1570,7 +1578,7 @@ function otf.copy_to_tfm(data,cache_id) -- we can save a copy when we reorder th tfm.name = tfm.filename or tfm.fullname or tfm.fontname tfm.units = metadata.units_per_em or 1000 tfm.encodingbytes = 2 - tfm.format = (metadata.order2 == 1 and 'truetype') or 'opentype' + tfm.format = fonts.fontformat(tfm.filename,"opentype") tfm.cidinfo = data.cidinfo tfm.cidinfo.registry = tfm.cidinfo.registry or "" tfm.type = "real" diff --git a/tex/context/base/strc-bkm.lua b/tex/context/base/strc-bkm.lua index e25f55fa8..f34d83ec5 100644 --- a/tex/context/base/strc-bkm.lua +++ b/tex/context/base/strc-bkm.lua @@ -77,11 +77,13 @@ function bookmarks.place() local structural = levelmap[name] lastlevel = structural or lastlevel local title = titledata.bookmark - if (not title or title == "") and not structural then - -- placeholder, todo: bookmarklabel - title = name .. ": " .. (titledata.title or "?") - else - title = titledata.title or "?" + if not title or title == "" then + if not structural then + -- placeholder, todo: bookmarklabel + title = name .. ": " .. (titledata.title or "?") + else + title = titledata.title or "?" + end end levels[#levels+1] = { lastlevel, diff --git a/tex/context/base/strc-lst.lua b/tex/context/base/strc-lst.lua index 2ef789f2c..fefbe52ce 100644 --- a/tex/context/base/strc-lst.lua +++ b/tex/context/base/strc-lst.lua @@ -338,12 +338,14 @@ function lists.analyze(...) lists.result = lists.filter(...) end -function lists.userdata(name,r,tag) -- to tex - local str = lists.result[r] - str = str and str.userdata - str = str and str[tag] - if str then - texsprint(ctxcatcodes,str) +function lists.userdata(name,r,tag) -- to tex (todo: xml) + local result = lists.result[r] + if result then + local userdata, metadata = result.userdata, result.metadata + local str = userdata and userdata[tag] + if str then + texsprint(metadata and metadata.catcodes or ctxcatcodes,str) + end end end diff --git a/tex/context/base/tabl-tab.mkiv b/tex/context/base/tabl-tab.mkiv index 72234eac8..d926dab98 100644 --- a/tex/context/base/tabl-tab.mkiv +++ b/tex/context/base/tabl-tab.mkiv @@ -982,6 +982,7 @@ \unexpanded\def\starttable {\bgroup + \let\stoptable\dostoptable \doif\@@tisplit\v!auto {\ifinsidesplitfloat\let\@@tisplit\v!yes\fi}% \doifinsetelse\@@tisplit{\v!yes,\v!repeat} @@ -993,7 +994,12 @@ \postponenotes \firststagestartTABLE}} -\unexpanded\def\stoptable +% We cannot define \unexpanded\def\dostoptable a ssomehow lookahead +% in alignments fail then, so we relax it and define it locally. + +\let\stoptabel\relax + +\def\dostoptable {\chuckTABLEautorow % before the tail, else noalign problem \insertTABLEtail \TABLEnoalign{\globalletempty\@@TABLEhead}% @@ -1210,6 +1216,7 @@ \unexpanded\def\starttables {\bgroup + \let\stoptables\dostoptables \splittablestrue \doifelse\@@tisplit\v!repeat {\settrue \tablerepeathead\settrue \tablerepeattail} @@ -1220,23 +1227,17 @@ \global\TABLEinbreakfalse \firststagestartTABLE} -% \unexpanded\def\stoptables -% {\ifconditional\tablerepeattail\else\insertTABLEtail\fi -% \finishTABLE -% \egroup -% \dosplittablebox\tablecontentbox -% \flushnotes -% \egroup} - -\unexpanded\def\stoptables - {\chuckTABLEautorow % AM: before the tail, else noalign problem - \ifconditional\tablerepeattail\else\insertTABLEtail\fi - \finishTABLE - \egroup -\dontcomplain - \dosplittablebox\tablecontentbox - \flushnotes - \egroup} +\let\stoptables\relax % needed for \noalign + +\def\dostoptables + {\chuckTABLEautorow % AM: before the tail, else noalign problem + \ifconditional\tablerepeattail\else\insertTABLEtail\fi + \finishTABLE + \egroup + \dontcomplain + \dosplittablebox\tablecontentbox + \flushnotes + \egroup} \newdimen\TABLEcaptionheight % obsolete diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index 333668aec..c6a88f6b5 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 : 05/22/10 12:06:27 +-- merge date : 05/23/10 15:03:42 do -- begin closure to overcome local limits and interference @@ -3588,55 +3588,27 @@ fonts.define.specify.synonyms = fonts.define.specify.synonyms or { } -- tracing -fonts.color = fonts.color or { } +if not fonts.color then -local attribute = attributes.private('color') -local mapping = (attributes and attributes.list[attribute]) or { } - -local set_attribute = node.set_attribute -local unset_attribute = node.unset_attribute + fonts.color = { + set = function() end, + reset = function() end, + } -function fonts.color.set(n,c) - local mc = mapping[c] - if not mc then - unset_attribute(n,attribute) - else - set_attribute(n,attribute,mc) - end -end -function fonts.color.reset(n) - unset_attribute(n,attribute) end --- this will change ... +-- format identification -function fonts.show_char_data(n) - local tfmdata = fonts.ids[font.current()] - if tfmdata then - if type(n) == "string" then - n = utf.byte(n) - end - local chr = tfmdata.characters[n] - if chr then - write_nl(format("%s @ %s => U%04X => %s => ",tfmdata.fullname,tfmdata.size,n,utf.char(n)) .. serialize(chr,false)) - end - end -end +fonts.formats = { } -function fonts.show_font_parameters() - local tfmdata = fonts.ids[font.current()] - if tfmdata then - local parameters, mathconstants = tfmdata.parameters, tfmdata.MathConstants - local hasparameters, hasmathconstants = parameters and next(parameters), mathconstants and next(mathconstants) - if hasparameters then - write_nl(format("%s @ %s => parameters => ",tfmdata.fullname,tfmdata.size) .. serialize(parameters,false)) - end - if hasmathconstants then - write_nl(format("%s @ %s => math constants => ",tfmdata.fullname,tfmdata.size) .. serialize(mathconstants,false)) - end - if not hasparameters and not hasmathconstants then - write_nl(format("%s @ %s => no parameters and/or mathconstants",tfmdata.fullname,tfmdata.size)) - end +function fonts.fontformat(filename,default) + local extname = file.extname(filename) + local format = fonts.formats[extname] + if format then + return format + else + logs.report("fonts define","unable to detemine font format for '%s'",filename) + return default end end @@ -6451,7 +6423,10 @@ end otf.enhancers["merge cid fonts"] = function(data,filename) -- we can also move the names to data.luatex.names which might -- save us some more memory (at the cost of harder tracing) - if data.subfonts and data.glyphs and next(data.glyphs) then + if data.subfonts then + if data.glyphs and next(data.glyphs) then + logs.report("load otf","replacing existing glyph table due to subfonts") + end local cidinfo = data.cidinfo local verbose = fonts.verbose if cidinfo.registry then @@ -7365,6 +7340,11 @@ end -- we cannot share descriptions as virtual fonts might extend them (ok, we could -- use a cache with a hash +fonts.formats.dfont = "truetype" +fonts.formats.ttc = "truetype" +fonts.formats.ttf = "truetype" +fonts.formats.otf = "opentype" + function otf.copy_to_tfm(data,cache_id) -- we can save a copy when we reorder the tma to unicode (nasty due to one->many) if data then local glyphs, pfminfo, metadata = data.glyphs or { }, data.pfminfo or { }, data.metadata or { } @@ -7445,7 +7425,7 @@ function otf.copy_to_tfm(data,cache_id) -- we can save a copy when we reorder th tfm.name = tfm.filename or tfm.fullname or tfm.fontname tfm.units = metadata.units_per_em or 1000 tfm.encodingbytes = 2 - tfm.format = (metadata.order2 == 1 and 'truetype') or 'opentype' + tfm.format = fonts.fontformat(tfm.filename,"opentype") tfm.cidinfo = data.cidinfo tfm.cidinfo.registry = tfm.cidinfo.registry or "" tfm.type = "real" -- cgit v1.2.3