summaryrefslogtreecommitdiff
path: root/luaotfload-database.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-11-09 05:19:45 -0800
committerPhilipp Gesang <phg42.2a@gmail.com>2013-11-09 05:19:45 -0800
commitb456ec23e850167d4e6397a56afc01b6379b466c (patch)
tree899f5c1de9fa08e59300545396e34a9998eefd56 /luaotfload-database.lua
parentadb03528f61cd71d61aa66bb237222c070fd3d3a (diff)
parent03bf4071685290a746bafb33deb448ee3246bfc0 (diff)
downloadluaotfload-b456ec23e850167d4e6397a56afc01b6379b466c.tar.gz
Merge pull request #147 from phi-gamma/master
further improvements
Diffstat (limited to 'luaotfload-database.lua')
-rw-r--r--luaotfload-database.lua74
1 files changed, 55 insertions, 19 deletions
diff --git a/luaotfload-database.lua b/luaotfload-database.lua
index d25b846..8f1f34d 100644
--- a/luaotfload-database.lua
+++ b/luaotfload-database.lua
@@ -1279,6 +1279,32 @@ find_closest = function (name, limit)
return false
end --- find_closest()
+--[[doc--
+
+ load_font_file -- Extract relevant information from a font. The
+ fields we require for the index are, by category:
+
+ -- style:
+ .design_size
+ .design_range_top
+ .design_range_bottom
+ .pfminfo (table)
+ .italicangle
+ .units_per_em
+ .fontstyle_name
+ -- font names:
+ .names (table)
+ .fullname
+ .fontname
+ .familyname
+ -- .version
+
+ Since we don’t actually require metrics and glyph information we
+ can omit calling the very expensive ``fontloader.to_table()``
+ altogether.
+
+--doc]]--
+
local load_font_file = function (filename, subfont)
local rawfont, _msg = fontloaderopen (filename, subfont)
if not rawfont then
@@ -1286,17 +1312,27 @@ local load_font_file = function (filename, subfont)
return
end
- local metadata = fontloaderto_table (rawfont)
+-- local metadata = fontloaderto_table (rawfont)
+ local fontstyle_name = rawfont.fontstyle_name
+ local names = rawfont.names
+ local pfminfo = rawfont.pfminfo
+
+ local metadata = {
+ design_size = rawfont.design_size,
+ design_range_top = rawfont.design_range_top,
+ design_range_bottom = rawfont.design_range_bottom,
+ names = names and tablecopy (names) or { },
+ fullname = rawfont.fullname,
+ fontstyle_name = fontstyle_name and tablecopy (fontstyle_name) or { },
+ fontname = rawfont.fontname,
+ familyname = rawfont.familyname,
+ pfminfo = pfminfo and tablecopy (pfminfo) or { },
+ italicangle = rawfont.italicangle,
+ units_per_em = rawfont.units_per_em,
+ version = rawfont.version,
+ }
fontloaderclose (rawfont)
-
- metadata.glyphs = nil
- metadata.subfonts = nil
- metadata.gpos = nil
- metadata.gsub = nil
- metadata.lookups = nil
-
collectgarbage "collect"
-
return metadata
end
@@ -2446,8 +2482,8 @@ local scan_os_fonts = function (currentnames,
dry_run)
local n_scanned, n_new = 0, 0
- report ("info", 2, "db", "Scanning OS fonts...")
- report ("info", 3, "db",
+ report ("info", 1, "db", "Scanning OS fonts...")
+ report ("info", 2, "db",
"Searching in static system directories...")
report_status_start (2, 4)
@@ -2628,12 +2664,12 @@ do
if prefmodifiers then
style = choose_exact (prefmodifiers)
elseif subfamily then
- --style = choose_exact (subfamily)
+ style = choose_exact (subfamily)
end
end
- if not style and splitstyle then
- style = choose_exact (splitstyle)
- end
+-- if not style and splitstyle then
+-- style = choose_exact (splitstyle)
+-- end
return style
end
@@ -3175,18 +3211,18 @@ save_names = function (currentnames)
tabletofile (luaname, currentnames, true)
caches.compile (currentnames, luaname, lucname)
end
- report ("info", 1, "db", "Font index saved at ...")
+ report ("info", 2, "db", "Font index saved at ...")
local success = false
if lfsisfile (luaname) then
- report ("info", 3, "db", "Text: " .. luaname)
+ report ("info", 2, "db", "Text: " .. luaname)
success = true
end
if lfsisfile (gzname) then
- report ("info", 3, "db", "Gzip: " .. gzname)
+ report ("info", 2, "db", "Gzip: " .. gzname)
success = true
end
if lfsisfile (lucname) then
- report ("info", 3, "db", "Byte: " .. lucname)
+ report ("info", 2, "db", "Byte: " .. lucname)
success = true
end
if success then