From 9ac243d09b484e3096e35a521df4328ceba78a8e Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 18 Sep 2019 21:58:28 +0000 Subject: luaotfload (18sep19) git-svn-id: svn://tug.org/texlive/trunk@52120 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/luatex/luaotfload/luaotfload-auxiliary.lua | 6 +- .../tex/luatex/luaotfload/luaotfload-colors.lua | 4 +- .../luatex/luaotfload/luaotfload-configuration.lua | 4 +- .../tex/luatex/luaotfload/luaotfload-database.lua | 90 ++++++--- .../luatex/luaotfload/luaotfload-diagnostics.lua | 4 +- .../tex/luatex/luaotfload/luaotfload-embolden.lua | 4 +- .../tex/luatex/luaotfload/luaotfload-features.lua | 4 +- .../tex/luatex/luaotfload/luaotfload-filelist.lua | 5 +- .../tex/luatex/luaotfload/luaotfload-glyphlist.lua | 4 +- .../tex/luatex/luaotfload/luaotfload-init.lua | 18 +- .../luatex/luaotfload/luaotfload-letterspace.lua | 4 +- .../tex/luatex/luaotfload/luaotfload-loaders.lua | 4 +- .../tex/luatex/luaotfload/luaotfload-log.lua | 4 +- .../tex/luatex/luaotfload/luaotfload-main.lua | 5 +- .../luatex/luaotfload/luaotfload-multiscript.lua | 208 +++++++++++++++++++++ .../tex/luatex/luaotfload/luaotfload-notdef.lua | 113 +++++++++-- .../tex/luatex/luaotfload/luaotfload-parsers.lua | 4 +- .../tex/luatex/luaotfload/luaotfload-resolvers.lua | 4 +- .../tex/luatex/luaotfload/luaotfload-status.lua | 49 ++--- .../tex/luatex/luaotfload/luaotfload-unicode.lua | 4 +- .../tex/luatex/luaotfload/luaotfload.sty | 2 +- 21 files changed, 449 insertions(+), 95 deletions(-) create mode 100644 Master/texmf-dist/tex/luatex/luaotfload/luaotfload-multiscript.lua (limited to 'Master/texmf-dist/tex/luatex') diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-auxiliary.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-auxiliary.lua index 3e3283b5ff1..d3b5c734183 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-auxiliary.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-auxiliary.lua @@ -6,8 +6,8 @@ local ProvidesLuaModule = { name = "luaotfload-auxiliary", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload submodule / auxiliary functions", license = "GPL v2.0" } @@ -285,7 +285,7 @@ luaotfload_callbacks [#luaotfload_callbacks + 1] = { local function set_xheight(tfmdata) local parameters = tfmdata.parameters if not parameters then return end - if not (parameters.x_height or parameters[5] or 0) == 0 then return end + if not ((parameters.x_height or parameters[5] or 0) == 0) then return end if tfmdata.characters and tfmdata.characters[120] then parameters.x_height = tfmdata.characters[120].height else diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-colors.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-colors.lua index d9dabd1c6c9..fdae0c4450c 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-colors.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-colors.lua @@ -5,8 +5,8 @@ local ProvidesLuaModule = { name = "luaotfload-colors", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload submodule / color", license = "GPL v2.0", author = "Khaled Hosny, Elie Roux, Philipp Gesang, Dohyun Kim, David Carlisle", diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-configuration.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-configuration.lua index 12fc63e0d58..fc30cc8343a 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-configuration.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-configuration.lua @@ -7,8 +7,8 @@ local ProvidesLuaModule = { name = "luaotfload-configuration", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload submodule / config file reader", license = "GPL v2.0" } diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-database.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-database.lua index a932456b6a7..06106189056 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-database.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-database.lua @@ -5,8 +5,8 @@ do -- block to avoid to many local variables error local ProvidesLuaModule = { name = "luaotfload-database", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload submodule / database", license = "GPL v2.0", author = "Khaled Hosny, Elie Roux, Philipp Gesang, Marcel Krüger", @@ -239,15 +239,53 @@ end --- string -> string -local invalidchars = "[^%a%d]" - +local macroman2utf8 do + local mapping = { + [0x80] = 0x00C4, [0x81] = 0x00C5, [0x82] = 0x00C7, [0x83] = 0x00C9, + [0x84] = 0x00D1, [0x85] = 0x00D6, [0x86] = 0x00DC, [0x87] = 0x00E1, + [0x88] = 0x00E0, [0x89] = 0x00E2, [0x8A] = 0x00E4, [0x8B] = 0x00E3, + [0x8C] = 0x00E5, [0x8D] = 0x00E7, [0x8E] = 0x00E9, [0x8F] = 0x00E8, + [0x90] = 0x00EA, [0x91] = 0x00EB, [0x92] = 0x00ED, [0x93] = 0x00EC, + [0x94] = 0x00EE, [0x95] = 0x00EF, [0x96] = 0x00F1, [0x97] = 0x00F3, + [0x98] = 0x00F2, [0x99] = 0x00F4, [0x9A] = 0x00F6, [0x9B] = 0x00F5, + [0x9C] = 0x00FA, [0x9D] = 0x00F9, [0x9E] = 0x00FB, [0x9F] = 0x00FC, + [0xA0] = 0x2020, [0xA1] = 0x00B0, [0xA2] = 0x00A2, [0xA3] = 0x00A3, + [0xA4] = 0x00A7, [0xA5] = 0x2022, [0xA6] = 0x00B6, [0xA7] = 0x00DF, + [0xA8] = 0x00AE, [0xA9] = 0x00A9, [0xAA] = 0x2122, [0xAB] = 0x00B4, + [0xAC] = 0x00A8, [0xAD] = 0x2260, [0xAE] = 0x00C6, [0xAF] = 0x00D8, + [0xB0] = 0x221E, [0xB1] = 0x00B1, [0xB2] = 0x2264, [0xB3] = 0x2265, + [0xB4] = 0x00A5, [0xB5] = 0x00B5, [0xB6] = 0x2202, [0xB7] = 0x2211, + [0xB8] = 0x220F, [0xB9] = 0x03C0, [0xBA] = 0x222B, [0xBB] = 0x00AA, + [0xBC] = 0x00BA, [0xBD] = 0x03A9, [0xBE] = 0x00E6, [0xBF] = 0x00F8, + [0xC0] = 0x00BF, [0xC1] = 0x00A1, [0xC2] = 0x00AC, [0xC3] = 0x221A, + [0xC4] = 0x0192, [0xC5] = 0x2248, [0xC6] = 0x2206, [0xC7] = 0x00AB, + [0xC8] = 0x00BB, [0xC9] = 0x2026, [0xCA] = 0x00A0, [0xCB] = 0x00C0, + [0xCC] = 0x00C3, [0xCD] = 0x00D5, [0xCE] = 0x0152, [0xCF] = 0x0153, + [0xD0] = 0x2013, [0xD1] = 0x2014, [0xD2] = 0x201C, [0xD3] = 0x201D, + [0xD4] = 0x2018, [0xD5] = 0x2019, [0xD6] = 0x00F7, [0xD7] = 0x25CA, + [0xD8] = 0x00FF, [0xD9] = 0x0178, [0xDA] = 0x2044, [0xDB] = 0x20AC, + [0xDC] = 0x2039, [0xDD] = 0x203A, [0xDE] = 0xFB01, [0xDF] = 0xFB02, + [0xE0] = 0x2021, [0xE1] = 0x00B7, [0xE2] = 0x201A, [0xE3] = 0x201E, + [0xE4] = 0x2030, [0xE5] = 0x00C2, [0xE6] = 0x00CA, [0xE7] = 0x00C1, + [0xE8] = 0x00CB, [0xE9] = 0x00C8, [0xEA] = 0x00CD, [0xEB] = 0x00CE, + [0xEC] = 0x00CF, [0xED] = 0x00CC, [0xEE] = 0x00D3, [0xEF] = 0x00D4, + [0xF0] = 0xF8FF, [0xF1] = 0x00D2, [0xF2] = 0x00DA, [0xF3] = 0x00DB, + [0xF4] = 0x00D9, [0xF5] = 0x0131, [0xF6] = 0x02C6, [0xF7] = 0x02DC, + [0xF8] = 0x00AF, [0xF9] = 0x02D8, [0xFA] = 0x02D9, [0xFB] = 0x02DA, + [0xFC] = 0x00B8, [0xFD] = 0x02DD, [0xFE] = 0x02DB, [0xFF] = 0x02C7, + } + function macroman2utf8(s) + local bytes = {string.byte(s, 1, -1)} + for i=1,#bytes do + bytes[i] = mapping[bytes[i]] or bytes[i] + end + return utf8.char(table.unpack(bytes)) + end +end local sanitize_fontname = function (str) if str ~= nil then - if utf8len(str) then - str = alphnum_only(casefold(str, true)) - else - str = stringgsub(stringlower(str), invalidchars, "") - end + str = utf8len(str) and str or macroman2utf8(str) + str = alphnum_only(casefold(str, true)) return str end return nil @@ -258,19 +296,13 @@ local sanitize_fontnames = function (rawnames) for category, namedata in next, rawnames do if type (namedata) == "string" then - if utf8len(namedata) then - result [category] = alphnum_only(casefold(namedata, true)) - else - result [category] = stringgsub(stringlower(namedata), invalidchars, "") - end + namedata = utf8len(namedata) and namedata or macroman2utf8(namedata) + result [category] = alphnum_only(casefold(namedata, true)) else local target = { } for field, name in next, namedata do - if utf8len(name) then - target [field] = alphnum_only(casefold(name, true)) - else - target [field] = stringgsub(stringlower(name), invalidchars, "") - end + name = utf8len(name) and name or macroman2utf8(name) + target [field] = alphnum_only(casefold(name, true)) end result [category] = target end @@ -2520,14 +2552,13 @@ local collect_font_filenames_local = function () local files = collect_font_filenames_dir (pwd, "local") local nfiles = #files if nfiles > 0 then - targetnames.meta["local"] = true --- prevent saving to disk logreport ("term", 1, "db", "Found %d files.", pwd) else logreport ("term", 1, "db", "Couldn’t find a thing here. What a waste.", pwd) end logreport ("term", 3, "db", "Collected %d files.", #files) - return files + return files, nfiles > 0 end --- fontentry list -> filemap @@ -3083,8 +3114,14 @@ local collect_font_filenames = function () tableappend (filenames, collect_font_filenames_texmf ()) tableappend (filenames, collect_font_filenames_system ()) - if config.luaotfload.db.scan_local == true then - tableappend (filenames, collect_font_filenames_local ()) + local scan_local = config.luaotfload.db.scan_local == true + if scan_local then + local localfonts, found = collect_font_filenames_local() + if found then + tableappend (filenames, localfonts) + else + scan_local = false + end end --- Now drop everything above max_fonts. if max_fonts < #filenames then @@ -3094,7 +3131,7 @@ local collect_font_filenames = function () if bisect then return { unpack (filenames, bisect[1], bisect[2]) } end - return filenames + return filenames, scan_local end --[[doc-- @@ -3365,7 +3402,10 @@ update_names = function (currentnames, force, dry_run) read_blacklist () --- pass 1: Collect the names of all fonts we are going to process. - local font_filenames = collect_font_filenames () + local font_filenames, local_fonts = collect_font_filenames () + if local_fonts then + targetnames.meta['local'] = true + end --- pass 2: read font files (normal case) or reuse information --- present in index diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-diagnostics.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-diagnostics.lua index 8ef443aedca..b38c1add0d2 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-diagnostics.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-diagnostics.lua @@ -7,8 +7,8 @@ local ProvidesLuaModule = { name = "luaotfload-diagnostics", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload-tool submodule / diagnostics", license = "GPL v2.0" } diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-embolden.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-embolden.lua index 5229c009f79..bd2237f0869 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-embolden.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-embolden.lua @@ -5,8 +5,8 @@ local ProvidesLuaModule = { name = "luaotfload-embolden", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload submodule / color", license = "GPL v2.0", author = "Marcel Krüger" diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-features.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-features.lua index 1d41cfd1925..3901d940dd8 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-features.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-features.lua @@ -5,8 +5,8 @@ local ProvidesLuaModule = { name = "luaotfload-features", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload submodule / features", license = "GPL v2.0", author = "Hans Hagen, Khaled Hosny, Elie Roux, Philipp Gesang, Marcel Krüger", diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-filelist.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-filelist.lua index 612822440fc..ade50b43166 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-filelist.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-filelist.lua @@ -6,8 +6,8 @@ local ProvidesLuaModule = { name = "luaotfload-filelist", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload submodule / filelist", license = "GPL v2.0" } @@ -249,6 +249,7 @@ luaotfload.filelist.data = { name = "embolden" ,kind = kind_library, ext =".lua", gitdir=gitdirsrc, texdir=texdirtex, gitpref = "luaotfload-" }, { name = "notdef" ,kind = kind_library, ext =".lua", gitdir=gitdirsrc, texdir=texdirtex, gitpref = "luaotfload-" }, { name = "loaders" ,kind = kind_library, ext =".lua", gitdir=gitdirsrc, texdir=texdirtex, gitpref = "luaotfload-" }, + { name = "multiscript" ,kind = kind_library, ext =".lua", gitdir=gitdirsrc, texdir=texdirtex, gitpref = "luaotfload-" }, { name = "parsers" ,kind = kind_library, ext =".lua", gitdir=gitdirsrc, texdir=texdirtex, gitpref = "luaotfload-" }, { name = "resolvers" ,kind = kind_library, ext =".lua", gitdir=gitdirsrc, texdir=texdirtex, gitpref = "luaotfload-" }, { name = "unicode" ,kind = kind_library, ext =".lua", gitdir=gitdirsrc, texdir=texdirtex, gitpref = "luaotfload-" }, diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-glyphlist.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-glyphlist.lua index 43c927b3d3a..1ba46ab0d76 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-glyphlist.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-glyphlist.lua @@ -1,7 +1,7 @@ local ProvidesLuaModule = { name = "luaotfload-glyphlist", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload submodule / autogenerated glyphlist", copyright = "derived from https://raw.githubusercontent.com/adobe-type-tools/agl-aglfn/master/glyphlist.txt", original = "Adobe Glyph List, version 2.0, September 20, 2002", diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-init.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-init.lua index 9c932892f40..6a80546d436 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-init.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-init.lua @@ -7,8 +7,8 @@ local ProvidesLuaModule = { name = "luaotfload-init", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload submodule / initialization", license = "GPL v2.0" } @@ -462,6 +462,14 @@ end --- [init_adapt] local init_main = function () + --[[doc-- + + First save a copy of font.each in order to also catch old-style fonts + + --doc]]-- + + font.originaleach = font.each + local load_fontloader_module = luaotfload.loaders.fontloader local ignore_module = luaotfload.loaders.ignore @@ -648,7 +656,11 @@ local init_post_install_callbacks = function () -- MK Pass current text direction to simple_font_handler local handler = nodes.simple_font_handler local callback = function(head, groupcode, _, _, direction) - return handler(head, groupcode, nil, nil, direction or tex.get'textdir') + if not direction then + direction = tex.get'textdir' + end + domultiscript(head, nil, nil, nil, direction) + return handler(head, groupcode, nil, nil, direction) end luatexbase.add_to_callback("pre_linebreak_filter", callback, diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-letterspace.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-letterspace.lua index 1acf67df8bc..bbd045e4f8c 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-letterspace.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-letterspace.lua @@ -5,8 +5,8 @@ local ProvidesLuaModule = { name = "luaotfload-letterspace", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload submodule / color", license = "GPL v2.0", copyright = "PRAGMA ADE / ConTeXt Development Team", diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-loaders.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-loaders.lua index 39ffd243f70..11e63c571aa 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-loaders.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-loaders.lua @@ -8,8 +8,8 @@ local ProvidesLuaModule = { name = "luaotfload-loaders", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload submodule / callback handling", license = "GPL v2.0" } diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-log.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-log.lua index 17938ffd3d0..04012632fa6 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-log.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-log.lua @@ -6,8 +6,8 @@ local ProvidesLuaModule = { name = "luaotfload-log", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload submodule / logging", license = "GPL v2.0", author = "Khaled Hosny, Elie Roux, Philipp Gesang", diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-main.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-main.lua index 6c4b9201812..26bbfab5066 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-main.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-main.lua @@ -20,8 +20,8 @@ local authors = "\z -- version number is used below! local ProvidesLuaModule = { name = "luaotfload-main", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload entry point", author = authors, copyright = authors, @@ -301,6 +301,7 @@ luaotfload.main = function () loadmodule "embolden" --- fake bold loadmodule "notdef" --- missing glyph handling initialize "auxiliary" --- additional high-level functionality + loadmodule "multiscript" --- ... luaotfload.aux.start_rewrite_fontname () --- to be migrated to fontspec diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-multiscript.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-multiscript.lua new file mode 100644 index 00000000000..ed3aef05c36 --- /dev/null +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-multiscript.lua @@ -0,0 +1,208 @@ +----------------------------------------------------------------------- +-- FILE: luaotfload-multiscript.lua +-- DESCRIPTION: part of luaotfload / multiscript +----------------------------------------------------------------------- + +local ProvidesLuaModule = { + name = "luaotfload-multiscript", + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE + description = "luaotfload submodule / multiscript", + license = "GPL v2.0", + author = "Marcel Krüger" +} + +if luatexbase and luatexbase.provides_module then + luatexbase.provides_module (ProvidesLuaModule) +end + +local nodenew = node.direct.new +local getfont = font.getfont +local setfont = node.direct.setfont +local getwhd = node.direct.getwhd +local insert_after = node.direct.insert_after +local traverse_char = node.direct.traverse_char +local protect_glyph = node.direct.protect_glyph +local otffeatures = fonts.constructors.newfeatures "otf" + +local sep = lpeg.P' '^0 * ';' * lpeg.P' '^0 +local codepoint = lpeg.S'0123456789ABCDEF'^4/function(c)return tonumber(c, 16)end +local codepoint_range = codepoint * ('..' * codepoint + lpeg.Cc(false)) +local function multirawset(table, key1, key2, value) + for key = key1,(key2 or key1) do + rawset(table, key, value) + end + return table +end +local script_extensions do + local entry = lpeg.Cg(codepoint_range * sep * lpeg.Ct((lpeg.C(lpeg.R'AZ' * lpeg.R'az'^1))^1 * ' ') * '#')^-1 * (1-lpeg.P'\n')^0 * '\n' + local file = lpeg.Cf( + lpeg.Ct'' + * entry^0 + , multirawset) + + local f = io.open(kpse.find_file"ScriptExtensions.txt") + script_extensions = file:match(f:read'*a') + f:close() + for cp,t in next, script_extensions do + for i=1,#t do + t[t[i]] = true + end + end +end +local script_mapping do + -- We could extract these from PropertyValueAliases.txt... + local script_aliases = { + Adlam = "Adlm", Caucasian_Albanian = "Aghb", Ahom = "Ahom", Arabic = "Arab", + Imperial_Aramaic = "Armi", Armenian = "Armn", Avestan = "Avst", + Balinese = "Bali", Bamum = "Bamu", Bassa_Vah = "Bass", Batak = "Batk", + Bengali = "Beng", Bhaiksuki = "Bhks", Bopomofo = "Bopo", Brahmi = "Brah", + Braille = "Brai", Buginese = "Bugi", Buhid = "Buhd", Chakma = "Cakm", + Canadian_Aboriginal = "Cans", Carian = "Cari", Cham = "Cham", + Cherokee = "Cher", Coptic = "Copt", Cypriot = "Cprt", Cyrillic = "Cyrl", + Devanagari = "Deva", Dogra = "Dogr", Deseret = "Dsrt", Duployan = "Dupl", + Egyptian_Hieroglyphs = "Egyp", Elbasan = "Elba", Elymaic = "Elym", + Ethiopic = "Ethi", Georgian = "Geor", Glagolitic = "Glag", + Gunjala_Gondi = "Gong", Masaram_Gondi = "Gonm", Gothic = "Goth", + Grantha = "Gran", Greek = "Grek", Gujarati = "Gujr", Gurmukhi = "Guru", + Hangul = "Hang", Han = "Hani", Hanunoo = "Hano", Hatran = "Hatr", + Hebrew = "Hebr", Hiragana = "Hira", Anatolian_Hieroglyphs = "Hluw", + Pahawh_Hmong = "Hmng", Nyiakeng_Puachue_Hmong = "Hmnp", + Katakana_Or_Hiragana = "Hrkt", Old_Hungarian = "Hung", Old_Italic = "Ital", + Javanese = "Java", Kayah_Li = "Kali", Katakana = "Kana", + Kharoshthi = "Khar", Khmer = "Khmr", Khojki = "Khoj", Kannada = "Knda", + Kaithi = "Kthi", Tai_Tham = "Lana", Lao = "Laoo", Latin = "Latn", + Lepcha = "Lepc", Limbu = "Limb", Linear_A = "Lina", Linear_B = "Linb", + Lisu = "Lisu", Lycian = "Lyci", Lydian = "Lydi", Mahajani = "Mahj", + Makasar = "Maka", Mandaic = "Mand", Manichaean = "Mani", Marchen = "Marc", + Medefaidrin = "Medf", Mende_Kikakui = "Mend", Meroitic_Cursive = "Merc", + Meroitic_Hieroglyphs = "Mero", Malayalam = "Mlym", Modi = "Modi", + Mongolian = "Mong", Mro = "Mroo", Meetei_Mayek = "Mtei", Multani = "Mult", + Myanmar = "Mymr", Nandinagari = "Nand", Old_North_Arabian = "Narb", + Nabataean = "Nbat", Newa = "Newa", Nko = "Nkoo", Nushu = "Nshu", + Ogham = "Ogam", Ol_Chiki = "Olck", Old_Turkic = "Orkh", Oriya = "Orya", + Osage = "Osge", Osmanya = "Osma", Palmyrene = "Palm", Pau_Cin_Hau = "Pauc", + Old_Permic = "Perm", Phags_Pa = "Phag", Inscriptional_Pahlavi = "Phli", + Psalter_Pahlavi = "Phlp", Phoenician = "Phnx", Miao = "Plrd", + Inscriptional_Parthian = "Prti", Rejang = "Rjng", Hanifi_Rohingya = "Rohg", + Runic = "Runr", Samaritan = "Samr", Old_South_Arabian = "Sarb", + Saurashtra = "Saur", SignWriting = "Sgnw", Shavian = "Shaw", + Sharada = "Shrd", Siddham = "Sidd", Khudawadi = "Sind", Sinhala = "Sinh", + Sogdian = "Sogd", Old_Sogdian = "Sogo", Sora_Sompeng = "Sora", + Soyombo = "Soyo", Sundanese = "Sund", Syloti_Nagri = "Sylo", + Syriac = "Syrc", Tagbanwa = "Tagb", Takri = "Takr", Tai_Le = "Tale", + New_Tai_Lue = "Talu", Tamil = "Taml", Tangut = "Tang", Tai_Viet = "Tavt", + Telugu = "Telu", Tifinagh = "Tfng", Tagalog = "Tglg", Thaana = "Thaa", + Thai = "Thai", Tibetan = "Tibt", Tirhuta = "Tirh", Ugaritic = "Ugar", + Vai = "Vaii", Warang_Citi = "Wara", Wancho = "Wcho", Old_Persian = "Xpeo", + Cuneiform = "Xsux", Yi = "Yiii", Zanabazar_Square = "Zanb", + Inherited = "Zinh", Common = "Zyyy", Unknown = "Zzzz", + } + local entry = lpeg.Cg(codepoint_range * sep * ((lpeg.R'AZ' + lpeg.R'az' + '_')^1/script_aliases))^-1 * (1-lpeg.P'\n')^0 * '\n' + -- local entry = lpeg.Cg(codepoint_range * sep * lpeg.Cc(true))^-1 * (1-lpeg.P'\n')^0 * '\n' + local file = lpeg.Cf( + lpeg.Ct'' + * entry^0 + , multirawset) + + local f = io.open(kpse.find_file"Scripts.txt") + script_mapping = file:match(f:read'*a') + f:close() +end + +local additional_scripts_tables = { } + +local additional_scripts_fonts = setmetatable({}, { + __index = function(t, fid) + local f = font.getfont(fid) + -- table.tofile('myfont2', f) + local res = f and f.additional_scripts or false + t[fid] = res + return res + end, +}) + +local function makecombifont(tfmdata, _, additional_scripts) + local basescript = tfmdata.properties.script + local scripts = {basescript = false} + additional_scripts = additional_scripts_tables[additional_scripts] + for script, fontname in pairs(additional_scripts) do + if script ~= basescript then + local f = fonts.definers.read(fontname, tfmdata.size) + local fid + if type(f) == 'table' then + fid = font.define(f) + else + error[[FIXME???]] + end + scripts[script] = { + fid = fid, + font = f, + characters = f.characters, + } + end + end + tfmdata.additional_scripts = scripts +end + +local glyph_id = node.id'glyph' +-- TODO: unset last_script, matching parentheses etc +function domultiscript(head, _, _, _, direction) + head = node.direct.todirect(head) + local last_fid, last_fonts, last_script + for cur, cid, fid in traverse_char(head) do + if fid ~= last_fid then + last_fid, last_fonts, last_script = fid, additional_scripts_fonts[fid] + end + if last_fonts then + local mapped_scr = script_mapping[cid] + if mapped_scr == "Zinh" then + mapped_scr = last_script + else + local additional_scr = script_extensions[cid] + if additional_scripts then + if additional_scripts[last_script] then + mapped_scr = last_script + elseif not last_fonts[mapped_scr] then + for i = 1, #additional_scripts do + if last_fonts[additional_scripts[i]] then + mapped_scr = additional_scripts[i] + break + end + end + end + elseif mapped_scr == "Zyyy" then + mapped_scr = last_script + end + end + last_script = mapped_scr + local mapped_font = last_fonts[mapped_scr] + if mapped_font then + setfont(cur, mapped_font.fid) + end + end + end +end + +function luaotfload.add_multiscript(name, fonts) + if fonts == nil then + fonts = name + name = #additional_scripts_fonts + 1 + end + additional_scripts_tables[name] = fonts + return name +end + +otffeatures.register { + name = "multiscript", + description = "Combine fonts for multiple scripts", + manipulators = { + node = makecombifont, + }, + -- processors = { -- processors would be nice, but they are applied + -- -- too late for our purposes + -- node = donotdef, + -- } +} + +--- vim:sw=2:ts=2:expandtab:tw=71 diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-notdef.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-notdef.lua index 196ea928bbb..0cc972a0e3e 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-notdef.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-notdef.lua @@ -5,8 +5,8 @@ local ProvidesLuaModule = { name = "luaotfload-notdef", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload submodule / color", license = "GPL v2.0", author = "Marcel Krüger" @@ -16,14 +16,69 @@ if luatexbase and luatexbase.provides_module then luatexbase.provides_module (ProvidesLuaModule) end -local nodenew = node.direct.new +local flush_node = node.direct.flush_node local getfont = font.getfont -local setfont = node.direct.setfont +local getnext = node.direct.getnext local getwhd = node.direct.getwhd +local insert = table.insert local insert_after = node.direct.insert_after -local traverse_char = node.direct.traverse_char +local kern_id = node.id'kern' +local nodenew = node.direct.new +local otfregister = fonts.constructors.features.otf.register local protect_glyph = node.direct.protect_glyph -local otffeatures = fonts.constructors.newfeatures "otf" +local remove = node.direct.remove +local setfont = node.direct.setfont +local traverse_char = node.direct.traverse_char + +-- According to DerivedCoreProperties.txt, Default_Ignorable_Code_Point +-- is generated from: +-- Other_Default_Ignorable_Code_Point +-- + Cf (Format characters) +-- + Variation_Selector +-- - White_Space +-- - FFF9..FFFB (Interlinear annotation format characters) +-- - 13430..13438 (Egyptian hieroglyph format characters) +-- - Prepended_Concatenation_Mark (Exceptional format characters that should be visible) +-- Based on HarfBuzz, we add the exclusion +-- - Lo (Letter, Other) +-- This affects Hangul fillers. +local ignorable_codepoints do + local sep = lpeg.P' '^0 * ';' * lpeg.P' '^0 + local codepoint = lpeg.S'0123456789ABCDEF'^4/function(c)return tonumber(c, 16)end + local codepoint_range = codepoint * ('..' * codepoint + lpeg.Cc(false)) + local function multirawset(table, key1, key2, value) + for key = key1,(key2 or key1) do + rawset(table, key, value) + end + return table + end + local entry = lpeg.Cg(codepoint * ';' * (1-lpeg.P';')^0 * ';Cf;' * lpeg.Cc(true))^-1 * (1-lpeg.P'\n')^0 * '\n' + local file = lpeg.Cf( + lpeg.Ct'' + * entry^0 + , rawset) + local f = io.open(kpse.find_file"UnicodeData.txt") + ignorable_codepoints = file:match(f:read'*a') + f:close() + entry = lpeg.Cg(codepoint_range * sep * ('Other_Default_Ignorable_Code_Point' * lpeg.Cc(true) + + 'Variation_Selector' * lpeg.Cc(true) + + 'White_Space' * lpeg.Cc(nil) + + 'Prepended_Concatenation_Mark' * lpeg.Cc(nil) + ) * ' # ' * (1-lpeg.P'Lo'))^-1 * (1-lpeg.P'\n')^0 * '\n' + file = lpeg.Cf( + lpeg.Carg(1) + * entry^0 + , multirawset) + f = io.open(kpse.find_file"PropList.txt") + ignorable_codepoints = file:match(f:read'*a', 1, ignorable_codepoints) + f:close() + for i = 0xFFF9,0xFFFB do + ignorable_codepoints[i] = nil + end + for i = 0x13430,0x13438 do + ignorable_codepoints[i] = nil + end +end local function setnotdef(tfmdata, factor) local desc = tfmdata.shared.rawdata.descriptions @@ -35,7 +90,6 @@ local function setnotdef(tfmdata, factor) tfmdata.notdefcode = 0xF0000 return end - print')' -- If this didn't happen, it might be mapped to one of the -- replacement characters: for code = 0xFFFC,0xFFFF do @@ -45,7 +99,6 @@ local function setnotdef(tfmdata, factor) return end end - print')))' -- Oh no, we couldn't find it. Maybe we can find it by name? local code = tfmdata.resources.unicodes[".notdef"] -- Better safe than sorry @@ -54,7 +107,6 @@ local function setnotdef(tfmdata, factor) tfmdata.notdefcode = code return end - print'))))' -- So the font didn't do the obvious things and then it lied to us. -- At this point we should think about sending an automated complain -- to the font author, but we probably can't trust the contact @@ -81,7 +133,7 @@ local function donotdef(head, font, _, _, _) if not notdef then return end for cur, cid, fid in traverse_char(head) do if fid == font then local w, h, d = getwhd(cur) - if w == 0 and h == 0 and d == 0 and not chars[cid] then + if w == 0 and h == 0 and d == 0 and not chars[cid] and not ignorable_codepoints[cid] then local notdefnode = nodenew(glyph_id, 256) setfont(notdefnode, font, notdef) insert_after(cur, cur, notdefnode) @@ -90,7 +142,7 @@ local function donotdef(head, font, _, _, _) end end end -otffeatures.register { +otfregister { name = "notdef", description = "Add notdef glyphs", default = 1, @@ -102,4 +154,43 @@ otffeatures.register { } } +function fonts.handlers.otf.handlers.gsub_remove(head,char,dataset,sequence,replacement) + local next + head, next = remove(head, char) + flush_node(char) + if not head and not next then -- Avoid a double free if we were alone + head = nodenew(kern_id) + end + return head, next, true, true +end + +local sequence = { + features = {invisible = {["*"] = {["*"] = true}}}, + flags = {false, false, false, false}, + name = "invisible", + order = {"invisible"}, + nofsteps = 1, + steps = {{ + coverage = ignorable_codepoints, + index = 1, + }}, + type = "gsub_remove", +} +local function invisibleinitialiser(tfmdata, value) + local resources = tfmdata.resources + local sequences = resources and resources.sequences + if sequences then + -- Now we get to the interesting part: At which point should our new sequence be inserted? Let's do it at the end, then they are still seen by all features. + insert(sequences, sequence) + end +end +otfregister { + name = 'invisible', + description = 'Remove invisible control characters', + default = true, + initializers = { + node = invisibleinitialiser, + }, +} + --- vim:sw=2:ts=2:expandtab:tw=71 diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-parsers.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-parsers.lua index 5a7ccd576f5..f9fd5c919e4 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-parsers.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-parsers.lua @@ -7,8 +7,8 @@ local ProvidesLuaModule = { name = "luaotfload-parsers", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload submodule / filelist", license = "GPL v2.0" } diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-resolvers.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-resolvers.lua index 839155a9796..5146f1d20e6 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-resolvers.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-resolvers.lua @@ -11,8 +11,8 @@ local ProvidesLuaModule = { name = "luaotfload-resolvers", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload submodule / resolvers", license = "GPL v2.0" } diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-status.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-status.lua index bd7b3289797..69948c43caa 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-status.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-status.lua @@ -55,36 +55,37 @@ return { { "fontloader-reference.lua", "759787e7ee75437382c0a2c4f8fe3b81" }, { "fontloader-basics-gen.lua", "b21e91bbd534f77e368f0ec13f865aed" }, { "mktests", "c7cff7025962922944376acc1ffa9c47" }, - { "mkstatus", "d84c8b2ae4c2335c5dbd9fba4846f0e9" }, + { "mkstatus", "64b9a6b302168fced414830a53fdcce1" }, { "mkcharacters", "92c24bb582fc84c0365634f29eb89863" }, { "mkglyphlist", "557836886d4f0e6d656eac3ded4456a2" }, { "mkimport", "60e0b11a1a68719033e86a3e0f4d5e86" }, - { "luaotfload-glyphlist.lua", "8a1cbf89f48a8ebe05a13345352a3435" }, + { "luaotfload-glyphlist.lua", "df822678061548ce6b510a0c1c7fc103" }, { "luaotfload-characters.lua", "593ce9dccf6ddc4f7d4be0514f581102" }, - { "luaotfload-unicode.lua", "aac378708c062d4de18132ae7600526f" }, - { "luaotfload-resolvers.lua", "7e777d41afc10c928cd26dccfed6ba09" }, - { "luaotfload-parsers.lua", "c69570b5f57d26abff8304f3a8eade58" }, - { "luaotfload-loaders.lua", "920578f2f66758755c20fbf3539b3542" }, - { "luaotfload-notdef.lua", "a4a40c92368510dcd81f6e95124bb2d3" }, - { "luaotfload-embolden.lua", "4b6a0240b0f696d63cf2b343603fc742" }, - { "luaotfload-letterspace.lua", "29453f635acb72ef76ec19942ce0449b" }, - { "luaotfload-features.lua", "1c837c95c485d54204157fd3840e177e" }, - { "luaotfload-database.lua", "3a3d0cbb02b0c9ff53b0dab969c7a879" }, - { "luaotfload-configuration.lua", "37ffbef314b79ca2ae9bfaf4e4552207" }, - { "luaotfload-colors.lua", "9b1ffa13d20cc4d1f2016e8d5b0939f1" }, - { "luaotfload-auxiliary.lua", "99ff2ebee659717c2d1f9999e3ab4448" }, - { "luaotfload-filelist.lua", "9de0e08f4b15acd7c56602ef362967e1" }, - { "luaotfload-tool.lua", "4a1be51390301a48480681e66d9be64f" }, - { "luaotfload-diagnostics.lua", "8c50e2459731ca15a511e4bd0b0d7685" }, - { "luaotfload-log.lua", "981ccf90bb3a970b056dbfa87046b36d" }, - { "luaotfload-init.lua", "acfe693817999d5c09272f3b33fe1aad" }, - { "luaotfload-main.lua", "80b07ab0301a7b8fb5d03acec1b5c5dc" }, + { "luaotfload-unicode.lua", "d9ce2f2a07e951be6310e85fdfcc785d" }, + { "luaotfload-resolvers.lua", "0b0d407501e68537971484ac2256af20" }, + { "luaotfload-parsers.lua", "9b199d5157d9972c415aee7f9350df5b" }, + { "luaotfload-multiscript.lua", "3a4cfa1687c9d1694cbf728183bb066e" }, + { "luaotfload-loaders.lua", "007be1e29cf23779f4d9d0097b56cc4a" }, + { "luaotfload-notdef.lua", "982810e9197d2261ffdc3acd5d8dcecf" }, + { "luaotfload-embolden.lua", "92dfba7dbf10484c85f7e3c971691f8e" }, + { "luaotfload-letterspace.lua", "bb123f78712cc0342419f3c2a5f6a940" }, + { "luaotfload-features.lua", "45ab2c6405c678f8834339fe0d9fb47a" }, + { "luaotfload-database.lua", "da3c5b55a086a2213ee825ecc2bf7e0f" }, + { "luaotfload-configuration.lua", "015022f5b9597254afafff26f9f0f98c" }, + { "luaotfload-colors.lua", "81a23496c5f5c855674b05180869b8cf" }, + { "luaotfload-auxiliary.lua", "81432ebaebfce3df73b5949e1001d13c" }, + { "luaotfload-filelist.lua", "aa3c9fa695042573d6f6c2e5d0c23558" }, + { "luaotfload-tool.lua", "1833a47868c3e5958d492bb947d39dec" }, + { "luaotfload-diagnostics.lua", "53dbf51623658f1e325d2e6279a2ee15" }, + { "luaotfload-log.lua", "30491ef5890898d5ae3af44f72e82b1f" }, + { "luaotfload-init.lua", "479854a620629b1934d16723aa4cae0c" }, + { "luaotfload-main.lua", "95c7d3ce348ac83e0659f7332e98eacc" }, }, ["notes"]={ - ["committer"]="Ulrike Fischer ", - ["description"]="v2.991/2019-08-11", + ["committer"]="Marcel Fabian Krüger ", + ["description"]="v3.00/2019-09-13", ["loader"]="fontloader-2019-08-11.lua", - ["revision"]="a86a6798c324c745af7b04f33fa188298d749a2a", - ["timestamp"]="2019-08-19 19:38:30 +0200", + ["revision"]="e758f5d39e3d416e4bc1e2a23918abed744563ae", + ["timestamp"]="2019-09-13 00:43:25 +0200", }, } \ No newline at end of file diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-unicode.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-unicode.lua index 928bfcec967..d7cb98a3387 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-unicode.lua +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-unicode.lua @@ -5,8 +5,8 @@ local ProvidesLuaModule = { name = "luaotfload-unicode", - version = "2.991", --TAGVERSION - date = "2019-08-11", --TAGDATE + version = "3.00", --TAGVERSION + date = "2019-09-13", --TAGDATE description = "luaotfload submodule / Unicode helpers", license = "CC0 1.0 Universal", author = "Marcel Krüger" diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.sty b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.sty index 69f2a4151f1..1dede25f2fd 100644 --- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.sty +++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload.sty @@ -40,7 +40,7 @@ \fi \ifdefined\ProvidesPackage \ProvidesPackage{luaotfload}% - [2019/08/11 v2.991 OpenType layout system] + [2019/09/13 v3.00 OpenType layout system] \fi \directlua{ if xpcall(function ()% -- cgit v1.2.3