From 3f931d6ada8fed6bfab060f660e938efbab3c5bb Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Fri, 4 Jun 2010 18:28:16 +0300 Subject: Continuing the fonts.conf parsing. * comments are handled correctly * include are handled * directories containing "texmf" are not explored... maybe it should be changed? --- otfl-font-nms.lua | 84 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 67 insertions(+), 17 deletions(-) diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index a735f3d..3e283b2 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -38,7 +38,7 @@ local splitpath, expandpath = file.split_path, kpse.expand_path local glob, basename = dir.glob, file.basename local upper, lower, format = string.upper, string.lower, string.format local gsub, match, rpadd = string.gsub, string.match, string.rpadd -local gmatch, sub = string.gmatch, string.sub +local gmatch, sub, find = string.gmatch, string.sub, string.find local utfgsub = unicode.utf8.gsub local trace_short = false --tracing adapted to rebuilding of the database inside a document @@ -579,26 +579,73 @@ end The code is minimal, please report any error it may generate. ]] -local function read_fonts_conf() - local f = io.open("/etc/fonts/fonts.conf") +local function read_fonts_conf(path, results) + local f = io.open(path) if not f then - error("Cannot open the file /etc/fonts/fonts.conf") + error("Cannot open the file "..path) end - local results = {} local incomments = false for line in f:lines() do - -- spaghetti code... hmmm... - if incomments and sub(line, 1, 3) == '-->' then - incomments = false - elseif sub(line, 1, 4) == '') + if tmp then + incomments = false + line = sub(line, tmp+3) + else + line = nil + end + else + local tmp = find(line, '