summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/font-osd.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/font-osd.lua')
-rw-r--r--tex/context/base/mkiv/font-osd.lua121
1 files changed, 46 insertions, 75 deletions
diff --git a/tex/context/base/mkiv/font-osd.lua b/tex/context/base/mkiv/font-osd.lua
index 9f99fd57f..32d791b48 100644
--- a/tex/context/base/mkiv/font-osd.lua
+++ b/tex/context/base/mkiv/font-osd.lua
@@ -6,6 +6,9 @@ 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
@@ -96,8 +99,6 @@ 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
@@ -152,47 +153,27 @@ replace_all_nbsp = function(head) -- delayed definition
return replace_all_nbsp(head)
end
-local xprocesscharacters = nil
+local processcharacters = nil
if context then
- xprocesscharacters = function(head,font)
- xprocesscharacters = nodes.handlers.characters
- return xprocesscharacters(head,font)
+ 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
end
else
- xprocesscharacters = function(head,font)
- xprocesscharacters = nodes.handlers.nodepass -- generic
- return xprocesscharacters(head,font)
+ function processcharacters(head,font)
+ local processors = fontdata[font].shared.processes
+ for i=1,#processors do
+ head = processors[i](head,font,0)
+ end
+ return head
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.
@@ -293,10 +274,6 @@ if not indicgroups and characters then
characters.indicgroups = indicgroups
-else
-
- indicgroups = table.setmetatableindex("table")
-
end
local consonant = indicgroups.consonant
@@ -422,19 +399,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,
@@ -605,9 +582,7 @@ local function initializedevanagi(tfmdata)
end
end
end
-if reph then
- seqsubset[#seqsubset+1] = { kind, coverage, reph }
-end
+ seqsubset[#seqsubset+1] = { kind, coverage, reph }
end
end
end
@@ -691,6 +666,19 @@ 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
@@ -793,10 +781,9 @@ local function reorder_one(head,start,stop,font,attr,nbspaces)
setprop(tempcurrent,a_state,unsetvalue)
if getchar(next) == getchar(tempcurrent) then
flush_list(tempcurrent)
- 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)
+ if show_syntax_errors then
+ head, current = inject_syntax_error(head,current,char)
+ end
else
setchar(current,getchar(tempcurrent)) -- we assumes that the result of blwf consists of one node
local freenode = getnext(current)
@@ -1217,7 +1204,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 after_subscript[char] then
+ if not c and mark_above_below_post[char] and not after_subscript[char] then
c = current
end
current = getnext(current)
@@ -1560,10 +1547,9 @@ 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)
- local nc = copy_node(current)
- copyinjection(nc,current)
- setchar(current,dotted_circle)
- head = insert_node_after(head,current,nc)
+ if show_syntax_errors then
+ head, current = inject_syntax_error(head,current,char)
+ end
else
setnext(current,tmp) -- assumes that result of pref, blwf, or pstf consists of one node
if changestop then
@@ -2058,24 +2044,10 @@ 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
@@ -2270,14 +2242,13 @@ local function method_one(head,font,attr)
head = replace_all_nbsp(head)
end
- return tonode(head), done
+ return 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
@@ -2366,7 +2337,7 @@ local function method_two(head,font,attr)
head = replace_all_nbsp(head)
end
- return tonode(head), done
+ return head, done
end
for i=1,nofscripts do