did you play with
\definefontfeature[whatever][keepligatures=auto]
\definecharacterkerning [extrakerning] [factor=0.125,features=whatever]
\starttext
\setcharacterkerning[extrakerning]
effe fietsen
\stoptext
Great! Thanks! This now works:
\definefontfeature[frac][frac=yes]
\definefontfeature[klig][keepligatures=auto]
\definecharacterkerning[narrow][factor=-.02,features=klig]
\definecharacterkerning[wide][factor=.02,features=klig]
\def\Narrow#1{\dontleavehmode\bgroup\setcharacterkerning[narrow]#1\egroup}
\def\Wide#1{\dontleavehmode\bgroup\setcharacterkerning[wide]#1\egroup}
\def\NoKerning#1{\dontleavehmode\bgroup\resetcharacterkerning #1\egroup}
\starttext
\feature[+][frac]%
Some ligatures: float, finance, affine; a fraction: 1/4.
\blank
Modified kerning:
\Narrow{Some ligatures: float, finance, affine; a fraction: 1/4.}
\Wide{Some ligatures: float, finance, affine; a fraction: 1/4.}
\stoptext
BTW, back to the automatic insertion of tags, how can i create children
elements? In other words, how should i rewrite new_dk_element?
The problem is this:
- you have an element t and t.dt = { "float, finance, affine, affluent" }
- t.dt should become = { DK1, "oat", DK2, "nance, a", DK3, "ne, a", DK4,
"uent" }
- where DK1 ... DK4 are children elements of t with tg="dk" and dt
respectively equal to { "fl" }, { "fi" }, { "ffi" }, { "ffl" }
My new_dk_element function should create such DKn elements, but they are
not created right, because they look ignored by \xmlflush.
\startbuffer[test]
<text>
<p>Some ligatures: float, finance, affine, affluent.</p>
<p>Modified kerning:</p>
<p class="narrow">Some ligatures: float, finance, affine, affluent.</p>
<p class="wide">Some ligatures: float, finance, affine, affluent.</p>
</text>
\stopbuffer
\startluacode
local function new_dk_element( parent, text )
return {
tag = "dk",
ns = "",
rn = "",
dt = { text },
at = {},
command = "xml:dk",
__p__ = parent
}
--[[
local t = xml.toxml( "<dk>" .. text .. "</dk>" )
t.__p__ = parent
return t
]]--
end
local append = table.insert
local function saveLigaturesFromKerning( t )
if t and t.dt then
local dt = t.dt
local t_copy = {}
for k,v in pairs( t ) do
if k ~= "dt" then t_copy[ k ] = v end
end
local new_dt = {}
local i
local child
local b, e
for i = 1, #dt, 1 do
child = dt[ i ]
if type( child ) == "string" then
local s = child
repeat
b, e = string.find( s, "f?f[il]" )
if b then
if b > 1 then append( new_dt, string.sub( s, 1, b - 1 ) )
end
append( new_dt, new_dk_element( t, string.sub( s, b, e ) ) )
-- append( new_dt, "[" .. string.sub( s, b, e ) .. "]" )
s = string.sub( s, e + 1 )
else
append( new_dt, s )
end
until not b
else
append( new_dt, child )
end
end
t.dt = new_dt
end
return t
end
function xml.functions.textWithKerning( t )
local kt = saveLigaturesFromKerning( t )
lxml.flush( kt )
end
\stopluacode
\definecharacterkerning[narrow][factor=-.02]
\definecharacterkerning[wide][factor=.02]
\def\Narrow#1{\bgroup\setcharacterkerning[narrow]#1\egroup}
\def\Wide#1{\bgroup\setcharacterkerning[wide]#1\egroup}
\def\NoKerning#1{\bgroup\resetcharacterkerning #1\egroup}
\startxmlsetups xml:test
\xmlsetsetup{#1}{text|p|dk}{xml:*}
\xmlsetsetup{#1}{{p.narrow}}{xml:p:narrow}
\xmlsetsetup{#1}{{p.wide}}{xml:p:wide}
\stopxmlsetups
\xmlregistersetup{xml:test}
\startxmlsetups xml:text
\xmlflush{#1}
\stopxmlsetups
\startxmlsetups xml:p
\xmlflush{#1}\par
\stopxmlsetups
\startxmlsetups xml:p:narrow
\Narrow{\xmlfunction{#1}{textWithKerning}}\par
\stopxmlsetups
\startxmlsetups xml:p:wide
\Wide{\xmlfunction{#1}{textWithKerning}}\par
\stopxmlsetups
\startxmlsetups xml:dk
\NoKerning{\red\xmlflush{#1}}
\stopxmlsetups
\starttext
\xmlprocessbuffer{xml:test}{test}{}
\stoptext
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________