summaryrefslogtreecommitdiff
path: root/otfl-font-nms.lua
diff options
context:
space:
mode:
authorElie Roux <elie.roux@telecom-bretagne.eu>2010-05-24 22:27:01 +0300
committerElie Roux <elie.roux@telecom-bretagne.eu>2010-05-24 22:27:01 +0300
commiteefe0894f844cae176d0844d627914cfc5432008 (patch)
tree9bd21d2444bd23aab7c9304a7b6405fa79ec0a5b /otfl-font-nms.lua
parent9cc482d4b37ed584c63abdfa4f075b0a07f3a0e6 (diff)
downloadluaotfload-eefe0894f844cae176d0844d627914cfc5432008.tar.gz
A bit of code reorganization
(warning very strange and unreadable diff due to indentation change) Now scan_os_fonts just scans os fonts without checking if OSFONTDIR is set or not, but it's called only if OSFONTDIR is not set (makes the code a bit more understandable).
Diffstat (limited to 'otfl-font-nms.lua')
-rw-r--r--otfl-font-nms.lua71
1 files changed, 34 insertions, 37 deletions
diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua
index aecdc0b..7900312 100644
--- a/otfl-font-nms.lua
+++ b/otfl-font-nms.lua
@@ -569,8 +569,7 @@ local function scan_texmf_tree(fontnames, newfontnames)
else
logs.report("scanning TEXMF and OS fonts:")
end
- end
- if trace_short then
+ elseif trace_short then
if expandpath("$OSFONTDIR"):is_empty() then
logs.info("scanning TEXMF fonts...")
else
@@ -621,47 +620,43 @@ local static_osx_dirs = {
local function scan_os_fonts(fontnames, newfontnames)
--[[
- This function scans the OS fonts through fontcache (fc-list), it executes
- only if OSFONTDIR is empty (which is the case under most Unix by default).
- If OSFONTDIR is non-empty, this means that the system fonts it contains have
- already been scanned, and thus we don't scan them again.
+ This function scans the OS fonts through
+ - fontcache for Unix (reads the fonts.conf file and scans the directories)
+ - a static set of directories for Windows and MacOSX
--]]
- if expandpath("$OSFONTDIR"):is_empty() then
- if trace_progress then
- logs.report("scanning OS fonts:")
+ if trace_progress then
+ logs.report("scanning OS fonts:")
+ elseif trace_short then
+ logs.info("scanning OS fonts...")
+ end
+ -- 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.info("searching in static system directories...")
end
- if trace_short then
- logs.info("scanning OS fonts...")
+ count = 0
+ for _,d in ipairs(static_osx_dirs) do
+ count = count + 1
+ progress(count, #static_osx_dirs)
+ scan_dir(d, fontnames, newfontnames, false)
end
- -- under OSX, we don't rely on fc-list, we rely on some static
- -- directories instead
- if os.name == "macosx" then
+ else
+ if trace_search then
+ logs.info("executing 'fc-list : file' and parsing its result...")
+ end
+ local data = io.popen("fc-list : file", 'r')
+ if data then
+ local list = read_fcdata(data)
+ data:close()
if trace_search then
- logs.info("searching in static system directories...")
+ logs.report("%d fonts found", #list)
end
count = 0
- for _,d in ipairs(static_osx_dirs) do
+ for _,fnt in ipairs(list) do
count = count + 1
- progress(count, #static_osx_dirs)
- scan_dir(d, fontnames, newfontnames, false)
- end
- else
- if trace_search then
- logs.info("executing 'fc-list : file' and parsing its result...")
- end
- local data = io.popen("fc-list : file", 'r')
- if data then
- 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, newfontnames, false)
- end
+ progress(count, #list)
+ load_font(fnt, fontnames, newfontnames, false)
end
end
end
@@ -691,7 +686,9 @@ local function update_names(fontnames, force)
end
local newfontnames = fontnames_init()
scan_texmf_tree(fontnames, newfontnames)
- scan_os_fonts (fontnames, newfontnames)
+ if expandpath("$OSFONTDIR"):is_empty() then
+ scan_os_fonts(fontnames, newfontnames)
+ end
return newfontnames
end