summaryrefslogtreecommitdiff
path: root/tex/generic
diff options
context:
space:
mode:
authorContext Git Mirror Bot <phg42.2a@gmail.com>2016-06-25 15:40:51 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2016-06-25 15:40:51 +0200
commitb2a2304cbb0c65040d7b118ac9b857d304e333e6 (patch)
treeed5212e37a91ec78c12d9f72ca1186a59c139b40 /tex/generic
parentb2276ae7a04a9f9c35403e508670049d8c3e4b3e (diff)
downloadcontext-b2a2304cbb0c65040d7b118ac9b857d304e333e6.tar.gz
2016-06-25 14:42:00
Diffstat (limited to 'tex/generic')
-rw-r--r--tex/generic/context/luatex/luatex-basics-gen.lua1
-rw-r--r--tex/generic/context/luatex/luatex-fonts-demo-vf-1.lua8
-rw-r--r--tex/generic/context/luatex/luatex-fonts-demo-vf-4.lua7
-rw-r--r--tex/generic/context/luatex/luatex-fonts-enc.lua59
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua99
-rw-r--r--tex/generic/context/luatex/luatex-plain-tfm.lua113
-rw-r--r--tex/generic/context/luatex/luatex-test.tex6
7 files changed, 266 insertions, 27 deletions
diff --git a/tex/generic/context/luatex/luatex-basics-gen.lua b/tex/generic/context/luatex/luatex-basics-gen.lua
index 2a68b1c18..871e54853 100644
--- a/tex/generic/context/luatex/luatex-basics-gen.lua
+++ b/tex/generic/context/luatex/luatex-basics-gen.lua
@@ -97,6 +97,7 @@ local remapper = {
-- fea = "font feature files", -- no longer supported
pfb = "type1 fonts", -- needed for vector loading
afm = "afm",
+ enc = "enc files",
}
function resolvers.findfile(name,fileformat)
diff --git a/tex/generic/context/luatex/luatex-fonts-demo-vf-1.lua b/tex/generic/context/luatex/luatex-fonts-demo-vf-1.lua
index 13acd16ca..793526f7b 100644
--- a/tex/generic/context/luatex/luatex-fonts-demo-vf-1.lua
+++ b/tex/generic/context/luatex/luatex-fonts-demo-vf-1.lua
@@ -1,3 +1,11 @@
+if not modules then modules = { } end modules ['luatex-fonts-demo-vf-1'] = {
+ version = 1.001,
+ comment = "companion to luatex-*.tex",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
local identifiers = fonts.hashes.identifiers
return function(specification)
diff --git a/tex/generic/context/luatex/luatex-fonts-demo-vf-4.lua b/tex/generic/context/luatex/luatex-fonts-demo-vf-4.lua
index 00fc636a1..92ce4ffcb 100644
--- a/tex/generic/context/luatex/luatex-fonts-demo-vf-4.lua
+++ b/tex/generic/context/luatex/luatex-fonts-demo-vf-4.lua
@@ -1,3 +1,10 @@
+if not modules then modules = { } end modules ['luatex-fonts-demo-vf-4'] = {
+ version = 1.001,
+ comment = "companion to luatex-*.tex",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
return function(specification)
local t = { }
diff --git a/tex/generic/context/luatex/luatex-fonts-enc.lua b/tex/generic/context/luatex/luatex-fonts-enc.lua
index 2e1c6a466..c076d5947 100644
--- a/tex/generic/context/luatex/luatex-fonts-enc.lua
+++ b/tex/generic/context/luatex/luatex-fonts-enc.lua
@@ -11,19 +11,66 @@ if context then
os.exit()
end
-local fonts = fonts
-fonts.encodings = { }
-fonts.encodings.agl = { }
-fonts.encodings.known = { }
+local fonts = fonts
+local encodings = { }
+fonts.encodings = encodings
+encodings.agl = { }
+encodings.known = { }
-setmetatable(fonts.encodings.agl, { __index = function(t,k)
+setmetatable(encodings.agl, { __index = function(t,k)
if k == "unicodes" then
texio.write(" <loading (extended) adobe glyph list>")
local unicodes = dofile(resolvers.findfile("font-age.lua"))
- fonts.encodings.agl = { unicodes = unicodes }
+ encodings.agl = { unicodes = unicodes }
return unicodes
else
return nil
end
end })
+-- adapted for generic
+
+encodings.cache = containers.define("fonts", "enc", encodings.version, true)
+
+function encodings.load(filename)
+ local name = file.removesuffix(filename)
+ local data = containers.read(encodings.cache,name)
+ if data then
+ return data
+ end
+ local vector, tag, hash, unicodes = { }, "", { }, { }
+ local foundname = resolvers.findfile(filename,'enc')
+ if foundname and foundname ~= "" then
+ local ok, encoding, size = resolvers.loadbinfile(foundname)
+ if ok and encoding then
+ encoding = string.gsub(encoding,"%%(.-)\n","")
+ local unicoding = encodings.agl.unicodes
+ local tag, vec = string.match(encoding,"/(%w+)%s*%[(.*)%]%s*def")
+ local i = 0
+ for ch in string.gmatch(vec,"/([%a%d%.]+)") do
+ if ch ~= ".notdef" then
+ vector[i] = ch
+ if not hash[ch] then
+ hash[ch] = i
+ else
+ -- duplicate, play safe for tex ligs and take first
+ end
+ local u = unicoding[ch]
+ if u then
+ unicodes[u] = i
+ end
+ end
+ i = i + 1
+ end
+ end
+ end
+ local data = {
+ name = name,
+ tag = tag,
+ vector = vector,
+ hash = hash,
+ unicodes = unicodes
+ }
+ return containers.write(encodings.cache, name, data)
+end
+
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 9981b1aa6..3c21f19c8 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua
-- parent file : c:/data/develop/context/sources/luatex-fonts.lua
--- merge date : 06/20/16 22:14:55
+-- merge date : 06/25/16 14:38:07
do -- begin closure to overcome local limits and interference
@@ -4327,6 +4327,7 @@ local remapper={
cidmap="cid maps",
pfb="type1 fonts",
afm="afm",
+ enc="enc files",
}
function resolvers.findfile(name,fileformat)
name=string.gsub(name,"\\","/")
@@ -5849,15 +5850,17 @@ end
local psfake=0
local function fixedpsname(psname,fallback)
local usedname=psname
- if not psname or psname=="" then
- psname=fallback
- usedname=gsub(psname,"[^a-zA-Z0-9]+","-")
- elseif find(psname," ") then
- usedname=gsub(psname,"[%s]+","-")
- end
- if not psname or psname=="" then
+ if psname and psname~="" then
+ if find(psname," ") then
+ usedname=gsub(psname,"[%s]+","-")
+ else
+ end
+ elseif not fallback or fallback=="" then
psfake=psfake+1
psname="fakename-"..psfake
+ else
+ psname=fallback
+ usedname=gsub(psname,"[^a-zA-Z0-9]+","-")
end
return usedname,psname~=usedname
end
@@ -6796,19 +6799,61 @@ if context then
os.exit()
end
local fonts=fonts
-fonts.encodings={}
-fonts.encodings.agl={}
-fonts.encodings.known={}
-setmetatable(fonts.encodings.agl,{ __index=function(t,k)
+local encodings={}
+fonts.encodings=encodings
+encodings.agl={}
+encodings.known={}
+setmetatable(encodings.agl,{ __index=function(t,k)
if k=="unicodes" then
texio.write(" <loading (extended) adobe glyph list>")
local unicodes=dofile(resolvers.findfile("font-age.lua"))
- fonts.encodings.agl={ unicodes=unicodes }
+ encodings.agl={ unicodes=unicodes }
return unicodes
else
return nil
end
end })
+encodings.cache=containers.define("fonts","enc",encodings.version,true)
+function encodings.load(filename)
+ local name=file.removesuffix(filename)
+ local data=containers.read(encodings.cache,name)
+ if data then
+ return data
+ end
+ local vector,tag,hash,unicodes={},"",{},{}
+ local foundname=resolvers.findfile(filename,'enc')
+ if foundname and foundname~="" then
+ local ok,encoding,size=resolvers.loadbinfile(foundname)
+ if ok and encoding then
+ encoding=string.gsub(encoding,"%%(.-)\n","")
+ local unicoding=encodings.agl.unicodes
+ local tag,vec=string.match(encoding,"/(%w+)%s*%[(.*)%]%s*def")
+ local i=0
+ for ch in string.gmatch(vec,"/([%a%d%.]+)") do
+ if ch~=".notdef" then
+ vector[i]=ch
+ if not hash[ch] then
+ hash[ch]=i
+ else
+ end
+ local u=unicoding[ch]
+ if u then
+ unicodes[u]=i
+ end
+ end
+ i=i+1
+ end
+ end
+ end
+ local data={
+ name=name,
+ tag=tag,
+ vector=vector,
+ hash=hash,
+ unicodes=unicodes
+ }
+ return containers.write(encodings.cache,name,data)
+end
end -- closure
@@ -11302,10 +11347,15 @@ local function readcoverage(f,offset,simple)
end
return coverage
end
-local function readclassdef(f,offset)
+local function readclassdef(f,offset,preset)
setposition(f,offset)
local classdefformat=readushort(f)
local classdef={}
+ if type(preset)=="number" then
+ for k=0,preset-1 do
+ classdef[k]=1
+ end
+ end
if classdefformat==1 then
local index=readushort(f)
local nofclassdef=readushort(f)
@@ -11327,6 +11377,13 @@ local function readclassdef(f,offset)
else
report("unknown classdef format %a ",classdefformat)
end
+ if type(preset)=="table" then
+ for k in next,preset do
+ if not classdef[k] then
+ classdef[k]=1
+ end
+ end
+ end
return classdef
end
local function classtocoverage(defs)
@@ -11491,7 +11548,7 @@ local function unchainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,n
local rules={}
if subclasssets then
coverage=readcoverage(f,tableoffset+coverage)
- currentclassdef=readclassdef(f,tableoffset+currentclassdef)
+ currentclassdef=readclassdef(f,tableoffset+currentclassdef,coverage)
local currentclasses=classtocoverage(currentclassdef,fontdata.glyphs)
for class=1,#subclasssets do
local offset=subclasssets[class]
@@ -11615,9 +11672,9 @@ local function chainedcontext(f,fontdata,lookupid,lookupoffset,offset,glyphs,nof
local rules={}
if subclasssets then
local coverage=readcoverage(f,tableoffset+coverage)
- local beforeclassdef=readclassdef(f,tableoffset+beforeclassdef)
- local currentclassdef=readclassdef(f,tableoffset+currentclassdef)
- local afterclassdef=readclassdef(f,tableoffset+afterclassdef)
+ local beforeclassdef=readclassdef(f,tableoffset+beforeclassdef,nofglyphs)
+ local currentclassdef=readclassdef(f,tableoffset+currentclassdef,coverage)
+ local afterclassdef=readclassdef(f,tableoffset+afterclassdef,nofglyphs)
local beforeclasses=classtocoverage(beforeclassdef,fontdata.glyphs)
local currentclasses=classtocoverage(currentclassdef,fontdata.glyphs)
local afterclasses=classtocoverage(afterclassdef,fontdata.glyphs)
@@ -12008,8 +12065,8 @@ function gposhandlers.pair(f,fontdata,lookupid,lookupoffset,offset,glyphs,nofgly
local nofclasses2=readushort(f)
local classlist=readpairclasssets(f,nofclasses1,nofclasses2,format1,format2)
coverage=readcoverage(f,tableoffset+coverage)
- classdef1=readclassdef(f,tableoffset+classdef1)
- classdef2=readclassdef(f,tableoffset+classdef2)
+ classdef1=readclassdef(f,tableoffset+classdef1,coverage)
+ classdef2=readclassdef(f,tableoffset+classdef2,nofglyphs)
local usedcoverage={}
for g1,c1 in next,classdef1 do
if coverage[g1] then
@@ -15310,7 +15367,7 @@ local trace_defining=false registertracker("fonts.defining",function(v) trace_de
local report_otf=logs.reporter("fonts","otf loading")
local fonts=fonts
local otf=fonts.handlers.otf
-otf.version=3.024
+otf.version=3.025
otf.cache=containers.define("fonts","otl",otf.version,true)
otf.svgcache=containers.define("fonts","svg",otf.version,true)
otf.pdfcache=containers.define("fonts","pdf",otf.version,true)
diff --git a/tex/generic/context/luatex/luatex-plain-tfm.lua b/tex/generic/context/luatex/luatex-plain-tfm.lua
new file mode 100644
index 000000000..87b453689
--- /dev/null
+++ b/tex/generic/context/luatex/luatex-plain-tfm.lua
@@ -0,0 +1,113 @@
+if not modules then modules = { } end modules ['luatex-plain-tfm'] = {
+ version = 1.001,
+ comment = "companion to luatex-*.tex",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- \font\foo=file:luatex-plain-tfm.lua:tfm=csr10;enc=csr;pfb=csr10 at 12pt
+--
+-- \foo áäčďěíĺľňóôŕřšťúýž ff ffi \input tufte
+
+return function(specification)
+
+ local size = specification.size
+ local feat = specification.features and specification.features.normal
+
+ if not feat then
+ return
+ end
+
+ local tfm = feat.tfm
+ local enc = feat.enc or tfm
+ local pfb = feat.pfb or tfm
+
+ if not tfm then
+ return
+ end
+
+ local tfmfile = tfm .. ".tfm"
+ local encfile = enc .. ".enc"
+ local pfbfile = pfb .. ".pfb"
+
+ local tfmdata, id = fonts.constructors.readanddefine("file:"..tfmfile,size)
+
+ local encoding = fonts.encodings.load(encfile)
+ if encoding then
+ encoding = encoding.hash
+ else
+ encoding = false
+ end
+
+ local unicoding = fonts.encodings.agl and fonts.encodings.agl.unicodes
+
+ if tfmdata and encoding and unicoding then
+
+ local characters = { }
+ local originals = tfmdata.characters
+ local indices = { }
+ local parentfont = { "font", 1 }
+ local mapline = tfm .. "<" .. pfbfile -- .."<"..encfile
+
+ local dummy = unicoding.foo -- foo forces loading
+
+ -- create characters table
+
+ for name, index in next, encoding do
+ local unicode = unicoding[name]
+ if unicode then
+ local original = originals[index]
+ original.name = name -- so one can lookup weird names
+ original.commands = { parentfont, { "char", index } }
+ characters[unicode] = original
+ indices[index] = unicode
+ else
+ -- unknown name
+ end
+ end
+
+ -- also include ligatures and whatever left
+
+ local p = fonts.constructors.privateoffset
+ for k, v in next, originals do
+ if not indices[k] then
+ characters[p] = v
+ indices[k] = p
+ p = p + 1
+ end
+ end
+
+ -- redo kerns and ligatures
+
+ for k, v in next, characters do
+ local kerns = v.kerns
+ if kerns then
+ local t = { }
+ for k, v in next, kerns do
+ local i = indices[k]
+ t[i] = v
+ end
+ v.kerns = t
+ end
+ local ligatures = v.ligatures
+ if ligatures then
+ local t = { }
+ for k, v in next, ligatures do
+ t[indices[k]] = v
+ v.char = indices[v.char]
+ end
+ v.ligatures = t
+ end
+ end
+
+ -- wrap up
+
+ tfmdata.fonts = { { id = id } }
+ tfmdata.characters = characters
+
+ pdf.mapline(mapline)
+
+ end
+ return tfmdata
+end
diff --git a/tex/generic/context/luatex/luatex-test.tex b/tex/generic/context/luatex/luatex-test.tex
index 0bb752b3f..9dc7c3113 100644
--- a/tex/generic/context/luatex/luatex-test.tex
+++ b/tex/generic/context/luatex/luatex-test.tex
@@ -158,4 +158,10 @@ $\sin{x}$
% \textdir TRT\amiri بِسْمِ اللَّـهِ الرَّ‌حْمَـٰنِ الرَّ‌حِيمِ
% \egroup
+% assumes csr10.tfm csr10.pfb csr.enc to be present
+%
+% \font\foo=file:luatex-plain-tfm.lua:tfm=csr10;enc=csr;pfb=csr10 at 12pt
+%
+% \foo áäčďěíĺľňóôŕřšťúýž ff ffi
+
\end