summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2010-02-25 00:38:44 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2010-02-25 00:41:34 +0200
commit6329e52d8aa7381a248e4a7dbf734d2ad083c50f (patch)
tree67c0f600cede869caf726c5d77a1d6371d6aa137
parente064aa2dc70fb819cfdb6b3c0bdf1d081859584f (diff)
downloadluaotfload-6329e52d8aa7381a248e4a7dbf734d2ad083c50f.tar.gz
Updating to latest ConTeXt beta (2010.02.24)
Now encoding related code gone.
-rw-r--r--luaotfload.dtx8
-rw-r--r--otfl-font-otb.lua78
-rw-r--r--otfl-font-otf.lua33
-rw-r--r--otfl-font-otn.lua2
-rw-r--r--otfl-font-tfm.lua180
-rw-r--r--otfl-luat-dum.lua2
-rw-r--r--otfl-node-inj.lua3
-rw-r--r--tests/fontencoding.tex4
8 files changed, 53 insertions, 257 deletions
diff --git a/luaotfload.dtx b/luaotfload.dtx
index f543fd0..33b8922 100644
--- a/luaotfload.dtx
+++ b/luaotfload.dtx
@@ -493,14 +493,6 @@ luaotfload.loadmodule('font-clr.lua')
% \end{macrocode}
%
-% This is a small patch that prevents errors in some \LaTeX\ files.
-%
-% \begin{macrocode}
-
-fonts.enc.known = {}
-
-% \end{macrocode}
-%
% Finally two functions
%
% \begin{macrocode}
diff --git a/otfl-font-otb.lua b/otfl-font-otb.lua
index a684580..020b107 100644
--- a/otfl-font-otb.lua
+++ b/otfl-font-otb.lua
@@ -134,43 +134,12 @@ local function resolve_ligatures(tfmdata,ligatures,kind)
end
end
-local function collect_lookups(otfdata,kind,script,language)
- -- maybe store this in the font
- local sequences = otfdata.luatex.sequences
- if sequences then
- local featuremap, featurelist = { }, { }
- for s=1,#sequences do
- local sequence = sequences[s]
- local features = sequence.features
- features = features and features[kind]
- features = features and (features[script] or features[default] or features[wildcard])
- features = features and (features[language] or features[default] or features[wildcard])
- if features then
- local subtables = sequence.subtables
- if subtables then
- for s=1,#subtables do
- local ss = subtables[s]
- if not featuremap[s] then
- featuremap[ss] = true
- featurelist[#featurelist+1] = ss
- end
- end
- end
- end
- end
- if #featurelist > 0 then
- return featuremap, featurelist
- end
- end
- return nil, nil
-end
-
local splitter = lpeg.splitat(" ")
function prepare_base_substitutions(tfmdata,kind,value) -- we can share some code with the node features
if value then
local otfdata = tfmdata.shared.otfdata
- local validlookups, lookuplist = collect_lookups(otfdata,kind,tfmdata.script,tfmdata.language)
+ local validlookups, lookuplist = otf.collect_lookups(otfdata,kind,tfmdata.script,tfmdata.language)
if validlookups then
local ligatures = { }
local unicodes = tfmdata.unicodes -- names to unicodes
@@ -218,7 +187,7 @@ function prepare_base_substitutions(tfmdata,kind,value) -- we can share some cod
end
if characters[upc] then
if trace_baseinit and trace_alternatives then
- logs.report("define otf","%s: base alternate %s => %s",cref(kind,lookup),gref(descriptions,k),gref(descriptions,upc))
+ logs.report("define otf","%s: base alternate %s %s => %s",cref(kind,lookup),tostring(value),gref(descriptions,k),gref(descriptions,upc))
end
changed[k] = upc
end
@@ -279,51 +248,10 @@ function prepare_base_substitutions(tfmdata,kind,value) -- we can share some cod
end
end
---~ local function prepare_base_kerns(tfmdata,kind,value) -- todo what kind of kerns, currently all
---~ if value then
---~ local otfdata = tfmdata.shared.otfdata
---~ local validlookups, lookuplist = collect_lookups(otfdata,kind,tfmdata.script,tfmdata.language)
---~ if validlookups then
---~ local unicodes = tfmdata.unicodes -- names to unicodes
---~ local indices = tfmdata.indices
---~ local characters = tfmdata.characters
---~ local descriptions = tfmdata.descriptions
---~ for u, chr in next, characters do
---~ local d = descriptions[u]
---~ if d then
---~ local dk = d.mykerns
---~ if dk then
---~ local t, done = chr.kerns or { }, false
---~ for l=1,#lookuplist do
---~ local lookup = lookuplist[l]
---~ local kerns = dk[lookup]
---~ if kerns then
---~ for k, v in next, kerns do
---~ if v ~= 0 and not t[k] then -- maybe no 0 test here
---~ t[k], done = v, true
---~ if trace_baseinit and trace_kerns then
---~ logs.report("define otf","%s: base kern %s + %s => %s",cref(kind,lookup),gref(descriptions,u),gref(descriptions,k),v)
---~ end
---~ end
---~ end
---~ end
---~ end
---~ if done then
---~ chr.kerns = t -- no empty assignments
---~ end
---~ -- elseif d.kerns then
---~ -- logs.report("define otf","%s: invalid mykerns for %s",cref(kind),gref(descriptions,u))
---~ end
---~ end
---~ end
---~ end
---~ end
---~ end
-
local function prepare_base_kerns(tfmdata,kind,value) -- todo what kind of kerns, currently all
if value then
local otfdata = tfmdata.shared.otfdata
- local validlookups, lookuplist = collect_lookups(otfdata,kind,tfmdata.script,tfmdata.language)
+ local validlookups, lookuplist = otf.collect_lookups(otfdata,kind,tfmdata.script,tfmdata.language)
if validlookups then
local unicodes = tfmdata.unicodes -- names to unicodes
local indices = tfmdata.indices
diff --git a/otfl-font-otf.lua b/otfl-font-otf.lua
index 94f5dcf..1465e13 100644
--- a/otfl-font-otf.lua
+++ b/otfl-font-otf.lua
@@ -1711,3 +1711,36 @@ function tfm.read_from_open_type(specification)
--~ print(tfmtable.fullname)
return tfmtable
end
+
+-- helpers
+
+function otf.collect_lookups(otfdata,kind,script,language)
+ -- maybe store this in the font
+ local sequences = otfdata.luatex.sequences
+ if sequences then
+ local featuremap, featurelist = { }, { }
+ for s=1,#sequences do
+ local sequence = sequences[s]
+ local features = sequence.features
+ features = features and features[kind]
+ features = features and (features[script] or features[default] or features[wildcard])
+ features = features and (features[language] or features[default] or features[wildcard])
+ if features then
+ local subtables = sequence.subtables
+ if subtables then
+ for s=1,#subtables do
+ local ss = subtables[s]
+ if not featuremap[s] then
+ featuremap[ss] = true
+ featurelist[#featurelist+1] = ss
+ end
+ end
+ end
+ end
+ end
+ if #featurelist > 0 then
+ return featuremap, featurelist
+ end
+ end
+ return nil, nil
+end
diff --git a/otfl-font-otn.lua b/otfl-font-otn.lua
index efafa30..16ecc2d 100644
--- a/otfl-font-otn.lua
+++ b/otfl-font-otn.lua
@@ -1988,6 +1988,7 @@ function fonts.methods.node.otf.features(head,font,attr)
if not lookupcache then
report_missing_cache(typ,lookupname)
else
+--~ print(typ,lookupname,lookupcache,table.serialize(lookupcache))
while start do
local id = start.id
if id == glyph then
@@ -1997,6 +1998,7 @@ function fonts.methods.node.otf.features(head,font,attr)
if lookupmatch then
-- sequence kan weg
local ok
+--~ print("!!!")
start, ok = handler(start,r[4],lookupname,lookupmatch,sequence,featuredata,1)
--~ texio.write_nl(tostring(lookupname),tostring(lookupmatch),tostring(ok))
if ok then
diff --git a/otfl-font-tfm.lua b/otfl-font-tfm.lua
index fd3d8b4..aa87398 100644
--- a/otfl-font-tfm.lua
+++ b/otfl-font-tfm.lua
@@ -36,6 +36,7 @@ fonts.initializers = fonts.initializers or { }
fonts.initializers.common = fonts.initializers.common or { }
local fontdata = fonts.ids
+local disc = node.id('disc')
local glyph = node.id('glyph')
local set_attribute = node.set_attribute
@@ -49,32 +50,7 @@ tfm.share_base_kerns = false -- true (.5 sec slower on mk but brings down mem fr
tfm.mathactions = { }
tfm.fontname_mode = "fullpath"
-function tfm.enhance(tfmdata,specification)
- local name, size = specification.name, specification.size
- local encoding, filename = match(name,"^(.-)%-(.*)$") -- context: encoding-name.*
- if filename and encoding and fonts.enc.known[encoding] then
- local data = fonts.enc.load(encoding)
- if data then
- local characters = tfmdata.characters
- tfmdata.encoding = encoding
- local vector = data.vector
- local original = { }
- for k, v in next, characters do
- v.name = vector[k]
- v.index = k
- original[k] = v
- end
- for k,v in next, data.unicodes do
- if k ~= v then
- if trace_defining then
- logs.report("define font","mapping %s onto %s",k,v)
- end
- characters[k] = original[v]
- end
- end
- end
- end
-end
+tfm.enhance = tfm.enhance or function() end
function tfm.read_from_tfm(specification)
local fname, tfmdata = specification.filename or "", nil
@@ -679,7 +655,8 @@ function fonts.analyzers.aux.setstate(head,font)
local descriptions = tfmdata.descriptions
local first, last, current, n, done = nil, nil, head, 0, false -- maybe make n boolean
while current do
- if current.id == glyph and current.font == font then
+ local id = current.id
+ if id == glyph and current.font == font then
local d = descriptions[current.char]
if d then
if d.class == "mark" then
@@ -700,6 +677,10 @@ function fonts.analyzers.aux.setstate(head,font)
end
first, last, n = nil, nil, 0
end
+ elseif id == disc then
+ -- always in the middle
+ set_attribute(current,state,2) -- midi
+ last = current
else -- finish
if first and first == last then
set_attribute(last,state,4) -- isol
@@ -727,151 +708,6 @@ function tfm.replacements(tfm,value)
-- tfm.characters[0x0060] = tfm.characters[0x2018]
end
--- auto complete font with missing composed characters
-
-table.insert(fonts.manipulators,"compose")
-
-function fonts.initializers.common.compose(tfmdata,value)
- if value then
- fonts.vf.aux.compose_characters(tfmdata)
- end
-end
-
--- tfm features, experimental
-
-tfm.features = tfm.features or { }
-tfm.features.list = tfm.features.list or { }
-tfm.features.default = tfm.features.default or { }
-
-function tfm.enhance(tfmdata,specification)
- -- we don't really share tfm data because we always reload
- -- but this is more in sycn with afm and such
- local features = (specification.features and specification.features.normal ) or { }
- tfmdata.shared = tfmdata.shared or { }
- tfmdata.shared.features = features
- -- tfmdata.shared.tfmdata = tfmdata -- circular
- tfmdata.filename = specification.name
- if not features.encoding then
- local name, size = specification.name, specification.size
- local encoding, filename = match(name,"^(.-)%-(.*)$") -- context: encoding-name.*
- if filename and encoding and fonts.enc.known[encoding] then
- features.encoding = encoding
- end
- end
- tfm.set_features(tfmdata)
-end
-
-function tfm.set_features(tfmdata)
- -- todo: no local functions
- local shared = tfmdata.shared
--- local tfmdata = shared.tfmdata
- local features = shared.features
- if not table.is_empty(features) then
- local mode = tfmdata.mode or fonts.mode
- local fi = fonts.initializers[mode]
- if fi and fi.tfm then
- local function initialize(list) -- using tex lig and kerning
- if list then
- for i=1,#list do
- local f = list[i]
- local value = features[f]
- if value and fi.tfm[f] then -- brr
- if tfm.trace_features then
- logs.report("define font","initializing feature %s to %s for mode %s for font %s",f,tostring(value),mode or 'unknown',tfmdata.name or 'unknown')
- end
- fi.tfm[f](tfmdata,value)
- mode = tfmdata.mode or fonts.mode
- fi = fonts.initializers[mode]
- end
- end
- end
- end
- initialize(fonts.triggers)
- initialize(tfm.features.list)
- initialize(fonts.manipulators)
- end
- local fm = fonts.methods[mode]
- if fm and fm.tfm then
- local function register(list) -- node manipulations
- if list then
- for i=1,#list do
- local f = list[i]
- if features[f] and fm.tfm[f] then -- brr
- if not shared.processors then -- maybe also predefine
- shared.processors = { fm.tfm[f] }
- else
- shared.processors[#shared.processors+1] = fm.tfm[f]
- end
- end
- end
- end
- end
- register(tfm.features.list)
- end
- end
-end
-
-function tfm.features.register(name,default)
- tfm.features.list[#tfm.features.list+1] = name
- tfm.features.default[name] = default
-end
-
-function tfm.reencode(tfmdata,encoding)
- if encoding and fonts.enc.known[encoding] then
- local data = fonts.enc.load(encoding)
- if data then
- local characters, original, vector = tfmdata.characters, { }, data.vector
- tfmdata.encoding = encoding -- not needed
- for k, v in next, characters do
- v.name, v.index, original[k] = vector[k], k, v
- end
- for k,v in next, data.unicodes do
- if k ~= v then
- if trace_defining then
- logs.report("define font","reencoding U+%04X to U+%04X",k,v)
- end
- characters[k] = original[v]
- end
- end
- end
- end
-end
-
-tfm.features.register('reencode')
-
-fonts.initializers.base.tfm.reencode = tfm.reencode
-fonts.initializers.node.tfm.reencode = tfm.reencode
-
-fonts.enc = fonts.enc or { }
-fonts.enc.remappings = fonts.enc.remappings or { }
-
-function tfm.remap(tfmdata,remapping)
- local vector = remapping and fonts.enc.remappings[remapping]
- if vector then
- local characters, original = tfmdata.characters, { }
- for k, v in next, characters do
- original[k], characters[k] = v, nil
- end
- for k,v in next, vector do
- if k ~= v then
- if trace_defining then
- logs.report("define font","remapping U+%04X to U+%04X",k,v)
- end
- local c = original[k]
- characters[v] = c
- c.index = k
- end
- end
- tfmdata.encodingbytes = 2
- tfmdata.format = 'type1'
- end
-end
-
-tfm.features.register('remap')
-
-fonts.initializers.base.tfm.remap = tfm.remap
-fonts.initializers.node.tfm.remap = tfm.remap
-
-- status info
statistics.register("fonts load time", function()
diff --git a/otfl-luat-dum.lua b/otfl-luat-dum.lua
index 34dd9ed..832f80d 100644
--- a/otfl-luat-dum.lua
+++ b/otfl-luat-dum.lua
@@ -64,7 +64,7 @@ local remapper = {
function resolvers.find_file(name,kind)
name = string.gsub(name,"\\","\/")
kind = string.lower(kind)
- return kpse.find_file(name,(kind and kind ~= "" and (remapper[kind] or kind)) or "tex")
+ return kpse.find_file(name,(kind and kind ~= "" and (remapper[kind] or kind)) or file.extname(name,"tex"))
end
function resolvers.findbinfile(name,kind)
diff --git a/otfl-node-inj.lua b/otfl-node-inj.lua
index 4c58409..9c4612a 100644
--- a/otfl-node-inj.lua
+++ b/otfl-node-inj.lua
@@ -70,7 +70,8 @@ function nodes.set_pair(current,factor,rlmode,r2lflag,spec,tfmchr)
local bound = has_attribute(current,kernpair)
if bound then
local kb = kerns[bound]
- kb[2], kb[3], kb[4], kb[5] = kb[2] + x, kb[3] + y, kb[4] + w, kb[5] + h
+ -- inefficient but singles have less, but weird anyway, needs checking
+ kb[2], kb[3], kb[4], kb[5] = (kb[2] or 0) + x, (kb[3] or 0) + y, (kb[4] or 0)+ w, (kb[5] or 0) + h
else
bound = #kerns + 1
set_attribute(current,kernpair,bound)
diff --git a/tests/fontencoding.tex b/tests/fontencoding.tex
new file mode 100644
index 0000000..bbbbac6
--- /dev/null
+++ b/tests/fontencoding.tex
@@ -0,0 +1,4 @@
+\input luaotfload.sty
+\font\tenrm=ec-lmr10
+\tenrm
+\bye