summaryrefslogtreecommitdiff
path: root/otfl-font-ltx.lua
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2011-10-04 02:38:35 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2011-10-04 03:18:05 +0200
commitae90a027a582c4831c2abb905a1193ca3be355a5 (patch)
tree9e4a3fa045acd2723fd08977ab7ff79d462ccb59 /otfl-font-ltx.lua
parentb58b5576bb3be118142ab5b7732befaf66d350ad (diff)
downloadluaotfload-ae90a027a582c4831c2abb905a1193ca3be355a5.tar.gz
Reduce the diff between otfl-font-ltx.lua otfl-fonts-def.lua and use the former
Diffstat (limited to 'otfl-font-ltx.lua')
-rw-r--r--otfl-font-ltx.lua109
1 files changed, 49 insertions, 60 deletions
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