summaryrefslogtreecommitdiff
path: root/tex/generic/context/luatex/luatex-fonts-syn.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2013-05-19 19:27:00 +0200
committerHans Hagen <pragma@wxs.nl>2013-05-19 19:27:00 +0200
commit9a10021cd4cb23995ad3ffa915fc5b7f6890aaf8 (patch)
tree983e02c29872e4713a10a9dc8ae7708c6da3de88 /tex/generic/context/luatex/luatex-fonts-syn.lua
parent0deffde58a47f5c85a46a7d999ff9cf817b81cef (diff)
downloadcontext-9a10021cd4cb23995ad3ffa915fc5b7f6890aaf8.tar.gz
beta 2013.05.19 19:27
Diffstat (limited to 'tex/generic/context/luatex/luatex-fonts-syn.lua')
-rw-r--r--tex/generic/context/luatex/luatex-fonts-syn.lua204
1 files changed, 102 insertions, 102 deletions
diff --git a/tex/generic/context/luatex/luatex-fonts-syn.lua b/tex/generic/context/luatex/luatex-fonts-syn.lua
index ea6e3cab5..50c43bce7 100644
--- a/tex/generic/context/luatex/luatex-fonts-syn.lua
+++ b/tex/generic/context/luatex/luatex-fonts-syn.lua
@@ -1,102 +1,102 @@
-if not modules then modules = { } end modules ['luatex-fonts-syn'] = {
- 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"
-}
-
-if context then
- texio.write_nl("fatal error: this module is not for context")
- os.exit()
-end
-
--- Generic font names support.
---
--- Watch out, the version number is the same as the one used in
--- the mtx-fonts.lua function scripts.fonts.names as we use a
--- simplified font database in the plain solution and by using
--- a different number we're less dependent on context.
---
--- mtxrun --script font --reload --simple
---
--- The format of the file is as follows:
---
--- return {
--- ["version"] = 1.001,
--- ["cache_version"] = 1.001,
--- ["mappings"] = {
--- ["somettcfontone"] = { "Some TTC Font One", "SomeFontA.ttc", 1 },
--- ["somettcfonttwo"] = { "Some TTC Font Two", "SomeFontA.ttc", 2 },
--- ["somettffont"] = { "Some TTF Font", "SomeFontB.ttf" },
--- ["someotffont"] = { "Some OTF Font", "SomeFontC.otf" },
--- },
--- }
-
-local fonts = fonts
-fonts.names = fonts.names or { }
-
-fonts.names.version = 1.001 -- not the same as in context but matches mtx-fonts --simple
-fonts.names.basename = "luatex-fonts-names"
-fonts.names.new_to_old = { }
-fonts.names.old_to_new = { }
-fonts.names.cache = containers.define("fonts","data",fonts.names.version,true)
-
-local data, loaded = nil, false
-
-local fileformats = { "lua", "tex", "other text files" }
-
-function fonts.names.reportmissingbase()
- texio.write("<missing font database, run: mtxrun --script fonts --reload --simple>")
- fonts.names.reportmissingbase = nil
-end
-
-function fonts.names.reportmissingname()
- texio.write("<unknown font in database, run: mtxrun --script fonts --reload --simple>")
- fonts.names.reportmissingname = nil
-end
-
-function fonts.names.resolve(name,sub)
- if not loaded then
- local basename = fonts.names.basename
- if basename and basename ~= "" then
- data = containers.read(fonts.names.cache,basename)
- if not data then
- basename = file.addsuffix(basename,"lua")
- for i=1,#fileformats do
- local format = fileformats[i]
- local foundname = resolvers.findfile(basename,format) or ""
- if foundname ~= "" then
- data = dofile(foundname)
- texio.write("<font database loaded: ",foundname,">")
- break
- end
- end
- end
- end
- loaded = true
- end
- if type(data) == "table" and data.version == fonts.names.version then
- local condensed = string.gsub(string.lower(name),"[^%a%d]","")
- local found = data.mappings and data.mappings[condensed]
- if found then
- local fontname, filename, subfont = found[1], found[2], found[3]
- if subfont then
- return filename, fontname
- else
- return filename, false
- end
- elseif fonts.names.reportmissingname then
- fonts.names.reportmissingname()
- return name, false -- fallback to filename
- end
- elseif fonts.names.reportmissingbase then
- fonts.names.reportmissingbase()
- end
-end
-
-fonts.names.resolvespec = fonts.names.resolve -- only supported in mkiv
-
-function fonts.names.getfilename(askedname,suffix) -- only supported in mkiv
- return ""
-end
+if not modules then modules = { } end modules ['luatex-fonts-syn'] = {
+ 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"
+}
+
+if context then
+ texio.write_nl("fatal error: this module is not for context")
+ os.exit()
+end
+
+-- Generic font names support.
+--
+-- Watch out, the version number is the same as the one used in
+-- the mtx-fonts.lua function scripts.fonts.names as we use a
+-- simplified font database in the plain solution and by using
+-- a different number we're less dependent on context.
+--
+-- mtxrun --script font --reload --simple
+--
+-- The format of the file is as follows:
+--
+-- return {
+-- ["version"] = 1.001,
+-- ["cache_version"] = 1.001,
+-- ["mappings"] = {
+-- ["somettcfontone"] = { "Some TTC Font One", "SomeFontA.ttc", 1 },
+-- ["somettcfonttwo"] = { "Some TTC Font Two", "SomeFontA.ttc", 2 },
+-- ["somettffont"] = { "Some TTF Font", "SomeFontB.ttf" },
+-- ["someotffont"] = { "Some OTF Font", "SomeFontC.otf" },
+-- },
+-- }
+
+local fonts = fonts
+fonts.names = fonts.names or { }
+
+fonts.names.version = 1.001 -- not the same as in context but matches mtx-fonts --simple
+fonts.names.basename = "luatex-fonts-names"
+fonts.names.new_to_old = { }
+fonts.names.old_to_new = { }
+fonts.names.cache = containers.define("fonts","data",fonts.names.version,true)
+
+local data, loaded = nil, false
+
+local fileformats = { "lua", "tex", "other text files" }
+
+function fonts.names.reportmissingbase()
+ texio.write("<missing font database, run: mtxrun --script fonts --reload --simple>")
+ fonts.names.reportmissingbase = nil
+end
+
+function fonts.names.reportmissingname()
+ texio.write("<unknown font in database, run: mtxrun --script fonts --reload --simple>")
+ fonts.names.reportmissingname = nil
+end
+
+function fonts.names.resolve(name,sub)
+ if not loaded then
+ local basename = fonts.names.basename
+ if basename and basename ~= "" then
+ data = containers.read(fonts.names.cache,basename)
+ if not data then
+ basename = file.addsuffix(basename,"lua")
+ for i=1,#fileformats do
+ local format = fileformats[i]
+ local foundname = resolvers.findfile(basename,format) or ""
+ if foundname ~= "" then
+ data = dofile(foundname)
+ texio.write("<font database loaded: ",foundname,">")
+ break
+ end
+ end
+ end
+ end
+ loaded = true
+ end
+ if type(data) == "table" and data.version == fonts.names.version then
+ local condensed = string.gsub(string.lower(name),"[^%a%d]","")
+ local found = data.mappings and data.mappings[condensed]
+ if found then
+ local fontname, filename, subfont = found[1], found[2], found[3]
+ if subfont then
+ return filename, fontname
+ else
+ return filename, false
+ end
+ elseif fonts.names.reportmissingname then
+ fonts.names.reportmissingname()
+ return name, false -- fallback to filename
+ end
+ elseif fonts.names.reportmissingbase then
+ fonts.names.reportmissingbase()
+ end
+end
+
+fonts.names.resolvespec = fonts.names.resolve -- only supported in mkiv
+
+function fonts.names.getfilename(askedname,suffix) -- only supported in mkiv
+ return ""
+end