summaryrefslogtreecommitdiff
path: root/otfl-font-nms.lua
diff options
context:
space:
mode:
authorWill Robertson <wspr81@gmail.com>2010-05-19 15:25:14 +0930
committerWill Robertson <wspr81@gmail.com>2010-05-19 18:13:33 +0930
commit94556836a52d7bdb41f405f9a7ea604c78a205d0 (patch)
treefa8c4001441bd060ff4c9546ab6ee03aea3f62a0 /otfl-font-nms.lua
parent0dd503b00ed24cc4a6628e7c0059c3b20fe0e177 (diff)
downloadluaotfload-94556836a52d7bdb41f405f9a7ea604c78a205d0.tar.gz
generalise which extensions to check (& filter out .ttc on Mac)
Diffstat (limited to 'otfl-font-nms.lua')
-rw-r--r--otfl-font-nms.lua31
1 files changed, 26 insertions, 5 deletions
diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua
index 3c033fa..39dac5b 100644
--- a/otfl-font-nms.lua
+++ b/otfl-font-nms.lua
@@ -38,6 +38,18 @@ local trace_progress = true --trackers.register("names.progress", function(v) t
local trace_search = false --trackers.register("names.search", function(v) trace_search = v end)
local trace_loading = false --trackers.register("names.loading", function(v) trace_loading = v end)
+
+-- Basic function from <http://stackoverflow.com/questions/2282444/how-to-check-if-a-table-contains-an-element-in-lua>
+function table.contains(table, element)
+ for _, value in pairs(table) do
+ if value == element then
+ return true
+ end
+ end
+ return false
+end
+
+
local function sanitize(str)
if str then
return utfgsub(lower(str), "[^%a%d]", "")
@@ -149,7 +161,7 @@ function names.resolve(specification)
-- if the specified name ends like a font file, we first look for
-- it through kpse, and if we don't find it, we look for it in
-- the database.
- if ext == 'otf' or ext == 'ttf' or ext == 'ttc' or ext == 'dfont' then
+ if table.contains(font_extensions_lc, ext) then
local fname = specification.name
-- for absolute and relative path, kpse will find them, so
-- there shouldn't be any problem
@@ -471,9 +483,18 @@ end
fonts.path_normalize = path_normalize
-font_extensions = {
- "otf", "ttf", "ttc", "dfont", "OTF", "TTF", "TTC", "DFONT"
-}
+if os.name == "macosx" then
+ -- While Mac OS X 10.6 has a problem with TTC files, ignore them globally:
+ font_extensions = {
+ "otf", "ttf", "dfont", "OTF", "TTF", "DFONT"
+ }
+ font_extensions_lc = { "otf", "ttf", "dfont" }
+else
+ font_extensions = {
+ "otf", "ttf", "ttc", "dfont", "OTF", "TTF", "TTC", "DFONT"
+ }
+ font_extensions_lc = { "otf", "ttf", "ttc", "dfont" }
+end
local function scan_dir(dirname, fontnames, newfontnames, texmf)
--[[
@@ -549,7 +570,7 @@ local function read_fcdata(data)
line = line:gsub(": ", "")
local ext = match(line,"^.+%.([^/\\]-)$") or ""
ext = lower(ext)
- if ext == "otf" or ext == "ttf" or ext == "ttc" or ext == "dfont" then
+ if table.contains(font_extensions_lc, ext) then
list[#list+1] = path_normalize(line:gsub(": ", ""))
end
end