summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--luaotfload.dtx2
-rw-r--r--otfl-font-ltx.lua109
-rw-r--r--otfl-fonts-def.lua97
3 files changed, 50 insertions, 158 deletions
diff --git a/luaotfload.dtx b/luaotfload.dtx
index 850c837..6b1cbd8 100644
--- a/luaotfload.dtx
+++ b/luaotfload.dtx
@@ -600,7 +600,7 @@ luaotfload.loadmodule('font-otn.lua')
luaotfload.loadmodule('font-ota.lua')
luaotfload.loadmodule('fonts-lua.lua')
luaotfload.loadmodule('font-def.lua')
-luaotfload.loadmodule('fonts-def.lua')
+luaotfload.loadmodule('font-ltx.lua')
luaotfload.loadmodule('fonts-ext.lua') -- some extensions
luaotfload.loadmodule('fonts-cbk.lua')
% \end{macrocode}
diff --git a/otfl-font-ltx.lua b/otfl-font-ltx.lua
index 12fef44..1865637 100644
--- a/otfl-font-ltx.lua
+++ b/otfl-font-ltx.lua
@@ -1,45 +1,28 @@
if not modules then modules = { } end modules ['font-ltx'] = {
version = 1.001,
- comment = "companion to font-ini.mkiv",
+ 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 texsprint, count = tex.sprint, tex.count
-local format, concat, gmatch, match, find, lower = string.format, table.concat, string.gmatch, string.match, string.find, string.lower
-local tostring, next = tostring, next
-local lpegmatch = lpeg.match
+local fonts = fonts
-local trace_defining = false trackers.register("fonts.defining", function(v) trace_defining = v end)
+-- A bit of tuning for definitions.
---[[ldx--
-<p>Choosing a font by name and specififying its size is only part of the
-game. In order to prevent complex commands, <l n='xetex'/> introduced
-a method to pass feature information as part of the font name. At the
-risk of introducing nasty parsing and compatinility problems, this
-syntax was expanded over time.</p>
+fonts.constructors.namemode = "specification" -- somehow latex needs this (changed name!) => will change into an overload
-<p>For the sake of users who have defined fonts using that syntax, we
-will support it, but we will provide additional methods as well.
-Normally users will not use this direct way, but use a more abstract
-interface.</p>
+-- tricky: we sort of bypass the parser and directly feed all into
+-- the sub parser
-<p>The next one is the official one. However, in the plain
-variant we need to support the crappy [] specification as
-well and that does not work too well with the general design
-of the specifier.</p>
---ldx]]--
+function fonts.definers.getspecification(str)
+ return "", str, "", ":", str
+end
-local fonts = fonts
-local definers = fonts.definers
-local specifiers = definers.specifiers
-local normalize_meanings = fonts.otf.meanings.normalize
+-- the generic name parser (different from context!)
local list = { }
-specifiers.colonizedpreference = "file"
-
local function isstyle(s)
local style = string.lower(s):split("/")
for _,v in ipairs(style) do
@@ -59,14 +42,7 @@ local function isstyle(s)
end
end
-fonts = fonts or { }
-fonts.otf = fonts.otf or { }
-
-local otf = fonts.otf
-
-otf.tables = otf.tables or { }
-
-otf.tables.defaults = {
+local defaults = {
dflt = {
"ccmp", "locl", "rlig", "liga", "clig",
"kern", "mark", "mkmk",
@@ -99,33 +75,33 @@ otf.tables.defaults = {
},
}
-otf.tables.defaults.beng = otf.tables.defaults.deva
-otf.tables.defaults.guru = otf.tables.defaults.deva
-otf.tables.defaults.gujr = otf.tables.defaults.deva
-otf.tables.defaults.orya = otf.tables.defaults.deva
-otf.tables.defaults.taml = otf.tables.defaults.deva
-otf.tables.defaults.telu = otf.tables.defaults.deva
-otf.tables.defaults.knda = otf.tables.defaults.deva
-otf.tables.defaults.mlym = otf.tables.defaults.deva
-otf.tables.defaults.sinh = otf.tables.defaults.deva
+defaults.beng = defaults.deva
+defaults.guru = defaults.deva
+defaults.gujr = defaults.deva
+defaults.orya = defaults.deva
+defaults.taml = defaults.deva
+defaults.telu = defaults.deva
+defaults.knda = defaults.deva
+defaults.mlym = defaults.deva
+defaults.sinh = defaults.deva
-otf.tables.defaults.syrc = otf.tables.defaults.arab
-otf.tables.defaults.mong = otf.tables.defaults.arab
-otf.tables.defaults.nko = otf.tables.defaults.arab
+defaults.syrc = defaults.arab
+defaults.mong = defaults.arab
+defaults.nko = defaults.arab
-otf.tables.defaults.tibt = otf.tables.defaults.khmr
+defaults.tibt = defaults.khmr
-otf.tables.defaults.lao = otf.tables.defaults.thai
+defaults.lao = defaults.thai
local function parse_script(script)
- if otf.tables.scripts[script] then
+ if defaults[script] then
local dflt
- if otf.tables.defaults[script] then
+ if defaults[script] then
logs.report("load font", "auto-selecting default features for script: %s", script)
- dflt = otf.tables.defaults[script]
+ dflt = defaults[script]
else
logs.report("load font", "auto-selecting default features for script: dflt (was %s)", script)
- dflt = otf.tables.defaults["dflt"]
+ dflt = defaults["dflt"]
end
for _,v in next, dflt do
list[v] = "yes"
@@ -135,9 +111,7 @@ local function parse_script(script)
end
end
-specifiers.colonizedpreference = "file"
-
-local function issome () list.lookup = specifiers.colonizedpreference end
+local function issome () list.lookup = 'name' end
local function isfile () list.lookup = 'file' end
local function isname () list.lookup = 'name' end
local function thename(s) list.name = s end
@@ -171,7 +145,7 @@ local pattern = (filename + fontname) * subvalue^0 * stylespec^0 * options^0
local function colonized(specification) -- xetex mode
list = { }
- lpegmatch(pattern,specification.specification)
+ lpeg.match(pattern,specification.specification)
if list.style then
specification.style = list.style
list.style = nil
@@ -200,9 +174,24 @@ local function colonized(specification) -- xetex mode
specification.sub = list.sub
list.sub = nil
end
- -- specification.features.normal = list
- specification.features.normal = normalize_meanings(list)
+ specification.features.normal = fonts.handlers.otf.features.normalize(list)
return specification
end
-definers.registersplit(":",colonized,"cryptic")
+fonts.definers.registersplit(":",colonized,"cryptic")
+fonts.definers.registersplit("", colonized,"more cryptic") -- catches \font\text=[names]
+
+function fonts.definers.applypostprocessors(tfmdata)
+ local postprocessors = tfmdata.postprocessors
+ if postprocessors then
+ for i=1,#postprocessors do
+ local extrahash = postprocessors[i](tfmdata) -- after scaling etc
+ if type(extrahash) == "string" and extrahash ~= "" then
+ -- e.g. a reencoding needs this
+ extrahash = string.gsub(lower(extrahash),"[^a-z]","-")
+ tfmdata.properties.fullname = format("%s-%s",tfmdata.properties.fullname,extrahash)
+ end
+ end
+ end
+ return tfmdata
+end
diff --git a/otfl-fonts-def.lua b/otfl-fonts-def.lua
deleted file mode 100644
index 0c2f0db..0000000
--- a/otfl-fonts-def.lua
+++ /dev/null
@@ -1,97 +0,0 @@
-if not modules then modules = { } end modules ['luatex-font-def'] = {
- 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
-
-local fonts = fonts
-
--- A bit of tuning for definitions.
-
-fonts.constructors.namemode = "specification" -- somehow latex needs this (changed name!) => will change into an overload
-
--- tricky: we sort of bypass the parser and directly feed all into
--- the sub parser
-
-function fonts.definers.getspecification(str)
- return "", str, "", ":", str
-end
-
--- the generic name parser (different from context!)
-
-local list = { }
-
-local function issome () list.lookup = 'name' end -- xetex mode prefers name (not in context!)
-local function isfile () list.lookup = 'file' end
-local function isname () list.lookup = 'name' end
-local function thename(s) list.name = s end
-local function issub (v) list.sub = v end
-local function iscrap (s) list.crap = string.lower(s) end
-local function iskey (k,v) list[k] = v end
-local function istrue (s) list[s] = true end
-local function isfalse(s) list[s] = false end
-
-local P, S, R, C = lpeg.P, lpeg.S, lpeg.R, lpeg.C
-
-local spaces = P(" ")^0
-local namespec = (1-S("/:("))^0 -- was: (1-S("/: ("))^0
-local crapspec = spaces * P("/") * (((1-P(":"))^0)/iscrap) * spaces
-local filename_1 = P("file:")/isfile * (namespec/thename)
-local filename_2 = P("[") * P(true)/isname * (((1-P("]"))^0)/thename) * P("]")
-local fontname_1 = P("name:")/isname * (namespec/thename)
-local fontname_2 = P(true)/issome * (namespec/thename)
-local sometext = (R("az","AZ","09") + S("+-."))^1
-local truevalue = P("+") * spaces * (sometext/istrue)
-local falsevalue = P("-") * spaces * (sometext/isfalse)
-local keyvalue = (C(sometext) * spaces * P("=") * spaces * C(sometext))/iskey
-local somevalue = sometext/istrue
-local subvalue = P("(") * (C(P(1-S("()"))^1)/issub) * P(")") -- for Kim
-local option = spaces * (keyvalue + falsevalue + truevalue + somevalue) * spaces
-local options = P(":") * spaces * (P(";")^0 * option)^0
-
-local pattern = (filename_1 + filename_2 + fontname_1 + fontname_2) * subvalue^0 * crapspec^0 * options^0
-
-local function colonized(specification) -- xetex mode
- list = { }
- lpeg.match(pattern,specification.specification)
- list.crap = nil -- style not supported, maybe some day
- if list.name then
- specification.name = list.name
- list.name = nil
- end
- if list.lookup then
- specification.lookup = list.lookup
- list.lookup = nil
- end
- if list.sub then
- specification.sub = list.sub
- list.sub = nil
- end
- specification.features.normal = fonts.handlers.otf.features.normalize(list)
- return specification
-end
-
-fonts.definers.registersplit(":",colonized,"cryptic")
-fonts.definers.registersplit("", colonized,"more cryptic") -- catches \font\text=[names]
-
-function fonts.definers.applypostprocessors(tfmdata)
- local postprocessors = tfmdata.postprocessors
- if postprocessors then
- for i=1,#postprocessors do
- local extrahash = postprocessors[i](tfmdata) -- after scaling etc
- if type(extrahash) == "string" and extrahash ~= "" then
- -- e.g. a reencoding needs this
- extrahash = string.gsub(lower(extrahash),"[^a-z]","-")
- tfmdata.properties.fullname = format("%s-%s",tfmdata.properties.fullname,extrahash)
- end
- end
- end
- return tfmdata
-end