summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2016-07-07 07:18:31 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2016-07-07 07:18:31 +0200
commit695225198ec64b4d3248268b0ca679251197b2d4 (patch)
tree81c99b5b25ed30308a02216f69b7c60c3b9bbe75
parent7247d0ed42102566c4e8522f7d4654b65196cfeb (diff)
downloadluaotfload-695225198ec64b4d3248268b0ca679251197b2d4.tar.gz
[status,import,fontloader] add luatex-plain-tfm.lua and update scripts
-rwxr-xr-xscripts/mkimport5
-rwxr-xr-xscripts/mkstatus2
-rw-r--r--src/fontloader/misc/fontloader-plain-tfm.lua120
3 files changed, 124 insertions, 3 deletions
diff --git a/scripts/mkimport b/scripts/mkimport
index 1dc0a29..c06594b 100755
--- a/scripts/mkimport
+++ b/scripts/mkimport
@@ -223,6 +223,7 @@ local imports = {
{ name = "swiglib-test" , ours = nil , kind = kind_ignored },
{ name = "swiglib-test" , ours = nil , kind = kind_tex },
{ name = "test" , ours = nil , kind = kind_tex },
+ { name = "plain-tfm" , ours = nil , kind = kind_ignored },
}, --[[ [fontloader] ]]
context = { --=> all merged
@@ -295,7 +296,6 @@ local package = {
--- [19] font-cid.lua
--- [20] font-map.lua
--- [21] luatex-fonts-syn.lua
---- [22] font-tfm.lua
--- [23] font-oti.lua
--- [24] font-otr.lua
--- [25] font-cff.lua
@@ -312,6 +312,7 @@ local package = {
--- [36] font-onr.lua
--- [37] font-one.lua
--- [38] font-afk.lua
+--- [22] font-tfm.lua
--- [39] font-lua.lua
--- [40] font-def.lua
--- [41] font-xtx.lua
@@ -361,7 +362,6 @@ local package = {
"font-cid",
"font-map",
"fonts-syn",
- "font-tfm",
"font-oti",
"font-otr",
"font-cff",
@@ -378,6 +378,7 @@ local package = {
"font-onr",
"font-one",
"font-afk",
+ "font-tfm",
"font-lua",
"font-def",
"fonts-ext",
diff --git a/scripts/mkstatus b/scripts/mkstatus
index 10f6680..f761213 100755
--- a/scripts/mkstatus
+++ b/scripts/mkstatus
@@ -101,7 +101,6 @@ local names = {
{ miscdir, "fontloader-font-lua.lua", },
{ miscdir, "fontloader-fonts-syn.lua", },
{ miscdir, "fontloader-font-tfm.lua", },
- { miscdir, "fontloader-font-tfm.lua", },
{ miscdir, "fontloader-font-otr.lua", },
{ miscdir, "fontloader-font-cff.lua", },
{ miscdir, "fontloader-font-ttf.lua", },
@@ -114,6 +113,7 @@ local names = {
{ miscdir, "fontloader-font-ots.lua", },
{ miscdir, "fontloader-font-osd.lua", },
{ miscdir, "fontloader-font-ocl.lua", },
+ { miscdir, "fontloader-plain-tfm.lua", },
--- lua libraries
{ miscdir, "fontloader-languages.lua", },
diff --git a/src/fontloader/misc/fontloader-plain-tfm.lua b/src/fontloader/misc/fontloader-plain-tfm.lua
new file mode 100644
index 0000000..4a08fb4
--- /dev/null
+++ b/src/fontloader/misc/fontloader-plain-tfm.lua
@@ -0,0 +1,120 @@
+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
+-- \font\bar=file:luatex-plain-tfm.lua:tfm=csr10;enc=csr at 12pt
+--
+-- \foo áäčďěíĺľňóôŕřšťúýž ff ffi \input tufte\par
+-- \bar áäčďěíĺľňóôŕřšťúýž ff ffi \input tufte\par
+
+local outfiles = { }
+
+return function(specification)
+
+ local size = specification.size
+ local name = specification.name
+ 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
+
+ if not tfm then
+ return
+ end
+
+ local tfmfile = tfm .. ".tfm"
+ local encfile = enc .. ".enc"
+
+ 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
+
+ tfmdata = table.copy(tfmdata) -- good enough for small fonts
+
+ local characters = { }
+ local originals = tfmdata.characters
+ local indices = { }
+ local parentfont = { "font", 1 }
+ local private = fonts.constructors.privateoffset
+
+ -- create characters table
+
+ for name, index in table.sortedhash(encoding) do -- predictable order
+ local unicode = unicoding[name]
+ local original = originals[index]
+ if not unicode then
+ unicode = private
+ private = private + 1
+ report_tfm("glyph %a in font %a gets private unicode %U",name,tfmfile,private)
+ end
+ characters[unicode] = original
+ indices[index] = unicode
+ original.name = name -- so one can lookup weird names
+ original.commands = { parentfont, { "char", index } }
+ 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
+
+ -- resources
+
+ local outfile = outfiles[tfmfile]
+
+ if outfile == nil then
+ if pfb then
+ outfile = pfb .. ".pfb"
+ pdf.mapline(tfm .. "<" .. outfile)
+ else
+ outfile = false
+ end
+ outfiles[tfmfile] = outfile
+ end
+
+ end
+
+ return tfmdata
+end