summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore8
-rw-r--r--NEWS2
-rw-r--r--filegraph.dot4
-rw-r--r--luaotfload-auxiliary.lua125
-rw-r--r--luaotfload-blacklist.cnf2
-rw-r--r--luaotfload-database.lua52
-rw-r--r--luaotfload-features.lua10
-rw-r--r--luaotfload-fontloader.lua (renamed from luaotfload-merged.lua)0
-rw-r--r--luaotfload-override.lua125
-rwxr-xr-xluaotfload-tool.lua2
-rw-r--r--luaotfload.dtx4
-rwxr-xr-xmkcharacters33
-rwxr-xr-xmkstatus2
13 files changed, 312 insertions, 57 deletions
diff --git a/.gitignore b/.gitignore
index 4160efd..f231acf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,13 @@ luaotfload.fdb_latexmk
luaotfload.log
luaotfload.out
luaotfload.toc
+luaotfload-characters.lua
+luaotfload-glyphlist.lua
+luaotfload-status.lua
+filegraph.pdf
+glyphlist.txt
+luaotfload-tool.1
+luaotfload/*
# Files generated by 'make world' and removed by 'make mrproper'
luaotfload.lua
@@ -33,3 +40,4 @@ tests/*.ovp
tests/*.ovf
tests/*.sty
tests/luaotfload*
+
diff --git a/NEWS b/NEWS
index 937040a..c72b943 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,8 @@ Change History
* ``luaotfload-tool --find`` now understands request syntax
* option ``--compress`` filters text (Lua script) version of the font
index through gzip
+ * rename ``luaotfload-merged.lua`` (the fontloader package from Context)
+ to ``luaotfload-fontloader.lua``
2013/07/10, luaotfload v2.3a
* Detect LuaJIT interpreter (LuaJITTeX)
diff --git a/filegraph.dot b/filegraph.dot
index 92506e5..f70ef87 100644
--- a/filegraph.dot
+++ b/filegraph.dot
@@ -30,7 +30,7 @@ strict digraph luaotfload_files { //looks weird with circo ...
fontdbutil -> font_names [label="--update",
style=dashed]
- luaotfload -> otfl_fonts_merged [label="merged"]
+ luaotfload -> otfl_fonts_merged [label="merged"]
luaotfload -> merged_lua_libs [label="unmerged", style=solid]
luaotfload -> merged_luatex_fonts [label="unmerged", style=solid]
luaotfload -> merged_context_libs [label="unmerged", style=solid]
@@ -139,7 +139,7 @@ strict digraph luaotfload_files { //looks weird with circo ...
* style = "filled,rounded",
* penwidth=2]
*/
- otfl_fonts_merged [label = "luaotfload-merged.lua",
+ otfl_fonts_merged [label = "luaotfload-fontloader.lua",
shape = rect,
width = "3.2cm",
height = "1.2cm",
diff --git a/luaotfload-auxiliary.lua b/luaotfload-auxiliary.lua
index 92e1fd9..7daf367 100644
--- a/luaotfload-auxiliary.lua
+++ b/luaotfload-auxiliary.lua
@@ -368,35 +368,124 @@ aux.name_of_slot = name_of_slot
resides. The file is huge (>3.7 MB as of 2013) and not part of the
isolated font loader. Nevertheless, we include a partial version
generated by the mkcharacters script that contains only the
- “direction” and “mirror” fields of each character defined.
+ a subset of the fields of each character defined.
+
+ Currently, these are (compare the mkcharacters script!)
+
+ · "direction"
+ · "mirror"
+ · "category"
+ · "textclass"
+
+ The directional information is required for packages like Simurgh [0]
+ to work correctly. In an early stage [1] it was necessary to load
+ further files from Context directly, including the full blown version
+ of char-def. Since we have no use for most of the so imported
+ functionality, the required parts have been isolated and are now
+ instated along with luaotfload-characters.lua. We can extend the set
+ of imported features easily should it not be enough.
+
+ [0] https://github.com/persian-tex/simurgh
+ [1] http://tex.stackexchange.com/a/132301/14066
--doc]]--
-characters = characters or { } --- should be created in basics-gen
-characters.data = { }
-local chardef = "luaotfload-characters"
+characters = characters or { } --- should be created in basics-gen
+characters.data = nil
+local chardef = "luaotfload-characters"
do
- local chardata
- local index = function (t, k)
+ local setmetatableindex = function (t, f)
+ local mt = getmetatable (t)
+ if mt then
+ mt.__index = f
+ else
+ setmetatable (t, { __index = f })
+ end
+ end
+
+ --- there are some special tables for each field that provide access
+ --- to fields of the character table by means of a metatable
+
+ local mkcharspecial = function (characters, tablename, field)
+
+ local chardata = characters.data
+
+ if chardata then
+ local newspecial = { }
+ characters [tablename] = newspecial --> e.g. “characters.data.mirrors”
+
+ local idx = function (t, char)
+ local c = chardata [char]
+ if c then
+ local m = c [field] --> e.g. “mirror”
+ if m then
+ t [char] = m
+ return m
+ end
+ end
+ newspecial [char] = false
+ return char
+ end
+
+ setmetatableindex (newspecial, idx)
+ end
+
+ end
+
+ local mkcategories = function (characters) -- different from the others
+
+ local chardata = characters.data
+
+ setmetatable (characters, { __index = function (t, char)
+ if char then
+ local c = chardata [char]
+ c = c.category or char
+ t [char] = c
+ return c
+ end
+ end})
+
+ end
+
+ local load_failed = false
+ local chardata --> characters.data; loaded on demand
+
+ local load_chardef = function ()
+
+ log ("Loading character metadata from %s.", chardef)
+ chardata = dofile (kpse.find_file (chardef, "lua"))
+
if chardata == nil then
- log("Loading character metadata from %s.", chardef)
- chardata = dofile(kpse.find_file(chardef, "lua"))
- if chardata == nil then
- warning("Could not load %s; continuing with empty character table.",
+ warning ("Could not load %s; continuing \z
+ with empty character table.",
chardef)
- chardata = { }
- end
+ chardata = { }
+ load_failed = true
end
- return chardata[k]
+
+ characters = { } --- nuke metatable
+ characters.data = chardata
+
+ --- institute some of the functionality from char-ini.lua
+
+ mkcharspecial (characters, "mirrors", "mirror")
+ mkcharspecial (characters, "directions", "direction")
+ mkcharspecial (characters, "textclasses", "textclass")
+ mkcategories (characters)
+
end
- local mt = getmetatable(characters.data)
- if mt then
- mt.__index = index
- else
- setmetatable(characters.data, { __index = index })
+ local charindex = function (t, k)
+ if chardata == nil and load_failed ~= true then
+ load_chardef ()
+ end
+
+ return characters [k]
end
+
+ setmetatableindex (characters, charindex)
+
end
-----------------------------------------------------------------------
diff --git a/luaotfload-blacklist.cnf b/luaotfload-blacklist.cnf
index 5f80e24..5c03dc2 100644
--- a/luaotfload-blacklist.cnf
+++ b/luaotfload-blacklist.cnf
@@ -8,3 +8,5 @@ spltfgbd.ttf
spltfgbi.ttf
spltfgit.ttf
spltfgrg.ttf
+% Buggy Max OS font, see https://github.com/lualatex/luaotfload/issues/139
+Skia.ttf
diff --git a/luaotfload-database.lua b/luaotfload-database.lua
index 4632626..1deca07 100644
--- a/luaotfload-database.lua
+++ b/luaotfload-database.lua
@@ -86,7 +86,7 @@ local tablefastcopy = table.fastcopy
local tabletofile = table.tofile
local tabletohash = table.tohash
local tableserialize = table.serialize
-
+local runasscript = caches == nil
--- the font loader namespace is “fonts”, same as in Context
--- we need to put some fallbacks into place for when running
--- as a script
@@ -127,7 +127,10 @@ local make_luanames = function (path)
filereplacesuffix(path, "luc")
end
-local report = logs.names_report
+local report = logs.names_report
+local report_status = logs.names_status
+local report_status_start = logs.names_status_start
+local report_status_stop = logs.names_status_stop
names.patterns = { }
local patterns = names.patterns
@@ -164,7 +167,7 @@ local location_precedence = {
created by different user.
--doc]]--
-if caches then
+if not runasscript then
local globals = names.path.globals
local names_dir = globals.names_dir
@@ -1349,6 +1352,7 @@ local organize_namedata = function (metadata,
},
}
+ -- see http://www.microsoft.com/typography/OTSPEC/features_pt.htm#size
if metadata.fontstyle_name then
--- not present in all fonts, often differs from the preferred
--- subfamily as well as subfamily fields, e.g. with LMSans10-BoldOblique:
@@ -1694,6 +1698,7 @@ local read_font_names = function (fullname,
local format = stringlower (filesuffix (basename))
local loader = loaders [format] --- ot_fullinfo, t1_fullinfo
+ local loader = loaders[format] --- ot_fullinfo, t1_fullinfo
if not loader then
report ("both", 0, "db",
"Unknown format: %q, skipping.", format)
@@ -2076,27 +2081,25 @@ local scan_dir = function (dirname, currentnames, targetnames,
local n_new = 0 --- total of fonts collected
local n_found = #found
- report ("both", 5, "db", "%d font files detected", n_found)
+ report ("both", 4, "db", "%d font files detected", n_found)
for j=1, n_found do
local fullname = found[j]
fullname = path_normalize(fullname)
local new
if dry_run == true then
- report ("both", 1, "db",
- "Would have been extracting metadata from %q",
- fullname)
+ report_status ("both", "db",
+ "Would have been loading %q", fullname)
else
- report ("both", 5, "db",
- "Extracting metadata from font %q", fullname)
- local new = read_font_names (fullname, currentnames,
- targetnames, location)
+ report_status ("both", "db", "Loading font %q", fullname)
+ local new = load_font (fullname, fontnames,
+ newfontnames, texmf)
if new == true then
n_new = n_new + 1
end
end
end
-
- report("both", 5, "db", "%d fonts found in '%s'", n_found, dirname)
+ report ("both", 4, "db", "Done. %d fonts indexed in %q",
+ n_found, dirname)
return n_found, n_new
end
@@ -2132,9 +2135,9 @@ local scan_texmf_fonts = function (currentnames, targetnames, dry_run)
local osfontdir = kpseexpand_path "$OSFONTDIR"
if stringis_empty (osfontdir) then
- report ("info", 2, "db", "Scanning TEXMF fonts...")
+ report ("info", 1, "db", "Scanning TEXMF fonts...")
else
- report ("info", 2, "db", "Scanning TEXMF and OS fonts...")
+ report ("info", 1, "db", "Scanning TEXMF and OS fonts...")
if logs.get_loglevel () > 3 then
local osdirs = filesplitpath (osfontdir)
report ("info", 0, "db",
@@ -2153,12 +2156,14 @@ local scan_texmf_fonts = function (currentnames, targetnames, dry_run)
local tasks = filter_out_pwd (filesplitpath (fontdirs))
report ("info", 3, "db",
"Initiating scan of %d directories.", #tasks)
+ report_status_start (2, 4)
for _, d in next, tasks do
local found, new = scan_dir (d, currentnames, targetnames,
dry_run, "texmf")
n_scanned = n_scanned + found
n_new = n_new + new
end
+ report_status_stop ("term", "db", "Scanned %d files, %d new.", n_scanned, n_new)
end
return n_scanned, n_new
@@ -2443,12 +2448,14 @@ local scan_os_fonts = function (currentnames,
report ("info", 3, "db",
"Searching in static system directories...")
+ report_status_start (2, 4)
for _, d in next, get_os_dirs () do
local found, new = scan_dir (d, currentnames,
targetnames, dry_run)
n_scanned = n_scanned + found
n_new = n_new + new
end
+ report_status_stop ("term", "db", "Scanned %d files, %d new.", n_scanned, n_new)
return n_scanned, n_new
end
@@ -2519,7 +2526,12 @@ local generate_filedata = function (mappings)
barename = filenameonly (fullpath)
subfont = entry.subfont
end
+ end
+ local addmap = function (lst)
+ --- this will overwrite existing entries
+ for i=1, #lst do
+ local idx, base, bare, intexmf, full = unpack(lst[i])
entry.index = index
@@ -3078,8 +3090,8 @@ update_names = function (currentnames, force, dry_run)
- “targetnames” is the final table to return
- force is whether we rebuild it from scratch or not
]]
- report ("both", 2, "db", "Updating the font names database"
- .. (force and " forcefully" or ""))
+ report("both", 1, "db", "Updating the font names database"
+ .. (force and " forcefully" or ""))
--- pass 1 get raw data: read font files (normal case) or reuse
--- information present in index
@@ -3260,9 +3272,9 @@ end
--- string -> string -> string list -> bool -> bool
local purge_from_cache = function (category, path, list, all)
- report("info", 2, "cache", "Luaotfload cache: %s %s",
+ report("info", 1, "cache", "Luaotfload cache: %s %s",
(all and "erase" or "purge"), category)
- report("info", 2, "cache", "location: %s",path)
+ report("info", 1, "cache", "location: %s",path)
local n = 0
for i=1,#list do
local filename = list[i]
@@ -3285,7 +3297,7 @@ local purge_from_cache = function (category, path, list, all)
end
end
end
- report("info", 2, "cache", "Removed lua files : %i", n)
+ report("info", 1, "cache", "Removed lua files : %i", n)
return true
end
diff --git a/luaotfload-features.lua b/luaotfload-features.lua
index f324be6..83f5a99 100644
--- a/luaotfload-features.lua
+++ b/luaotfload-features.lua
@@ -1423,9 +1423,13 @@ local tlig = {
[0x2014] = {0x002D, 0x002D, 0x002D}, -- emdash
[0x201C] = {0x2018, 0x2018}, -- quotedblleft
[0x201D] = {0x2019, 0x2019}, -- quotedblright
- [0x201E] = {0x002C, 0x002C}, -- quotedblbase
[0x00A1] = {0x0021, 0x2018}, -- exclamdown
[0x00BF] = {0x003F, 0x2018}, -- questiondown
+ --- next three originate in T1 encoding; Xetex applies
+ --- them too
+ [0x201E] = {0x002C, 0x002C}, -- quotedblbase
+ [0x00AB] = {0x003C, 0x003C}, -- LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ [0x00BB] = {0x003E, 0x003E}, -- RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
},
flags = { },
},
@@ -1442,8 +1446,8 @@ local tlig = {
},
}
-otf.addfeature("tlig", tlig)
-otf.addfeature("trep", { }) -- empty, all in tlig now
+otf.addfeature ("tlig", tlig)
+otf.addfeature ("trep", { })
local anum_arabic = { --- these are the same as in font-otc
[0x0030] = 0x0660,
diff --git a/luaotfload-merged.lua b/luaotfload-fontloader.lua
index 3e89856..3e89856 100644
--- a/luaotfload-merged.lua
+++ b/luaotfload-fontloader.lua
diff --git a/luaotfload-override.lua b/luaotfload-override.lua
index 0609541..ea6af9a 100644
--- a/luaotfload-override.lua
+++ b/luaotfload-override.lua
@@ -32,6 +32,8 @@ local texio_write = texio.write
local texiowrite = texio.write
local type = type
+local dummyfunction = function () end
+
local texjob = false
if tex and (tex.jobname or tex.formatname) then
--- TeX
@@ -52,7 +54,7 @@ We recreate the verbosity levels previously implemented in font-nms:
--doc]]--
-local loglevel = 1 --- default
+local loglevel = 0 --- default
local logout = "log"
--- int -> bool
@@ -74,7 +76,9 @@ logs.getloglevel = get_loglevel
logs.get_loglevel = get_loglevel
logs.get_log_level = get_loglevel
-local writeln --- scope so we can change it
+local writeln --- pointer to terminal/log writer
+local statusln --- terminal writer that reuses the current line
+local first_status = true --- indicate the begin of a status region
local log_msg = [[
logging output redirected to %s
@@ -126,6 +130,7 @@ local set_logout = function (s, finalizers)
texiowrite = writefile
texiowrite_nl = writefile_nl
writeln = writefile_nl
+ statusln = dummyfunction
finalizers[#finalizers+1] = function ()
chan:write (stringformat ("\nlogging finished at %s\n",
@@ -164,18 +169,34 @@ end
io.stdout:setvbuf "no"
io.stderr:setvbuf "no"
+local kill_line = "\r\x1b[K"
+
if texjob == true then
+ --- We imitate the texio.* functions so the output is consistent.
writeln = function (str)
- texiowrite_nl ("term", str)
+ iowrite "\n"
+ iowrite(str)
+ end
+ statusln = function (str)
+ if first_status == false then
+ iowrite (kill_line)
+ end
+ iowrite (str)
end
else
writeln = function (str)
iowrite(str)
iowrite "\n"
end
+ statusln = function (str)
+ if first_status == false then
+ iowrite (kill_line)
+ end
+ iowrite (str)
+ end
end
-stdout = function (category, ...)
+stdout = function (writer, category, ...)
local res = { module_name, "|", category, ":" }
local nargs = select("#", ...)
if nargs == 0 then
@@ -186,7 +207,7 @@ stdout = function (category, ...)
else
res[#res+1] = stringformat(...)
end
- writeln(tableconcat(res, " "))
+ writer (tableconcat(res, " "))
end
--- at default (zero), we aim to be quiet
@@ -229,9 +250,9 @@ local names_report = function (mode, lvl, ...)
log (...)
elseif mode == "both" and logout ~= "redirect" then
log (...)
- stdout (...)
+ stdout (writeln, ...)
else
- stdout (...)
+ stdout (writeln, ...)
end
end
end
@@ -240,6 +261,95 @@ logs.names_report = names_report
--[[doc--
+ status_logger -- Overwrites the most recently printed line of the
+ terminal. Its purpose is to provide feedback without spamming
+ stdout with irrelevant messages, i.e. when building the database.
+
+ Status logging must be initialized by calling status_start() and
+ properly reset via status_stop().
+
+ The arguments low and high indicate the loglevel threshold at which
+ linewise and full logging is triggered, respectively. E.g.
+
+ names_status (1, 4, "term", "Hello, world!")
+
+ will print nothing if the loglevel is less than one, reuse the
+ current line if the loglevel ranges from one to three inclusively,
+ and output the message on a separate line otherwise.
+
+--doc]]--
+
+local status_logger = function (mode, ...)
+ if mode == "log" then
+ log (...)
+ else
+ if mode == "both" and logout ~= "redirect" then
+ log (...)
+ stdout (statusln, ...)
+ else
+ stdout (statusln, ...)
+ end
+ first_status = false
+ end
+end
+
+--[[doc--
+
+ status_start -- Initialize status logging. This installs the status
+ logger if the loglevel is in the specified range, and the normal
+ logger otherwise. It also resets the first line state which
+ causing the next line printed using the status logger to not kill
+ the current line.
+
+--doc]]--
+
+local status_writer
+local status_low = 99
+local status_high = 99
+
+local status_start = function (low, high)
+ first_status = true
+ status_low = low
+ status_high = high
+
+ if os.type == "windows" --- Assume broken terminal.
+ or os.getenv "TERM" == "dumb"
+ then
+ status_writer = function (mode, ...)
+ names_report (mode, high, ...)
+ end
+ return
+ end
+
+ if low <= loglevel and loglevel < high then
+ status_writer = status_logger
+ else
+ status_writer = function (mode, ...)
+ names_report (mode, high, ...)
+ end
+ end
+end
+
+--[[doc--
+
+ status_stop -- Finalize a status region by outputting a newline and
+ printing a message.
+
+--doc]]--
+
+local status_stop = function (...)
+ if first_status == false then
+ status_writer(...)
+ writeln ""
+ end
+end
+
+logs.names_status = function (...) status_writer (...) end
+logs.names_status_start = status_start
+logs.names_status_stop = status_stop
+
+--[[doc--
+
The fontloader comes with the Context logging mechanisms
inaccessible. Instead, it provides dumb fallbacks based
on the functions in texio.write*() that can be overridden
@@ -276,7 +386,6 @@ texio.reporter = texioreporter
if fonts then --- need to be running TeX
if next(fonts.encodings.agl) then
- print(next, fonts.encodings.agl)
--- unnecessary because the file shouldn’t be loaded at this time
--- but we’re just making sure
fonts.encodings.agl = nil
diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua
index 737485f..4f084ae 100755
--- a/luaotfload-tool.lua
+++ b/luaotfload-tool.lua
@@ -1141,7 +1141,7 @@ local process_cmdline = function ( ) -- unit -> jobspec
if result.log_level > 0 then
result.log_level = result.log_level + 1
else
- result.log_level = 2
+ result.log_level = 1
end
elseif v == "V" then
action_pending["version"] = true
diff --git a/luaotfload.dtx b/luaotfload.dtx
index 5d80318..4107185 100644
--- a/luaotfload.dtx
+++ b/luaotfload.dtx
@@ -1095,7 +1095,7 @@ and the derived files
% See figure \ref{file-graph} on page \pageref{file-graph} for a
% graphical representation of the dependencies.
% From \LUATEX-Fonts, only the file \fileent{luatex-fonts-merged.lua}
-% has been imported as \fileent{luaotfload-merged.lua}.
+% has been imported as \fileent{luaotfload-fontloader.lua}.
% It is generated by \fileent{mtx-package}, a \LUA source code merging
% too developed by Hans Hagen.\footnote{%
% \fileent{mtx-package} is
@@ -1784,7 +1784,7 @@ tex.attribute[0] = 0
%
% \begin{macrocode}
-loadmodule"merged.lua"
+loadmodule"fontloader.lua"
---loadmodule"font-odv.lua" --- <= Devanagari support from Context
if fonts then
diff --git a/mkcharacters b/mkcharacters
index a1c4204..63c78ed 100755
--- a/mkcharacters
+++ b/mkcharacters
@@ -15,10 +15,39 @@
-- config
-----------------------------------------------------------------------
local charfile = "./luaotfload-characters.lua"
-local chardef = "~phg/base/char-def.lua"
-local import = {
+local chardef = "/home/phg/base/char-def.lua"
+
+--- for every code point char-def.lua provides a set of fields. they
+--- are:
+---
+--- * adobename
+--- * category
+--- * cjkwd
+--- * comment
+--- * contextname
+--- * description
+--- * direction
+--- * lccode
+--- * linebreak
+--- * mathclass
+--- * mathextensible
+--- * mathfiller
+--- * mathname
+--- * mathspec
+--- * mathstretch
+--- * mathsymbol
+--- * mirror
+--- * shcode
+--- * specials
+--- * textclass
+--- * uccode
+--- * unicodeslot
+--- * variants
+
+local import = {
"direction", "mirror", --> πολυγλωσσία/uax9
"category", --> https://gist.github.com/phi-gamma/5812290
+ "textclass", --> https://gist.github.com/phi-gamma/6488187
}
-----------------------------------------------------------------------
diff --git a/mkstatus b/mkstatus
index 16d0b5d..a8d9233 100755
--- a/mkstatus
+++ b/mkstatus
@@ -52,7 +52,7 @@ local names = {
"luaotfload-letterspace.lua",
"luaotfload-loaders.lua",
"luaotfload.lua",
- "luaotfload-merged.lua",
+ "luaotfload-fontloader.lua",
"luaotfload-override.lua",
"luaotfload-tool.lua",
"luaotfload-typo-krn.lua",