summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2011-02-14 20:00:14 +0200
committerMarius <mariausol@gmail.com>2011-02-14 20:00:14 +0200
commit1d534cdaf5a15ab7191504b5b82d78d8f54435b9 (patch)
treeb18b7f9fa25fd28ccded25e10e166d02aa9ddd18 /tex
parentab20b3338556714d8be0ae8fbf8d79a7cfe70e21 (diff)
downloadcontext-1d534cdaf5a15ab7191504b5b82d78d8f54435b9.tar.gz
beta 2011.02.14 18:50
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/back-ini.lua2
-rw-r--r--tex/context/base/char-ini.lua45
-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.mkii2
-rw-r--r--tex/context/base/context.mkiv4
-rw-r--r--tex/context/base/core-con.lua33
-rw-r--r--tex/context/base/font-mis.lua2
-rw-r--r--tex/context/base/font-otf.lua11
-rw-r--r--tex/context/base/font-tfm.lua2
-rw-r--r--tex/context/base/grph-raw.lua39
-rw-r--r--tex/context/base/grph-raw.mkiv64
-rw-r--r--tex/context/base/lpdf-grp.lua69
-rw-r--r--tex/context/base/m-graph.mkiv156
-rw-r--r--tex/context/base/meta-tex.lua2
-rw-r--r--tex/context/base/mlib-pdf.lua160
-rw-r--r--tex/context/base/mlib-pps.lua643
-rw-r--r--tex/context/base/mult-de.mkii1
-rw-r--r--tex/context/base/mult-def.lua4
-rw-r--r--tex/context/base/mult-en.mkii1
-rw-r--r--tex/context/base/mult-fr.mkii1
-rw-r--r--tex/context/base/mult-it.mkii1
-rw-r--r--tex/context/base/mult-nl.mkii1
-rw-r--r--tex/context/base/mult-pe.mkii1
-rw-r--r--tex/context/base/mult-ro.mkii1
-rw-r--r--tex/context/base/page-lay.mkiv22
-rw-r--r--tex/context/base/sort-lan.lua23
-rw-r--r--tex/context/base/status-files.pdfbin23209 -> 23258 bytes
-rw-r--r--tex/context/base/strc-ref.mkiv6
-rw-r--r--tex/context/base/task-ini.lua2
-rw-r--r--tex/context/base/typo-cap.mkiv2
-rw-r--r--tex/context/base/typo-cln.lua87
-rw-r--r--tex/context/base/typo-cln.mkiv30
-rw-r--r--tex/context/base/util-seq.lua3
-rw-r--r--tex/context/interface/keys-cs.xml1
-rw-r--r--tex/context/interface/keys-de.xml1
-rw-r--r--tex/context/interface/keys-en.xml1
-rw-r--r--tex/context/interface/keys-fr.xml1
-rw-r--r--tex/context/interface/keys-it.xml1
-rw-r--r--tex/context/interface/keys-nl.xml1
-rw-r--r--tex/context/interface/keys-pe.xml1
-rw-r--r--tex/context/interface/keys-ro.xml1
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua15
43 files changed, 941 insertions, 506 deletions
diff --git a/tex/context/base/back-ini.lua b/tex/context/base/back-ini.lua
index dc510acc6..bc690f946 100644
--- a/tex/context/base/back-ini.lua
+++ b/tex/context/base/back-ini.lua
@@ -51,6 +51,8 @@ backends.nodeinjections = {
insertmovie = nothing,
insertsound = nothing,
+ injectbitmap = nothing,
+
}
backends.codeinjections = {
diff --git a/tex/context/base/char-ini.lua b/tex/context/base/char-ini.lua
index 103250d2b..8e94d5917 100644
--- a/tex/context/base/char-ini.lua
+++ b/tex/context/base/char-ini.lua
@@ -105,6 +105,8 @@ local private = {
description = "PRIVATE SLOT",
}
+local extenders = { }
+
setmetatablekey(data, "__index", function(t,k)
if type(k) == "string" then
k = lpegmatch(pattern,k) or utfbyte(k)
@@ -125,6 +127,10 @@ setmetatablekey(data, "__index", function(t,k)
local first, last = rr.first, rr.last
if k >= first and k <= last then
local v = t[first]
+ local extender = extenders[v.description]
+ if extender then
+ v = extender(k,v)
+ end
t[k] = v
return v
end
@@ -133,6 +139,45 @@ setmetatablekey(data, "__index", function(t,k)
return private -- handy for when we loop over characters in fonts and check for a property
end )
+local metatables = { }
+
+extenders["<Hangul Syllable>"] = function(k,v)
+ local shcode = -- for the moment we misuse the shcode .. in fact we should have the components
+ k < 0xAC00 and k -- original
+ or k > 0xD7AF and k -- original
+ or k >= 0xD558 and 0x314E -- 하 => ㅎ
+ or k >= 0xD30C and 0x314D -- 파 => ㅍ
+ or k >= 0xD0C0 and 0x314C -- 타 => ㅌ
+ or k >= 0xCE74 and 0x314B -- 카 => ㅋ
+ or k >= 0xCC28 and 0x314A -- 차 => ㅊ
+ or k >= 0xC790 and 0x3148 -- 자 => ㅈ
+ or k >= 0xC544 and 0x3147 -- 아 => ㅇ
+ or k >= 0xC0AC and 0x3145 -- 사 => ㅅ
+ or k >= 0xBC14 and 0x3142 -- 바 => ㅂ
+ or k >= 0xB9C8 and 0x3141 -- 마 => ㅁ
+ or k >= 0xB77C and 0x3139 -- 라 => ㄹ
+ or k >= 0xB2E4 and 0x3137 -- 다 => ㄷ
+ or k >= 0xB098 and 0x3134 -- 나 => ㄴ
+ or k >= 0xAC00 and 0x3131 -- 가 => ㄱ -- was 0xAC20
+ or k -- can't happen
+ local t = {
+ -- category = "lo",
+ -- cjkwd = "w",
+ -- description = "<Hangul Syllable>",
+ -- direction = "l",
+ -- linebreak = "h2",
+ shcode = shcode,
+ unicodeslot = k,
+ }
+ local m = metatables[v]
+ if not m then
+ m = { __index = v }
+ metatables[v] = m
+ end
+ setmetatable(t,m)
+ return t
+end
+
--~ setmetatable(data,{ __index = function(t,k) return "" end }) -- quite old, obsolete
characters.blocks = allocate {
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index c0a3c31a9..098a998de 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{2011.02.11 18:18}
+\newcontextversion{2011.02.14 18:50}
%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 e6fa95485..66d087466 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{2011.02.11 18:18}
+\newcontextversion{2011.02.14 18:50}
%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.mkii b/tex/context/base/context.mkii
index 15327a382..6ce2a0c58 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{2011.02.11 18:18}
+\edef\contextversion{2011.02.14 18:50}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index a6c526ad2..1f3c32c13 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2011.02.11 18:18}
+\edef\contextversion{2011.02.14 18:50}
%D For those who want to use this:
@@ -295,6 +295,7 @@
\loadmarkfile{font-col}
\loadmarkfile{font-gds}
+\loadmarkfile{typo-cln}
\loadmarkfile{typo-spa}
\loadmarkfile{typo-krn}
\loadmarkfile{typo-dir}
@@ -362,6 +363,7 @@
\loadmarkfile{grph-trf}
\loadmarkfile{grph-inc}
\loadmarkfile{grph-fig}
+\loadmarkfile{grph-raw}
\loadmarkfile{pack-box}
\loadmarkfile{pack-bar}
diff --git a/tex/context/base/core-con.lua b/tex/context/base/core-con.lua
index 5b8417d00..e2f0b164e 100644
--- a/tex/context/base/core-con.lua
+++ b/tex/context/base/core-con.lua
@@ -238,7 +238,7 @@ local function leapyear(year)
end
local function nofdays(year,month)
- return days[sleapyear(year)][month]
+ return days[isleapyear(year)][month]
end
local function year () return date("%Y") end
@@ -700,34 +700,3 @@ end
-- function converters.Alphabetic(n,code)
-- do_alphabetic(n,counters[code] or counters['**'],uppercased)
-- end
-
--- For the moment here:
-
-languages.firstcharacters = { }
-local firstcharacters = languages.firstcharacters
-
--- korean:
-
-function firstcharacters.korean(chr)
- local consonant
- if chr < 0xAC00 then consonant = chr -- original
- elseif chr > 0xD7AF then consonant = chr -- original
- elseif chr >= 0xD558 then consonant = 0x314E -- 하 => ㅎ
- elseif chr >= 0xD30C then consonant = 0x314D -- 파 => ㅍ
- elseif chr >= 0xD0C0 then consonant = 0x314C -- 타 => ㅌ
- elseif chr >= 0xCE74 then consonant = 0x314B -- 카 => ㅋ
- elseif chr >= 0xCC28 then consonant = 0x314A -- 차 => ㅊ
- elseif chr >= 0xC790 then consonant = 0x3148 -- 자 => ㅈ
- elseif chr >= 0xC544 then consonant = 0x3147 -- 아 => ㅇ
- elseif chr >= 0xC0AC then consonant = 0x3145 -- 사 => ㅅ
- elseif chr >= 0xBC14 then consonant = 0x3142 -- 바 => ㅂ
- elseif chr >= 0xB9C8 then consonant = 0x3141 -- 마 => ㅁ
- elseif chr >= 0xB77C then consonant = 0x3139 -- 라 => ㄹ
- elseif chr >= 0xB2E4 then consonant = 0x3137 -- 다 => ㄷ
- elseif chr >= 0xB098 then consonant = 0x3134 -- 나 => ㄴ
- elseif chr >= 0xAC00 then consonant = 0x3131 -- 가 => ㄱ -- was 0xAC20
- else consonant = chr -- can't happen
- end
- -- print(format("korean: 0x%04X 0x%04X",chr,consonant))
- return consonant
-end
diff --git a/tex/context/base/font-mis.lua b/tex/context/base/font-mis.lua
index 216af0155..954135be1 100644
--- a/tex/context/base/font-mis.lua
+++ b/tex/context/base/font-mis.lua
@@ -11,7 +11,7 @@ local lower, strip = string.lower, string.strip
fonts.otf = fonts.otf or { }
-fonts.otf.version = fonts.otf.version or 2.707
+fonts.otf.version = fonts.otf.version or 2.710
fonts.otf.cache = containers.define("fonts", "otf", fonts.otf.version, true)
function fonts.otf.loadcached(filename,format,sub)
diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua
index 68d3c730c..0cffc5348 100644
--- a/tex/context/base/font-otf.lua
+++ b/tex/context/base/font-otf.lua
@@ -61,7 +61,7 @@ local readers = fonts.tfm.readers
otf.glists = { "gsub", "gpos" }
-otf.version = 2.707 -- beware: also sync font-mis.lua
+otf.version = 2.710 -- beware: also sync font-mis.lua
otf.cache = containers.define("fonts", "otf", otf.version, true)
local loadmethod = "table" -- table, mixed, sparse
@@ -443,6 +443,7 @@ function otf.load(filename,format,sub,featurefile)
end
data.size = size
data.time = time
+ data.format = format
if featurefiles then
data.featuredata = featurefiles
end
@@ -1705,7 +1706,7 @@ local function copytotfm(data,cache_id) -- we can save a copy when we reorder th
spaceunits, spacer = metadata.charwidth, "charwidth"
end
end
- spaceunits = tonumber(spaceunits) or tfm.units/2 -- 500 -- brrr
+ spaceunits = tonumber(spaceunits) or 500 -- brrr
-- we need a runtime lookup because of running from cdrom or zip, brrr (shouldn't we use the basename then?)
local filename = fonts.tfm.checkedfilename(luatex)
local fontname = metadata.fontname
@@ -1748,6 +1749,10 @@ local function copytotfm(data,cache_id) -- we can save a copy when we reorder th
end
end
--
+ local fileformat = data.format or fonts.fontformat(filename,"opentype")
+ if units > 1000 then
+ fileformat = "truetype"
+ end
return {
characters = characters,
parameters = parameters,
@@ -1769,7 +1774,7 @@ local function copytotfm(data,cache_id) -- we can save a copy when we reorder th
psname = fontname or fullname,
name = filename or fullname,
units = units,
- format = fonts.fontformat(filename,"opentype"),
+ format = fileformat,
cidinfo = cidinfo,
ascender = abs(metadata.ascent or 0),
descender = abs(metadata.descent or 0),
diff --git a/tex/context/base/font-tfm.lua b/tex/context/base/font-tfm.lua
index 7fa308c25..5e841b24c 100644
--- a/tex/context/base/font-tfm.lua
+++ b/tex/context/base/font-tfm.lua
@@ -279,7 +279,9 @@ function tfm.scale(tfmtable, scaledpoints, relativeid)
-- tfm.prepare_base_kerns(tfmtable) -- optimalization
local t = { } -- the new table
local scaledpoints, delta, units = tfm.calculatescale(tfmtable, scaledpoints, relativeid)
+ -- is just a trigger for the backend
t.units_per_em = units or 1000
+ --
local hdelta, vdelta = delta, delta
-- unicoded unique descriptions shared cidinfo characters changed parameters indices
for k,v in next, tfmtable do
diff --git a/tex/context/base/grph-raw.lua b/tex/context/base/grph-raw.lua
new file mode 100644
index 000000000..361f6944d
--- /dev/null
+++ b/tex/context/base/grph-raw.lua
@@ -0,0 +1,39 @@
+if not modules then modules = { } end modules ['grph-raw'] = {
+ version = 1.001,
+ comment = "companion to grph-raw.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- This module is for Mojca, who wanted something like this for
+-- her gnuplot project. It's somewhat premliminary code but it
+-- works ok for that purpose.
+
+local report_bitmap = logs.reporter("graphics","bitmaps")
+
+local texsp = tex.sp
+
+function figures.bitmapimage(t)
+ local data = t.data
+ local xresolution = tonumber(t.xresolution)
+ local yresolution = tonumber(t.yresolution)
+ if data and xresolution and yresolution then
+ local width, height = t.width or "", t.height or ""
+ local n = backends.nodeinjections.injectbitmap {
+ xresolution = xresolution,
+ yresolution = yresolution,
+ width = width ~= "" and texsp(width) or nil,
+ height = height ~= "" and texsp(height) or nil,
+ data = data,
+ colorspace = t.colorspace,
+ }
+ if n then
+ context.hbox(n)
+ else
+ report_bitmap("format no supported by backend")
+ end
+ else
+ report_bitmap("invalid specification")
+ end
+end
diff --git a/tex/context/base/grph-raw.mkiv b/tex/context/base/grph-raw.mkiv
new file mode 100644
index 000000000..426262b4f
--- /dev/null
+++ b/tex/context/base/grph-raw.mkiv
@@ -0,0 +1,64 @@
+%D \module
+%D [ file=grph-raw,
+%D version=2006.08.26, % overhaul of 1997.03.31
+%D title=\CONTEXT\ Graphic Macros,
+%D subtitle=Raw Bitmaps,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Graphic Macros / Raw Bitmaps}
+
+%D \startluacode
+%D function document.TestBitmap(nx,ny)
+%D local random = math.random
+%D local maxbit = 2^24
+%D for i=1,nx do
+%D for i=1,ny do
+%D context("%06x",random(0,maxbit))
+%D end
+%D end
+%D end
+%D \stopluacode
+%D
+%D \def\TestBitmap#1#2{\ctxlua{document.TestBitmap(#1,#2)}}
+%D
+%D \blank
+%D
+%D \startMPcode
+%D draw textext("\bitmapimage[x=100,y=100]{\TestBitmap{100}{100}}") xsized 10cm ;
+%D \stopMPcode
+%D
+%D \blank
+%D
+%D \startMPcode
+%D draw textext("\bitmapimage[x=200,y=50]{\TestBitmap{50}{200}}") xsized 10cm ;
+%D \stopMPcode
+
+\registerctxluafile{grph-raw}{1.001}
+
+\unprotect
+
+\unexpanded\def\bitmapimage[#1]#2%
+ {\hbox\bgroup
+ \getparameters[@@im][\c!color=rgb,\c!width=,\c!height=,\c!x=,\c!y=,#1]%
+ \ctxlua{figures.bitmapimage {
+ data = \!!bs#2\!!es,
+ xresolution = "\@@imx",
+ yresolution = "\@@imy",
+ colorspace = "\@@imcolor",
+ width = "\@@imwidth",
+ height = "\@@imheight"
+ }}%
+ \egroup}
+
+\unexpanded\def\startbitmapimage[#1]#2\stopbitmapimage
+ {\bitmapimage[#1]{#2}}
+
+\let\stopbitmapimage\relax
+
+\protect \endinput
diff --git a/tex/context/base/lpdf-grp.lua b/tex/context/base/lpdf-grp.lua
index 36362ce69..692517c1f 100644
--- a/tex/context/base/lpdf-grp.lua
+++ b/tex/context/base/lpdf-grp.lua
@@ -10,7 +10,11 @@ local format = string.format
local backends, lpdf = backends, lpdf
+local nodeinjections = backends.pdf.nodeinjections
+
local colors = attributes.colors
+local basepoints = number.dimenfactors["bp"]
+local inches = number.dimenfactors["in"]
local nodeinjections = backends.pdf.nodeinjections
local codeinjections = backends.pdf.codeinjections
@@ -70,3 +74,68 @@ function lpdf.colorspec(model,ca,default)
return default
end
end
+
+-- inline bitmaps but xform'd
+--
+-- we could derive the colorspace if we strip the data
+-- and divide by x*y
+
+local template = "q BI %s ID %s > EI Q"
+local factor = 72/300
+
+function nodeinjections.injectbitmap(t)
+ -- encoding is ascii hex, no checking here
+ local xresolution, yresolution = t.xresolution or 0, t.yresolution or 0
+ if xresolution == 0 or yresolution == 0 then
+ return -- fatal error
+ end
+ local colorspace = t.colorspace
+ if colorspace ~= "rgb" and colorspace ~= "cmyk" and colorspace ~= "gray" then
+ -- not that efficient but ok
+ local d = string.gsub(t.data,"[^0-9a-f]","")
+ local b = math.round(#d / (xresolution * yresolution))
+ if b == 2 then
+ colorspace = "gray"
+ elseif b == 6 then
+ colorspace = "rgb"
+ elseif b == 8 then
+ colorspace = "cmyk"
+ end
+ end
+ if colorspace == "gray" then
+ colorspace = pdfconstant("DeviceGray")
+ elseif colorspace == "rgb" then
+ colorspace = pdfconstant("DeviceRGB")
+ elseif colorspace == "cmyk" then
+ colorspace = pdfconstant("DeviceCMYK")
+ else
+ return -- fatal error
+ end
+ local d = pdfdictionary {
+ W = xresolution,
+ H = yresolution,
+ CS = colorspace,
+ BPC = 8,
+ F = pdfconstant("AHx"),
+ }
+ -- for some reasons it only works well if we take a 1bp boundingbox
+ local urx, ury = 1/basepoints, 1/basepoints
+ -- urx = (xresolution/300)/basepoints
+ -- ury = (yresolution/300)/basepoints
+ local width, height = t.width or 0, t.height or 0
+ if width == 0 and height == 0 then
+ width = factor * xresolution / basepoints
+ height = factor * yresolution / basepoints
+ elseif width == 0 then
+ width = height * xresolution / yresolution
+ elseif height == 0 then
+ height = width * yresolution / xresolution
+ end
+ local image = img.new {
+ stream = format(template,d(),t.data),
+ width = width,
+ height = height,
+ bbox = { 0, 0, urx, ury },
+ }
+ return img.node(image)
+end
diff --git a/tex/context/base/m-graph.mkiv b/tex/context/base/m-graph.mkiv
index 837bdf888..9b28b6fd9 100644
--- a/tex/context/base/m-graph.mkiv
+++ b/tex/context/base/m-graph.mkiv
@@ -37,8 +37,44 @@
\unexpanded\long\def\MPgraphformat#1#2{\ctxlua{metapost.format_n("#1","#2")}}
+% We could also delegate parsing using lower level plugins.
+
\startMPinclusions
- input graph.mp ;
+% input string ;
+% input marith ;
+% input graph.mp ;
+
+% vardef roundd(expr x, d) =
+% if abs d > 4 :
+% if d > 0 :
+% x
+% else :
+% 0
+% fi
+% elseif d > 0 :
+% save i ; i = floor x ;
+% i + round(Ten_to[d]*(x-i))/Ten_to[d]
+% else :
+% round(x/Ten_to[-d])*Ten_to[-d]
+% fi
+% enddef ;
+
+% Ten_to0 = 1 ;
+% Ten_to1 = 10 ;
+% Ten_to2 = 100 ;
+% Ten_to3 = 1000 ;
+% Ten_to4 = 10000 ;
+%
+% def sFe_base =
+% enddef ;
+%
+% picture Fe_plus ; Fe_plus := btex + etex ;
+
+% vardef format (expr f,x) = dofmt_.Feform_(f,x) enddef ;
+% vardef Mformat (expr f,x) = dofmt_.Meform (f,x) enddef ;
+% vardef formatstr (expr f,x) = dofmt_.Feform_(f,x) enddef ;
+% vardef Mformatstr(expr f,x) = dofmt_.Meform(f,x) enddef ;
+
vardef escaped_format(expr s) =
"" for n=1 upto length(s) : &
if ASCII substring (n,n+1) of s = 37 :
@@ -48,6 +84,7 @@
fi
endfor
enddef ;
+
vardef dofmt_@\#(expr f, x) =
textext("\MPgraphformat{"&escaped_format(f)&"}{"&(if string x : x else: decimal x fi)&"}")
enddef ;
@@ -58,6 +95,7 @@
% vardef Mformat(expr f, x) =
% format(f,x)
% enddef;
+
\stopMPinclusions
\doifnotmode {demo} {\endinput}
@@ -68,63 +106,63 @@
\starttext
-\startMPpage
-draw begingraph(3in,2in);
- gdraw "agepop91.d";
-endgraph;
-\stopMPpage
-
-\startMPpage
-draw begingraph(3in,2in);
- gdraw "agepop91.d" plot btex$\bullet$etex;
-endgraph;
-\stopMPpage
-
-\startMPpage
-draw begingraph(3in,2in);
- glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
- glabel.bot(btex Age in years etex, OUT);
- gdraw "agepopm.d";
-endgraph;
-\stopMPpage
-
-\startMPpage
-draw begingraph(3in,2in);
- glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
- glabel.bot(btex Age in years etex, OUT);
- setrange(origin, whatever,whatever);
- gdraw "agepopm.d";
-endgraph;
-\stopMPpage
-
-\startMPpage
-draw begingraph(2.3in,2in);
- setcoords(log,log);
- glabel.lft(btex Seconds etex,OUT);
- glabel.bot(btex Matrix size etex,
- OUT);
- gdraw "matmul.d" dashed evenly;
- glabel.ulft(btex Standard etex,8);
- gdraw "matmul.d";
- glabel.lrt(btex Strassen etex,7);
-endgraph;
-\stopMPpage
-
-\startMPpage
-draw begingraph(6.5cm,4.5cm);
- setrange(80,0, 90,whatever);
- glabel.bot(btex Year etex, OUT);
- glabel.lft(btex \vbox{\hbox{Emissions in} \hbox{thousands of}
- \hbox{metric tons} \hbox{(heavy line)}}etex, OUT);
- gdraw "lead.d" withpen pencircle scaled 1.5pt;
- autogrid(,otick.lft);
- setcoords(linear,linear);
- setrange(80,0, 90,whatever);
- glabel.rt(btex \vbox{\hbox{Micrograms} \hbox{per cubic}
- \hbox{meter of air} \hbox{(thin line)}}etex, OUT);
- gdraw "lead.d";
- autogrid(otick.bot,otick.rt);
-endgraph;
-\stopMPpage
+% \startMPpage
+% draw begingraph(3in,2in);
+% gdraw "t:/metapost/grphdata/agepop91.d";
+% endgraph;
+% \stopMPpage
+
+% \startMPpage
+% draw begingraph(3in,2in);
+% gdraw "agepop91.d" plot btex $\bullet$ etex;
+% endgraph;
+% \stopMPpage
+
+% \startMPpage
+% draw begingraph(3in,2in);
+% glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
+% glabel.bot(btex Age in years etex, OUT);
+% gdraw "agepopm.d";
+% endgraph;
+% \stopMPpage
+
+% \startMPpage
+% draw begingraph(3in,2in);
+% glabel.lft(btex \vbox{\hbox{Population} \hbox{in millions}} etex, OUT);
+% glabel.bot(btex Age in years etex, OUT);
+% setrange(origin, whatever,whatever);
+% gdraw "agepopm.d";
+% endgraph;
+% \stopMPpage
+
+% \startMPpage
+% draw begingraph(2.3in,2in);
+% setcoords(log,log);
+% glabel.lft(btex Seconds etex,OUT);
+% glabel.bot(btex Matrix size etex,
+% OUT);
+% gdraw "matmul.d" dashed evenly;
+% glabel.ulft(btex Standard etex,8);
+% gdraw "matmul.d";
+% glabel.lrt(btex Strassen etex,7);
+% endgraph;
+% \stopMPpage
+
+% \startMPpage
+% draw begingraph(6.5cm,4.5cm);
+% setrange(80,0, 90,whatever);
+% glabel.bot(btex Year etex, OUT);
+% glabel.lft(btex \vbox{\hbox{Emissions in} \hbox{thousands of}
+% \hbox{metric tons} \hbox{(heavy line)}}etex, OUT);
+% gdraw "lead.d" withpen pencircle scaled 1.5pt;
+% autogrid(,otick.lft);
+% setcoords(linear,linear);
+% setrange(80,0, 90,whatever);
+% glabel.rt(btex \vbox{\hbox{Micrograms} \hbox{per cubic}
+% \hbox{meter of air} \hbox{(thin line)}}etex, OUT);
+% gdraw "lead.d";
+% autogrid(otick.bot,otick.rt);
+% endgraph;
+% \stopMPpage
\stoptext
diff --git a/tex/context/base/meta-tex.lua b/tex/context/base/meta-tex.lua
index 3cd70024b..872e8154c 100644
--- a/tex/context/base/meta-tex.lua
+++ b/tex/context/base/meta-tex.lua
@@ -31,7 +31,7 @@ if not modules then modules = { } end modules ['meta-tex'] = {
local P, Cs, lpegmatch = lpeg.P, lpeg.Cs, lpeg.match
-local pattern = Cs((P([[\"]]) + P([["]])/"\\quotedbl " + P(1))^0)
+local pattern = Cs((P([[\"]]) + P([["]])/"\\quotedbl{}" + P(1))^0)
function metapost.escaped(str)
context(lpegmatch(pattern,str))
diff --git a/tex/context/base/mlib-pdf.lua b/tex/context/base/mlib-pdf.lua
index b7f2863ad..8000d5a28 100644
--- a/tex/context/base/mlib-pdf.lua
+++ b/tex/context/base/mlib-pdf.lua
@@ -8,6 +8,8 @@ if not modules then modules = { } end modules ['mlib-pdf'] = {
local format, concat, gsub = string.format, table.concat, string.gsub
local abs, sqrt, round = math.abs, math.sqrt, math.round
+local setmetatable = setmetatable
+local Cf, C, Cg, Ct, P, S, lpegmatch = lpeg.Cf, lpeg.C, lpeg.Cg, lpeg.Ct, lpeg.P, lpeg.S, lpeg.match
local allocate = utilities.storage.allocate
@@ -24,7 +26,6 @@ local metapost = metapost
metapost.multipass = false
metapost.n = 0
metapost.optimize = true -- false
-metapost.specials = allocate()
--~ Because in MKiV we always have two passes, we save the objects. When an extra
--~ mp run is done (due to for instance texts identifier in the parse pass), we
@@ -240,18 +241,28 @@ end
metapost.flushnormalpath = flushnormalpath
--- we have two extension handlers, one for pre and postscripts, and one for colors
+-- The flusher is pdf based, if another backend is used, we need to overload the
+-- flusher; this is beta code, the organization will change (already upgraded in
+-- sync with mplib)
+--
+-- We can avoid the before table but I like symmetry. There is of course a small
+-- performance penalty, but so is passing extra arguments (result, flusher, after)
+-- and returning stuff.
--- the flusher is pdf based, if another backend is used, we need to overload the
--- flusher; this is beta code, the organization will change
+local function ignore() end
-function metapost.flush(result,flusher,askedfig) -- pdf flusher, table en dan concat is sneller, 1 literal
+function metapost.flush(result,flusher,askedfig)
if result then
local figures = result.fig
if figures then
flusher = flusher or metapost.flushers.pdf
- local colorconverter = metapost.colorconverter() -- function !
- local colorhandler = metapost.colorhandler
+ local resetplugins = metapost.resetplugins or ignore
+ local processplugins = metapost.processplugins or ignore
+ local pluginactions = metapost.pluginactions or ignore
+ local startfigure = flusher.startfigure
+ local stopfigure = flusher.stopfigure
+ local flushfigure = flusher.flushfigure
+ local textfigure = flusher.textfigure
for f=1, #figures do
local figure = figures[f]
local objects = getobjects(result,figure,f)
@@ -267,19 +278,18 @@ function metapost.flush(result,flusher,askedfig) -- pdf flusher, table en dan co
metapost.ury = ury
if urx < llx then
-- invalid
- flusher.startfigure(fignum,0,0,0,0,"invalid",figure)
- flusher.stopfigure()
+ startfigure(fignum,0,0,0,0,"invalid",figure)
+ stopfigure()
else
- flusher.startfigure(fignum,llx,lly,urx,ury,"begin",figure)
+ startfigure(fignum,llx,lly,urx,ury,"begin",figure)
t[#t+1] = "q"
if objects then
+ resetplugins() -- we should move the colorinitializer here
t[#t+1] = metapost.colorinitializer()
- -- once we have multiple prescripts we can do more tricky things like
- -- text and special colors at the same time
for o=1,#objects do
local object = objects[o]
local objecttype = object.type
- if objecttype == "start_bounds" or objecttype == "stop_bounds" then
+ if objecttype == "start_bounds" or objecttype == "stop_bounds" or objecttype == "special" then
-- skip
elseif objecttype == "start_clip" then
t[#t+1] = "q"
@@ -288,76 +298,44 @@ function metapost.flush(result,flusher,askedfig) -- pdf flusher, table en dan co
elseif objecttype == "stop_clip" then
t[#t+1] = "Q"
miterlimit, linecap, linejoin, dashed = -1, -1, -1, false
- elseif objecttype == "special" then
- metapost.specials.register(object.prescript)
elseif objecttype == "text" then
t[#t+1] = "q"
local ot = object.transform -- 3,4,5,6,1,2
t[#t+1] = format("%f %f %f %f %f %f cm",ot[3],ot[4],ot[5],ot[6],ot[1],ot[2]) -- TH: format("%f %f m %f %f %f %f 0 0 cm",unpack(ot))
- flusher.flushfigure(t) -- flush accumulated literals
+ flushfigure(t) -- flush accumulated literals
t = { }
- flusher.textfigure(object.font,object.dsize,object.text,object.width,object.height,object.depth)
+ textfigure(object.font,object.dsize,object.text,object.width,object.height,object.depth)
t[#t+1] = "Q"
else
- -- alternatively we can pass on the stack, could be a helper
- -- can be optimized with locals
- local currentobject = { -- not needed when no extensions
- type = object.type,
- miterlimit = object.miterlimit,
- linejoin = object.linejoin,
- linecap = object.linecap,
- color = object.color,
- dash = object.dash,
- path = object.path,
- htap = object.htap,
- pen = object.pen,
- prescript = object.prescript,
- postscript = object.postscript,
- }
- --
- local before, inbetween, after, grouped = nil, nil, nil, false
- --
- local cs, cr = currentobject.color, nil
- -- todo document why ...
- if cs and colorhandler and #cs > 0 and round(cs[1]*10000) == 123 then -- test in function
- currentobject, cr = colorhandler(cs,currentobject,t,colorconverter)
- objecttype = currentobject.type
- end
- --
- local prescript = currentobject.prescript
- if prescript and prescript ~= "" then
- -- move test to function
- local special = metapost.specials[prescript]
- if special then
- currentobject, before, inbetween, after, grouped = special(currentobject.postscript,currentobject,t,flusher)
- objecttype = currentobject.type
- end
- end
- --
- cs = currentobject.color
- if cs and #cs > 0 then
- t[#t+1], cr = colorconverter(cs)
- end
- --
+ -- we use an indirect table as we want to overload
+ -- entries but this is not possible in userdata
+ local original = object
+ local object = { }
+ setmetatable(object, {
+ __index = original
+ })
+ -- first we analyze
+ local before, after = processplugins(object)
+ local objecttype = object.type -- can have changed
if before then
- currentobject, t = before()
+ t = pluginactions(before,t,flushfigure)
end
- local ml = currentobject.miterlimit
+ local ml = object.miterlimit
if ml and ml ~= miterlimit then
miterlimit = ml
t[#t+1] = format("%f M",ml)
end
- local lj = currentobject.linejoin
+ local lj = object.linejoin
if lj and lj ~= linejoin then
linejoin = lj
t[#t+1] = format("%i j",lj)
end
- local lc = currentobject.linecap
+ local lc = object.linecap
if lc and lc ~= linecap then
linecap = lc
t[#t+1] = format("%i J",lc)
end
- local dl = currentobject.dash
+ local dl = object.dash
if dl then
local d = format("[%s] %i d",concat(dl.dashes or {}," "),dl.offset)
if d ~= dashed then
@@ -368,14 +346,13 @@ function metapost.flush(result,flusher,askedfig) -- pdf flusher, table en dan co
t[#t+1] = "[] 0 d"
dashed = false
end
- if inbetween then currentobject, t = inbetween() end
- local path = currentobject.path
+ local path = object.path -- newpath
local transformed, penwidth = false, 1
local open = path and path[1].left_type and path[#path].right_type -- at this moment only "end_point"
- local pen = currentobject.pen
+ local pen = object.pen
if pen then
if pen.type == 'elliptical' then
- transformed, penwidth = pen_characteristics(object) -- boolean, value
+ transformed, penwidth = pen_characteristics(original) -- boolean, value
t[#t+1] = format("%f w",penwidth) -- todo: only if changed
if objecttype == 'fill' then
objecttype = 'both'
@@ -404,7 +381,7 @@ function metapost.flush(result,flusher,askedfig) -- pdf flusher, table en dan co
if transformed then
t[#t+1] = "Q"
end
- local path = currentobject.htap
+ local path = object.htap
if path then
if transformed then
t[#t+1] = "q"
@@ -425,22 +402,19 @@ function metapost.flush(result,flusher,askedfig) -- pdf flusher, table en dan co
t[#t+1] = "Q"
end
end
- if cr then
- t[#t+1] = cr
- end
if after then
- currentobject, t = after()
+ t = pluginactions(after,t,flushfigure)
end
- if grouped then
+ if object.grouped then
-- can be qQ'd so changes can end up in groups
miterlimit, linecap, linejoin, dashed = -1, -1, -1, false
end
end
- end
+ end
end
t[#t+1] = "Q"
- flusher.flushfigure(t)
- flusher.stopfigure("end")
+ flushfigure(t)
+ stopfigure("end")
end
if askedfig then
break
@@ -455,6 +429,7 @@ function metapost.parse(result,askedfig)
if result then
local figures = result.fig
if figures then
+ local analyzeplugins = metapost.analyzeplugins
for f=1, #figures do
local figure = figures[f]
local fignum = figure:charcode() or 0
@@ -467,17 +442,14 @@ function metapost.parse(result,askedfig)
metapost.ury = ury
local objects = getobjects(result,figure,f)
if objects then
+ -- for o=1,#objects do
+ -- local object = objects[o]
+ -- local prescript = object.prescript
+ -- if prescript then
+ -- analyzeplugins(object)
+ -- end
for o=1,#objects do
- local object = objects[o]
- if object.type == "outline" then
- local prescript = object.prescript
- if prescript then
- local special = metapost.specials[prescript]
- if special then
- special(object.postscript,object)
- end
- end
- end
+ analyzeplugins(objects[o])
end
end
break
@@ -539,21 +511,3 @@ function metapost.totable(result)
return nil
end
end
-
--- will be overloaded later
-
-function metapost.colorconverter()
- return function(cr)
- local n = #cr
- if n == 4 then
- local c, m, y, k = cr[1], cr[2], cr[3], cr[4]
- return format("%.3f %.3f %.3f %.3f k %.3f %.3f %.3f %.3f K",c,m,y,k,c,m,y,k), "0 g 0 G"
- elseif n == 3 then
- local r, g, b = cr[1], cr[2], cr[3]
- return format("%.3f %.3f %.3f rg %.3f %.3f %.3f RG",r,g,b,r,g,b), "0 g 0 G"
- else
- local s = cr[1]
- return format("%.3f g %.3f G",s,s), "0 g 0 G"
- end
- end
-end
diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua
index 947c19af4..a8cdf7275 100644
--- a/tex/context/base/mlib-pps.lua
+++ b/tex/context/base/mlib-pps.lua
@@ -1,4 +1,4 @@
-if not modules then modules = { } end modules ['mlib-pps'] = { -- prescript, postscripts and specials
+if not modules then modules = { } end modules ['mlib-pps'] = {
version = 1.001,
comment = "companion to mlib-ctx.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
@@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['mlib-pps'] = { -- prescript, pos
license = "see context related readme files",
}
+-- pps: prescript, postscripts and specials (although specials are dropped)
+--
-- current limitation: if we have textext as well as a special color then due to
-- prescript/postscript overload we can have problems
--
@@ -17,7 +19,7 @@ local lpegmatch = lpeg.match
local texbox = tex.box
local copy_list, free_list = node.copy_list, node.flush_list
-local P, S, V, Cs = lpeg.P, lpeg.S, lpeg.V, lpeg.Cs
+local Cs, Cf, C, Cg, Ct, P, S, V = lpeg.Cs, lpeg.Cf, lpeg.C, lpeg.Cg, lpeg.Ct, lpeg.P, lpeg.S, lpeg.V
local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming
@@ -26,34 +28,20 @@ local context = context
local trace_textexts = false trackers.register("metapost.textexts", function(v) trace_textexts = v end)
local report_metapost = logs.reporter("metapost")
+local report_textexts = logs.reporter("metapost","textexts")
local colors = attributes.colors
-local rgbtocmyk = colors.rgbtocmyk or function() return 0,0,0,1 end
-local cmyktorgb = colors.cmyktorgb or function() return 0,0,0 end
-local rgbtogray = colors.rgbtogray or function() return 0 end
-local cmyktogray = colors.cmyktogray or function() return 0 end
-
-local mplib, lpdf = mplib, lpdf
+local rgbtocmyk = colors.rgbtocmyk or function() return 0,0,0,1 end
+local cmyktorgb = colors.cmyktorgb or function() return 0,0,0 end
+local rgbtogray = colors.rgbtogray or function() return 0 end
+local cmyktogray = colors.cmyktogray or function() return 0 end
-local metapost = metapost
-local specials = metapost.specials
-
-specials.data = specials.data or { }
-local data = specials.data
+local mplib, metapost, lpdf = mplib, metapost, lpdf
metapost.makempy = metapost.makempy or { nofconverted = 0 }
local makempy = metapost.makempy
-local colordata = { {}, {}, {}, {}, {} }
-
---~ (r,g,b) => cmyk : r=123 g= 1 b=hash
---~ => spot : r=123 g= 2 b=hash
---~ => transparent rgb : r=123 g= 3 b=hash
---~ => transparent cmyk : r=123 g= 4 b=hash
---~ => transparent spot : r=123 g= 5 b=hash
---~ => rest : r=123 g=n>10 b=whatever
-
local nooutercolor = "0 g 0 G"
local nooutertransparency = "/Tr0 gs" -- only when set
local outercolormode = 0
@@ -105,161 +93,19 @@ function metapost.colorinitializer()
return outercolor, outertransparency
end
-function specials.register(str) -- only colors
- local size, content, n, class = match(str,"^%%%%MetaPostSpecial: (%d+) (.*) (%d+) (%d+)$")
- if class then
- -- use lpeg splitter
- local data , d = { }, 0
- for s in gmatch(content,"[^ ]+") do
- d = d + 1
- data[d] = s
- end
- class, n = tonumber(class), tonumber(n)
- if class == 3 or class == 4 or class == 5 then
- -- hm, weird
- else
- n = tonumber(data[1])
- end
- if n then
- local cc = colordata[class]
- if cc then
- cc[n] = data
- else
- report_metapost("problematic special: %s (no colordata class %s)", str or "?",class)
- end
- else
- -- there is some bug to be solved, so we issue a message
- report_metapost("problematic special: %s", str or "?")
- end
- end
---~ if match(str,"^%%%%MetaPostOption: multipass") then
---~ metapost.multipass = true
---~ end
-end
-
-local function spotcolorconverter(parent, n, d, p)
- registerspotcolor(parent)
- return pdfcolor(colors.model,registercolor(nil,'spot',parent,n,d,p))
-end
-
-function metapost.colorhandler(cs, object, result, colorconverter) -- handles specials
- local cr = outercolor
- local what = round(cs[2]*10000)
- local data = colordata[what]
- if data then
- data = data[round(cs[3]*10000)]
- end
- if not data then
- --
- elseif what == 1 then
- result[#result+1], cr = colorconverter({ data[2], data[3], data[4], data[5] })
- elseif what == 2 then
- result[#result+1] = spotcolorconverter(data[2],data[3],data[4],data[5])
- else
- if what == 3 then
- result[#result+1], cr = colorconverter({ data[3], data[4], data[5]})
- elseif what == 4 then
- result[#result+1], cr = colorconverter({ data[3], data[4], data[5], data[6]})
- elseif what == 5 then
- result[#result+1] = spotcolorconverter(data[3],data[4],data[5],data[6])
- end
- object.prescript = "tr"
- object.postscript = data[1] .. "," .. data[2]
- end
- object.color = nil
- return object, cr
-end
-
-function metapost.colorspec(cs) -- used for shades ... returns table (for checking) or string (spot)
- local what = round(cs[2]*10000)
- local data = colordata[what][round(cs[3]*10000)]
- if not data then
- return { 0 }
- elseif what == 1 then
- return { tonumber(data[2]), tonumber(data[3]), tonumber(data[4]), tonumber(data[5]) }
- elseif what == 2 then
- return spotcolorconverter(data[2],data[3],data[4],data[5])
- elseif what == 3 then
- return { tonumber(data[3]), tonumber(data[4]), tonumber(data[5]) }
- elseif what == 4 then
- return { tonumber(data[3]), tonumber(data[4]), tonumber(data[5]), tonumber(data[6]) }
- elseif what == 5 then
- return spotcolorconverter(data[3],data[4],data[5],data[6])
- end
-end
-
-function specials.tr(specification,object,result)
- local a, t = match(specification,"^(.+),(.+)$")
- local before = a and t and function()
- result[#result+1] = format("/Tr%s gs",registertransparency(nil,a,t,true)) -- maybe nil instead of 'mp'
- return object, result
- end
- local after = before and function()
- result[#result+1] = outertransparency -- here we could revert to the outer color
- return object, result
- end
- return object, before, nil, after
-end
+--~
local specificationsplitter = lpeg.Ct(lpeg.splitat(" "))
-local colorsplitter = lpeg.Ct(lpeg.splitat(":"))
-local colorsplitter = lpeg.Ct(lpeg.splitter(":",tonumber))
-
--- Unfortunately we cannot use cmyk colors natively because there is no
--- generic color allocation primitive ... it's just an rgbcolor color.. This
--- means that we cannot pass colors in either cmyk or rgb form.
---
--- def cmyk(expr c,m,y,k) =
--- 1 withprescript "cc" withpostscript ddddecimal (c,m,y,k)
--- enddef ;
---
--- This is also an example of a simple plugin.
-
---~ function specials.cc(specification,object,result)
---~ object.color = lpegmatch(specificationsplitter,specification)
---~ return object, nil, nil, nil
---~ end
---~ function specials.cc(specification,object,result)
---~ local c = lpegmatch(specificationsplitter,specification)
---~ local o = object.color[1]
---~ c[1],c[2],c[3],c[4] = o*c[1],o*c[2],o*c[3],o*c[4]
---~ return object, nil, nil, nil
---~ end
+local colorsplitter = lpeg.Ct(lpeg.splitter(":",tonumber)) -- no need for :
+local domainsplitter = lpeg.Ct(lpeg.splitter(" ",tonumber))
+local centersplitter = domainsplitter
+local coordinatesplitter = domainsplitter
-- thanks to taco's reading of the postscript manual:
--
-- x' = sx * x + ry * y + tx
-- y' = rx * x + sy * y + ty
-function specials.fg(specification,object,result,flusher) -- graphics
- local op = object.path
- local first, second, fourth = op[1], op[2], op[4]
- local tx, ty = first.x_coord , first.y_coord
- local sx, sy = second.x_coord - tx, fourth.y_coord - ty
- local rx, ry = second.y_coord - ty, fourth.x_coord - tx
- if sx == 0 then sx = 0.00001 end
- if sy == 0 then sy = 0.00001 end
- local before = specification and function()
- flusher.flushfigure(result)
- context.MPLIBfigure(sx,rx,ry,sy,tx,ty,specification)
- object.path = nil
- return object, { }
- end
- return { } , before, nil, nil, true -- replace { } by object for tracing
-end
-
-function specials.ps(specification,object,result) -- positions
- local op = object.path
- local first, third = op[1], op[3]
- local x, y = first.x_coord, first.y_coord
- local w, h = third.x_coord - x, third.y_coord - y
- local label = specification
- x = x - metapost.llx
- y = metapost.ury - y
- context.MPLIBpositionwhd(label,x,y,w,h)
- return { }, nil, nil, nil, true
-end
-
local nofshades = 0 -- todo: hash resources, start at 1000 in order not to clash with older
local function normalize(ca,cb)
@@ -285,8 +131,6 @@ end
local function checkandconvert(ca,cb)
local name = format("MpSh%s",nofshades)
- if round(ca[1]*10000) == 123 then ca = metapost.colorspec(ca) end
- if round(cb[1]*10000) == 123 then cb = metapost.colorspec(cb) end
if type(ca) == "string" then
return { 0 }, { 1 }, "DeviceGray", name
else
@@ -332,52 +176,6 @@ local function checkandconvert(ca,cb)
end
end
-local function resources(object,name,flusher,result)
- -- There is no real need for flushing in between, so:
- --
- -- flusher.flushfigure(result)
- -- local result = { }
- --
- local before = function()
- result[#result+1] = "q /Pattern cs"
- return object, result
- end
- local after = function()
- result[#result+1] = format("W n /%s sh Q", name)
- return object, result
- end
- object.color, object.type = nil, nil
- return object, before, nil, after, true
-end
-
--- todo: we need a way to move/scale
-
-function specials.cs(specification,object,result,flusher) -- spot colors?
- nofshades = nofshades + 1
- local t = lpegmatch(specificationsplitter,specification)
- local ca = lpegmatch(colorsplitter,t[4])
- local cb = lpegmatch(colorsplitter,t[8])
- local domain = { tonumber(t[1]), tonumber(t[2]) }
- local coordinates = { tonumber(t[5]), tonumber(t[6]), tonumber(t[7]), tonumber(t[9]), tonumber(t[10]), tonumber(t[11]) }
- local ca, cb, colorspace, name = checkandconvert(ca,cb)
- lpdf.circularshade(name,domain,ca,cb,1,colorspace,coordinates) -- backend specific (will be renamed)
- return resources(object,name,flusher,result) -- object, before, nil, after, grouped
-end
-
-function specials.ls(specification,object,result,flusher)
- nofshades = nofshades + 1
- local t = lpegmatch(specificationsplitter,specification)
- local ca = lpegmatch(colorsplitter,t[4])
- local cb = lpegmatch(colorsplitter,t[7])
- local domain = { tonumber(t[1]), tonumber(t[2]) }
- local coordinates = { tonumber(t[5]), tonumber(t[6]), tonumber(t[8]), tonumber(t[9]) }
- local ca, cb, colorspace, name = checkandconvert(ca,cb)
- lpdf.linearshade(name,domain,ca,cb,1,colorspace,coordinates) -- backend specific (will be renamed)
- return resources(object,name,flusher,result) -- object, before, nil, after, grouped
-end
-
--- no need for a before here
-
local current_format, current_graphic, current_initializations
metapost.multipass = false
@@ -393,7 +191,7 @@ local function freeboxes() -- todo: mp direct list ipv box
-- texbox[scratchbox] = tn
-- texbox[scratchbox] = nil -- this frees too
if trace_textexts then
- report_metapost("freeing textext %s",n)
+ report_textexts("freeing %s",n)
end
end
end
@@ -413,72 +211,11 @@ end
function metapost.gettext(box,slot)
texbox[box] = copy_list(textexts[slot])
if trace_textexts then
- report_metapost("putting textext %s in box %s",slot,box)
+ report_textexts("putting %s in box %s",slot,box)
end
-- textexts[slot] = nil -- no, pictures can be placed several times
end
-function specials.tf(specification,object)
- local n, str = match(specification,"^(%d+):(.+)$")
- if n and str then
- n = tonumber(n)
- if trace_textexts then
- report_metapost("setting textext %s (first pass)",n)
- end
- context.MPLIBsettext(n,str)
- metapost.multipass = true
- end
- return { }, nil, nil, nil, true
-end
-
-local factor = 65536*(7227/7200)
-
-function metapost.edefsxsy(wd,ht,dp) -- helper for figure
- local hd = ht + dp
- context.setvalue("sx",wd ~= 0 and factor/wd or 0)
- context.setvalue("sy",hd ~= 0 and factor/hd or 0)
-end
-
-local function sxsy(wd,ht,dp) -- helper for text
- local hd = ht + dp
- return (wd ~= 0 and factor/wd) or 0, (hd ~= 0 and factor/hd) or 0
-end
-
-function specials.ts(specification,object,result,flusher)
- local n, str = match(specification,"^(%d+):(.+)$")
- if n and str then
- n = tonumber(n)
- if trace_textexts then
- report_metapost("processing textext %s (second pass)",n)
- end
- local op = object.path
- local first, second, fourth = op[1], op[2], op[4]
- local tx, ty = first.x_coord , first.y_coord
- local sx, sy = second.x_coord - tx, fourth.y_coord - ty
- local rx, ry = second.y_coord - ty, fourth.x_coord - tx
- if sx == 0 then sx = 0.00001 end
- if sy == 0 then sy = 0.00001 end
- if not trace_textexts then
- object.path = nil
- end
- local before = function() -- no need for before function (just do it directly)
- result[#result+1] = format("q %f %f %f %f %f %f cm", sx,rx,ry,sy,tx,ty)
- flusher.flushfigure(result)
- local box = textexts[n]
- if box then
- context.MPLIBgettextscaled(n,sxsy(box.width,box.height,box.depth))
- else
- -- error
- end
- result = { "Q" }
- return object, result
- end
- return { }, before, nil, nil, true -- replace { } by object for tracing
- else
- return { }, nil, nil, nil, true -- replace { } by object for tracing
- end
-end
-
-- rather generic pdf, so use this elsewhere too it no longer pays
-- off to distinguish between outline and fill (we now have both
-- too, e.g. in arrows)
@@ -615,8 +352,19 @@ function models.gray(cr)
return checked_color_pair(format("%.3f g %.3f G",s,s))
end
-function metapost.colorconverter()
- return models[colors.model] or gray
+setmetatable(models, { __index = function(t,k)
+ local v = models.gray
+ t[k] = v
+ return v
+end })
+
+local function colorconverter(cs)
+ return models[colors.model](cs)
+end
+
+local function spotcolorconverter(parent, n, d, p)
+ registerspotcolor(parent)
+ return pdfcolor(colors.model,registercolor(nil,'spot',parent,n,d,p)), outercolor
end
local btex = P("btex")
@@ -679,6 +427,19 @@ end
metapost.checktexts = checktexts
+local factor = 65536*(7227/7200)
+
+function metapost.edefsxsy(wd,ht,dp) -- helper for figure
+ local hd = ht + dp
+ context.setvalue("sx",wd ~= 0 and factor/wd or 0)
+ context.setvalue("sy",hd ~= 0 and factor/hd or 0)
+end
+
+local function sxsy(wd,ht,dp) -- helper for text
+ local hd = ht + dp
+ return (wd ~= 0 and factor/wd) or 0, (hd ~= 0 and factor/hd) or 0
+end
+
local no_trial_run = "_trial_run_ := false ;"
local do_trial_run = "if unknown _trial_run_ : boolean _trial_run_ fi ; _trial_run_ := true ;"
local text_data_template = "_tt_w_[%i]:=%f;_tt_h_[%i]:=%f;_tt_d_[%i]:=%f;"
@@ -692,7 +453,7 @@ function metapost.texttextsdata()
if box then
local wd, ht, dp = box.width/factor, box.height/factor, box.depth/factor
if trace_textexts then
- report_metapost("passed textext data %s: (%0.4f,%0.4f,%0.4f)",n,wd,ht,dp)
+ report_textexts("passed data %s: (%0.4f,%0.4f,%0.4f)",n,wd,ht,dp)
end
nt = nt + 1
t[nt] = format(text_data_template,n,wd,n,ht,n,dp)
@@ -709,6 +470,8 @@ metapost.intermediate.needed = false
metapost.method = 1 -- 1:dumb 2:clever
+-- maybe we can latelua the texts some day
+
function metapost.graphic_base_pass(mpsformat,str,initializations,preamble,askedfig)
local nofig = (askedfig and "") or false
local done_1, done_2, forced_1, forced_2
@@ -802,18 +565,320 @@ function makempy.processgraphics(graphics)
end
end
-local graphics = { }
+-- -- the new plugin handler -- --
+
+local sequencers = utilities.sequencers
+local appendgroup = sequencers.appendgroup
+local appendaction = sequencers.appendaction
+
+local resetter = nil
+local analyzer = nil
+local processor = nil
+
+local resetteractions = sequencers.reset { arguments = "" }
+local analyzeractions = sequencers.reset { arguments = "object,prescript" }
+local processoractions = sequencers.reset { arguments = "object,prescript,before,after" }
+
+appendgroup(resetteractions, "system")
+appendgroup(analyzeractions, "system")
+appendgroup(processoractions,"system")
+
+local scriptsplitter = Cf(Ct("") * (
+ Cg(C((1-S("= "))^1) * S("= ")^1 * C((1-S("\n\r"))^0) * S("\n\r")^0)
+)^0, rawset)
+
+function metapost.pluginactions(what,t,flushfigure) -- to be checked: too many 0 g 0 G
+ for i=1,#what do
+ local wi = what[i]
+ if type(wi) == "function" then
+ -- assume injection
+ flushfigure(t)
+ t = { }
+ wi()
+ else
+ t[#t+1] = wi
+ end
+ end
+ return t
+end
+
+function metapost.resetplugins()
+ resetter()
+end
+
+function metapost.analyzeplugins(object)
+ local prescript = object.prescript -- specifications
+ if prescript and #prescript > 0 then
+ local prescript = lpegmatch(scriptsplitter,prescript)
+ return analyzer(object,prescript)
+ end
+end
+
+function metapost.processplugins(object) -- maybe environment table
+ local prescript = object.prescript -- specifications
+ if prescript and #prescript > 0 then
+ local prescript = lpegmatch(scriptsplitter,prescript)
+ local before = { }
+ local after = { }
+ processor(object,prescript,before,after)
+ return #before > 0 and before, #after > 0 and after
+ else
+ local c = object.color
+ if c and #c > 0 then
+ local b, a = colorconverter(c)
+ return { b }, { a }
+ end
+ end
+end
+
+-- helpers
-function specials.gt(specification,object) -- number, so that we can reorder
- graphics[#graphics+1] = format("\\MPLIBgraphictext{%s}",specification)
- metapost.intermediate.needed = true
- metapost.multipass = true
- return { }, nil, nil, nil, true
+local basepoints = number.dimenfactors["bp"]
+
+local cm = function(object)
+ local op = object.path
+ local first, second, fourth = op[1], op[2], op[4]
+ local tx, ty = first.x_coord , first.y_coord
+ local sx, sy = second.x_coord - tx, fourth.y_coord - ty
+ local rx, ry = second.y_coord - ty, fourth.x_coord - tx
+ if sx == 0 then sx = 0.00001 end
+ if sy == 0 then sy = 0.00001 end
+ return sx,rx,ry,sy,tx,ty
+end
+
+-- text
+
+local tx_done = { }
+
+local function tx_reset()
+ tx_done = { }
+end
+
+local function tx_analyze(object,prescript) -- todo: hash content and reuse them
+ local tx_stage = prescript.tx_stage
+ if tx_stage then
+ local tx_number = tonumber(prescript.tx_number)
+ if not tx_done[tx_number] then
+ tx_done[tx_number] = true
+ if trace_textexts then
+ report_textexts("setting %s %s (first pass)",tx_stage,tx_number)
+ end
+ local s = object.postscript or ""
+ local c = object.color -- only simple ones, no transparency
+ local a = prescript.tr_alternative
+ local t = prescript.tr_transparency
+ if not c then
+ -- no color
+ elseif #c == 1 then
+ if a and t then
+ s = format("\\colored[s=%f,a=%f,t=%f]%s",c[1],a,t,s)
+ else
+ s = format("\\colored[s=%f]%s",c[1],s)
+ end
+ elseif #c == 3 then
+ if a and t then
+ s = format("\\colored[r=%f,g=%f,b=%f,a=%f,t=%f]%s",c[1],c[2],c[3],a,t,s)
+ else
+ s = format("\\colored[r=%f,g=%f,b=%f]%s",c[1],c[2],c[3],s)
+ end
+ elseif #c == 4 then
+ if a and t then
+ s = format("\\colored[c=%f,m=%f,y=%f,k=%f,a=%f,t=%f]%s",c[1],c[2],c[3],c[4],a,t,s)
+ else
+ s = format("\\colored[c=%f,m=%f,y=%f,k=%f]%s",c[1],c[2],c[3],c[4],s)
+ end
+ end
+ context.MPLIBsettext(tx_number,s)
+ metapost.multipass = true
+ end
+ end
end
+local function tx_process(object,prescript,before,after)
+ local tx_number = prescript.tx_number
+ if tx_number then
+ tx_number = tonumber(tx_number)
+ local tx_stage = prescript.tx_stage
+ if tx_stage == "final" then -- redundant test
+ if trace_textexts then
+ report_textexts("processing %s (second pass)",tx_number)
+ end
+ before[#before+1] = format("q %f %f %f %f %f %f cm",cm(object))
+ before[#before+1] = function()
+ -- flush always happens, we can have a special flush function injected before
+ local box = textexts[tx_number]
+ if box then
+ context.MPLIBgettextscaled(tx_number,sxsy(box.width,box.height,box.depth))
+ else
+ report_textexts("unknown %s",tx_number)
+ end
+ end
+ before[#before+1] = "Q"
+ if not trace_textexts then
+ object.path = false -- else: keep it
+ end
+ object.color = false
+ object.grouped = true
+ end
+ end
+end
+
+-- graphics
+
+local graphics = { }
+
function metapost.intermediate.actions.makempy()
if #graphics > 0 then
makempy.processgraphics(graphics)
graphics = { } -- ?
end
end
+
+local function gt_analyze(object,prescript)
+ local gt_stage = prescript.gt_stage
+ if gt_stage == "trial" then
+ graphics[#graphics+1] = format("\\MPLIBgraphictext{%s}",object.postscript or "")
+ metapost.intermediate.needed = true
+ metapost.multipass = true
+ end
+end
+
+-- local function gt_process(object,prescript,before,after)
+-- local gt_stage = prescript.gt_stage
+-- if gt_stage == "final" then
+-- end
+-- end
+
+-- shades
+
+local function sh_process(object,prescript,before,after)
+ local sh_type = prescript.sh_type
+ if sh_type then
+ nofshades = nofshades + 1
+ local domain = lpegmatch(domainsplitter,prescript.sh_domain)
+ local colora = lpegmatch(colorsplitter, prescript.sh_color_a)
+ local colorb = lpegmatch(colorsplitter, prescript.sh_color_b)
+ local centera = lpegmatch(centersplitter,prescript.sh_center_a)
+ local centerb = lpegmatch(centersplitter,prescript.sh_center_b)
+ local ca, cb, colorspace, name = checkandconvert(colora,colorb)
+ if sh_type == "linear" then
+ local coordinates = { centera[1], centera[2], centerb[1], centerb[2] }
+ lpdf.linearshade(name,domain,ca,cb,1,colorspace,coordinates) -- backend specific (will be renamed)
+ elseif sh_type == "circular" then
+ local radiusa = tonumber(prescript.sh_radius_a)
+ local radiusb = tonumber(prescript.sh_radius_b)
+ local coordinates = { centera[1], centera[2], radiusa, centerb[1], centerb[2], radiusb }
+ lpdf.circularshade(name,domain,ca,cb,1,colorspace,coordinates) -- backend specific (will be renamed)
+ else
+ -- fatal error
+ end
+ before[#before+1], after[#after+1] = "q /Pattern cs", format("W n /%s sh Q",name)
+ object.color, object.type, object.grouped = false, false, true -- not nil, otherwise mt
+ end
+end
+
+-- bitmaps
+
+local function bm_process(object,prescript,before,after)
+ local bm_xresolution = prescript.bm_xresolution
+ if bm_xresolution then
+ before[#before+1] = format("q %f %f %f %f %f %f cm",cm(object))
+ before[#before+1] = function()
+ figures.bitmapimage {
+ xresolution = tonumber(bm_xresolution),
+ yresolution = tonumber(prescript.bm_yresolution),
+ width = 1/basepoints,
+ height = 1/basepoints,
+ data = object.postscript
+ }
+ end
+ before[#before+1] = "Q"
+ object.path = false
+ object.color = false
+ object.grouped = true
+ end
+end
+
+-- positions
+
+local function ps_process(object,prescript,before,after)
+ local ps_label = prescript.ps_label
+ if ps_label then
+ local op = object.path
+ local first, third = op[1], op[3]
+ local x, y = first.x_coord, first.y_coord
+ local w, h = third.x_coord - x, third.y_coord - y
+ x = x - metapost.llx
+ y = metapost.ury - y
+ before[#before+1] = function()
+ context.MPLIBpositionwhd(ps_label,x,y,w,h)
+ end
+ end
+end
+
+-- figures
+
+local function fg_process(object,prescript,before,after)
+ local fg_name = prescript.fg_name
+ if fg_name then
+ -- now uses textext
+ local op = object.path
+ local first, second, fourth = op[1], op[2], op[4]
+ local tx, ty = first.x_coord , first.y_coord
+ local sx, sy = second.x_coord - tx, fourth.y_coord - ty
+ local rx, ry = second.y_coord - ty, fourth.x_coord - tx
+ if sx == 0 then sx = 0.00001 end
+ if sy == 0 then sy = 0.00001 end
+ object.path = nil
+ before[#before+1] = function()
+ context.MPLIBfigure(sx,rx,ry,sy,tx,ty,fg_name)
+ end
+ object.grouped = true
+ end
+end
+
+-- color and transparency
+
+local function tr_process(object,prescript,before,after)
+ local cs = object.color
+ if cs and #cs > 0 then
+ -- before can be shortcut to t
+ local tr_alternative = prescript.tr_alternative
+ if tr_alternative then
+ tr_alternative = tonumber(tr_alternative)
+ local tr_transparency = tonumber(prescript.tr_transparency)
+ before[#before+1], after[#after+1] = format("/Tr%s gs",registertransparency(nil,tr_alternative,tr_transparency,true)), "/Tr0 gs" -- outertransparency
+ end
+ local sp_name = prescript.sp_name
+ if sp_name then
+ local sp_fractions = prescript.sp_fractions or 1
+ local sp_components = prescript.sp_components or ""
+ local sp_value = prescript.sp_value or 1
+ sp_value = tonumber(sp_value) * cs[1]
+ before[#before+1], after[#after+1] = spotcolorconverter(sp_name,sp_fractions,sp_components,sp_value)
+ else
+ before[#before+1], after[#after+1] = colorconverter(cs)
+ end
+ end
+end
+
+-- definitions
+
+appendaction(resetteractions,"system",tx_reset)
+
+appendaction(analyzeractions,"system",tx_analyze)
+appendaction(analyzeractions,"system",gt_analyze)
+
+appendaction(processoractions,"system",sh_process)
+-- (processoractions,"system",gt_process)
+appendaction(processoractions,"system",bm_process)
+appendaction(processoractions,"system",tx_process)
+appendaction(processoractions,"system",ps_process)
+appendaction(processoractions,"system",fg_process)
+appendaction(processoractions,"system",tr_process) -- last, as color can be reset
+
+-- no auto here
+
+resetter = sequencers.compile(resetteractions )
+analyzer = sequencers.compile(analyzeractions )
+processor = sequencers.compile(processoractions)
diff --git a/tex/context/base/mult-de.mkii b/tex/context/base/mult-de.mkii
index 0f18b009a..6c95f4aaa 100644
--- a/tex/context/base/mult-de.mkii
+++ b/tex/context/base/mult-de.mkii
@@ -544,6 +544,7 @@
\setinterfaceconstant{authoretallimit}{authoretallimit}
\setinterfaceconstant{authoretaltext}{authoretaltext}
\setinterfaceconstant{auto}{auto}
+\setinterfaceconstant{autocase}{autocase}
\setinterfaceconstant{autofile}{autofile}
\setinterfaceconstant{autofocus}{autofocus}
\setinterfaceconstant{autohang}{autohang}
diff --git a/tex/context/base/mult-def.lua b/tex/context/base/mult-def.lua
index 41da6fcf5..fd1837147 100644
--- a/tex/context/base/mult-def.lua
+++ b/tex/context/base/mult-def.lua
@@ -6729,6 +6729,10 @@ return {
["pe"]="خودکار",
["ro"]="auto",
},
+ ["autocase"]={
+ ["en"]="autocase",
+ ["nl"]="autocase",
+ },
["autofile"]={
["cs"]="autofile",
["de"]="autofile",
diff --git a/tex/context/base/mult-en.mkii b/tex/context/base/mult-en.mkii
index 9263f465c..383e731a1 100644
--- a/tex/context/base/mult-en.mkii
+++ b/tex/context/base/mult-en.mkii
@@ -544,6 +544,7 @@
\setinterfaceconstant{authoretallimit}{authoretallimit}
\setinterfaceconstant{authoretaltext}{authoretaltext}
\setinterfaceconstant{auto}{auto}
+\setinterfaceconstant{autocase}{autocase}
\setinterfaceconstant{autofile}{autofile}
\setinterfaceconstant{autofocus}{autofocus}
\setinterfaceconstant{autohang}{autohang}
diff --git a/tex/context/base/mult-fr.mkii b/tex/context/base/mult-fr.mkii
index 29adf8314..a686e2811 100644
--- a/tex/context/base/mult-fr.mkii
+++ b/tex/context/base/mult-fr.mkii
@@ -544,6 +544,7 @@
\setinterfaceconstant{authoretallimit}{authoretallimit}
\setinterfaceconstant{authoretaltext}{authoretaltext}
\setinterfaceconstant{auto}{auto}
+\setinterfaceconstant{autocase}{autocase}
\setinterfaceconstant{autofile}{autofile}
\setinterfaceconstant{autofocus}{autofocus}
\setinterfaceconstant{autohang}{autohang}
diff --git a/tex/context/base/mult-it.mkii b/tex/context/base/mult-it.mkii
index b1fa81a66..65061f61c 100644
--- a/tex/context/base/mult-it.mkii
+++ b/tex/context/base/mult-it.mkii
@@ -544,6 +544,7 @@
\setinterfaceconstant{authoretallimit}{authoretallimit}
\setinterfaceconstant{authoretaltext}{authoretaltext}
\setinterfaceconstant{auto}{auto}
+\setinterfaceconstant{autocase}{autocase}
\setinterfaceconstant{autofile}{autofile}
\setinterfaceconstant{autofocus}{autofocus}
\setinterfaceconstant{autohang}{autohang}
diff --git a/tex/context/base/mult-nl.mkii b/tex/context/base/mult-nl.mkii
index 772e7bb6d..4676f1951 100644
--- a/tex/context/base/mult-nl.mkii
+++ b/tex/context/base/mult-nl.mkii
@@ -544,6 +544,7 @@
\setinterfaceconstant{authoretallimit}{authoretallimit}
\setinterfaceconstant{authoretaltext}{authoretaltext}
\setinterfaceconstant{auto}{auto}
+\setinterfaceconstant{autocase}{autocase}
\setinterfaceconstant{autofile}{autofile}
\setinterfaceconstant{autofocus}{autofocus}
\setinterfaceconstant{autohang}{autohang}
diff --git a/tex/context/base/mult-pe.mkii b/tex/context/base/mult-pe.mkii
index 61de69d6c..da48701e4 100644
--- a/tex/context/base/mult-pe.mkii
+++ b/tex/context/base/mult-pe.mkii
@@ -544,6 +544,7 @@
\setinterfaceconstant{authoretallimit}{authoretallimit}
\setinterfaceconstant{authoretaltext}{authoretaltext}
\setinterfaceconstant{auto}{خودکار}
+\setinterfaceconstant{autocase}{autocase}
\setinterfaceconstant{autofile}{پرونده‌خودکار}
\setinterfaceconstant{autofocus}{تمرکز‌خودکار}
\setinterfaceconstant{autohang}{آویزان‌خودکار}
diff --git a/tex/context/base/mult-ro.mkii b/tex/context/base/mult-ro.mkii
index 33649b07c..83943d3fa 100644
--- a/tex/context/base/mult-ro.mkii
+++ b/tex/context/base/mult-ro.mkii
@@ -544,6 +544,7 @@
\setinterfaceconstant{authoretallimit}{authoretallimit}
\setinterfaceconstant{authoretaltext}{authoretaltext}
\setinterfaceconstant{auto}{auto}
+\setinterfaceconstant{autocase}{autocase}
\setinterfaceconstant{autofile}{autofile}
\setinterfaceconstant{autofocus}{autofocus}
\setinterfaceconstant{autohang}{autohang}
diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv
index 9efc7ff6d..bdd78e445 100644
--- a/tex/context/base/page-lay.mkiv
+++ b/tex/context/base/page-lay.mkiv
@@ -876,12 +876,24 @@
\def\mirrorprintbox{\mirrorpagebodybox\printmirror}
\def\scalepagebox#1%
- {\ifdim\@@lyscale\points=\onepoint \else
- \setbox#1\vbox{\scale[\c!sx=\@@lyscale,\c!sy=\@@lyscale]{\box#1}}%
- \paperwidth \@@lyscale\paperwidth
- \paperheight\@@lyscale\paperheight
+ {\ifdim\@@lyscale\points=\onepoint
+ \ifdim\@@lysx\points=\onepoint
+ \ifdim\@@lysy\points=\onepoint
+ \else
+ \doscalepagebox{#1}\@@lysx\@@lysy
+ \fi
+ \else
+ \doscalepagebox{#1}\@@lysx\@@lysy
+ \fi
+ \else
+ \doscalepagebox{#1}\@@lysscale\@@lyscale
\fi}
+\def\doscalepagebox#1#2#3%
+ {\setbox#1\vbox{\scale[\c!sx=#2,\c!sy=#3]{\box#1}}%
+ \paperwidth #2\paperwidth
+ \paperheight#3\paperheight}
+
\def\negateprintbox#1%
{\ifnegateprintbox
\negatecolorbox{#1}%
@@ -1229,6 +1241,8 @@
\c!marking=\v!off,
\c!location=, % \v!singlesided, but empty is signal
\c!scale=1,
+ \c!sx=1,
+ \c!sy=1,
\c!nx=1,
\c!ny=1,
\c!dx=\zeropoint,
diff --git a/tex/context/base/sort-lan.lua b/tex/context/base/sort-lan.lua
index 0c3ece223..452423842 100644
--- a/tex/context/base/sort-lan.lua
+++ b/tex/context/base/sort-lan.lua
@@ -860,13 +860,32 @@ definitions["et"] = {
--- Korean
-local firstcharacter = languages.firstcharacters.korean
+local shchars = characters.shchars
function firstofsplit(first)
- first = utfchar(firstcharacter(utfbyte(first)))
+ first = shchars[first] or first
return first, first -- entry, tag
end
definitions["kr"] = {
firstofsplit = firstofsplit,
+ orders = { -- copying utf fails somehow
+ "ㄱ", -- utfchar(0x3131),
+ "ㄴ", -- utfchar(0x3134),
+ "ㄷ", -- utfchar(0x3137),
+ "ㄹ", -- utfchar(0x3139),
+ "ㅁ", -- utfchar(0x3141),
+ "ㅂ", -- utfchar(0x3142),
+ "ㅅ", -- utfchar(0x3145),
+ "ㅇ", -- utfchar(0x3147),
+ "ㅈ", -- utfchar(0x3148),
+ "ㅊ", -- utfchar(0x314a),
+ "ㅋ", -- utfchar(0x314b),
+ "ㅌ", -- utfchar(0x314c),
+ "ㅍ", -- utfchar(0x314d),
+ "ㅎ", -- utfchar(0x314e),
+ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
+ "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
+ "u", "v", "w", "x", "y", "z",
+ }
}
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index cde9a0dac..cedd20dc6 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/strc-ref.mkiv b/tex/context/base/strc-ref.mkiv
index 22267ef9b..281cf838b 100644
--- a/tex/context/base/strc-ref.mkiv
+++ b/tex/context/base/strc-ref.mkiv
@@ -1050,12 +1050,12 @@
\def\dodefinereferenceformat[#1][#2]%
{\iffirstargument
- \getparameters[\??rf#1][\c!left=,\c!right=,\c!text=,\c!label=,#2]%
+ \getparameters[\??rf#1][\c!left=,\c!right=,\c!text=,\c!label=,\c!autocase=v!no,#2]%
\setuvalue{#1}{\doexecutereferenceformat{#1}}%
\fi}
\def\doexecutereferenceformat#1% quite slow due to all assignments but we will speed it up
- {\dostartgotoreference
+ {\dostartgotoreference % once it's stable
\edef\currentreferenceformat{#1}%
\gdef\leftofreference {\referenceformatparameter\c!left }%
\gdef\rightofreference{\referenceformatparameter\c!right}%
@@ -1073,6 +1073,8 @@
\ifx\currentreferenceformatlabel\autoreferencelabeltextflag
\edef\currentreferenceformatlabel{\autoreferencelabeltext}%
\fi
+ \doif{\referenceformatparameter\c!autocase}\v!yes
+ {\setcharactercleaning[1]}%
\ifx\currentreferenceformatlabel\empty
\defaultleftreferencetoks {\referenceformatparameter\c!text}%
\defaultrightreferencetoks\emptytoks
diff --git a/tex/context/base/task-ini.lua b/tex/context/base/task-ini.lua
index c7f6d5794..ca7023569 100644
--- a/tex/context/base/task-ini.lua
+++ b/tex/context/base/task-ini.lua
@@ -16,6 +16,7 @@ local tasks = nodes.tasks
tasks.appendaction("processors", "normalizers", "fonts.collections.process") -- todo
tasks.appendaction("processors", "normalizers", "fonts.checkers.missing") -- disabled
+tasks.appendaction("processors", "characters", "typesetters.cleaners.handler") -- disabled
tasks.appendaction("processors", "characters", "typesetters.directions.handler") -- disabled
tasks.appendaction("processors", "characters", "typesetters.cases.handler") -- disabled
tasks.appendaction("processors", "characters", "typesetters.breakpoints.handler") -- disabled
@@ -77,6 +78,7 @@ tasks.appendaction("vboxbuilders", "normalizers", "builders.vspacing.vboxhandler
tasks.disableaction("processors", "fonts.checkers.missing")
tasks.disableaction("processors", "chars.handle_breakpoints")
+tasks.disableaction("processors", "typesetters.cleaners.handler")
tasks.disableaction("processors", "typesetters.cases.handler")
tasks.disableaction("processors", "typesetters.digits.handler")
tasks.disableaction("processors", "typesetters.breakpoints.handler")
diff --git a/tex/context/base/typo-cap.mkiv b/tex/context/base/typo-cap.mkiv
index 749f9fcbd..68645d260 100644
--- a/tex/context/base/typo-cap.mkiv
+++ b/tex/context/base/typo-cap.mkiv
@@ -2,7 +2,7 @@
%D [ file=typo-cap,
%D version=2009.03.27, % code moved from core-spa.mkiv
%D title=\CONTEXT\ Typesetting Macros,
-%D subtitle=Mirroring,
+%D subtitle=Capping,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright=\PRAGMA]
diff --git a/tex/context/base/typo-cln.lua b/tex/context/base/typo-cln.lua
new file mode 100644
index 000000000..09e8744ea
--- /dev/null
+++ b/tex/context/base/typo-cln.lua
@@ -0,0 +1,87 @@
+if not modules then modules = { } end modules ['typo-cap'] = {
+ version = 1.001,
+ comment = "companion to typo-cap.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- This quick and dirty hack took less time than listening to a CD (In
+-- this case Dream Theaters' Octavium. Of course extensions will take
+-- more time.
+
+local utfbyte = utf.byte
+
+local trace_cleaners = false trackers.register("typesetters.cleaners", function(v) trace_cleaners = v end)
+local trace_autocase = false trackers.register("typesetters.cleaners.autocase",function(v) trace_autocase = v end)
+
+local report_cleaners = logs.reporters("nodes","cleaners")
+local report_autocase = logs.reporters("nodes","autocase")
+
+typesetters.cleaners = typesetters.cleaners or { }
+local cleaners = typesetters.cleaners
+
+local nodecodes = nodes.nodecodes
+local tasks = nodes.tasks
+
+local texattribute = tex.attribute
+
+local has_attribute = node.has_attribute
+local traverse_id = node.traverse_id
+
+local glyph_code = nodecodes.glyph
+local uccodes = characters.uccodes
+
+local a_cleaner = attributes.private("cleaner")
+
+local resetter = { -- this will become an entry in char-def
+ [utfbyte(".")] = true
+}
+
+-- Contrary to the casing code we need to keep track of a state.
+-- We could extend the casing code with a status tracker but on
+-- the other hand we might want to apply casing afterwards. So,
+-- cleaning comes first.
+
+local function process(namespace,attribute,head)
+ local inline, done = false, false
+ for n in traverse_id(glyph_code,head) do
+ local char = n.char
+ if resetter[char] then
+ inline = false
+ elseif not inline then
+ local a = has_attribute(n,attribute)
+ if a == 1 then -- currently only one cleaner so no need to be fancy
+ local upper = uccodes[char]
+ n.char = upper
+ inline = true
+ done = true
+ if trace_autocase then
+ report_autocase("")
+ end
+ end
+ end
+ end
+ return head, done
+end
+
+-- see typo-cap for a more advanced settings handler .. now needed now
+
+local enabled = false
+
+function cleaners.set(n)
+ if not enabled then
+ tasks.enableaction("processors","typesetters.cleaners.handler")
+ if trace_cleaners then
+ report_cleaners("enabling cleaners")
+ end
+ enabled = true
+ end
+ texattribute[a_cleaner] = n
+end
+
+cleaners.handler = nodes.installattributehandler {
+ name = "cleaner",
+ namespace = cleaners,
+ processor = process,
+}
diff --git a/tex/context/base/typo-cln.mkiv b/tex/context/base/typo-cln.mkiv
new file mode 100644
index 000000000..d247b20d2
--- /dev/null
+++ b/tex/context/base/typo-cln.mkiv
@@ -0,0 +1,30 @@
+%D \module
+%D [ file=typo-cln,
+%D version=2011.02.11,
+%D title=\CONTEXT\ Typesetting Macros,
+%D subtitle=Cleaning,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright=\PRAGMA]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{ConTeXt Typesetting Macros / Cleaning}
+
+\unprotect
+
+\registerctxluafile{typo-cln}{1.001}
+
+\definesystemattribute[cleaner][public]
+
+%D Currently there is no interface.
+%D
+%D 1: Autocap first character of a line
+%D 2: Maybe dropped caps.
+
+\unexpanded\def\setcharactercleaning[#1]% This name might change!
+ {\ctxlua{typesetters.cleaners.set(\number#1)}}
+
+\protect \endinput
diff --git a/tex/context/base/util-seq.lua b/tex/context/base/util-seq.lua
index 9f7cb4ca2..f36d1d640 100644
--- a/tex/context/base/util-seq.lua
+++ b/tex/context/base/util-seq.lua
@@ -193,7 +193,8 @@ sequencers.localize = localize
local function compile(t,compiler,n)
if not t or type(t) == "string" then
- t.compiled = t
+ -- weird ... t.compiled = t .. so
+ return false
elseif compiler then
t.compiled = compiler(t,n)
else
diff --git a/tex/context/interface/keys-cs.xml b/tex/context/interface/keys-cs.xml
index 01e3a8aa8..8aba0cca6 100644
--- a/tex/context/interface/keys-cs.xml
+++ b/tex/context/interface/keys-cs.xml
@@ -550,6 +550,7 @@
<cd:constant name='authoretallimit' value='authoretallimit'/>
<cd:constant name='authoretaltext' value='authoretaltext'/>
<cd:constant name='auto' value='auto'/>
+ <cd:constant name='autocase' value='autocase'/>
<cd:constant name='autofile' value='autofile'/>
<cd:constant name='autofocus' value='autoostreni'/>
<cd:constant name='autohang' value='autohang'/>
diff --git a/tex/context/interface/keys-de.xml b/tex/context/interface/keys-de.xml
index 369c02150..fefab4d55 100644
--- a/tex/context/interface/keys-de.xml
+++ b/tex/context/interface/keys-de.xml
@@ -550,6 +550,7 @@
<cd:constant name='authoretallimit' value='authoretallimit'/>
<cd:constant name='authoretaltext' value='authoretaltext'/>
<cd:constant name='auto' value='auto'/>
+ <cd:constant name='autocase' value='autocase'/>
<cd:constant name='autofile' value='autofile'/>
<cd:constant name='autofocus' value='autofocus'/>
<cd:constant name='autohang' value='autohang'/>
diff --git a/tex/context/interface/keys-en.xml b/tex/context/interface/keys-en.xml
index 725f5b584..34ed39349 100644
--- a/tex/context/interface/keys-en.xml
+++ b/tex/context/interface/keys-en.xml
@@ -550,6 +550,7 @@
<cd:constant name='authoretallimit' value='authoretallimit'/>
<cd:constant name='authoretaltext' value='authoretaltext'/>
<cd:constant name='auto' value='auto'/>
+ <cd:constant name='autocase' value='autocase'/>
<cd:constant name='autofile' value='autofile'/>
<cd:constant name='autofocus' value='autofocus'/>
<cd:constant name='autohang' value='autohang'/>
diff --git a/tex/context/interface/keys-fr.xml b/tex/context/interface/keys-fr.xml
index fc888363d..f2e5990be 100644
--- a/tex/context/interface/keys-fr.xml
+++ b/tex/context/interface/keys-fr.xml
@@ -550,6 +550,7 @@
<cd:constant name='authoretallimit' value='authoretallimit'/>
<cd:constant name='authoretaltext' value='authoretaltext'/>
<cd:constant name='auto' value='auto'/>
+ <cd:constant name='autocase' value='autocase'/>
<cd:constant name='autofile' value='autofile'/>
<cd:constant name='autofocus' value='autofocus'/>
<cd:constant name='autohang' value='autohang'/>
diff --git a/tex/context/interface/keys-it.xml b/tex/context/interface/keys-it.xml
index 2ceb1d797..313d27e09 100644
--- a/tex/context/interface/keys-it.xml
+++ b/tex/context/interface/keys-it.xml
@@ -550,6 +550,7 @@
<cd:constant name='authoretallimit' value='authoretallimit'/>
<cd:constant name='authoretaltext' value='authoretaltext'/>
<cd:constant name='auto' value='auto'/>
+ <cd:constant name='autocase' value='autocase'/>
<cd:constant name='autofile' value='autofile'/>
<cd:constant name='autofocus' value='autofocus'/>
<cd:constant name='autohang' value='autohang'/>
diff --git a/tex/context/interface/keys-nl.xml b/tex/context/interface/keys-nl.xml
index 8b7bfb4f9..f486a03c0 100644
--- a/tex/context/interface/keys-nl.xml
+++ b/tex/context/interface/keys-nl.xml
@@ -550,6 +550,7 @@
<cd:constant name='authoretallimit' value='authoretallimit'/>
<cd:constant name='authoretaltext' value='authoretaltext'/>
<cd:constant name='auto' value='auto'/>
+ <cd:constant name='autocase' value='autocase'/>
<cd:constant name='autofile' value='autofile'/>
<cd:constant name='autofocus' value='autofocus'/>
<cd:constant name='autohang' value='autohang'/>
diff --git a/tex/context/interface/keys-pe.xml b/tex/context/interface/keys-pe.xml
index 23a7ab4a6..a6b3024f6 100644
--- a/tex/context/interface/keys-pe.xml
+++ b/tex/context/interface/keys-pe.xml
@@ -550,6 +550,7 @@
<cd:constant name='authoretallimit' value='authoretallimit'/>
<cd:constant name='authoretaltext' value='authoretaltext'/>
<cd:constant name='auto' value='خودکار'/>
+ <cd:constant name='autocase' value='autocase'/>
<cd:constant name='autofile' value='پرونده‌خودکار'/>
<cd:constant name='autofocus' value='تمرکز‌خودکار'/>
<cd:constant name='autohang' value='آویزان‌خودکار'/>
diff --git a/tex/context/interface/keys-ro.xml b/tex/context/interface/keys-ro.xml
index 9c983af86..7e08e8a8b 100644
--- a/tex/context/interface/keys-ro.xml
+++ b/tex/context/interface/keys-ro.xml
@@ -550,6 +550,7 @@
<cd:constant name='authoretallimit' value='authoretallimit'/>
<cd:constant name='authoretaltext' value='authoretaltext'/>
<cd:constant name='auto' value='auto'/>
+ <cd:constant name='autocase' value='autocase'/>
<cd:constant name='autofile' value='autofile'/>
<cd:constant name='autofocus' value='autofocus'/>
<cd:constant name='autohang' value='autohang'/>
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index ebd305744..0968ff77e 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 : 02/11/11 18:18:29
+-- merge date : 02/14/11 18:50:16
do -- begin closure to overcome local limits and interference
@@ -3713,7 +3713,9 @@ function tfm.scale(tfmtable, scaledpoints, relativeid)
-- tfm.prepare_base_kerns(tfmtable) -- optimalization
local t = { } -- the new table
local scaledpoints, delta, units = tfm.calculatescale(tfmtable, scaledpoints, relativeid)
+ -- is just a trigger for the backend
t.units_per_em = units or 1000
+ --
local hdelta, vdelta = delta, delta
-- unicoded unique descriptions shared cidinfo characters changed parameters indices
for k,v in next, tfmtable do
@@ -5760,7 +5762,7 @@ local readers = fonts.tfm.readers
otf.glists = { "gsub", "gpos" }
-otf.version = 2.707 -- beware: also sync font-mis.lua
+otf.version = 2.710 -- beware: also sync font-mis.lua
otf.cache = containers.define("fonts", "otf", otf.version, true)
local loadmethod = "table" -- table, mixed, sparse
@@ -6142,6 +6144,7 @@ function otf.load(filename,format,sub,featurefile)
end
data.size = size
data.time = time
+ data.format = format
if featurefiles then
data.featuredata = featurefiles
end
@@ -7404,7 +7407,7 @@ local function copytotfm(data,cache_id) -- we can save a copy when we reorder th
spaceunits, spacer = metadata.charwidth, "charwidth"
end
end
- spaceunits = tonumber(spaceunits) or tfm.units/2 -- 500 -- brrr
+ spaceunits = tonumber(spaceunits) or 500 -- brrr
-- we need a runtime lookup because of running from cdrom or zip, brrr (shouldn't we use the basename then?)
local filename = fonts.tfm.checkedfilename(luatex)
local fontname = metadata.fontname
@@ -7447,6 +7450,10 @@ local function copytotfm(data,cache_id) -- we can save a copy when we reorder th
end
end
--
+ local fileformat = data.format or fonts.fontformat(filename,"opentype")
+ if units > 1000 then
+ fileformat = "truetype"
+ end
return {
characters = characters,
parameters = parameters,
@@ -7468,7 +7475,7 @@ local function copytotfm(data,cache_id) -- we can save a copy when we reorder th
psname = fontname or fullname,
name = filename or fullname,
units = units,
- format = fonts.fontformat(filename,"opentype"),
+ format = fileformat,
cidinfo = cidinfo,
ascender = abs(metadata.ascent or 0),
descender = abs(metadata.descent or 0),