summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2011-10-14 20:35:20 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2011-10-14 20:35:20 +0200
commitee1fab567ddf9949c01459a22f7dcb1053e3c48a (patch)
tree86c883ff84a54d64bb8f113bb06e761ad2d37220
parentaef64a50686ae146e9b87f626b789508e8288fa3 (diff)
downloadluaotfload-ee1fab567ddf9949c01459a22f7dcb1053e3c48a.tar.gz
Sync with ConTeXt beta 2011.10.13 21:36
-rw-r--r--otfl-font-con.lua62
-rw-r--r--otfl-font-otn.lua111
2 files changed, 105 insertions, 68 deletions
diff --git a/otfl-font-con.lua b/otfl-font-con.lua
index 18123ed..5352977 100644
--- a/otfl-font-con.lua
+++ b/otfl-font-con.lua
@@ -26,30 +26,30 @@ local report_defining = logs.reporter("fonts","defining")
<p>Here we only implement a few helper functions.</p>
--ldx]]--
-local fonts = fonts
-local constructors = { }
-fonts.constructors = constructors
-local handlers = { }
-fonts.handlers = handlers
+local fonts = fonts
+local constructors = { }
+fonts.constructors = constructors
+local handlers = { }
+fonts.handlers = handlers
-local specifiers = fonts.specifiers
-local contextsetups = specifiers.contextsetups
-local contextnumbers = specifiers.contextnumbers
+local specifiers = fonts.specifiers
+local contextsetups = specifiers.contextsetups
+local contextnumbers = specifiers.contextnumbers
-local allocate = utilities.storage.allocate
-local setmetatableindex = table.setmetatableindex
+local allocate = utilities.storage.allocate
+local setmetatableindex = table.setmetatableindex
-- will be directives
-constructors.dontembed = allocate()
-constructors.mathactions = { }
-constructors.autocleanup = true
-constructors.namemode = "fullpath" -- will be a function
+constructors.dontembed = allocate()
+constructors.mathactions = { }
+constructors.autocleanup = true
+constructors.namemode = "fullpath" -- will be a function
-constructors.version = 1.01
-constructors.cache = containers.define("fonts", "constructors", constructors.version, false)
+constructors.version = 1.01
+constructors.cache = containers.define("fonts", "constructors", constructors.version, false)
-constructors.privateoffset = 0xF0000 -- 0x10FFFF
+constructors.privateoffset = 0xF0000 -- 0x10FFFF
-- This might become an interface;
@@ -406,6 +406,26 @@ function constructors.scale(tfmdata,specification)
target.mathparameters = nil -- nop
end
--
+ local italickey = "italic"
+ if hasmath then
+ if properties.no_mathitalics then
+ italickey = "italic_correction" -- context specific trickery
+ if trace_defining then
+ report_defining("math italics disabled for: name '%s', fullname: '%s', filename: '%s'",
+ name or "noname",fullname or "nofullname",filename or "nofilename")
+ end
+ end
+ autoitalic = false -- new
+ else
+ if properties.no_textitalics then
+ italickey = "italic_correction" -- context specific trickery
+ if trace_defining then
+ report_defining("text italics disabled for: name '%s', fullname: '%s', filename: '%s'",
+ name or "noname",fullname or "nofullname",filename or "nofilename")
+ end
+ end
+ end
+ --
local sharedkerns = { }
--
for unicode, character in next, characters do
@@ -501,16 +521,16 @@ function constructors.scale(tfmdata,specification)
chr.right_protruding = protrusionfactor*width*vr
end
end
- -- todo: hasitalic
+ --
if autoitalic then
local vi = description.italic or (description.boundingbox[3] - description.width + autoitalic)
if vi and vi ~= 0 then
- chr.italic = vi*hdelta
+ chr[italickey] = vi*hdelta
end
elseif hasitalic then
local vi = description.italic or character.italic -- why character
if vi and vi ~= 0 then
- chr.italic = vi*hdelta
+ chr[italickey] = vi*hdelta
end
end
-- to be tested
@@ -1128,7 +1148,7 @@ function constructors.collectprocessors(what,tfmdata,features,trace,report)
end
end
end
- else
+ elseif trace then
report("no feature processors for mode %s for font %s",
mode or 'unknown', tfmdata.properties.fullname or 'unknown')
end
diff --git a/otfl-font-otn.lua b/otfl-font-otn.lua
index 914a7de..beb3ae7 100644
--- a/otfl-font-otn.lua
+++ b/otfl-font-otn.lua
@@ -445,7 +445,7 @@ local function alternative_glyph(start,alternatives,kind,chainname,chainlookupna
return choice, value
end
-local function multiple_glyphs(start,multiple)
+local function multiple_glyphs(start,multiple) -- marks ?
local nofmultiples = #multiple
if nofmultiples > 0 then
start.char = multiple[1]
@@ -957,7 +957,7 @@ single lookup case. The efficiency of the replacements can be improved by deleti
as less as needed but that would also make the code even more messy.</p>
--ldx]]--
-local function delete_till_stop(start,stop,ignoremarks)
+local function delete_till_stop(start,stop,ignoremarks) -- keeps start
local n = 1
if start == stop then
-- done
@@ -986,10 +986,6 @@ match.</p>
function chainprocs.gsub_single(start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname,chainindex)
-- todo: marks ?
---~ if not chainindex then
---~ delete_till_stop(start,stop) -- ,currentlookup.flags[1]
---~ stop = start
---~ end
local current = start
local subtables = currentlookup.subtables
if #subtables > 1 then
@@ -1035,7 +1031,7 @@ the match.</p>
--ldx]]--
function chainprocs.gsub_multiple(start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname)
- delete_till_stop(start,stop) -- we can assume that marks are to be deleted
+ delete_till_stop(start,stop) -- we could pass ignoremarks as #3 ..
local startchar = start.char
local subtables = currentlookup.subtables
local lookupname = subtables[1]
@@ -1565,37 +1561,41 @@ local function show_skip(kind,chainname,char,ck,class)
end
local function normal_handle_contextchain(start,kind,chainname,contexts,sequence,lookuphash)
- -- local rule, lookuptype, sequence, f, l, lookups = ck[1], ck[2] ,ck[3], ck[4], ck[5], ck[6]
- local flags, done = sequence.flags, false
- local skipmark, skipligature, skipbase = flags[1], flags[2], flags[3]
- local someskip = skipmark or skipligature or skipbase -- could be stored in flags for a fast test (hm, flags could be false !)
- local markclass = sequence.markclass -- todo, first we need a proper test
- local skipped = false
+ -- local rule, lookuptype, sequence, f, l, lookups = ck[1], ck[2] ,ck[3], ck[4], ck[5], ck[6]
+ local flags = sequence.flags
+ local done = false
+ local skipmark = flags[1]
+ local skipligature = flags[2]
+ local skipbase = flags[3]
+ local someskip = skipmark or skipligature or skipbase -- could be stored in flags for a fast test (hm, flags could be false !)
+ local markclass = sequence.markclass -- todo, first we need a proper test
+ local skipped = false
for k=1,#contexts do
- local match, current, last = true, start, start
- local ck = contexts[k]
- local seq = ck[3]
- local s = #seq
+ local match = true
+ local current = start
+ local last = start
+ local ck = contexts[k]
+ local seq = ck[3]
+ local s = #seq
-- f..l = mid string
if s == 1 then
-- never happens
match = current.id == glyph_code and current.subtype<256 and current.font == currentfont and seq[1][current.char]
else
- -- todo: better space check (maybe check for glue)
+ -- maybe we need a better space check (maybe check for glue or category or combination)
+ -- we cannot optimize for n=2 because there can be disc nodes
local f, l = ck[4], ck[5]
-- current match
- if f == 1 and f == l then
+ if f == 1 and f == l then -- current only
-- already a hit
- match = true
- else
+ -- match = true
+ else -- before/current/after | before/current | current/after
-- no need to test first hit (to be optimized)
- local n = f + 1
- last = last.next
- -- we cannot optimize for n=2 because there can be disc nodes
- -- if not someskip and n == l then
- -- -- n=2 and no skips then faster loop
- -- match = last and last.id == glyph_code and last.subtype<256 and last.font == currentfont and seq[n][last.char]
- -- else
+ if f == l then -- new, else last out of sync (f is > 1)
+ -- match = true
+ else
+ local n = f + 1
+ last = last.next
while n <= l do
if last then
local id = last.id
@@ -1617,24 +1617,29 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence
end
n = n + 1
else
- match = false break
+ match = false
+ break
end
else
- match = false break
+ match = false
+ break
end
else
- match = false break
+ match = false
+ break
end
- elseif id == disc_code then -- what to do with kerns?
+ elseif id == disc_code then
last = last.next
else
- match = false break
+ match = false
+ break
end
else
- match = false break
+ match = false
+ break
end
end
- -- end
+ end
end
-- before
if match and f > 1 then
@@ -1658,26 +1663,31 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence
elseif seq[n][char] then
n = n -1
else
- match = false break
+ match = false
+ break
end
else
- match = false break
+ match = false
+ break
end
else
- match = false break
+ match = false
+ break
end
elseif id == disc_code then
-- skip 'm
elseif seq[n][32] then
n = n -1
else
- match = false break
+ match = false
+ break
end
prev = prev.prev
elseif seq[n][32] then -- somehat special, as zapfino can have many preceding spaces
n = n -1
else
- match = false break
+ match = false
+ break
end
end
elseif f == 2 then
@@ -1685,7 +1695,8 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence
else
for n=f-1,1 do
if not seq[n][32] then
- match = false break
+ match = false
+ break
end
end
end
@@ -1713,26 +1724,31 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence
elseif seq[n][char] then
n = n + 1
else
- match = false break
+ match = false
+ break
end
else
- match = false break
+ match = false
+ break
end
else
- match = false break
+ match = false
+ break
end
elseif id == disc_code then
-- skip 'm
elseif seq[n][32] then -- brrr
n = n + 1
else
- match = false break
+ match = false
+ break
end
current = current.next
elseif seq[n][32] then
n = n + 1
else
- match = false break
+ match = false
+ break
end
end
elseif s-l == 1 then
@@ -1740,7 +1756,8 @@ local function normal_handle_contextchain(start,kind,chainname,contexts,sequence
else
for n=l+1,s do
if not seq[n][32] then
- match = false break
+ match = false
+ break
end
end
end