summaryrefslogtreecommitdiff
path: root/otfl-font-xtx.lua
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2010-01-15 08:18:40 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2010-01-15 09:24:38 +0200
commit4962a4a9bc747e2ba62331c652a1802922509365 (patch)
tree6b2e96eb4e8fc8f180fa317905913dcc48836b05 /otfl-font-xtx.lua
parentd219fcfa58d00d321aaf8966c7d62a38d0cb4d45 (diff)
downloadluaotfload-4962a4a9bc747e2ba62331c652a1802922509365.tar.gz
Support auto-detecting font style
We now support XeTeX's syntax, try: \input luaotfload.sty \font\termesr ={TeX Gyre Termes:+liga} at 10pt \font\termesb ={TeX Gyre Termes/B:+liga} at 10pt \font\termesi ={TeX Gyre Termes/I:+liga} at 10pt \font\termesbi={TeX Gyre Termes/BI:+liga} at 10pt \font\termesib={TeX Gyre Termes/IB:+liga} at 10pt \termesr What a nice day fi fl ffi ffl ff\par \termesb What a nice day fi fl ffi ffl ff\par \termesi What a nice day fi fl ffi ffl ff\par \termesbi What a nice day fi fl ffi ffl ff\par \termesib What a nice day fi fl ffi ffl ff\par \bye
Diffstat (limited to 'otfl-font-xtx.lua')
-rw-r--r--otfl-font-xtx.lua20
1 files changed, 17 insertions, 3 deletions
diff --git a/otfl-font-xtx.lua b/otfl-font-xtx.lua
index 56bedf9..ac4ebb1 100644
--- a/otfl-font-xtx.lua
+++ b/otfl-font-xtx.lua
@@ -62,12 +62,23 @@ local list = { }
fonts.define.specify.colonized_default_lookup = "file"
+local function isstyle(s)
+ local style = string.lower(s):split("/")
+ for _,v in ipairs(style) do
+ if v == "b" then
+ list.style = "bold"
+ elseif v == "i" then
+ list.style = "italic"
+ elseif v == "bi" or list.style == "ib" then
+ list.style = "bolditalic"
+ end
+ end
+end
local function issome () list.lookup = fonts.define.specify.colonized_default_lookup end
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 istrue (s) list[s] = 'yes' end
--KH local function isfalse(s) list[s] = 'no' end
local function isfalse(s) list[s] = nil end -- see mpg/luaotfload#4
@@ -75,7 +86,7 @@ local function iskey (k,v) list[k] = v end
local spaces = lpeg.P(" ")^0
local namespec = (1-lpeg.S("/:("))^0 -- was: (1-lpeg.S("/: ("))^0
-local crapspec = spaces * lpeg.P("/") * (((1-lpeg.P(":"))^0)/iscrap) * spaces
+local crapspec = spaces * lpeg.P("/") * (((1-lpeg.P(":"))^0)/isstyle) * spaces
local filename = (lpeg.P("file:")/isfile * (namespec/thename)) + (lpeg.P("[") * lpeg.P(true)/isname * (((1-lpeg.P("]"))^0)/thename) * lpeg.P("]"))
local fontname = (lpeg.P("name:")/isname * (namespec/thename)) + lpeg.P(true)/issome * (namespec/thename)
local sometext = (lpeg.R("az") + lpeg.R("AZ") + lpeg.R("09"))^1
@@ -98,7 +109,10 @@ function fonts.define.specify.colonized(specification) -- xetex mode
list[k] = v
end
end
- list.crap = nil -- style not supported, maybe some day
+ if list.style then
+ specification.style = list.style
+ list.style = nil
+ end
if list.name then
specification.name = list.name
list.name = nil