summaryrefslogtreecommitdiff
path: root/tex/context/base
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2012-06-05 17:36:00 +0200
committerHans Hagen <pragma@wxs.nl>2012-06-05 17:36:00 +0200
commit51a2dad390d6229948b4366ad232c662c0e3ea8b (patch)
treed5b6fcd58061fbee48a8894dce58e9ea9b3be1a5 /tex/context/base
parent1cbef76ff4aa6cc1f7dc1d38c4b0514e94ad59a5 (diff)
downloadcontext-51a2dad390d6229948b4366ad232c662c0e3ea8b.tar.gz
beta 2012.06.05 17:36
Diffstat (limited to 'tex/context/base')
-rw-r--r--tex/context/base/catc-ctx.mkiv11
-rw-r--r--tex/context/base/char-def.lua4
-rw-r--r--tex/context/base/cont-new.mkii2
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4142 -> 4142 bytes
-rw-r--r--tex/context/base/context-version.pngbin105447 -> 105663 bytes
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/font-con.lua4
-rw-r--r--tex/context/base/font-ctx.lua22
-rw-r--r--tex/context/base/font-mat.mkvi1
-rw-r--r--tex/context/base/grph-fig.mkiv15
-rw-r--r--tex/context/base/grph-inc.lua60
-rw-r--r--tex/context/base/math-fbk.lua170
-rw-r--r--tex/context/base/math-ini.mkiv1
-rw-r--r--tex/context/base/mult-low.lua1
-rw-r--r--tex/context/base/status-files.pdfbin24381 -> 24371 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin181077 -> 181182 bytes
18 files changed, 263 insertions, 34 deletions
diff --git a/tex/context/base/catc-ctx.mkiv b/tex/context/base/catc-ctx.mkiv
index bd5c16d69..ddade7f52 100644
--- a/tex/context/base/catc-ctx.mkiv
+++ b/tex/context/base/catc-ctx.mkiv
@@ -128,11 +128,18 @@
% for the moment here:
-\def\starttexcode
+\normalprotected\def\starttexcode
{\pushcatcodetable
\catcodetable\prtcatcodes}
-\def\stoptexcode
+\normalprotected\def\stoptexcode
+ {\popcatcodetable}
+
+\normalprotected\def\startcontextcode
+ {\pushcatcodetable
+ \catcodetable\ctxcatcodes}
+
+\normalprotected\def\stopcontextcode
{\popcatcodetable}
\endinput
diff --git a/tex/context/base/char-def.lua b/tex/context/base/char-def.lua
index 804468c2d..3c8f9d5d9 100644
--- a/tex/context/base/char-def.lua
+++ b/tex/context/base/char-def.lua
@@ -57244,6 +57244,8 @@ characters.data={
description="SUPERSCRIPT PLUS SIGN",
direction="es",
linebreak="al",
+ mathclass="binary",
+ mathname ="positivesign",
specials={ "super", 0x002B },
unicodeslot=0x207A,
},
@@ -57252,6 +57254,8 @@ characters.data={
description="SUPERSCRIPT MINUS",
direction="es",
linebreak="al",
+ mathclass="binary",
+ mathname ="negativesign",
specials={ "super", 0x2212 },
unicodeslot=0x207B,
},
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index 2f49f0bd4..396bd5d57 100644
--- a/tex/context/base/cont-new.mkii
+++ b/tex/context/base/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2012.06.05 09:16}
+\newcontextversion{2012.06.05 17:36}
%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/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index 2c7ae9942..fb9ded80e 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2012.06.05 09:16}
+\newcontextversion{2012.06.05 17:36}
%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-version.pdf b/tex/context/base/context-version.pdf
index edf4268a2..125e89677 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png
index eb6d3d9ea..0ce53dc16 100644
--- a/tex/context/base/context-version.png
+++ b/tex/context/base/context-version.png
Binary files differ
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index 3686f12d0..ac5b0c0ba 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2012.06.05 09:16}
+\edef\contextversion{2012.06.05 17:36}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 896baecbf..222722c92 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -23,7 +23,7 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2012.06.05 09:16}
+\edef\contextversion{2012.06.05 17:36}
%D For those who want to use this:
diff --git a/tex/context/base/font-con.lua b/tex/context/base/font-con.lua
index 928099688..ba1906364 100644
--- a/tex/context/base/font-con.lua
+++ b/tex/context/base/font-con.lua
@@ -358,6 +358,10 @@ function constructors.scale(tfmdata,specification)
elseif forcedsize > 1000 then -- safeguard
scaledpoints = forcedsize
end
+ targetparameters.mathsize = mathsize -- context specific
+ targetparameters.textsize = textsize -- context specific
+ targetparameters.forcedsize = forcedsize -- context specific
+ targetparameters.extrafactor = extrafactor -- context specific
--
local tounicode = resources.tounicode
local defaultwidth = resources.defaultwidth or 0
diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua
index 4b324a6db..4c8bc98e3 100644
--- a/tex/context/base/font-ctx.lua
+++ b/tex/context/base/font-ctx.lua
@@ -145,6 +145,7 @@ local markdata = allocate()
local xheightdata = allocate()
local csnames = allocate() -- namedata
local italicsdata = allocate()
+local lastmathids = allocate()
hashes.characters = chardata
hashes.descriptions = descriptions
@@ -156,6 +157,7 @@ hashes.marks = markdata
hashes.xheights = xheightdata
hashes.csnames = csnames
hashes.italics = italicsdata
+hashes.lastmathids = lastmathids
setmetatableindex(chardata, function(t,k)
local characters = fontdata[k].characters
@@ -905,9 +907,11 @@ function commands.definefont_two(global,cs,str,size,inheritancemode,classfeature
end
end
local tfmdata = definers.read(specification,size) -- id not yet known (size in spec?)
+ --
+ local lastfontid = 0
if not tfmdata then
report_defining("unable to define %s as [%s]",name,nice_cs(cs))
- texsetcount("global","lastfontid",-1)
+ lastfontid = -1
context.letvaluerelax(cs) -- otherwise the current definition takes the previous one
elseif type(tfmdata) == "number" then
if trace_defining then
@@ -918,14 +922,13 @@ function commands.definefont_two(global,cs,str,size,inheritancemode,classfeature
tex.definefont(global,cs,tfmdata)
-- resolved (when designsize is used):
setsomefontsize(fontdata[tfmdata].parameters.size .. "sp")
- texsetcount("global","lastfontid",tfmdata)
+ lastfontid = tfmdata
else
-- setting the extra characters will move elsewhere
local characters = tfmdata.characters
local parameters = tfmdata.parameters
- -- we use char0 as signal
+ -- we use char0 as signal; cf the spec pdf can handle this (no char in slot)
characters[0] = nil
- -- cf the spec pdf can handle this (no char in slot)
-- characters[0x00A0] = { width = parameters.space }
-- characters[0x2007] = { width = characters[0x0030] and characters[0x0030].width or parameters.space } -- figure
-- characters[0x2008] = { width = characters[0x002E] and characters[0x002E].width or parameters.space } -- period
@@ -943,15 +946,18 @@ function commands.definefont_two(global,cs,str,size,inheritancemode,classfeature
end
-- resolved (when designsize is used):
setsomefontsize((tfmdata.parameters.size or 655360) .. "sp")
- --~ if specification.fallbacks then
- --~ fonts.collections.prepare(specification.fallbacks)
- --~ end
- texsetcount("global","lastfontid",id)
+ lastfontid = id
end
if trace_defining then
report_defining("memory usage after: %s",statistics.memused())
report_defining("stop stage two")
end
+ --
+ texsetcount("global","lastfontid",lastfontid)
+ if mathsize then
+ lastmathids[mathsize] = lastfontid
+ end
+ --
statistics.stoptiming(fonts)
end
diff --git a/tex/context/base/font-mat.mkvi b/tex/context/base/font-mat.mkvi
index c8ab45b75..2a4abbff0 100644
--- a/tex/context/base/font-mat.mkvi
+++ b/tex/context/base/font-mat.mkvi
@@ -106,6 +106,7 @@
\def\font_helpers_set_math_family_indeed#mrtag#family% \fontface etc are also used later on
{\let\savedfontbody\fontbody
\let\fontfamily#family%
+ % the order is important as we depend on known id's when completing fonts
\let\fontface\!!plusthree\font_helpers_set_math_family_a\scriptscriptfont#mrtag\font
\let\fontface\!!plustwo \font_helpers_set_math_family_a\scriptfont #mrtag\font
\let\fontface\!!plusone \font_helpers_set_math_family_a\textfont #mrtag\font
diff --git a/tex/context/base/grph-fig.mkiv b/tex/context/base/grph-fig.mkiv
index 1908e6445..2e661bdb1 100644
--- a/tex/context/base/grph-fig.mkiv
+++ b/tex/context/base/grph-fig.mkiv
@@ -17,13 +17,23 @@
\unprotect
+\newtoks\everysetupexternalfigures % todo: command handler
+
\unexpanded\def\setupexternalfigures
{\dosingleempty\dosetupexternalfigures}
\def\dosetupexternalfigures[#1]%
- {\getparameters[\??ef][#1]% local settings
+ {\getparameters[\??ef][#1]% local settings
\getparameters[\??ex][#1]% global settings
- \setfigurepathlist} % the path may be used elsewhere too (as in x-res-04)
+ \the \everysetupexternalfigures}
+
+\appendtoks
+ \setfigurepathlist % the path may be used elsewhere too (as in x-res-04)
+\to \everysetupexternalfigures
+
+\appendtoks
+ \ctxcommand{setfigurelookuporder("\@@exorder")}%
+\to \everysetupexternalfigures
\presetlocalframed[\??ef]
@@ -495,6 +505,7 @@
\c!frame=\v!off,
\c!background=, % new
\c!splitcolor=\s!white,
+ \c!order=,
\c!conversion=,
\c!resolution=,
\c!prefix=,
diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua
index 33dd0766d..0b03fbcd1 100644
--- a/tex/context/base/grph-inc.lua
+++ b/tex/context/base/grph-inc.lua
@@ -154,16 +154,16 @@ figures.cachepaths = allocate {
figures.paths = allocate(table.copy(figures.localpaths))
-figures.order = allocate{
+local lookuporder = allocate {
"pdf", "mps", "jpg", "png", "jp2", "jbig", "svg", "eps", "tif", "gif", "mov", "buffer", "tex", "cld", "auto",
}
-local formats = allocate {
+local formats = allocate { -- magic and order will move here
["pdf"] = { list = { "pdf" } },
["mps"] = { patterns = { "mps", "%d+" } },
["jpg"] = { list = { "jpg", "jpeg" } },
- ["jp2"] = { list = { "jp2" } },
["png"] = { list = { "png" } },
+ ["jp2"] = { list = { "jp2" } },
["jbig"] = { list = { "jbig", "jbig2", "jb2" } },
["svg"] = { list = { "svg", "svgz" } },
["eps"] = { list = { "eps", "ai" } },
@@ -187,6 +187,30 @@ local magics = allocate {
figures.formats = formats -- frozen
figures.magics = magics -- frozen
+-- We can set the order but only indirectly so that we can
+-- check for support.
+
+function figures.setorder(list) -- can be table or string
+ if type(list) == "string" then
+ list = settings_to_array(list)
+ end
+ if list and #list > 0 then
+ lookuporder = allocate()
+ figures.order = lookuporder
+ local done = { } -- just to be sure in case the list is generated
+ for i=1,#list do
+ local l = lower(list[i])
+ if formats[l] and not done[l] then
+ lookuporder[#lookuporder+1] = l
+ done[l] = true
+ end
+ end
+ report_inclusion("lookup order: %s",concat(lookuporder," "))
+ else
+ -- invalid list
+ end
+end
+
function figures.guess(filename)
local f = io.open(filename,'rb')
if f then
@@ -208,7 +232,7 @@ end
function figures.setlookups() -- tobe redone .. just set locals
local fs, fp = allocate(), allocate()
figures.suffixes, figures.patterns = fs, fp
- for _, format in next, figures.order do
+ for _, format in next, lookuporder do
local data = formats[format]
local list = data.list
if list then
@@ -247,8 +271,8 @@ local function register(tag,target,what)
else
data[tag] = { what }
end
- if not contains(figures.order,target) then
- figures.order[#figures.order+1] = target
+ if not contains(lookuporder,target) then
+ lookuporder[#lookuporder+1] = target
end
figures.setlookups()
end
@@ -699,9 +723,8 @@ local function locate(request) -- name, format, cache
if trace_figures then
report_inclusion("strategy: rootbased path")
end
- local figureorder = figures.order
- for i=1,#figureorder do
- local format = figureorder[i]
+ for i=1,#lookuporder do
+ local format = lookuporder[i]
local list = formats[format].list or { format }
for j=1,#list do
local suffix = list[j]
@@ -725,9 +748,8 @@ local function locate(request) -- name, format, cache
report_inclusion("strategy: unknown format, prefer quality")
end
local figurepaths = figures.paths
- local figureorder = figures.order
- for j=1,#figureorder do
- local format = figureorder[j]
+ for j=1,#lookuporder do
+ local format = lookuporder[j]
local list = formats[format].list or { format }
for k=1,#list do
local suffix = list[k]
@@ -762,11 +784,10 @@ local function locate(request) -- name, format, cache
report_inclusion("strategy: unknown format, prefer path")
end
local figurepaths = figures.paths
- local figureorder = figures.order
for i=1,#figurepaths do
local path = figurepaths[i]
- for j=1,#figureorder do
- local format = figureorder[j]
+ for j=1,#lookuporder do
+ local format = lookuporder[j]
local list = formats[format].list or { format }
for k=1,#list do
local suffix = list[k]
@@ -790,9 +811,8 @@ local function locate(request) -- name, format, cache
if trace_figures then
report_inclusion("strategy: default tex path")
end
- local figureorder = figures.order
- for j=1,#figureorder do
- local format = figureorder[j]
+ for j=1,#lookuporder do
+ local format = lookuporder[j]
local list = formats[format].list or { format }
for k=1,#list do
local suffix = list[k]
@@ -1449,3 +1469,7 @@ end
-- figures.check()
-- local nofpages = fig.used.pages
-- figures.pop()
+
+-- interfacing
+
+commands.setfigurelookuporder = figures.setorder
diff --git a/tex/context/base/math-fbk.lua b/tex/context/base/math-fbk.lua
new file mode 100644
index 000000000..192e58f0f
--- /dev/null
+++ b/tex/context/base/math-fbk.lua
@@ -0,0 +1,170 @@
+if not modules then modules = { } end modules ['math-fbk'] = {
+ version = 1.001,
+ comment = "companion to math-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local trace_fallbacks = false trackers.register("math.fallbacks", function(v) trace_fallbacks = v end)
+
+local report_fallbacks = logs.reporter("math","fallbacks")
+
+local fallbacks = { }
+mathematics.fallbacks = fallbacks
+
+local virtualcharacters = { }
+
+local identifiers = fonts.hashes.identifiers
+local lastmathids = fonts.hashes.lastmathids
+
+-- we need a trick (todo): if we define scriptscript, script and text in
+-- that order we could use their id's .. i.e. we could always add a font
+-- table with those id's .. in fact, we could also add a whole lot more
+-- as it doesn't hurt
+--
+-- todo: use index 'true when luatex provides that feature (on the agenda)
+
+function fallbacks.apply(target,original)
+ local mathparameters = target.mathparameters -- why not hasmath
+ if mathparameters then
+ local characters = target.characters
+ local parameters = target.parameters
+ local mathsize = parameters.mathsize
+ local size = parameters.size
+ local usedfonts = target.fonts
+ if not usedfonts then
+ usedfonts = { }
+ target.fonts = usedfonts
+ end
+ local textid = true -- font.nextid() -- this will fail when we create more than one virtual set
+ local scriptid = textid
+ local scriptscriptid = textid
+ local lastscriptid = lastmathids[2]
+ local lastscriptscriptid = lastmathids[3]
+ if mathsize == 3 then
+ -- scriptscriptsize
+ elseif mathsize == 2 then
+ -- scriptsize
+ scriptid = lastscriptscriptid or textid
+ scriptscriptid = scriptid
+ else
+ -- textsize
+ scriptid = lastscriptid or textid
+ scriptscriptid = lastscriptscriptid or scriptid
+ end
+ local textindex, scriptindex, scriptscriptindex
+ local textdata, scriptdata, scriptscriptdata
+ if textid ~= true then
+ textindex = #usedfonts + 1
+ usedfonts[textindex] = { id = textid }
+ textdata = identifiers[textid]
+ else
+ textid = nil
+ textdata = target
+ end
+ if scriptid ~= true then
+ scriptindex = #usedfonts + 1
+ usedfonts[scriptindex] = { id = scriptid }
+ scriptdata = identifiers[scriptid]
+ else
+ scriptid = textid
+ scriptdata = textdata
+ end
+ if scriptscriptid ~= true then
+ scriptscriptindex = #usedfonts + 1
+ usedfonts[scriptscriptindex] = { id = scriptscriptid }
+ scriptscriptdata = identifiers[scriptscriptid]
+ else
+ scriptscriptid = scriptid
+ scriptscriptdata = scriptdata
+ end
+ local data = {
+ textdata = textdata,
+ scriptdata = scriptdata,
+ scriptscriptdata = scriptscriptdata,
+ textindex = textindex,
+ scriptindex = scriptindex,
+ scriptscriptindex = scriptscriptindex,
+ characters = characters,
+ unicode = k,
+ target = target,
+ original = original,
+ size = size,
+ }
+ for k, v in next, virtualcharacters do
+ if not characters[k] then
+ local tv = type(v)
+ if tv == "table" then
+ characters[k] = v
+ elseif tv == "number" then
+ characters[k] = characters[v]
+ elseif tv == "function" then
+ characters[k] = v(data)
+ end
+ if trace_fallbacks then
+ if characters[k] then
+ report_fallbacks("extending font %q with U+%05X",target.properties.fullname,k)
+ end
+ end
+ end
+ end
+ end
+end
+
+utilities.sequencers.appendaction("aftercopyingcharacters","system","mathematics.fallbacks.apply")
+
+function fallbacks.install(unicode,value)
+ virtualcharacters[unicode] = value
+end
+
+-- a few examples:
+
+local function reference(index,char)
+ if index then
+ return { "slot", index, char }
+ else
+ return { "char", char }
+ end
+end
+
+local function raised(data,down)
+ local replacement = data.replacement
+ local character = data.scriptdata.characters[replacement]
+ if character then
+ return {
+ width = character.width,
+ height = character.height,
+ depth = character.depth,
+ commands = {
+ { "down", down and data.size/4 or -data.size/2 } , -- maybe exheight
+ reference(data.scriptindex,replacement)
+ }
+ }
+ end
+end
+
+-- virtualcharacters[0x207A] = 0x2212
+-- virtualcharacters[0x207B] = 0x002B
+-- virtualcharacters[0x208A] = 0x2212
+-- virtualcharacters[0x208B] = 0x002B
+
+virtualcharacters[0x207A] = function(data)
+ data.replacement = 0x2212
+ return raised(data)
+end
+
+virtualcharacters[0x207B] = function(data)
+ data.replacement = 0x002B
+ return raised(data)
+end
+
+virtualcharacters[0x208A] = function(data)
+ data.replacement = 0x2212
+ return raised(data,true)
+end
+
+virtualcharacters[0x208B] = function(data)
+ data.replacement = 0x002B
+ return raised(data,true)
+end
diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv
index 710a65f5b..868fa7f5c 100644
--- a/tex/context/base/math-ini.mkiv
+++ b/tex/context/base/math-ini.mkiv
@@ -49,6 +49,7 @@
\registerctxluafile{math-ren}{1.001}
\registerctxluafile{math-noa}{1.001}
\registerctxluafile{math-tag}{1.001}
+\registerctxluafile{math-fbk}{1.001}
\definesystemattribute[mathalphabet] [public]
\definesystemattribute[mathsize] [public]
diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua
index 134e4c82a..404af4f05 100644
--- a/tex/context/base/mult-low.lua
+++ b/tex/context/base/mult-low.lua
@@ -122,6 +122,7 @@ return {
"startlocalsetups", "stoplocalsetups",
"starttexdefinition", "stoptexdefinition",
"starttexcode", "stoptexcode",
+ "startcontextcode", "stopcontextcode",
--
"doifsetupselse", "doifsetups", "doifnotsetups", "setup", "setups", "texsetup", "xmlsetup", "luasetup", "directsetup",
"doifelsecommandhandler","doifnotcommandhandler","doifcommandhandler",
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index d92622355..a9ea6ced5 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index d8ab22c4e..4141cf299 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ