From 2f5da31926b15ba663a65335fd17e8970eb7b49d Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Thu, 11 Apr 2013 14:26:39 +0200 Subject: Compatibility with LuaTeX 0.75 --- otfl-font-nms.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'otfl-font-nms.lua') diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index a8b3100..f6d6a6e 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -493,8 +493,8 @@ local function scan_texmf_fonts(fontnames, newfontnames) else logs.info("Scanning TEXMF and OS fonts...") end - local fontdirs = expandpath("$OPENTYPEFONTS"):gsub("^\.", "") - fontdirs = fontdirs .. expandpath("$TTFONTS"):gsub("^\.", "") + local fontdirs = expandpath("$OPENTYPEFONTS"):gsub("^%.", "") + fontdirs = fontdirs .. expandpath("$TTFONTS"):gsub("^%.", "") if not fontdirs:is_empty() then for _,d in next, splitpath(fontdirs) do scan_dir(d, fontnames, newfontnames, true) -- cgit v1.2.3 From df8d8a5e5ec4a3e885a6b15087fc283ee69ecf06 Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Tue, 16 Apr 2013 09:40:52 +0200 Subject: Better error handling for font config reading The code is still quite experimental and sometimes generate errors while it could still continue. --- otfl-font-nms.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'otfl-font-nms.lua') diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index f6d6a6e..4271b3c 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -522,7 +522,7 @@ local function read_fonts_conf(path, results) ]] local f = io.open(path) if not f then - error("Cannot open the file "..path) + return results end local incomments = false for line in f:lines() do @@ -571,7 +571,7 @@ local function read_fonts_conf(path, results) elseif not lfs.isfile(include) and not lfs.isdir(include) then include = file.join(file.dirname(path), include) end - if lfs.isfile(include) then + if lfs.isfile(include) and kpse.readable_file(include) then -- maybe we should prevent loops here? -- we exclude path with texmf in them, as they should -- be found otherwise -- cgit v1.2.3 From 9e597b20c304c3dd1f2a49277e5c4bbbbb5ac9a1 Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Tue, 16 Apr 2013 09:44:51 +0200 Subject: Warning if a file cannot be read in font conf --- otfl-font-nms.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'otfl-font-nms.lua') diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index 4271b3c..02ae859 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -522,6 +522,7 @@ local function read_fonts_conf(path, results) ]] local f = io.open(path) if not f then + logs.info("Warning: unable to read "..path.. ", skipping...") return results end local incomments = false -- cgit v1.2.3 From ca2e2bdcdbe78131ff1766e527ca0a9f5b01afa4 Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Tue, 16 Apr 2013 09:54:04 +0200 Subject: Adding semibold as a synonym for bold, not sure it's useful... --- otfl-font-nms.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'otfl-font-nms.lua') diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index 02ae859..e6faeab 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -76,9 +76,12 @@ end local synonyms = { regular = { "normal", "roman", "plain", "book", "medium" }, - bold = { "boldregular", "demi", "demibold" }, + -- boldregular was for old versions of Linux Libertine, is it still useful? + -- semibold is in new versions of Linux Libertine, but there is also a bold, + -- not sure it's useful here... + bold = { "demi", "demibold", "semibold", "boldregular" }, italic = { "regularitalic", "normalitalic", "oblique", "slanted" }, - bolditalic = { "boldoblique", "boldslanted", "demiitalic", "demioblique", "demislanted", "demibolditalic" }, + bolditalic = { "boldoblique", "boldslanted", "demiitalic", "demioblique", "demislanted", "demibolditalic", "semibolditalic" }, } local loaded = false -- cgit v1.2.3 From 246ef30f958ee3f9a957703a385fcc65607f07a1 Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Tue, 16 Apr 2013 18:47:44 +0200 Subject: Preventing loop-references in fontconfig files I just had this case on a recent Ubuntu... --- otfl-font-nms.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'otfl-font-nms.lua') diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index e6faeab..0f44eb4 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -518,12 +518,13 @@ end in OSFONTDIR. ]] -local function read_fonts_conf(path, results) +local function read_fonts_conf(path, results, passed_paths) --[[ This function parses /etc/fonts/fonts.conf and returns all the dir it finds. The code is minimal, please report any error it may generate. ]] local f = io.open(path) + table.insert(passed_paths, path) if not f then logs.info("Warning: unable to read "..path.. ", skipping...") return results @@ -575,14 +576,14 @@ local function read_fonts_conf(path, results) elseif not lfs.isfile(include) and not lfs.isdir(include) then include = file.join(file.dirname(path), include) end - if lfs.isfile(include) and kpse.readable_file(include) then + if lfs.isfile(include) and kpse.readable_file(include) and not table.contains(passed_paths, include) then -- maybe we should prevent loops here? -- we exclude path with texmf in them, as they should -- be found otherwise - read_fonts_conf(include, results) + read_fonts_conf(include, results, passed_paths) elseif lfs.isdir(include) then for _,f in next, glob(file.join(include, "*.conf")) do - read_fonts_conf(f, results) + read_fonts_conf(f, results, passed_paths) end end end @@ -608,7 +609,7 @@ local function get_os_dirs() local windir = os.getenv("WINDIR") return { file.join(windir, 'Fonts') } else - return read_fonts_conf("/etc/fonts/fonts.conf", {}) + return read_fonts_conf("/etc/fonts/fonts.conf", {}, {}) end end -- cgit v1.2.3 From 0b5a6761f55ed9fa03c7ba0564764ad89ee9a925 Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Tue, 16 Apr 2013 18:50:41 +0200 Subject: Removing the todo of previous commit --- otfl-font-nms.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'otfl-font-nms.lua') diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index 0f44eb4..5cca490 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -577,7 +577,6 @@ local function read_fonts_conf(path, results, passed_paths) include = file.join(file.dirname(path), include) end if lfs.isfile(include) and kpse.readable_file(include) and not table.contains(passed_paths, include) then - -- maybe we should prevent loops here? -- we exclude path with texmf in them, as they should -- be found otherwise read_fonts_conf(include, results, passed_paths) -- cgit v1.2.3 From 64b8916cca621917b4fcd971e7921ec44f1f3352 Mon Sep 17 00:00:00 2001 From: Elie Roux Date: Thu, 18 Apr 2013 14:32:54 +0200 Subject: I had forgotten this check for reference-looping --- otfl-font-nms.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'otfl-font-nms.lua') diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua index 5cca490..50febab 100644 --- a/otfl-font-nms.lua +++ b/otfl-font-nms.lua @@ -582,7 +582,9 @@ local function read_fonts_conf(path, results, passed_paths) read_fonts_conf(include, results, passed_paths) elseif lfs.isdir(include) then for _,f in next, glob(file.join(include, "*.conf")) do - read_fonts_conf(f, results, passed_paths) + if not table.contains(passed_paths, f) then + read_fonts_conf(f, results, passed_paths) + end end end end -- cgit v1.2.3