From 94556836a52d7bdb41f405f9a7ea604c78a205d0 Mon Sep 17 00:00:00 2001 From: Will Robertson Date: Wed, 19 May 2010 15:25:14 +0930 Subject: generalise which extensions to check (& filter out .ttc on Mac) --- otfl-font-nms.lua | 31 ++++++++++++++++++++++++++----- 1 file 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 +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 -- cgit v1.2.3