summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/font-osd.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/font-osd.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/font-osd.lua121
1 files changed, 75 insertions, 46 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/font-osd.lua b/Master/texmf-dist/tex/context/base/mkiv/font-osd.lua
index 32d791b48e9..9f99fd57f1c 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/font-osd.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/font-osd.lua
@@ -6,9 +6,6 @@ if not modules then modules = { } end modules ['font-osd'] = { -- script devanag
license = "see context related readme files"
}
-
--- we need to check nbsphash (context only)
-
-- A few remarks:
--
-- This code is a partial rewrite of the code that deals with devanagari. The data
@@ -99,6 +96,8 @@ local otffeatures = fonts.constructors.features.otf
local registerotffeature = otffeatures.register
local nuts = nodes.nuts
+local tonode = nuts.tonode
+local tonut = nuts.tonut
local getnext = nuts.getnext
local getprev = nuts.getprev
@@ -153,27 +152,47 @@ replace_all_nbsp = function(head) -- delayed definition
return replace_all_nbsp(head)
end
-local processcharacters = nil
+local xprocesscharacters = nil
if context then
- local fontprocesses = fonts.hashes.processes
- function processcharacters(head,font)
- local processors = fontprocesses[font]
- for i=1,#processors do
- head = processors[i](head,font,0)
- end
- return head
+ xprocesscharacters = function(head,font)
+ xprocesscharacters = nodes.handlers.characters
+ return xprocesscharacters(head,font)
end
else
- function processcharacters(head,font)
- local processors = fontdata[font].shared.processes
- for i=1,#processors do
- head = processors[i](head,font,0)
- end
- return head
+ xprocesscharacters = function(head,font)
+ xprocesscharacters = nodes.handlers.nodepass -- generic
+ return xprocesscharacters(head,font)
end
end
+local function processcharacters(head,font)
+ return tonut(xprocesscharacters(tonode(head))) -- can be more efficient in context, just direct call
+end
+
+-- to be tested:
+--
+-- local processcharacters = nil
+--
+-- if context then
+-- local fontprocesses = fonts.hashes.processes
+-- function processcharacters(head,font)
+-- local processors = fontprocesses[font]
+-- for i=1,#processors do
+-- head = processors[i](head,font,0)
+-- end
+-- return head, true
+-- end
+-- else
+-- function processcharacters(head,font)
+-- local processors = fontdata[font].shared.processes
+-- for i=1,#processors do
+-- head = processors[i](head,font,0)
+-- end
+-- return head, true
+-- end
+-- end
+
-- We can assume that script are not mixed in the source but if that is the case
-- we might need to have consonants etc per script and initialize a local table
-- pointing to the right one. But not now.
@@ -274,6 +293,10 @@ if not indicgroups and characters then
characters.indicgroups = indicgroups
+else
+
+ indicgroups = table.setmetatableindex("table")
+
end
local consonant = indicgroups.consonant
@@ -399,19 +422,19 @@ local sequence_remove_joiners = {
-- as it might depends on the font. Not that it's a bottleneck.
local basic_shaping_forms = {
- -- init = true, -- new
- -- abvs = true, -- new
+ init = true, -- new
+ abvs = true, -- new
akhn = true,
blwf = true,
- -- calt = true, -- new
+ calt = true, -- new
cjct = true,
half = true,
- -- haln = true, -- new
+ haln = true, -- new
nukt = true,
pref = true,
- -- pres = true, -- new
+ pres = true, -- new
pstf = true,
- -- psts = true, -- new
+ psts = true, -- new
rkrf = true,
rphf = true,
vatu = true,
@@ -582,7 +605,9 @@ local function initializedevanagi(tfmdata)
end
end
end
- seqsubset[#seqsubset+1] = { kind, coverage, reph }
+if reph then
+ seqsubset[#seqsubset+1] = { kind, coverage, reph }
+end
end
end
end
@@ -666,19 +691,6 @@ registerotffeature {
},
}
-local show_syntax_errors = false
-
-local function inject_syntax_error(head,current,char)
- local signal = copy_node(current)
- copyinjection(signal,current)
- if pre_mark[char] then
- setchar(signal,dotted_circle)
- else
- setchar(current,dotted_circle)
- end
- return insert_node_after(head,current,signal)
-end
-
-- hm, this is applied to one character:
local function initialize_one(font,attr) -- we need a proper hook into the dataset initializer
@@ -781,9 +793,10 @@ local function reorder_one(head,start,stop,font,attr,nbspaces)
setprop(tempcurrent,a_state,unsetvalue)
if getchar(next) == getchar(tempcurrent) then
flush_list(tempcurrent)
- if show_syntax_errors then
- head, current = inject_syntax_error(head,current,char)
- end
+ local n = copy_node(current)
+ copyinjection(n,current) -- KE: necessary? HH: probably not as positioning comes later and we rawget/set
+ setchar(current,dotted_circle)
+ head = insert_node_after(head, current, n)
else
setchar(current,getchar(tempcurrent)) -- we assumes that the result of blwf consists of one node
local freenode = getnext(current)
@@ -1204,7 +1217,7 @@ function handlers.devanagari_reorder_reph(head,start)
while current do
local char = ischar(current,startfont)
if char and getprop(current,a_syllabe) == startattr then
- if not c and mark_above_below_post[char] and not after_subscript[char] then
+ if not c and mark_above_below_post[char] and after_subscript[char] then
c = current
end
current = getnext(current)
@@ -1547,9 +1560,10 @@ local function reorder_two(head,start,stop,font,attr,nbspaces) -- maybe do a pas
setprop(current,a_state,unsetvalue)
if halant[getchar(current)] then
setnext(getnext(current),tmp)
- if show_syntax_errors then
- head, current = inject_syntax_error(head,current,char)
- end
+ local nc = copy_node(current)
+ copyinjection(nc,current)
+ setchar(current,dotted_circle)
+ head = insert_node_after(head,current,nc)
else
setnext(current,tmp) -- assumes that result of pref, blwf, or pstf consists of one node
if changestop then
@@ -2044,10 +2058,24 @@ local function analyze_next_chars_two(c,font)
end
end
+local show_syntax_errors = false
+
+local function inject_syntax_error(head,current,char)
+ local signal = copy_node(current)
+ copyinjection(signal,current)
+ if pre_mark[char] then
+ setchar(signal,dotted_circle)
+ else
+ setchar(current,dotted_circle)
+ end
+ return insert_node_after(head,current,signal)
+end
+
-- It looks like these two analyzers were written independently but they share
-- a lot. Common code has been synced.
local function method_one(head,font,attr)
+ head = tonut(head)
local current = head
local start = true
local done = false
@@ -2242,13 +2270,14 @@ local function method_one(head,font,attr)
head = replace_all_nbsp(head)
end
- return head, done
+ return tonode(head), done
end
-- there is a good change that when we run into one with subtype < 256 that the rest is also done
-- so maybe we can omit this check (it's pretty hard to get glyphs in the stream out of the blue)
local function method_two(head,font,attr)
+ head = tonut(head)
local current = head
local start = true
local done = false
@@ -2337,7 +2366,7 @@ local function method_two(head,font,attr)
head = replace_all_nbsp(head)
end
- return head, done
+ return tonode(head), done
end
for i=1,nofscripts do