summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tex/context/base/char-ini.lua121
-rw-r--r--tex/context/base/cont-new.tex2
-rw-r--r--tex/context/base/context.tex2
-rw-r--r--tex/context/base/lpdf-ano.lua5
-rw-r--r--tex/context/base/sort-ini.lua6
-rw-r--r--tex/context/base/strc-ref.lua1
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua2
7 files changed, 97 insertions, 42 deletions
diff --git a/tex/context/base/char-ini.lua b/tex/context/base/char-ini.lua
index ae496b4de..6a9d1117d 100644
--- a/tex/context/base/char-ini.lua
+++ b/tex/context/base/char-ini.lua
@@ -122,9 +122,11 @@ setmetatablekey(data, "__index", function(t,k)
if k < 0xF0000 then
for r=1,#ranges do
local rr = ranges[r].range
- if k >= rr.first and k <= rr.last then
- t[k] = rr
- return rr
+ local first, last = rr.first, rr.last
+ if k >= first and k <= last then
+ local v = t[first]
+ t[k] = v
+ return v
end
end
end
@@ -308,11 +310,11 @@ characters.blocks = allocate {
}
setmetatable(characters.blocks, { __index = function(t,k)
- return rawget(t,lower(gsub(k,"[^a-zA-Z]","")))
+ return k and rawget(t,lower(gsub(k,"[^a-zA-Z]","")))
end } )
function characters.getrange(name) -- used in font fallback definitions (name or range)
- local range = characters.blocks[tag]
+ local range = characters.blocks[name]
if range then
return range[1], range[2], range[3]
end
@@ -328,7 +330,7 @@ function characters.getrange(name) -- used in font fallback definitions (name or
return slot, slot, nil
end
-characters.categories = allocate {
+local categorytags = allocate {
lu = "Letter Uppercase",
ll = "Letter Lowercase",
lt = "Letter Titlecase",
@@ -361,6 +363,8 @@ characters.categories = allocate {
cn = "Other Not Assigned",
}
+characters.categorytags = categorytags
+
--~ special : cf (softhyphen) zs (emspace)
--~ characters: ll lm lo lt lu mn nl no pc pd pe pf pi po ps sc sk sm so
@@ -381,9 +385,30 @@ local is_command = allocate ( table.tohash {
"cf","zs"
} )
+local is_spacing = allocate ( table.tohash {
+ "zs", "zl","zp",
+} )
+
characters.is_character = is_character
characters.is_letter = is_letter
characters.is_command = is_command
+characters.is_spacing = is_spacing
+
+local mt = { -- yes or no ?
+ __index = function(t,k)
+ if type(k) == "number" then
+ local c = characters.data[k].category
+ return c and rawget(t,c)
+ else
+ -- avoid auto conversion in data.characters lookups
+ end
+ end
+}
+
+setmetatable(characters.is_character, mt)
+setmetatable(characters.is_letter, mt)
+setmetatable(characters.is_command, mt)
+setmetatable(characters.is_spacing, mt)
-- linebreak: todo: hash
--
@@ -608,7 +633,18 @@ accessing the data table.</p>
function characters.contextname(n) return data[n].contextname or "" end
function characters.adobename (n) return data[n].adobename or "" end
function characters.description(n) return data[n].description or "" end
-function characters.category (n) return data[n].category or "" end
+-------- characters.category (n) return data[n].category or "" end
+
+function characters.category(n,verbose)
+ local c = data[n].category
+ if not c then
+ return ""
+ elseif verbose then
+ return categorytags[c]
+ else
+ return c
+ end
+end
--[[ldx--
<p>Requesting lower and uppercase codes:</p>
@@ -684,35 +720,27 @@ characters.categories = allocate() local categories = characters.categories --
setmetatable(categories, { __index = function(t,u) if u then local c = data[u] c = c and c.category or u t[u] = c return c end end } )
-characters.lccodes = allocate() local lccodes = characters.lccodes -- lazy table
-characters.uccodes = allocate() local uccodes = characters.uccodes -- lazy table
-characters.shcodes = allocate() local shcodes = characters.shcodes -- lazy table
+characters.lccodes = allocate() local lccodes = characters.lccodes -- lazy table
+characters.uccodes = allocate() local uccodes = characters.uccodes -- lazy table
+characters.shcodes = allocate() local shcodes = characters.shcodes -- lazy table
-setmetatable(lccodes, { __index = function(t,u) if u then local c = data[u] c = c and c.lccode or u t[u] = c return c end end } )
-setmetatable(uccodes, { __index = function(t,u) if u then local c = data[u] c = c and c.uccode or u t[u] = c return c end end } )
-setmetatable(shcodes, { __index = function(t,u) if u then local c = data[u] c = c and c.shcode or u t[u] = c return c end end } )
+setmetatable(lccodes, { __index = function(t,u) if u then local c = data[u] c = c and c.lccode or (type(u) == "string" and utfbyte(u)) or u t[u] = c return c end end } )
+setmetatable(uccodes, { __index = function(t,u) if u then local c = data[u] c = c and c.uccode or (type(u) == "string" and utfbyte(u)) or u t[u] = c return c end end } )
+setmetatable(shcodes, { __index = function(t,u) if u then local c = data[u] c = c and c.shcode or (type(u) == "string" and utfbyte(u)) or u t[u] = c return c end end } )
characters.lcchars = allocate() local lcchars = characters.lcchars -- lazy table
characters.ucchars = allocate() local ucchars = characters.ucchars -- lazy table
characters.shchars = allocate() local shchars = characters.shchars -- lazy table
-setmetatable(lcchars, { __index = function(t,u) if u then local c = data[utfbyte(u)] c = c and c.lccode c = c and utfchar (c) or u t[u] = c return c end end } )
-setmetatable(ucchars, { __index = function(t,u) if u then local c = data[utfbyte(u)] c = c and c.uccode c = c and utfchar (c) or u t[u] = c return c end end } )
-setmetatable(shchars, { __index = function(t,u) if u then local c = data[utfbyte(u)] c = c and c.shcode c = c and utfstring(c) or u t[u] = c return c end end } )
-
---~ characters.lccharcodes = allocate() local lccharcodes = characters.lccharcodes -- lazy table
---~ characters.uccharcodes = allocate() local uccharcodes = characters.uccharcodes -- lazy table
---~ characters.shcharcodes = allocate() local shcharcodes = characters.shcharcodes -- lazy table
-
---~ setmetatable(lccharcodes, { __index = function(t,u) if u then local c = data[utfbyte(u)] c = c and c.lccode or u t[u] = c return c end end } )
---~ setmetatable(uccharcodes, { __index = function(t,u) if u then local c = data[utfbyte(u)] c = c and c.uccode or u t[u] = c return c end end } )
---~ setmetatable(shcharcodes, { __index = function(t,u) if u then local c = data[utfbyte(u)] c = c and c.shcode or u t[u] = c return c end end } )
+setmetatable(lcchars, { __index = function(t,u) if u then local c = data[u] c = c and c.lccode c = c and utfchar (c) or (type(u) == "number" and utfchar(u)) or u t[u] = c return c end end } )
+setmetatable(ucchars, { __index = function(t,u) if u then local c = data[u] c = c and c.uccode c = c and utfchar (c) or (type(u) == "number" and utfchar(u)) or u t[u] = c return c end end } )
+setmetatable(shchars, { __index = function(t,u) if u then local c = data[u] c = c and c.shcode c = c and utfstring(c) or (type(u) == "number" and utfchar(u)) or u t[u] = c return c end end } )
characters.specialchars = allocate() local specialchars = characters.specialchars -- lazy table
setmetatable(specialchars, { __index = function(t,u)
if u then
- local c = data[utfbyte(u)]
+ local c = data[u]
local s = c and c.specials
if s then
local tt, ttn = { }, 0
@@ -728,6 +756,9 @@ setmetatable(specialchars, { __index = function(t,u)
t[u] = c
return c
else
+ if type(u) == "number" then
+ u = utfchar(u)
+ end
t[u] = u
return u
end
@@ -738,7 +769,7 @@ function characters.lower(str)
local new, n = { }, 0
for u in utfvalues(str) do
n = n + 1
- new[n] = utfchar(lccodes[u])
+ new[n] = lcchars[u]
end
return concat(new)
end
@@ -747,18 +778,44 @@ function characters.upper(str)
local new, n = { }, 0
for u in utfvalues(str) do
n = n + 1
- new[n] = utfchar(uccodes[u])
+ new[n] = ucchars[u]
end
return concat(new)
end
-function characters.lettered(str)
+function characters.shaped(str)
local new, n = { }, 0
for u in utfvalues(str) do
- local d = data[u]
- if is_letter[d.category] then
- n = n + 1
- new[n] = utfchar(lccodes[u])
+ n = n + 1
+ new[n] = shchars[u]
+ end
+ return concat(new)
+end
+
+function characters.lettered(str,spacing)
+ local new, n = { }, 0
+ if spacing then
+ local done = false
+ for u in utfvalues(str) do
+ local c = data[u].category
+ if is_letter[c] then
+ if done and n > 1 then
+ n = n + 1
+ new[n] = " "
+ done = false
+ end
+ n = n + 1
+ new[n] = utfchar(u)
+ elseif spacing and is_spacing[c] then
+ done = true
+ end
+ end
+ else
+ for u in utfvalues(str) do
+ if is_letter[data[u].category] then
+ n = n + 1
+ new[n] = utfchar(u)
+ end
end
end
return concat(new)
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index 6903ee474..ed43fb610 100644
--- a/tex/context/base/cont-new.tex
+++ b/tex/context/base/cont-new.tex
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2010.11.03 09:12}
+\newcontextversion{2010.11.03 19:42}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex
index cec1133a4..bfd1b6119 100644
--- a/tex/context/base/context.tex
+++ b/tex/context/base/context.tex
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2010.11.03 09:12}
+\edef\contextversion{2010.11.03 19:42}
%D For those who want to use this:
diff --git a/tex/context/base/lpdf-ano.lua b/tex/context/base/lpdf-ano.lua
index 839930238..fcb330506 100644
--- a/tex/context/base/lpdf-ano.lua
+++ b/tex/context/base/lpdf-ano.lua
@@ -319,8 +319,6 @@ end node.free(lln)
-- -- -- --
-- -- -- --
-
-
function nodeinjections.destination(width,height,depth,name,view)
if trace_destinations then
report_destinations("w=%s, h=%s, d=%s, n=%s, v=%s",width,height,depth,name,view or "no view")
@@ -335,7 +333,7 @@ runners["inner"] = function(var,actions)
local vir = var.i.references
local internal = vir and vir.internal
if internal then
- var.inner = "aut:"..internal
+ var.inner = "aut:" .. internal
end
else
var.inner = nil
@@ -401,6 +399,7 @@ function specials.internal(var,actions) -- better resolve in strc-ref
local v = references.internals[i]
if not v then
-- error
+ report_references("no internal reference '%s'",var.operation)
elseif getinnermethod() == "names" then
-- named
return link(nil,nil,"aut:"..i,v.references.realpage,actions)
diff --git a/tex/context/base/sort-ini.lua b/tex/context/base/sort-ini.lua
index 5b8575219..2cf92bf67 100644
--- a/tex/context/base/sort-ini.lua
+++ b/tex/context/base/sort-ini.lua
@@ -99,8 +99,6 @@ local constants = sorters.constants
local data, language, method, digits
local replacements, m_mappings, z_mappings, p_mappings, entries, orders, lower, upper, method, sequence
---~ local shchars = characters.specialchars -- no specials for AE and ae
-
local mte = {
__index = function(t,k)
if k ~= "" and utfbyte(k) < digitsoffset then
@@ -112,8 +110,8 @@ local mte = {
if not el then
local l = shchars[k]
if l and l ~= k then
- if #l > 0 then
- l = sub(l,1,1)
+ if #l > 1 then
+ l = sub(l,1,1) -- todo
end
el = rawget(t,l)
if not el then
diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua
index 3dddc6bc5..c380fb4ea 100644
--- a/tex/context/base/strc-ref.lua
+++ b/tex/context/base/strc-ref.lua
@@ -1179,6 +1179,7 @@ function references.setinternalreference(prefix,tag,internal,view)
end
end
if internal and innermethod == "names" then -- mixed or page
+ tn = tn + 1
t[tn] = "aut:" .. internal
end
local destination = references.mark(t,nil,nil,view) -- returns an attribute
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index 6aa7e5aa0..2f3ad7e85 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 : 11/03/10 09:12:20
+-- merge date : 11/03/10 19:42:18
do -- begin closure to overcome local limits and interference