diff options
author | Elie Roux <elie.roux@telecom-bretagne.eu> | 2010-05-15 16:42:28 +0300 |
---|---|---|
committer | Elie Roux <elie.roux@telecom-bretagne.eu> | 2010-05-15 16:42:28 +0300 |
commit | e089d4bfe982517075edb3517ee4cd4e6e6768d4 (patch) | |
tree | 6665e42eca70c77f45d8b19b131f1eb4b0bdabb7 /otfl-font-nms.lua | |
parent | 27fde1816474507a7cdd3af0401e2ea233b6d8d0 (diff) | |
download | luaotfload-e089d4bfe982517075edb3517ee4cd4e6e6768d4.tar.gz |
Attempt to fix the behaviour on macosx
Now if we are under macosx and if osfontdir is empty, we don't rely
on fc-list to give us the system fonts, but we use some static
directories.
Diffstat (limited to 'otfl-font-nms.lua')
-rw-r--r-- | otfl-font-nms.lua | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index 1efd90c..e910af8 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -368,8 +368,7 @@ local function scan_dir(dirname, fontnames, status, newfontnames, newstatus, rec - names is the font database to fill - recursive is whether we scan all directories recursively (always false in this script) - - texmf is a boolean saying if we are scanning a texmf directory (always - true in this script) + - texmf is a boolean saying if we are scanning a texmf directory --]] local list, found = { }, { } local nbfound = 0 @@ -449,6 +448,17 @@ local function read_fcdata(data) return list end +--[[ + Under Mac OSX, fc-list does not exist and there is no guaranty that OSFONTDIR + is correctly filled, so for now we use static paths. +]] + +local static_osx_dirs = { + "~/Library/Fonts", + "/Library/Fonts", + "/System/Library/Fonts", + } + local function scan_os_fonts(fontnames, status, newfontnames, newstatus) --[[ This function scans the OS fonts through fontcache (fc-list), it executes @@ -460,20 +470,34 @@ local function scan_os_fonts(fontnames, status, newfontnames, newstatus) if trace_progress then logs.report("scanning OS fonts:") end - if trace_search then - logs.report("executing 'fc-list : file' and parsing its result...") - end - local data = io.popen("fc-list : file", 'r') - local list = read_fcdata(data) - data:close() - if trace_search then - logs.report("%d fonts found", #list) - end - count = 0 - for _,fnt in ipairs(list) do - count = count + 1 - progress(count, #list) - load_font(fnt, fontnames, status, newfontnames, newstatus, false) + -- under OSX, we don't rely on fc-list, we rely on some static + -- directories instead + if os.name == "macosx" then + if trace_search then + logs.report("searching in static system directories") + end + count = 0 + for _,d in ipairs(static_osx_dirs) do + count = count + 1 + progress(count, #static_osx_dirs) + scan_dir(d, fontnames, status, newfontnames, newstatus, false, false) + end + else + if trace_search then + logs.report("executing 'fc-list : file' and parsing its result...") + end + local data = io.popen("fc-list : file", 'r') + local list = read_fcdata(data) + data:close() + if trace_search then + logs.report("%d fonts found", #list) + end + count = 0 + for _,fnt in ipairs(list) do + count = count + 1 + progress(count, #list) + load_font(fnt, fontnames, status, newfontnames, newstatus, false) + end end end end |