summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-nms.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luaotfload/otfl-font-nms.lua')
-rw-r--r--Master/texmf-dist/tex/luatex/luaotfload/otfl-font-nms.lua122
1 files changed, 28 insertions, 94 deletions
diff --git a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-nms.lua b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-nms.lua
index ac3f0ba0b79..1f37d164a75 100644
--- a/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-nms.lua
+++ b/Master/texmf-dist/tex/luatex/luaotfload/otfl-font-nms.lua
@@ -6,20 +6,6 @@ if not modules then modules = { } end modules ['font-nms'] = {
license = "GNU GPL v2"
}
--- This is a patch for otfl-font-def.lua, that defines a reader for ofm fonts,
--- this is necessary if we set the forced field of the specification to 'ofm'
--- we use it only when using luaotfload, not mkluatexfontdb.
-if fonts and fonts.tfm and fonts.tfm.readers then
- fonts.tfm.readers.ofm = fonts.tfm.readers.tfm
-end
-
--- This is a necessary initalization in order not to rebuild an existing font.
--- Maybe 600 should be replaced by \pdfpkresolution
--- or texconfig.pk_dpi (and it should be replaced dynamically), but we don't
--- have access (yet) to the texconfig table, so we let it be 600. Anyway, it
--- does still work fine even if \pdfpkresolution is changed.
-kpse.init_prog('', 600, '/')
-
fonts = fonts or { }
fonts.names = fonts.names or { }
@@ -42,7 +28,6 @@ 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
-local trace_progress = true --trackers.register("names.progress", function(v) trace_progress = v end)
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)
@@ -63,8 +48,6 @@ local function fontnames_init()
end
function names.load()
- -- this sets the output of the database building accordingly.
- names.set_log_level(-1)
local localpath = file.join(names.path.localdir, names.path.basename)
local systempath = file.join(names.path.systemdir, names.path.basename)
local kpsefound = kpse.find_file(names.path.basename)
@@ -121,7 +104,7 @@ function names.resolve(specification)
if type(data) == "table" and data.version == names.version then
if data.mappings then
local found = { }
- for _,face in ipairs(data.mappings) do
+ for _,face in next, data.mappings do
local family = sanitize(face.names.family)
local subfamily = sanitize(face.names.subfamily)
local fullname = sanitize(face.names.fullname)
@@ -201,7 +184,7 @@ function names.resolve(specification)
-- least difference from the requested size.
local closest
local least = math.huge -- initial value is infinity
- for i,face in ipairs(found) do
+ for i,face in next, found do
local dsnsize = face.size[1]/10
local difference = math.abs(dsnsize-size)
if difference < least then
@@ -245,14 +228,9 @@ end
names.resolvespec = names.resolve
function names.set_log_level(level)
- if level == -1 then
- trace_progress = false
- trace_short = true
- elseif level == 2 then
- trace_progress = false
+ if level == 2 then
trace_loading = true
elseif level >= 3 then
- trace_progress = false
trace_loading = true
trace_search = true
end
@@ -272,26 +250,6 @@ logs.info = logs.info or log
local log = names.log
--- The progress bar
-local function progress(current, total)
- if trace_progress then
--- local width = os.getenv("COLUMNS") -2 --doesn't work
- local width = 78
- local percent = current/total
- local gauge = format("[%s]", rpadd(" ", width, " "))
- if percent > 0 then
- local done = rpadd("=", (width * percent) - 1, "=") .. ">"
- gauge = format("[%s]", rpadd(done, width, " ") )
- end
- if lastislog == 1 then
- texio.write_nl("")
- lastislog = 0
- end
- io.stderr:write("\r"..gauge)
- io.stderr:flush()
- end
-end
-
local function font_fullinfo(filename, subfont, texmf)
local t = { }
local f = fontloader.open(filename, subfont)
@@ -306,14 +264,14 @@ local function font_fullinfo(filename, subfont, texmf)
collectgarbage('collect')
-- see http://www.microsoft.com/typography/OTSPEC/features_pt.htm#size
if m.fontstyle_name then
- for _,v in pairs(m.fontstyle_name) do
+ for _,v in next, m.fontstyle_name do
if v.lang == 1033 then
t.fontstyle_name = v.name
end
end
end
if m.names then
- for _,v in pairs(m.names) do
+ for _,v in next, m.names do
if v.lang == "English (US)" then
t.names = {
-- see
@@ -372,7 +330,7 @@ local function load_font(filename, fontnames, newfontnames, texmf)
newstatus[basefile].index = newstatus[basefile].index or { }
if db_timestamp == timestamp and not newstatus[basefile].index[1] then
- for _,v in ipairs(status[basefile].index) do
+ for _,v in next, status[basefile].index do
local index = #newstatus[basefile].index
newmappings[#newmappings+1] = mappings[v]
newstatus[basefile].index[index+1] = #newmappings
@@ -385,7 +343,7 @@ local function load_font(filename, fontnames, newfontnames, texmf)
local info = fontloader.info(filename)
if info then
if type(info) == "table" and #info > 1 then
- for i in ipairs(info) do
+ for i in next, info do
local fullinfo = font_fullinfo(filename, i-1, texmf)
local index = newstatus[basefile].index[i]
if newstatus[basefile].index[i] then
@@ -423,9 +381,8 @@ local function path_normalize(path)
- /cygdrive/a/b -> a:/b
- reading symlinks under non-Win32
- using kpse.readable_file on Win32
- --]]
+ ]]
if os.type == "windows" or os.type == "msdos" or os.name == "cygwin" then
--- path = kpse.readable_file(path)
path = path:gsub('\\', '/')
path = path:lower()
path = path:gsub('^/cygdrive/(%a)/', '%1:/')
@@ -479,12 +436,12 @@ local font_extensions = { "otf", "ttf", "ttc", "dfont" }
local function scan_dir(dirname, fontnames, newfontnames, texmf)
--[[
- this function scans a directory and populates the list of fonts
+ This function scans a directory and populates the list of fonts
with all the fonts it finds.
- dirname is the name of the directory to scan
- names is the font database to fill
- texmf is a boolean saying if we are scanning a texmf directory
- --]]
+ ]]
local list, found = { }, { }
local nbfound = 0
if trace_search then
@@ -517,30 +474,18 @@ end
local function scan_texmf_fonts(fontnames, newfontnames)
--[[
- The function that scans all fonts in the texmf tree, through kpathsea
+ This function scans all fonts in the texmf tree, through kpathsea
variables OPENTYPEFONTS and TTFONTS of texmf.cnf
- --]]
- if trace_progress then
- if expandpath("$OSFONTDIR"):is_empty() then
- logs.report("Scanning TEXMF fonts:")
- else
- logs.report("Scanning TEXMF and OS fonts:")
- end
- elseif trace_short then
- if expandpath("$OSFONTDIR"):is_empty() then
- logs.info("Scanning TEXMF fonts...")
- else
- logs.info("Scanning TEXMF and OS fonts...")
- end
+ ]]
+ if expandpath("$OSFONTDIR"):is_empty() then
+ logs.info("Scanning TEXMF fonts...")
+ else
+ logs.info("Scanning TEXMF and OS fonts...")
end
local fontdirs = expandpath("$OPENTYPEFONTS"):gsub("^\.", "")
fontdirs = fontdirs .. expandpath("$TTFONTS"):gsub("^\.", "")
if not fontdirs:is_empty() then
- fontdirs = splitpath(fontdirs)
- count = 0
- for _,d in ipairs(fontdirs) do
- count = count + 1
- progress(count, #fontdirs)
+ for _,d in next, splitpath(fontdirs) do
scan_dir(d, fontnames, newfontnames, true)
end
end
@@ -559,12 +504,11 @@ end
in OSFONTDIR.
]]
---[[
- 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 function read_fonts_conf(path, results)
+ --[[
+ 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)
if not f then
error("Cannot open the file "..path)
@@ -622,8 +566,7 @@ local function read_fonts_conf(path, results)
-- be found otherwise
read_fonts_conf(include, results)
elseif lfs.isdir(include) then
- found = glob(file.join(include, "*.conf"))
- for _, f in ipairs(found) do
+ for _,f in next, glob(file.join(include, "*.conf")) do
read_fonts_conf(f, results)
end
end
@@ -659,20 +602,12 @@ local function scan_os_fonts(fontnames, newfontnames)
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 trace_progress then
- logs.report("Scanning OS fonts:")
- elseif trace_short then
- logs.info("Scanning OS fonts...")
- end
+ ]]
+ logs.info("Scanning OS fonts...")
if trace_search then
logs.info("Searching in static system directories...")
end
- count = 0
- local os_dirs = get_os_dirs()
- for _,d in ipairs(os_dirs) do
- count = count + 1
- progress(count, #os_dirs)
+ for _,d in next, get_os_dirs() do
scan_dir(d, fontnames, newfontnames, false)
end
end
@@ -682,10 +617,9 @@ local function update_names(fontnames, force)
The main function, scans everything
- fontnames is the final table to return
- force is whether we rebuild it from scratch or not
- --]]
- if trace_short then
- logs.info("Updating the font names database:")
- end
+ ]]
+ logs.info("Updating the font names database:")
+
if force then
fontnames = fontnames_init()
else