summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex')
-rw-r--r--tex/context/base/bibl-tra.lua9
-rw-r--r--tex/context/base/font-dum.lua131
-rw-r--r--tex/context/base/font-ext.lua121
-rw-r--r--tex/context/base/font-xtx.lua2
-rw-r--r--tex/context/base/sort-lan.lua14
-rw-r--r--tex/context/base/strc-reg.mkiv67
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua135
-rw-r--r--tex/generic/context/luatex-test.tex6
8 files changed, 350 insertions, 135 deletions
diff --git a/tex/context/base/bibl-tra.lua b/tex/context/base/bibl-tra.lua
index b2603a71d..7a54ca810 100644
--- a/tex/context/base/bibl-tra.lua
+++ b/tex/context/base/bibl-tra.lua
@@ -77,6 +77,15 @@ local function compare(a,b)
return ordered[a[1]] < ordered[b[1]]
end
+local function compare(a,b)
+ local aa, bb = a[1], a[b]
+ if aa and bb then
+ return ordered[aa] < ordered[bb]
+ else
+ return true
+ end
+end
+
function hacks.flush(sortvariant)
if sortvariant == "" or sortvariant == variables.cite or sortvariant == "default" then
-- order is cite order i.e. same as list
diff --git a/tex/context/base/font-dum.lua b/tex/context/base/font-dum.lua
index e13f8a255..9dcabf6a3 100644
--- a/tex/context/base/font-dum.lua
+++ b/tex/context/base/font-dum.lua
@@ -113,5 +113,136 @@ end
fonts.initializers.base.otf.itlc = itlc
fonts.initializers.node.otf.itlc = itlc
+-- slant and extend
+
+function fonts.initializers.common.slant(tfmdata,value)
+ value = tonumber(value)
+ if not value then
+ value = 0
+ elseif value > 1 then
+ value = 1
+ elseif value < -1 then
+ value = -1
+ end
+ tfmdata.slant_factor = value
+end
+
+function fonts.initializers.common.extend(tfmdata,value)
+ value = tonumber(value)
+ if not value then
+ value = 0
+ elseif value > 10 then
+ value = 10
+ elseif value < -10 then
+ value = -10
+ end
+ tfmdata.extend_factor = value
+end
+
+table.insert(fonts.triggers,"slant")
+table.insert(fonts.triggers,"extend")
+
+fonts.initializers.base.otf.slant = fonts.initializers.common.slant
+fonts.initializers.node.otf.slant = fonts.initializers.common.slant
+fonts.initializers.base.otf.extend = fonts.initializers.common.extend
+fonts.initializers.node.otf.extend = fonts.initializers.common.extend
+
+-- expansion and protrusion
+
+fonts.protrusions = fonts.protrusions or { }
+fonts.protrusions.setups = fonts.protrusions.setups or { }
+
+local setups = fonts.protrusions.setups
+
+function fonts.initializers.common.protrusion(tfmdata,value)
+ if value then
+ local setup = setups[value]
+ if setup then
+ local factor, left, right = setup.factor or 1, setup.left or 1, setup.right or 1
+ local emwidth = tfmdata.parameters.quad
+ tfmdata.auto_protrude = true
+ for i, chr in next, tfmdata.characters do
+ local v, pl, pr = setup[i], nil, nil
+ if v then
+ pl, pr = v[1], v[2]
+ end
+ if pl and pl ~= 0 then chr.left_protruding = left *pl*factor end
+ if pr and pr ~= 0 then chr.right_protruding = right*pr*factor end
+ end
+ end
+ end
+end
+
+fonts.expansions = fonts.expansions or { }
+fonts.expansions.setups = fonts.expansions.setups or { }
+
+local setups = fonts.expansions.setups
+
+function fonts.initializers.common.expansion(tfmdata,value)
+ if value then
+ local setup = setups[value]
+ if setup then
+ local stretch, shrink, step, factor = setup.stretch or 0, setup.shrink or 0, setup.step or 0, setup.factor or 1
+ tfmdata.stretch, tfmdata.shrink, tfmdata.step, tfmdata.auto_expand = stretch * 10, shrink * 10, step * 10, true
+ for i, chr in next, tfmdata.characters do
+ local v = setup[i]
+ if v and v ~= 0 then
+ chr.expansion_factor = v*factor
+ else -- can be option
+ chr.expansion_factor = factor
+ end
+ end
+ end
+ end
+end
+
+table.insert(fonts.manipulators,"protrusion")
+table.insert(fonts.manipulators,"expansion")
+
+fonts.initializers.base.otf.protrusion = fonts.initializers.common.protrusion
+fonts.initializers.node.otf.protrusion = fonts.initializers.common.protrusion
+fonts.initializers.base.otf.expansion = fonts.initializers.common.expansion
+fonts.initializers.node.otf.expansion = fonts.initializers.common.expansion
+
+-- left over
+
function fonts.register_message()
end
+
+-- example vectors
+
+local byte = string.byte
+
+fonts.expansions.setups['default'] = {
+
+ stretch = 2, shrink = 2, step = .5, factor = 1,
+
+ [byte('A')] = 0.5, [byte('B')] = 0.7, [byte('C')] = 0.7, [byte('D')] = 0.5, [byte('E')] = 0.7,
+ [byte('F')] = 0.7, [byte('G')] = 0.5, [byte('H')] = 0.7, [byte('K')] = 0.7, [byte('M')] = 0.7,
+ [byte('N')] = 0.7, [byte('O')] = 0.5, [byte('P')] = 0.7, [byte('Q')] = 0.5, [byte('R')] = 0.7,
+ [byte('S')] = 0.7, [byte('U')] = 0.7, [byte('W')] = 0.7, [byte('Z')] = 0.7,
+ [byte('a')] = 0.7, [byte('b')] = 0.7, [byte('c')] = 0.7, [byte('d')] = 0.7, [byte('e')] = 0.7,
+ [byte('g')] = 0.7, [byte('h')] = 0.7, [byte('k')] = 0.7, [byte('m')] = 0.7, [byte('n')] = 0.7,
+ [byte('o')] = 0.7, [byte('p')] = 0.7, [byte('q')] = 0.7, [byte('s')] = 0.7, [byte('u')] = 0.7,
+ [byte('w')] = 0.7, [byte('z')] = 0.7,
+ [byte('2')] = 0.7, [byte('3')] = 0.7, [byte('6')] = 0.7, [byte('8')] = 0.7, [byte('9')] = 0.7,
+}
+
+fonts.protrusions.setups['default'] = {
+
+ factor = 1, left = 1, right = 1,
+
+ [0x002C] = { 0, 1 }, -- comma
+ [0x002E] = { 0, 1 }, -- period
+ [0x003A] = { 0, 1 }, -- colon
+ [0x003B] = { 0, 1 }, -- semicolon
+ [0x002D] = { 0, 1 }, -- hyphen
+ [0x2013] = { 0, 0.50 }, -- endash
+ [0x2014] = { 0, 0.33 }, -- emdash
+ [0x3001] = { 0, 1 }, -- ideographic comma 、
+ [0x3002] = { 0, 1 }, -- ideographic full stop 。
+ [0x060C] = { 0, 1 }, -- arabic comma ،
+ [0x061B] = { 0, 1 }, -- arabic semicolon ؛
+ [0x06D4] = { 0, 1 }, -- arabic full stop ۔
+
+}
diff --git a/tex/context/base/font-ext.lua b/tex/context/base/font-ext.lua
index efbe50e89..ade80fa9e 100644
--- a/tex/context/base/font-ext.lua
+++ b/tex/context/base/font-ext.lua
@@ -12,6 +12,8 @@ local gmatch = string.gmatch
local trace_protrusion = false trackers.register("fonts.protrusion", function(v) trace_protrusion = v end)
local trace_expansion = false trackers.register("fonts.expansion" , function(v) trace_expansion = v end)
+commands = commands or { }
+
--[[ldx--
<p>When we implement functions that deal with features, most of them
will depend of the font format. Here we define the few that are kind
@@ -85,119 +87,6 @@ function initializers.common.lineheight(tfmdata,value)
end
end
---[[ldx--
-<p>It does not make sense any more to support messed up encoding vectors
-so we stick to those that implement oldstyle and small caps. After all,
-we move on. We can extend the next function on demand. This features is
-only used with <l n='afm'/> files.</p>
---ldx]]--
-
---~ do
---~
---~ local smallcaps = lpeg.P(".sc") + lpeg.P(".smallcaps") + lpeg.P(".caps") + lpeg.P("small")
---~ local oldstyle = lpeg.P(".os") + lpeg.P(".oldstyle") + lpeg.P(".onum")
---~
---~ smallcaps = lpeg.Cs((1-smallcaps)^1) * smallcaps^1
---~ oldstyle = lpeg.Cs((1-oldstyle )^1) * oldstyle ^1
---~
---~ local lpegmatch = lpeg.match
---~
---~ function initializers.common.encoding(tfmdata,value)
---~ if value then
---~ local afmdata = tfmdata.shared.afmdata
---~ if afmdata then
---~ local encodingfile = value .. '.enc'
---~ local encoding = fonts.enc.load(encodingfile)
---~ if encoding then
---~ local vector = encoding.vector
---~ local characters = tfmdata.characters
---~ local unicodes = afmdata.luatex.unicodes
---~ local function remap(pattern,name)
---~ local p = lpegmatch(pattern,name)
---~ if p then
---~ local oldchr, newchr = unicodes[p], unicodes[name]
---~ if oldchr and newchr and type(oldchr) == "number" and type(newchr) == "number" then
---~ -- logs.report("encoding","%s (%s) -> %s (%s)",p,oldchr or -1,name,newchr or -1)
---~ characters[oldchr] = characters[newchr]
---~ end
---~ end
---~ return p
---~ end
---~ for _, name in next, vector do
---~ local ok = remap(smallcaps,name) or remap(oldstyle,name)
---~ end
---~ if fonts.map.data[tfmdata.name] then
---~ fonts.map.data[tfmdata.name].encoding = encodingfile
---~ end
---~ end
---~ end
---~ end
---~ end
---~
---~ -- when needed we can provide this as features in e.g. afm files
---~
---~ function initializers.common.remap(tfmdata,value,pattern) -- will go away
---~ if value then
---~ local afmdata = tfmdata.shared.afmdata
---~ if afmdata then
---~ local characters = tfmdata.characters
---~ local descriptions = tfmdata.descriptions
---~ local unicodes = afmdata.luatex.unicodes
---~ local done = false
---~ for u, _ in next, characters do
---~ local name = descriptions[u].name
---~ if name then
---~ local p = lpegmatch(pattern,name)
---~ if p then
---~ local oldchr, newchr = unicodes[p], unicodes[name]
---~ if oldchr and newchr and type(oldchr) == "number" and type(newchr) == "number" then
---~ characters[oldchr] = characters[newchr]
---~ end
---~ end
---~ end
---~ end
---~ end
---~ end
---~ end
---~
---~ function initializers.common.oldstyle(tfmdata,value)
---~ initializers.common.remap(tfmdata,value,oldstyle)
---~ end
---~ function initializers.common.smallcaps(tfmdata,value)
---~ initializers.common.remap(tfmdata,value,smallcaps)
---~ end
---~
---~ function initializers.common.fakecaps(tfmdata,value)
---~ if value then
---~ -- todo: scale down
---~ local afmdata = tfmdata.shared.afmdata
---~ if afmdata then
---~ local characters = tfmdata.characters
---~ local descriptions = tfmdata.descriptions
---~ local unicodes = afmdata.luatex.unicodes
---~ for u, _ in next, characters do
---~ local name = descriptions[u].name
---~ if name then
---~ local p = lower(name)
---~ if p then
---~ local oldchr, newchr = unicodes[p], unicodes[name]
---~ if oldchr and newchr and type(oldchr) == "number" and type(newchr) == "number" then
---~ characters[oldchr] = characters[newchr]
---~ end
---~ end
---~ end
---~ end
---~ end
---~ end
---~ end
---~
---~ end
---~
---~ function initializers.common.install(format,feature) -- 'afm','lineheight'
---~ initializers.base[format][feature] = initializers.common[feature]
---~ initializers.node[format][feature] = initializers.common[feature]
---~ end
-
-- -- -- -- -- --
-- expansion (hz)
-- -- -- -- -- --
@@ -247,10 +136,10 @@ function initializers.common.expansion(tfmdata,value)
logs.report("fonts","set expansion class %s, vector: %s, factor: %s, stretch: %s, shrink: %s, step: %s",value,class.vector,factor,stretch,shrink,step)
end
tfmdata.stretch, tfmdata.shrink, tfmdata.step, tfmdata.auto_expand = stretch * 10, shrink * 10, step * 10, true
- local data = characters.data
+ local data = characters and characters.data
for i, chr in next, tfmdata.characters do
local v = vector[i]
- if not v then
+ if data and not v then -- we could move the data test outside (needed for plain)
local d = data[i]
if d then
local s = d.shcode
@@ -504,6 +393,7 @@ initializers.node.afm.itlc = initializers.common.itlc
table.insert(fonts.triggers,"slant")
function initializers.common.slant(tfmdata,value)
+ value = tonumber(value)
if not value then
value = 0
elseif value > 1 then
@@ -523,6 +413,7 @@ initializers.node.afm.slant = initializers.common.slant
table.insert(fonts.triggers,"extend")
function initializers.common.extend(tfmdata,value)
+ value = tonumber(value)
if not value then
value = 0
elseif value > 10 then
diff --git a/tex/context/base/font-xtx.lua b/tex/context/base/font-xtx.lua
index 574221b5d..ec7b2a26e 100644
--- a/tex/context/base/font-xtx.lua
+++ b/tex/context/base/font-xtx.lua
@@ -77,7 +77,7 @@ local namespec = (1-lpeg.S("/:("))^0 -- was: (1-lpeg.S("/: ("))^0
local crapspec = spaces * lpeg.P("/") * (((1-lpeg.P(":"))^0)/iscrap) * spaces
local filename = (lpeg.P("file:")/isfile * (namespec/thename)) + (lpeg.P("[") * lpeg.P(true)/isname * (((1-lpeg.P("]"))^0)/thename) * lpeg.P("]"))
local fontname = (lpeg.P("name:")/isname * (namespec/thename)) + lpeg.P(true)/issome * (namespec/thename)
-local sometext = (lpeg.R("az") + lpeg.R("AZ") + lpeg.R("09"))^1
+local sometext = (lpeg.R("az") + lpeg.R("AZ") + lpeg.R("09") + lpeg.P("."))^1
local truevalue = lpeg.P("+") * spaces * (sometext/istrue)
local falsevalue = lpeg.P("-") * spaces * (sometext/isfalse)
local keyvalue = (lpeg.C(sometext) * spaces * lpeg.P("=") * spaces * lpeg.C(sometext))/iskey
diff --git a/tex/context/base/sort-lan.lua b/tex/context/base/sort-lan.lua
index 4e2d0f926..0b351b062 100644
--- a/tex/context/base/sort-lan.lua
+++ b/tex/context/base/sort-lan.lua
@@ -16,6 +16,8 @@ local utf = unicode.utf8
-- The next one can be more efficient when not indexed this way, but
-- other languages are sparse so for the moment we keep this one.
+sorters = sorters or { entries = { }, replacements = { }, mappings = { } }
+
sorters.entries['en'] = {
["a"] = "a", ["b"] = "b", ["c"] = "c", ["d"] = "d", ["e"] = "e",
["f"] = "f", ["g"] = "g", ["h"] = "h", ["i"] = "i", ["j"] = "j",
@@ -38,12 +40,12 @@ sorters.mappings['en'] = {
["p"] = 31, ["q"] = 33, ["r"] = 35, ["s"] = 37, ["t"] = 39,
["u"] = 41, ["v"] = 43, ["w"] = 45, ["x"] = 47, ["y"] = 49,
["z"] = 51,
- ["A"] = 2, ["B"] = 4, ["C"] = 6, ["D"] = 8, ["E"] = 10,
- ["F"] = 12, ["G"] = 14, ["H"] = 16, ["I"] = 18, ["J"] = 20,
- ["K"] = 22, ["L"] = 24, ["M"] = 26, ["N"] = 28, ["O"] = 30,
- ["P"] = 32, ["Q"] = 34, ["R"] = 36, ["S"] = 38, ["T"] = 40,
- ["U"] = 42, ["V"] = 44, ["W"] = 46, ["X"] = 48, ["Y"] = 50,
- ["Z"] = 52,
+--~ ["A"] = 2, ["B"] = 4, ["C"] = 6, ["D"] = 8, ["E"] = 10,
+--~ ["F"] = 12, ["G"] = 14, ["H"] = 16, ["I"] = 18, ["J"] = 20,
+--~ ["K"] = 22, ["L"] = 24, ["M"] = 26, ["N"] = 28, ["O"] = 30,
+--~ ["P"] = 32, ["Q"] = 34, ["R"] = 36, ["S"] = 38, ["T"] = 40,
+--~ ["U"] = 42, ["V"] = 44, ["W"] = 46, ["X"] = 48, ["Y"] = 50,
+--~ ["Z"] = 52,
}
-- dutch
diff --git a/tex/context/base/strc-reg.mkiv b/tex/context/base/strc-reg.mkiv
index 2b73c4ae5..5a6e42a71 100644
--- a/tex/context/base/strc-reg.mkiv
+++ b/tex/context/base/strc-reg.mkiv
@@ -632,13 +632,14 @@
\setvalue{\??id:\c!indicator:a}#1%
{\registerparameter\c!before
- \vskip\lineheight\goodbreak\vskip-\lineheight
+ % bugged, why does leftskip gets set: \vskip\lineheight\goodbreak\vskip-\lineheight
\begingroup\dosetregisterattributes\c!style\c!color
\registerparameter\c!command{\strut#1}%
\endgroup
\registerparameter\c!after
\par\nobreak}
+
% b = <goodbreak> <before> <character> <after> <nobreak>
\setvalue{\??id:\c!indicator:b}#1%
@@ -655,6 +656,10 @@
%D The following macros are the interface to the rendering. These are
%D generated by \LUA. This might change.
+%D Beware, we get funny side effects when a dangling \index precedes an
+%D placeindex as then flushing takes place inside the index. Took me hours
+%D to notice that.
+
\def\startregisteroutput
{\endgraf
\begingroup
@@ -708,14 +713,29 @@
\settrue\registerpagedone
\fi}
+\def\registeronepagerangeseparator{|\endash|}
+
+\def\withregisterpagecommand#1#2#3%
+ {\def\currentregisterpageindex{#1}%
+ \iflocation
+ \goto{\registerparameter\c!pagecommand{#2}}[internal(#1)]%
+ \else
+ \registerparameter\c!pagecommand{#2}%
+ \fi}
+
\def\registeronepage#1#2#3% content
- {\registerpageseparator\registerparameter\c!pagecommand{\goto{#3}[internal(#1)]}}
+ {\registerpageseparator
+ \withregisterpagecommand{#1}{#2}{#3}}
\def\registerpagerange#1#2#3#4#5#6% content, content todo: -- configurable
- {\registerpageseparator\registerparameter\c!pagecommand{\goto{#3}[internal(#1)]}|--|\registerparameter\c!pagecommand{\goto{#6}[internal(#4)]}}
+ {\registerpageseparator
+ \withregisterpagecommand{#1}{#2}{#3}%
+ \registeronepagerangeseparator
+ \withregisterpagecommand{#4}{#5}{#6}}
\def\registeroneword#1#2#3% content
- {\registerpageseparator\registerseeword{#3}}
+ {\registerpageseparator
+ \registerseeword{#3}}
\def\defaultregisterentry #1{\registerparameter\c!textcommand{\limitedregisterentry{\registerparameter\c!deeptextcommand{#1}}}}
\def\defaultregisterseeword#1{\labeltexts\v!see{#1}}
@@ -732,17 +752,41 @@
% todo: \installregisterpagehandler
-\def\registerpageuserdata#1#2{\ctxlua{jobregisters.userdata(#1,"#2")}}
+% \def\MyRegisterPageCommand#1%
+% {#1\currentregisterpageuserdata{whatever}}
+%
+% \starttext
+% \setregisterentry[index][entries=aaa][whatever=f.] test \index{bbb} test
+% \placeregister[index][n=1,pagecommand=\MyRegisterPageCommand]
+% \stoptext
+
+\def\registerpageuserdata #1#2{\ctxlua{jobregisters.userdata(#1,"#2")}}
+\def\currentregisterpageuserdata {\registerpageuserdata\currentregisterpageindex} % {#1}
% not yet ok : new internal handler names
\def\registerpagebuttonsymbol{\vrule\!!width1em\!!height1ex\!!depth\zeropoint\relax}
-\setvalue{\??id:\c!symbol :\c!n}{\def\registerpageseparatorsymbol{, }\let\registerpagenumberhandler\firstofoneargument}
-\setvalue{\??id:\c!symbol :\c!a}{\def\registerpageseparatorsymbol{, }\let\registerpagenumberhandler\firstofoneargument} % now done via conversion
-\setvalue{\??id:\c!symbol:\v!none}{\let\registerpageseparatorsymbol\empty\let\registerpagenumberhandler\gobbleoneargument}
-\setvalue{\??id:\c!symbol :1}{\let\registerpageseparatorsymbol\space\def\registerpagenumberhandler{\symbol[1]\gobbleoneargument}}
-\setvalue{\??id:\c!symbol :2}{\let\registerpageseparatorsymbol\space\def\registerpagenumberhandler{\registerpagebuttonsymbol\gobbleoneargument}}
+\setvalue{\??id:\c!symbol:\c!n}%
+ {\def\registerpageseparatorsymbol{, }}
+
+\setvalue{\??id:\c!symbol:\c!a}%
+ {\def\registerpageseparatorsymbol{, }} % now done via conversion
+
+\setvalue{\??id:\c!symbol:\v!none}%
+ {\let\registerpageseparatorsymbol\empty
+ \let\registeronepage \gobblethreearguments
+ \let\registerpagerange \gobblesixarguments}
+
+\setvalue{\??id:\c!symbol:1}%
+ {\let\registerpageseparatorsymbol\space
+ \def\registeronepage {\symbol[1]\gobblethreearguments}%
+ \def\registerpagerange {\symbol[1]\gobblesixarguments}}
+
+\setvalue{\??id:\c!symbol:2}%
+ {\let\registerpageseparatorsymbol\space
+ \def\registeronepage {\registerpagebuttonsymbol\gobblethreearguments}%
+ \def\registerpagerange {\registerpagebuttonsymbol\gobblesixarguments}}
\def\setregisterpagerendering
{\edef\currentregisterpagesymbol{\registerparameter\c!symbol}%
@@ -752,7 +796,8 @@
\csname\??id:\c!symbol:\currentregisterpagesymbol\endcsname
\else
\let\registerpageseparatorsymbol\space
- \def\registerpagenumberhandle{\registerparameter\c!symbol\gobbleoneargument}%
+ \def\registeronepage {\registerparameter\c!symbol\gobblethreearguments}%
+ \def\registerpagerange {\registerparameter\c!symbol\gobblesixarguments}%
\fi\fi}
\appendtoks
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index bb3ad1aed..c936fd8f6 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts-merged.lua
-- parent file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts.lua
--- merge date : 02/11/10 15:54:42
+-- merge date : 02/12/10 10:26:48
do -- begin closure to overcome local limits and interference
@@ -11726,7 +11726,7 @@ local namespec = (1-lpeg.S("/:("))^0 -- was: (1-lpeg.S("/: ("))^0
local crapspec = spaces * lpeg.P("/") * (((1-lpeg.P(":"))^0)/iscrap) * spaces
local filename = (lpeg.P("file:")/isfile * (namespec/thename)) + (lpeg.P("[") * lpeg.P(true)/isname * (((1-lpeg.P("]"))^0)/thename) * lpeg.P("]"))
local fontname = (lpeg.P("name:")/isname * (namespec/thename)) + lpeg.P(true)/issome * (namespec/thename)
-local sometext = (lpeg.R("az") + lpeg.R("AZ") + lpeg.R("09"))^1
+local sometext = (lpeg.R("az") + lpeg.R("AZ") + lpeg.R("09") + lpeg.P("."))^1
local truevalue = lpeg.P("+") * spaces * (sometext/istrue)
local falsevalue = lpeg.P("-") * spaces * (sometext/isfalse)
local keyvalue = (lpeg.C(sometext) * spaces * lpeg.P("=") * spaces * lpeg.C(sometext))/iskey
@@ -12112,7 +12112,138 @@ end
fonts.initializers.base.otf.itlc = itlc
fonts.initializers.node.otf.itlc = itlc
+-- slant and extend
+
+function fonts.initializers.common.slant(tfmdata,value)
+ value = tonumber(value)
+ if not value then
+ value = 0
+ elseif value > 1 then
+ value = 1
+ elseif value < -1 then
+ value = -1
+ end
+ tfmdata.slant_factor = value
+end
+
+function fonts.initializers.common.extend(tfmdata,value)
+ value = tonumber(value)
+ if not value then
+ value = 0
+ elseif value > 10 then
+ value = 10
+ elseif value < -10 then
+ value = -10
+ end
+ tfmdata.extend_factor = value
+end
+
+table.insert(fonts.triggers,"slant")
+table.insert(fonts.triggers,"extend")
+
+fonts.initializers.base.otf.slant = fonts.initializers.common.slant
+fonts.initializers.node.otf.slant = fonts.initializers.common.slant
+fonts.initializers.base.otf.extend = fonts.initializers.common.extend
+fonts.initializers.node.otf.extend = fonts.initializers.common.extend
+
+-- expansion and protrusion
+
+fonts.protrusions = fonts.protrusions or { }
+fonts.protrusions.setups = fonts.protrusions.setups or { }
+
+local setups = fonts.protrusions.setups
+
+function fonts.initializers.common.protrusion(tfmdata,value)
+ if value then
+ local setup = setups[value]
+ if setup then
+ local factor, left, right = setup.factor or 1, setup.left or 1, setup.right or 1
+ local emwidth = tfmdata.parameters.quad
+ tfmdata.auto_protrude = true
+ for i, chr in next, tfmdata.characters do
+ local v, pl, pr = setup[i], nil, nil
+ if v then
+ pl, pr = v[1], v[2]
+ end
+ if pl and pl ~= 0 then chr.left_protruding = left *pl*factor end
+ if pr and pr ~= 0 then chr.right_protruding = right*pr*factor end
+ end
+ end
+ end
+end
+
+fonts.expansions = fonts.expansions or { }
+fonts.expansions.setups = fonts.expansions.setups or { }
+
+local setups = fonts.expansions.setups
+
+function fonts.initializers.common.expansion(tfmdata,value)
+ if value then
+ local setup = setups[value]
+ if setup then
+ local stretch, shrink, step, factor = setup.stretch or 0, setup.shrink or 0, setup.step or 0, setup.factor or 1
+ tfmdata.stretch, tfmdata.shrink, tfmdata.step, tfmdata.auto_expand = stretch * 10, shrink * 10, step * 10, true
+ for i, chr in next, tfmdata.characters do
+ local v = setup[i]
+ if v and v ~= 0 then
+ chr.expansion_factor = v*factor
+ else -- can be option
+ chr.expansion_factor = factor
+ end
+ end
+ end
+ end
+end
+
+table.insert(fonts.manipulators,"protrusion")
+table.insert(fonts.manipulators,"expansion")
+
+fonts.initializers.base.otf.protrusion = fonts.initializers.common.protrusion
+fonts.initializers.node.otf.protrusion = fonts.initializers.common.protrusion
+fonts.initializers.base.otf.expansion = fonts.initializers.common.expansion
+fonts.initializers.node.otf.expansion = fonts.initializers.common.expansion
+
+-- left over
+
function fonts.register_message()
end
+-- example vectors
+
+local byte = string.byte
+
+fonts.expansions.setups['default'] = {
+
+ stretch = 2, shrink = 2, step = .5, factor = 1,
+
+ [byte('A')] = 0.5, [byte('B')] = 0.7, [byte('C')] = 0.7, [byte('D')] = 0.5, [byte('E')] = 0.7,
+ [byte('F')] = 0.7, [byte('G')] = 0.5, [byte('H')] = 0.7, [byte('K')] = 0.7, [byte('M')] = 0.7,
+ [byte('N')] = 0.7, [byte('O')] = 0.5, [byte('P')] = 0.7, [byte('Q')] = 0.5, [byte('R')] = 0.7,
+ [byte('S')] = 0.7, [byte('U')] = 0.7, [byte('W')] = 0.7, [byte('Z')] = 0.7,
+ [byte('a')] = 0.7, [byte('b')] = 0.7, [byte('c')] = 0.7, [byte('d')] = 0.7, [byte('e')] = 0.7,
+ [byte('g')] = 0.7, [byte('h')] = 0.7, [byte('k')] = 0.7, [byte('m')] = 0.7, [byte('n')] = 0.7,
+ [byte('o')] = 0.7, [byte('p')] = 0.7, [byte('q')] = 0.7, [byte('s')] = 0.7, [byte('u')] = 0.7,
+ [byte('w')] = 0.7, [byte('z')] = 0.7,
+ [byte('2')] = 0.7, [byte('3')] = 0.7, [byte('6')] = 0.7, [byte('8')] = 0.7, [byte('9')] = 0.7,
+}
+
+fonts.protrusions.setups['default'] = {
+
+ factor = 1, left = 1, right = 1,
+
+ [0x002C] = { 0, 1 }, -- comma
+ [0x002E] = { 0, 1 }, -- period
+ [0x003A] = { 0, 1 }, -- colon
+ [0x003B] = { 0, 1 }, -- semicolon
+ [0x002D] = { 0, 1 }, -- hyphen
+ [0x2013] = { 0, 0.50 }, -- endash
+ [0x2014] = { 0, 0.33 }, -- emdash
+ [0x3001] = { 0, 1 }, -- ideographic comma 、
+ [0x3002] = { 0, 1 }, -- ideographic full stop 。
+ [0x060C] = { 0, 1 }, -- arabic comma ،
+ [0x061B] = { 0, 1 }, -- arabic semicolon ؛
+ [0x06D4] = { 0, 1 }, -- arabic full stop ۔
+
+}
+
end -- closure
diff --git a/tex/generic/context/luatex-test.tex b/tex/generic/context/luatex-test.tex
index 1c423ec5b..a142d1635 100644
--- a/tex/generic/context/luatex-test.tex
+++ b/tex/generic/context/luatex-test.tex
@@ -32,6 +32,12 @@
% \testy این یک متن نمونه است با قلم ذر که درست آمده است.
% \font\testz=name:linlibertineo \testz
+\pdfprotrudechars2 \pdfadjustspacing2
+
+\font\testb=file:lmroman12-regular:+liga;extend=1.5 at 12pt \testb \input tufte \par
+\font\testb=file:lmroman12-regular:+liga;slant=0.8 at 12pt \testb \input tufte \par
+\font\testb=file:lmroman12-regular:+liga;protrusion=default at 12pt \testb \input tufte \par
+
\setmplibformat{plain}
\mplibcode