diff options
author | Karl Berry <karl@freefriends.org> | 2018-09-26 20:50:34 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-09-26 20:50:34 +0000 |
commit | 78334b0d4607b242273f9d0cde94f6a6fba51832 (patch) | |
tree | 5b604ee30bb611eeeae95ed4218b4e7fd6eb00b8 /Master/texmf-dist/scripts | |
parent | 3a0140d05a7e481750ec23a30ed5cf3cdef61eb7 (diff) |
luaotfload (26sep18)
git-svn-id: svn://tug.org/texlive/trunk@48771 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rwxr-xr-x | Master/texmf-dist/scripts/luaotfload/luaotfload-tool.lua | 4 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/luaotfload/mkcharacters | 226 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/luaotfload/mkglyphlist | 167 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/luaotfload/mkimport | 1063 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/luaotfload/mkstatus | 307 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/luaotfload/mktests | 362 |
6 files changed, 2 insertions, 2127 deletions
diff --git a/Master/texmf-dist/scripts/luaotfload/luaotfload-tool.lua b/Master/texmf-dist/scripts/luaotfload/luaotfload-tool.lua index e7df3ce4482..75144922799 100755 --- a/Master/texmf-dist/scripts/luaotfload/luaotfload-tool.lua +++ b/Master/texmf-dist/scripts/luaotfload/luaotfload-tool.lua @@ -2,13 +2,13 @@ ----------------------------------------------------------------------- -- FILE: luaotfload-tool.lua -- DESCRIPTION: database functionality --- REQUIREMENTS: luaotfload 2.8 +-- REQUIREMENTS: luaotfload 2.9 -- AUTHOR: Khaled Hosny, Élie Roux, Philipp Gesang -- LICENSE: GPL v2.0 ----------------------------------------------------------------------- luaotfload = luaotfload or { } -local version = "2.8" +local version = "2.9" luaotfload.version = version luaotfload.min_luatex_version = { 0, 95, 0 } luaotfload.self = "luaotfload-tool" diff --git a/Master/texmf-dist/scripts/luaotfload/mkcharacters b/Master/texmf-dist/scripts/luaotfload/mkcharacters deleted file mode 100755 index a31c19c035e..00000000000 --- a/Master/texmf-dist/scripts/luaotfload/mkcharacters +++ /dev/null @@ -1,226 +0,0 @@ -#!/usr/bin/env texlua ------------------------------------------------------------------------ --- FILE: mkcharacters.lua --- USAGE: ./mkcharacters.lua --- DESCRIPTION: import parts of char-def.lua --- REQUIREMENTS: lua, ConTeXt, the lualibs package --- AUTHOR: Philipp Gesang (Phg), <phg@phi-gamma.net> ------------------------------------------------------------------------ --- We create a stripped-down version of char-def.lua, suitable for use --- with the generic font loader. ------------------------------------------------------------------------ - ------------------------------------------------------------------------ --- config ------------------------------------------------------------------------ -local mkivpath = arg[1] -local charfile = arg[2] or "./build/luaotfload-characters.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 -} - ------------------------------------------------------------------------ --- includes ------------------------------------------------------------------------ - -kpse.set_program_name"luatex" - -require "lualibs" - -local chardef -local charini - -if not mkivpath then - mkivpath = assert (kpse.expand_path - "~/context/tex/texmf-context/tex/context/base/mkiv/", - "Failed to locate ConTeXt.") -end - -chardef = mkivpath .. "/char-def.lua" -charini = mkivpath .. "/char-ini.lua" - ---- we could grab the files from contextgarden but as Context is part ---- of TL it’s not worth bothering -if not (chardef and lfs.isfile(chardef)) then - chardef = assert(kpse.find_file("char-def.lua", "lua"), - "Failed to locate file char-def.lua from ConTeXt.") -end - -if not (charini and lfs.isfile(charini)) then - charini = assert(kpse.find_file("char-ini.lua", "lua"), - "Failed to locate file char-ini.lua from ConTeXt.") -end - -io.write(string.format("extracting data from char-def.lua at %s\n", - chardef)) -io.write(string.format("loading code from char-ini.lua at %s\n", - charini)) - ------------------------------------------------------------------------ --- functionality ------------------------------------------------------------------------ - -local get_characters = function ( ) - local data - local inchan = io.open(chardef, "r") - if not inchan then - io.write("Could not open file for reading: "..chardef.."\n.") - goto fail - end - data = inchan:read "*all" - inchan:close() - data = loadstring(data) - if data then - data() --> characters.data - data = nil - collectgarbage "collect" - if characters.data and next(characters.data) then - return characters.data - end - io.write "Character table empty.\n" - goto fail - end - io.write(chardef .. " is not a valid Lua file.\n") - ::fail:: - io.write "Emergency exit.\n" - os.exit(1) -end - -local extract_fields_indeed -extract_fields_indeed = function (data, acc, lastidx) - local idx, char = next(data, lastidx) - if idx then - local imported = { } - for i=1, #import do - local field = import[i] - imported[field] = char[field] - end - acc[idx] = imported - return extract_fields_indeed(data, acc, idx) - end - return acc -end - -local extract_fields = function (data) - return extract_fields_indeed(data, {}, nil) -end - ---[[ extract_classifiers : from luatex-basics-prepare.tex ]] - -local extract_classifiers = function (chardata) - dofile (charini) - local s_init = 1 local s_rphf = 7 - local s_medi = 2 local s_half = 8 - local s_fina = 3 local s_pref = 9 - local s_isol = 4 local s_blwf = 10 - local s_mark = 5 local s_pstf = 11 - local s_rest = 6 - - local mappers = { - l = s_init, -- left - d = s_medi, -- double - c = s_medi, -- joiner - r = s_fina, -- right - u = s_isol, -- nonjoiner - } - - local first_arabic, last_arabic = characters.blockrange("arabic") - local first_syriac, last_syriac = characters.blockrange("syriac") - local first_mandiac, last_mandiac = characters.blockrange("mandiac") - local first_nko, last_nko = characters.blockrange("nko") - - local classifiers = { } - - for k, c in next, chardata do - if k > 0 then - local c = chardata[k] - if c then - local arabic = c.arabic - if arabic then - classifiers[k] = mappers[arabic] - elseif k >= first_arabic and k <= last_arabic or k >= first_syriac and k <= last_syriac or - k >= first_mandiac and k <= last_mandiac or k >= first_nko and k <= last_nko then - if c.category == "mn" then - classifiers[k] = s_mark - else - classifiers[k] = s_rest - end - end - end - end - end - return classifiers - end - -local amend_table_fields = function (data, classifiers) - --- installed by luatex-basics-prepare.tex - data.characters = { } - data.classifiers = classifiers - return data -end - -local writedata = function (data) - local outchan = io.open(charfile, "w") - if not outchan then - io.write("Could not open "..charfile.." for writing.\n") - return false - end - outchan:write(data) - outchan:close() - return true -end - -do - local chardata = get_characters() - local classifiers = extract_classifiers(chardata) - local stripped = extract_fields(chardata) - local amended = amend_table_fields(stripped, classifiers) - local serialized = table.serialize(amended, true, { - compact = true, - noquotes = true, - hexify = true, --- for consistency with char-def - }) - if writedata(serialized) then - goto done - end - goto fail -end - -::done:: - os.exit(0) - -::fail:: - io.write "Emergency exit.\n" - os.exit(1) - ---- vim:ft=lua:ts=2:et:sw=2 diff --git a/Master/texmf-dist/scripts/luaotfload/mkglyphlist b/Master/texmf-dist/scripts/luaotfload/mkglyphlist deleted file mode 100755 index b9d5309d529..00000000000 --- a/Master/texmf-dist/scripts/luaotfload/mkglyphlist +++ /dev/null @@ -1,167 +0,0 @@ -#!/usr/bin/env texlua ------------------------------------------------------------------------ --- FILE: mkglyphlist.lua --- USAGE: ./mkglyphlist.lua --- DESCRIPTION: part of the luaotfload package --- REQUIREMENTS: lua, lpeg, luasocket, the lualibs package --- AUTHOR: Philipp Gesang (Phg), <phg42.2a@gmail.com> ------------------------------------------------------------------------ --- interesting thread on the Context list: --- http://www.ntg.nl/pipermail/ntg-context/2008/029057.html --- --- N.B. this script assumes network connectivity! ------------------------------------------------------------------------ - - ------------------------------------------------------------------------ --- config ------------------------------------------------------------------------ -local glyphfile = "./build/glyphlist.txt" -local font_age = "./build/luaotfload-glyphlist.lua" -local glyph_source = "https://raw.githubusercontent.com/adobe-type-tools/agl-aglfn/master/glyphlist.txt" - ------------------------------------------------------------------------ --- fallbacks ------------------------------------------------------------------------ ---- Hans adds a small list of mappings that are not in the original ---- glyph list but seem to be normalizations of some sort. I trust his ---- experience, so I’ll just include them here. Background: ---- http://www.ntg.nl/pipermail/ntg-context/2013/073089.html - -local fallbacks = { - ["SF10000"]=9484, ["SF20000"]=9492, ["SF30000"]=9488, - ["SF40000"]=9496, ["SF50000"]=9532, ["SF60000"]=9516, - ["SF70000"]=9524, ["SF80000"]=9500, ["SF90000"]=9508, - ["afii208"]=8213, -} - ------------------------------------------------------------------------ --- includes ------------------------------------------------------------------------ -require"lpeg" -require"socket" - -kpse.set_program_name"luatex" -for _, lib in next, { "lualibs-lua.lua", - "lualibs-lpeg.lua", - "lualibs-table.lua", } do - local found = assert(kpse.find_file(lib, "lua"), - "Could not locate " .. lib) - require(found) -end - -local C, Cf, Cg, Ct, P, R = - lpeg.C, lpeg.Cf, lpeg.Cg, lpeg.Ct, lpeg.P, lpeg.R - -local http = socket.http - ------------------------------------------------------------------------ --- functionality ------------------------------------------------------------------------ - -local dec_of_hex = function (hex) return tonumber(hex, 16) end - -local separator = P";" -local gartenzaun = P"#" -local eol = P"\n\r" + P"\r\n" + P"\r" + P"\n" -local space = P" " -local alphanum = R("az", "AZ", "09") -local hexdigit = R("af", "AF", "09") -local eof_tag = gartenzaun * P"END" -local header_line = gartenzaun * (1-eol)^0 * eol -local codepoint = hexdigit^1 -local glyphname = alphanum^1 - -local definition = Cg(C(glyphname) * separator * (C(codepoint)/ dec_of_hex)) - --- With combined glyphs we take only the first - --- value as char-def and font-age do, and skip - --- the rest. - * (space * codepoint)^0 - * eol -local definitions = Cf(Ct"" * definition^1, rawset) - -local p_glyphs = header_line^0 * definitions * eof_tag - -local get_glyphs = function (data) - local res = lpeg.match(p_glyphs, data) - if not res then - print("error: could not parse glyph list") - os.exit(-1) - end - for name, glyph in next, fallbacks do - res[name] = res[name] or glyph - end - return res -end - -local file_header = [==[ -if not modules then modules = { } end modules ["font-age"] = { - version = 2.400, - comment = "part of the luaotfload package", - author = "luaotfload team / mkglyphlist", - copyright = "derived from %s", - original = "Adobe Glyph List, version 2.0, September 20, 2002", - dataonly = true, -} - -if context then - logs.report("fatal error","this module is not for context") - os.exit(-1) -end - ---[[doc-- -Everything below has been autogenerated. Run mkglyphlist to rebuild -luaotfload-glyphlist.lua. ---doc]]-- - -]==] - -local writedata = function (data) - data = table.serialize(data, true) - data = string.format(file_header, glyph_source) .. data - local fh = io.open(font_age, "wb") - if not fh then - print(string.format("error: %s not writable", font_age)) - os.exit(-1) - end - print(string.format("saving %d bytes to %s", #data, font_age)) - fh:write(data) - fh:close() -end - - -local get_raw get_raw = function (retry) - local fh = io.open(glyphfile, "rb") - if fh then - print ("info: reading glyph list from", glyphfile) - local data = fh:read"*all" - fh:close() - if data then return data end - elseif not retry then --- attempt download - print"info: retrieving glyph list from" - print(glyph_source) - local cmd = string.format("wget '%s' -o '%s'", glyph_source, glyphfile) - local st = os.execute(string.format("wget '%s' -O '%s'", glyph_source, glyphfile)) - if st ~= 0 then - print(string.format("error: download failed; status: %d, command: %q", st, cmd)) - os.exit(-1) - end - end - print("error: could not obtain glyph data from "..glyphfile) - os.exit(-1) -end - -local main = function () - if arg[1] then glyphfile = arg[1] end - if arg[2] then font_age = arg[2] end - - local data = get_raw() - local parsed = get_glyphs(data) - writedata(parsed) - return 0 -end - - -return main() - ---- vim:ft=lua:ts=2:et:sw=2 diff --git a/Master/texmf-dist/scripts/luaotfload/mkimport b/Master/texmf-dist/scripts/luaotfload/mkimport deleted file mode 100755 index 94e1f0bc5b2..00000000000 --- a/Master/texmf-dist/scripts/luaotfload/mkimport +++ /dev/null @@ -1,1063 +0,0 @@ -#!/usr/bin/env texlua -------------------------------------------------------------------------------- --- FILE: mkimport.lua --- USAGE: texlua ./mkimport.lua --- DESCRIPTION: check luaotfload imports against Context --- REQUIREMENTS: luatex, the lualibs package, Context MkIV --- AUTHOR: Philipp Gesang (Phg), <phg@phi-gamma.net> -------------------------------------------------------------------------------- --- - -------------------------------------------------------------------------------- ---- PURPOSE ---- ---- - Facilitate detecting changes in the fontloader source. ---- - Assist in updating source code and (partially) automate importing. ---- ---- - Account for files in the plain fontloader distribution, alert in case of ---- additions or deletions. ---- ---- - Fontloader packaging. ---- -------------------------------------------------------------------------------- - -local debug = false - -kpse.set_program_name "luatex" - -local lfs = require "lfs" -local md5 = require "md5" -local os = require "os" - -require "lualibs" -require "util-mrg" - -assert (utilities and utilities.merger and utilities.merger.compact - and type (utilities.merger.compact) == "function", - "Whoa, util-mrg.lua is not accessible! How do you expect this to work‽") - -local filedirname = file.dirname -local fileiswritable = file.is_writable -local ioloaddata = io.loaddata -local iosavedata = io.savedata -local iopopen = io.popen -local iowrite = io.write -local lfschdir = lfs.chdir -local lfscurrentdir = lfs.currentdir -local lfsisdir = lfs.isdir -local lfsisfile = lfs.isfile -local md5sumhexa = md5.sumhexa -local osdate = os.date -local osgettimeofday = os.gettimeofday -local osrename = os.rename -local stringformat = string.format -local tableconcat = table.concat - -------------------------------------------------------------------------------- --- config -------------------------------------------------------------------------------- - -local parms = { } -local our_prefix = "fontloader" -local luatex_fonts_prefix = "luatex" -local fontloader_subdir = "src/fontloader" - -local origin_paths = { - context = { "tex/context/base/mkiv", "tex/context/base", }, - fontloader = "tex/generic/context/luatex", -} - -local subdirs = { - "runtime", - "misc" -} - -local searchdirs = { - --- order is important! - fontloader_subdir, -} - -local prefixes = { - context = nil, - fontloader = "luatex", -} - ---[[doc-- - - The output name is fixed so we have to deal with it but maybe we - can get a patch to mtx-package upstreamed in the future. In any - case, we are content with renaming the result for the time being. - - The target name is constructed on the fly from the current date. - TODO It should be possible to supply a name and possibly - destination path on the command line. - - Paths are relative to the base directory (``$PWD``). - ---doc]]-- - -local loader_target_name = "fontloader-%s.lua" -local loader_orig_dir = "/src/fontloader/" -local loader_target_dir = "/build/" - -------------------------------------------------------------------------------- --- helpers -------------------------------------------------------------------------------- - -local die = function (...) - io.stderr:write "[\x1b[1;30;41mfatal error\x1b[0m] " - io.stderr:write (stringformat (...)) - io.stderr:write "\naborting.\n" - os.exit (1) -end - -local uncertain = 0 - -local hmm = function (...) - uncertain = uncertain + 1 - --[[ sorta like an error but non-fatal ]] - io.stderr:write "[\x1b[1;31merror\x1b[0m] " - io.stderr:write (stringformat (...)) - io.stderr:write "; continuing nontheless.\n" -end - -local emphasis = function (txt) - return stringformat("\x1b[1m%s\x1b[0m", txt) -end - -local msg = function (...) - iowrite (stringformat (...)) - iowrite "\n" -end - -local separator_string = string.rep ("-", 79) -local separator = function () - iowrite (separator_string) - iowrite "\n" -end - -local good_tag = stringformat("[\x1b[1;30;%dmgood\x1b[0m] · ", 42) -local bad_tag = stringformat("[\x1b[1;30;%dmBAD\x1b[0m] · ", 41) -local alert_tag = stringformat("[\x1b[1;%dmalert\x1b[0m] · " , 36) -local status_tag = stringformat("[\x1b[0;%dmstatus\x1b[0m] · " , 36) - -local good = function (...) - local msg = (stringformat (...)) - iowrite (good_tag) - iowrite (msg) - iowrite "\n" -end - -local bad = function (...) - local msg = (stringformat (...)) - iowrite (bad_tag) - iowrite (msg) - iowrite "\n" -end - -local attention = function (...) - local msg = (stringformat (...)) - iowrite (alert_tag) - iowrite (msg) - iowrite "\n" -end - -local status = function (...) - local msg = (stringformat (...)) - iowrite (status_tag) - iowrite (msg) - iowrite "\n" -end - -------------------------------------------------------------------------------- --- definitions -------------------------------------------------------------------------------- - ---- Accounting of upstream files. There are different categories: ---- ---- · *essential*: Files required at runtime. ---- · *merged*: Files merged into the fontloader package. ---- · *ignored*: Lua files not merged, but part of the format. ---- · *tex*: TeX code, i.e. format and examples. ---- · *lualibs*: Files merged, but also provided by the Lualibs package. - -local kind_essential = 0 -local kind_merged = 1 -local kind_tex = 2 -local kind_ignored = 3 -local kind_lualibs = 4 - -local kind_name = { - [0] = "essential", - [1] = "merged" , - [2] = "tex" , - [3] = "ignored" , - [4] = "lualibs" , -} - -local imports = { - - fontloader = { - { name = "basics-gen" , ours = nil , kind = kind_essential }, - { name = "basics-nod" , ours = nil , kind = kind_merged }, - { name = "basics" , ours = nil , kind = kind_tex }, - { name = "fonts-demo-vf-1" , ours = nil , kind = kind_ignored }, - { name = "fonts-enc" , ours = nil , kind = kind_merged }, - { name = "fonts-ext" , ours = nil , kind = kind_merged }, - { name = "fonts-merged" , ours = "reference" , kind = kind_essential }, - { name = "fonts" , ours = nil , kind = kind_merged }, - { name = "fonts" , ours = nil , kind = kind_tex }, - { name = "fonts-syn" , ours = nil , kind = kind_ignored }, - { name = "languages" , ours = nil , kind = kind_ignored }, - { name = "languages" , ours = nil , kind = kind_tex }, - { name = "math" , ours = nil , kind = kind_ignored }, - { name = "math" , ours = nil , kind = kind_tex }, - { name = "mplib" , ours = nil , kind = kind_ignored }, - { name = "mplib" , ours = nil , kind = kind_tex }, - { name = "plain" , ours = nil , kind = kind_tex }, - { name = "preprocessor" , ours = nil , kind = kind_ignored }, - { name = "preprocessor" , ours = nil , kind = kind_tex }, - { name = "preprocessor-test" , ours = nil , kind = kind_tex }, - { name = "swiglib" , ours = nil , kind = kind_ignored }, - { name = "swiglib" , ours = nil , kind = kind_tex }, - { name = "swiglib-test" , ours = nil , kind = kind_ignored }, - { name = "swiglib-test" , ours = nil , kind = kind_tex }, - { name = "test" , ours = nil , kind = kind_tex }, - }, --[[ [fontloader] ]] - - context = { --=> all merged - { name = "data-con" , ours = "data-con" , kind = kind_merged }, - { name = "font-afk" , ours = "font-afk" , kind = kind_merged }, - { name = "font-cff" , ours = "font-cff" , kind = kind_merged }, - { name = "font-cid" , ours = "font-cid" , kind = kind_merged }, - { name = "font-con" , ours = "font-con" , kind = kind_merged }, - { name = "font-def" , ours = "font-def" , kind = kind_merged }, - { name = "font-dsp" , ours = "font-dsp" , kind = kind_merged }, - { name = "font-gbn" , ours = "font-gbn" , kind = kind_merged }, - { name = "font-ini" , ours = "font-ini" , kind = kind_merged }, - { name = "font-lua" , ours = "font-lua" , kind = kind_merged }, - { name = "font-map" , ours = "font-map" , kind = kind_merged }, - { name = "font-ocl" , ours = "font-ocl" , kind = kind_merged }, - { name = "font-otc" , ours = "font-otc" , kind = kind_merged }, - { name = "font-onr" , ours = "font-onr" , kind = kind_merged }, - { name = "font-one" , ours = "font-one" , kind = kind_merged }, - { name = "font-osd" , ours = "font-osd" , kind = kind_merged }, - { name = "font-ota" , ours = "font-ota" , kind = kind_merged }, - { name = "font-oti" , ours = "font-oti" , kind = kind_merged }, - { name = "font-otj" , ours = "font-otj" , kind = kind_merged }, - { name = "font-otl" , ours = "font-otl" , kind = kind_merged }, - { name = "font-oto" , ours = "font-oto" , kind = kind_merged }, - { name = "font-otr" , ours = "font-otr" , kind = kind_merged }, - { name = "font-ots" , ours = "font-ots" , kind = kind_merged }, - { name = "font-oup" , ours = "font-oup" , kind = kind_merged }, - { name = "font-tfm" , ours = "font-tfm" , kind = kind_merged }, - { name = "font-ttf" , ours = "font-ttf" , kind = kind_merged }, - - { name = "l-boolean" , ours = "l-boolean" , kind = kind_lualibs }, - { name = "l-file" , ours = "l-file" , kind = kind_lualibs }, - { name = "l-function" , ours = "l-function" , kind = kind_lualibs }, - { name = "l-io" , ours = "l-io" , kind = kind_lualibs }, - { name = "l-lpeg" , ours = "l-lpeg" , kind = kind_lualibs }, - { name = "l-lua" , ours = "l-lua" , kind = kind_lualibs }, - { name = "l-math" , ours = "l-math" , kind = kind_lualibs }, - { name = "l-string" , ours = "l-string" , kind = kind_lualibs }, - { name = "l-table" , ours = "l-table" , kind = kind_lualibs }, - { name = "util-str" , ours = "util-str" , kind = kind_lualibs }, - { name = "util-fil" , ours = "util-fil" , kind = kind_lualibs }, - }, --[[ [context] ]] -} --[[ [imports] ]] - -local package = { - - optional = { --- components not included in the default package - ---- The original initialization sequence by Hans Hagen, see the file ---- luatex-fonts.lua for details: ---- ---- [01] l-lua.lua ---- [02] l-lpeg.lua ---- [03] l-function.lua ---- [04] l-string.lua ---- [05] l-table.lua ---- [06] l-io.lua ---- [07] l-file.lua ---- [08] l-boolean.lua ---- [09] l-math.lua ---- [10] util-str.lua ---- [11] util-fil.lua ---- [12] luatex-basics-gen.lua ---- [13] data-con.lua ---- [14] luatex-basics-nod.lua ---- [15] luatex-basics-chr.lua ---- [16] font-ini.lua ---- [17] font-con.lua ---- [18] luatex-fonts-enc.lua ---- [19] font-cid.lua ---- [20] font-map.lua ---- [21] luatex-fonts-syn.lua ---- [23] font-oti.lua ---- [24] font-otr.lua ---- [25] font-cff.lua ---- [26] font-ttf.lua ---- [27] font-dsp.lua ---- [28] font-oup.lua ---- [29] font-otl.lua ---- [30] font-oto.lua ---- [31] font-otj.lua ---- [32] font-ota.lua ---- [33] font-ots.lua ---- [34] font-osd.lua ---- [35] font-ocl.lua ---- [36] font-otc.lua ---- [37] font-onr.lua ---- [38] font-one.lua ---- [39] font-afk.lua ---- [40] font-tfm.lua ---- [41] font-lua.lua ---- [42] font-def.lua ---- [43] font-xtx.lua ---- [44] luatex-fonts-ext.lua ---- [45] font-gbn.lua ---- ---- Of these, nos. 01--11 are provided by the Lualibs. Keeping them ---- around in the Luaotfload fontloader is therefore unnecessary. ---- Packaging needs to account for this difference. - - "l-lua", - "l-lpeg", - "l-function", - "l-string", - "l-table", - "l-io", - "l-file", - "l-boolean", - "l-math", - "util-str", - "util-fil", - ---- Another file containing auxiliary definitions must be present ---- prior to initialization of the configuration. - - "luatex-basics-gen", - ---- We have a custom script for autogenerating data so we don’t use the ---- definitions from upstream. - - "basics-chr", - - }, --[[ [package.optional] ]] - ---- The files below constitute the “fontloader proper”. Some of the ---- functionality like file resolvers is overloaded later by ---- Luaotfload. Consequently, the resulting package is pretty ---- bare-bones and not usable independently. - - required = { - - "data-con", - "basics-nod", - "font-ini", - "font-con", - "fonts-enc", - "font-cid", - "font-map", - "font-oti", - "font-otr", - "font-cff", - "font-ttf", - "font-dsp", - "font-oup", - "font-otl", - "font-oto", - "font-otj", - "font-ota", - "font-ots", - "font-osd", - "font-ocl", - "font-otc", - "font-onr", - "font-one", - "font-afk", - "font-tfm", - "font-lua", - "font-def", - "fonts-ext", - "font-gbn", - - }, --[[ [package.required] ]] - -} --[[ [package] ]] - -local hash_file = function (fname) - if not lfsisfile (fname) then - hmm ("cannot find %s", fname) - return nil - end - local raw = ioloaddata (fname) - if not raw then - die ("cannot read from %s.", fname) - end - return md5sumhexa (raw) -end - -local first_existing_subpath = function (pfx, subs) - if not subs then return nil end - local t_subs = type (subs) - if t_subs == "table" then - for i = 1, #subs do - local sub = subs[i] - local pth = file.join (pfx, sub) - if lfsisdir (pth) then return pth end - end - elseif t_subs == "string" then - local pth = file.join (pfx, subs) - if lfsisdir (pth) then return pth end - end - return nil -end - -local derive_category_path = function (cat) - local location = first_existing_subpath (parms.context_root, - origin_paths[cat]) - if not location then - die ("invalid base path defined for category " .. cat) - end - return location -end - -local derive_suffix = function (kind) - if kind == kind_tex then return ".tex" end - return ".lua" -end - -local pfxlen = { } -local strip_prefix = function (fname, prefix) - prefix = prefix or our_prefix - if not pfxlen[prefix] then pfxlen[prefix] = #prefix end - local len = pfxlen[prefix] - if #fname <= len + 2 then - --- too short to accomodate prefix + basename - return - end - if string.sub (fname, 1, len) == prefix then - return string.sub (fname, len + 2) - end -end - -local derive_fullname = function (cat, name, kind) - local tmp = prefixes[cat] - tmp = tmp and tmp .. "-" .. name or name - return tmp .. derive_suffix (kind) -end - -local derive_ourname = function (name, kind) - local suffix = derive_suffix (kind) - local subdir = kind == kind_essential and "runtime" or "misc" - return subdir, our_prefix .. "-" .. name .. suffix -end - -local format_file_definition = function (def) - return stringformat ("name = \"%s\", kind = \"%s\"", - def.name, - kind_name[def.kind] or def.kind) - .. (def.ours and (", ours = \"" .. def.ours .. "\"") or "") -end - -local is_readable = function (f) - local fh = io.open (f, "r") - if fh then - fh:close() - return true - end - return false -end - -local summarize_news = function (status) - local ni = #status.import - local nc = #status.create - local ng = #status.good - local nm = #status.missing - - separator () - msg ("Summary: Inspected %d files.", ni + nc + ng + nm) - separator () - if ng > 0 then good ("%d are up to date", ng) end - if ni > 0 then attention ("%d changed" , ni) end - if nc > 0 then attention ("%d new" , nc) end - if nm > 0 then bad ("%d missing" , nm) end - separator () - - if nm == 0 and nc == 0 and ni == 0 then - return 0 - end - - return -1 -end - -local news = function () - local status = { - import = { }, - good = { }, - create = { }, - missing = { }, - } - - for cat, entries in next, imports do - local location = derive_category_path (cat) - local nfiles = #entries - - for i = 1, nfiles do - local def = entries[i] - local name = def.name - local ours = def.ours - local kind = def.kind - local fullname = derive_fullname (cat, name, kind) - local fullpath = file.join (location, fullname) - local subdir, ourname = derive_ourname (ours or name, kind) - local ourpath = file.join (fontloader_subdir, subdir, ourname) -- relative - local imported = false - - if not is_readable (fullpath) then - bad ("source for file %s not found at %s", - emphasis (ourname), - emphasis (fullpath)) - status.missing[#status.missing + 1] = ourname - else - --- Source file exists and is readable. - if not lfsisdir (fontloader_subdir) then - die ("path for fontloader tree (" - .. fontloader_subdir .. ") is not a directory") - end - if is_readable (ourpath) then imported = true end - local src_hash = hash_file (fullpath) - if src_hash then - local dst_hash = imported and hash_file (ourpath) - local same = src_hash == dst_hash -- same! - if same then - good ("file %s unchanged", emphasis (ourname)) - status.good[#status.good + 1] = ourname - elseif not dst_hash then - attention ("new file %s requires import from %s", - emphasis (ourname), - emphasis (fullpath)) - status.create[#status.create + 1] = ourname - else --- src and dst exist but differ - attention ("file %s requires import", emphasis (ourname)) - status.import[#status.import + 1] = ourname - end - end - end - - end - end - - return summarize_news (status) -end --[[ [local news = function ()] ]] - -local get_file_definition = function (name, ourname, kind) - kind = kind or "lua" - for cat, defs in next, imports do - local fullname = derive_fullname (cat, name, kind) - local ndefs = #defs - for i = 1, ndefs do - local def = defs[i] - local dname = def.name - local dours = def.ours or def.name - local dkind = def.kind - - --- test properties - local subdir, derived = derive_ourname (dours, dkind) - if derived == ourname then return def, cat end - if derive_fullname (cat, dname, dkind) == fullname then return def, cat end - if dours == ourname then return def, cat end - if dname == fullname then return def, cat end - end - end - --- search unsuccessful -end --[[ [local get_file_definition = function (name, ourname, kind)] ]] - -local import_imported = 0 -local import_skipped = 1 -local import_failed = 2 -local import_created = 3 - -local import_status = { - [import_imported] = "imported", - [import_skipped ] = "skipped", - [import_failed ] = "failed", - [import_created ] = "created", -} - -local summarize_status = function (counters) - local imported = counters[import_imported] or 0 - local skipped = counters[import_skipped ] or 0 - local created = counters[import_created ] or 0 - local failed = counters[import_failed ] or 0 - local sum = imported + skipped + created + failed - if sum < 1 then die ("garbage total of imported files: %s", sum) end - separator () - status (" RESULT: %d files processed, %d errors", sum, uncertain) - separator () - if created > 0 then status ("created: %d (%d %%)", created , created * 100 / sum) end - if imported > 0 then status ("imported: %d (%d %%)", imported, imported * 100 / sum) end - if skipped > 0 then status ("skipped: %d (%d %%)", skipped , skipped * 100 / sum) end - separator () -end - -local import_file = function (name, kind, def, cat) - local expected_ourname = derive_ourname (name) - if not def or not cat then - def, cat = get_file_definition (name, expected_ourname, kind) - end - - if not def then die ("unable to find a definition matching " .. name) end - if not cat then die ("missing category for file " .. name .. " -- WTF‽") end - - local dname = def.name - local dours = def.ours or dname - local dkind = def.kind - local srcdir = derive_category_path (cat) - local fullname = derive_fullname (cat, dname, kind) - local subdir, ourname = derive_ourname (dours, kind) - local ourpath = file.join (fontloader_subdir, subdir) - local src = file.join (srcdir, fullname) - local dst = file.join (ourpath, ourname) - local new = not lfsisfile (dst) - if not new and hash_file (src) == hash_file (dst) then - status ("file %s is unchanged, skipping", fullname) - return import_skipped - end - if not (lfsisdir (ourpath) or not lfs.mkdirs (ourpath)) then - die ("failed to create directory %s for file %s", - ourpath, ourname) - end - status ("importing file %s", fullname) - file.copy (src, dst) - if hash_file (src) == hash_file (dst) then - if new then return import_created end - return import_imported end - return import_failed -end --[[ [local import_file = function (name, kind)] ]] - -local import = function (arg) - --- Multiple files - local statcount = { } -- import status codes -> size_t - for cat, defs in next, imports do - local ndefs = #defs - for i = 1, ndefs do - local def = defs[i] - local stat = import_file (def.name, def.kind, def, cat) - if stat == import_failed then - hmm (stringformat ("import failed at file %d of %d (%s)", - i, ndefs, def.name)) - end - statcount[stat] = statcount[stat] or 0 - statcount[stat] = statcount[stat] + 1 - end - end - summarize_status (statcount) - return uncertain == 0 and 0 or -42 -end --[[ [local import = function (arg)] ]] - -local find_in_path = function (root, subdir, target) - local file = file.join (root, subdir, target) - if lfsisfile (file) then - return file - end -end - -local search_paths = function (target) - for i = 1, #searchdirs do - local root = searchdirs[i] - - for j = 1, #subdirs do - local found = find_in_path (root, subdirs[j], target) - if found then return found end - end - - end - - local found = find_in_path (parms.context_root, origin_paths.context, target) - if found then return found end - - local found = find_in_path (parms.context_root, origin_paths.fontloader, target) - if found then return found end - return false -end - -local search_defs = function (target) - local variants = { target, --[[ unstripped ]] } - local tmp - tmp = strip_prefix (target) - if tmp then variants[#variants + 1] = tmp end - tmp = strip_prefix (target, luatex_fonts_prefix) - if tmp then variants[#variants + 1] = tmp end - - local nvariants = #variants - - for cat, defs in next, imports do - local ndefs = #defs - for i = 1, ndefs do - local def = defs[i] - - for i = 1, nvariants do - local variant = variants[i] - - local dname = def.name - if variant == dname then - local found = search_paths (variant .. derive_suffix (def.kind)) - if found then return found end - end - - local dkind = def.kind - local dfull = derive_fullname (cat, dname, dkind) - if derive_fullname (cat, variant, dkind) == dfull then - local found = search_paths (dfull) - if found then return found end - end - - local dours = def.ours - if dours then - - local _, ourname = derive_ourname (dours, dkind) - if variant == dours then - local found = search_paths (ourname) - if found then return found end - end - - if variant == ourname then - local found = search_paths (ourname) - if found then return found end - end - end - - end - end - end - return false -end - -local search = function (target) - local look_for - --- pick a file - if lfsisfile (target) then --- absolute path given - look_for = target - goto found - else - - --- search as file name in local tree - look_for = search_paths (target) - if look_for then goto found end - - --- seach the definitions - look_for = search_defs (target) - if look_for then goto found end - - end - -::fail:: - if not look_for then return end - -::found:: - return look_for -end - -local find_matching_def = function (location) - local basename = file.basename (location) - if not basename then die ("corrupt path %s", location) end - local barename = file.removesuffix (basename) - local pfxless = strip_prefix (barename) - local kind = file.suffix (pfxless) or "lua" - for cat, defs in next, imports do - for _, def in next, defs do - local dname = def.name - local dours = def.ours - if dname == pfxless - or dname == barename - -- dname == basename -- can’t happen for lack of suffix - or dours == pfxless - or dours == barename - then - return cat, def - end - end - end - return false -end - -local describe = function (target, location) - --- Map files to import definitions - separator () - status ("found file %s at %s", target, location) - local cat, def = find_matching_def (location) - if not cat or not def then - die ("file %s not found in registry", location) - end - - local dname = def.name - local dkind = def.kind - local subdir, ourname = derive_ourname (def.ours or dname, dkind) - separator () - status ("category %s", cat) - status ("kind %s", kind_name[dkind]) - status ("in Context %s", derive_fullname (cat, dname, dkind)) - status ("in Luaotfload %s", ourname) - separator () - return 0 -end - -local tell = function (arg) - local target = parms.target - if not target then die "no filename given" end - - local location = search (target) - if not location then - die ("file %s not found in any of the search locations", target) - end - - return describe (target, location) -end - -local build_paths = function (argv) - if not argv or type (argv) ~= "table" then die "build_paths" end - - local orig_dir = lfscurrentdir () - local base_dir = orig_dir .. loader_orig_dir - local loader_name = stringformat (loader_target_name, os.date ("%F")) - local target_name = orig_dir .. loader_target_dir .. loader_name - - if #argv >= 2 then - local fname = argv[2] - local dir = filedirname (fname) .. "/" - if not lfsisdir (dir) then - die ("second argument must be point into existing directory, not “%s”", - argv[2]) - end - base_dir = dir - target_name = fname - end - - if #argv == 3 then - --- also set the target name - local fname = argv[3] - local dir = filedirname (fname) - if not string.is_empty (dir) and not lfsisdir (dir) then - die ("third argument must be point into writable directory, not “%s”", - argv[3]) - end - target_name = fname - end - - local ret = { - orig_dir = orig_dir, - base_dir = base_dir, - merge_name = merge_name, - target_name = target_name, - loader_name = loader_name, - } - return ret -end - -local luaotfload_header = [==[ ---[[info----------------------------------------------------------------------- - Luaotfload fontloader package - build %s by %s@%s -------------------------------------------------------------------------------- - - © %s PRAGMA ADE / ConTeXt Development Team - - The code in this file is provided under the GPL v2.0 license. See the - file COPYING in the Luaotfload repository for details. - - Report bugs to github.com/lualatex/luaotfload - - This file has been assembled from components taken from Context. See - the Luaotfload documentation for details: - - $ texdoc luaotfload - $ man 1 luaotfload-tool - $ man 5 luaotfload.conf - - Included files: - -%s - ---info]]----------------------------------------------------------------------- - -]==] - -local make_header = function (files) - local filelist = { } - for i = 1, #files do - local f = files[i] - local _void, ourname = derive_ourname (f, kind_merged) - filelist [#filelist + 1] = stringformat (" · %s", ourname) - end - return stringformat (luaotfload_header, - os.date "%F %T", - os.getenv "USER" or "anon", - os.getenv "HOSTNAME" or "void", - os.date "%Y", - table.concat (filelist, "\n")) -end - - -local scope_start = "\ndo --- [luaotfload, %s scope for “%s” %s] ---\n\n" -local scope_stop = "\nend --- [luaotfload, %s scope for “%s”] ---\n\n" -local luaotfload_modeline = "\n--- vim:ft=lua:sw=2:ts=8:et:tw=79\n" - -local assemble_fontloader = function (tgt, dst) - status ("packaging fontloader as “%s”.", emphasis (tgt)) - local required = package.required - local compact = utilities.merger.compact - local sequence = { [1] = make_header (required) } - for i = 1, #required do - local cur = required [i] - local subdir, ourname = derive_ourname (cur, kind_merged) - local ourpath = file.join (fontloader_subdir, subdir, ourname) - local data = ioloaddata (ourpath) - if not data then - bad ("file “%s” cannot be loaded from “%s”", ourname, ourpath) - return false - end - sequence[#sequence + 1] = stringformat (scope_start, tgt, cur, md5sumhexa (data)) - sequence[#sequence + 1] = compact (data) - sequence[#sequence + 1] = stringformat (scope_stop , tgt, cur) - end - sequence[#sequence + 1] = luaotfload_modeline - local raw = table.concat (sequence) - local _void, chunk, err = pcall (loadstring, raw) - print(_void, chunk) - if chunk == nil then - bad ("packaging result not well-formed") - bad ("error message: “%s”", err) - bad ("dumping to fontloader-junk.lua") - iosavedata ("fontloader-junk.lua", raw) - return false - end - iosavedata (dst, raw) - status ("amalgamated %d files, written to “%s”.", - #required, dst) - return dst -end - -local package = function (argv) - local t0 = osgettimeofday () - local paths = build_paths (argv) - - status ("assuming fontloader source in %s", paths.base_dir) - status ("reading merge instructions from %s", paths.merge_name) - status ("writing output to %s", paths.target_name) - - --- check preconditions - - if not lfsisdir (paths.base_dir) then die ("directory %s does not exist", emphasis (paths.base_dir )) end - if not fileiswritable (paths.target_name) then die ("cannot write to %s", emphasis (paths.target_name)) end ----- not lfschdir (paths.base_dir) then die ("failed to cd into %s", emphasis (paths.base_dir )) end - - if lfsisfile (paths.target_name) then - status ("output file already exists at “%s”, unlinking", - paths.target_name) - local ret, err = os.remove (paths.target_name) - if ret == nil then - if not lfschdir (paths.orig_dir) then - status ("warning: failed to cd retour into %s", - emphasis (paths.orig_dir)) - end - die ("failed to remove existing merge package") - end - end - --- perform merge - - local ret = assemble_fontloader (paths.loader_name, paths.target_name) - - if not ret then - if not lfschdir (paths.orig_dir) then - status ("warning: failed to cd retour into %s", - emphasis (paths.orig_dir)) - end - die ("merge failed; failed to invoke mtxrun") - end - - --- clean up - - if not lfschdir (paths.orig_dir) then - status ("warning: failed to cd retour into %s", - emphasis (paths.orig_dir)) - end - - --- check postconditions - - if not lfsisfile (ret) then - die ("merge failed; package not found at “%s”", paths.output_name) - end - - --- at this point we know that mtxrun was invoked correctly and the - --- result file has been created - - status ("merge complete; operation finished in %.0f ms", - (osgettimeofday() - t0) * 1000) - status ("a fresh fontloader at %s is ready to roll", paths.target_name) -end - -local help = function () - iowrite "usage: mkimport <command> [<args>]\n" - iowrite "\n" - iowrite "Where <command> is one of\n" - iowrite " help Print this help message\n" - iowrite " tell Display information about a file’s integration\n" - iowrite " news Check Context for updated files\n" - iowrite " import Update with files from Context\n" - iowrite " package Invoke mtx-package on the current fontloader\n" - iowrite "\n" -end - -local job_kind = table.mirrored { - help = help, - import = import, - news = news, - package = package, - tell = tell, -} - -------------------------------------------------------------------------------- --- functionality -------------------------------------------------------------------------------- - ---- job_kind -> bool -local check_job = function (j) - return job_kind[j] or die ("invalid job type “%s”.", j) -end - -local parse_argv = function (argv) - local job - local tgt - local pth - - local argc = #arg - if argc < 1 or argc > 3 then return "help" end - job = arg[1] or "help" - if argc > 1 then - tgt = arg[2] - if argc == 3 then pth = arg[3] end - end - if not pth then pth = "~/context/tex/texmf-context" end - parms.context_root = kpse.expand_path (pth) - parms.target = tgt - searchdirs [#searchdirs + 1] = pth - return job -end - -------------------------------------------------------------------------------- --- entry point -------------------------------------------------------------------------------- - -local main = function () - local job = parse_argv (arg) - local runner = check_job (job) - return runner(arg) -end - -os.exit (main ()) - ---- vim:ft=lua:ts=2:et:sw=2 diff --git a/Master/texmf-dist/scripts/luaotfload/mkstatus b/Master/texmf-dist/scripts/luaotfload/mkstatus deleted file mode 100755 index 4fda6a7ff95..00000000000 --- a/Master/texmf-dist/scripts/luaotfload/mkstatus +++ /dev/null @@ -1,307 +0,0 @@ -#!/usr/bin/env texlua ------------------------------------------------------------------------ --- FILE: mkstatus.lua --- USAGE: ./mkstatus.lua --- DESCRIPTION: writes the repository state --- REQUIREMENTS: luatex, the lualibs package --- AUTHOR: Philipp Gesang (Phg), <phg42.2a@gmail.com> --- CREATED: 2013-07-07 14:01:12+0200 ------------------------------------------------------------------------ --- --- This script generates a list of hashes that serves as the input --- for the file integrity check (option --diagnose). md5 is all we can --- assume in Luatex, so it’s really only a superficial test. --- --- Not that this file also incorporates the Git revision information. --- Of this, only the actual commit hash is authoritative. The latest --- tag is included for reference only. Besides that, it’s meaningless. --- Do not rely on it: Two distinct versions of Luaotfload might very --- well share the same tag. - -kpse.set_program_name "luatex" - -local md5 = require "md5" - -require "lualibs" - -local stringformat = string.format -local md5sumhexa = md5.sumhexa -local ioloaddata = io.loaddata -local iosavedata = io.savedata -local iopopen = io.popen -local iowrite = io.write -local lfsisdir = lfs.isdir -local stringmatch = string.match - ------------------------------------------------------------------------ --- settings ------------------------------------------------------------------------ - -local verbose = false -local filelist = "./build/luaotfload-status.lua" --- result - -local srcdir = "src" -local builddir = "build" -local scriptdir = "scripts" -local loaderdir = "src/fontloader" -local rtdir = "src/fontloader/runtime" -local miscdir = "src/fontloader/misc" - -local names = { - - --- Luaotfload runtime files - { srcdir, "luaotfload-auxiliary.lua", }, - { srcdir, "luaotfload-colors.lua", }, - { srcdir, "luaotfload-configuration.lua", }, - { srcdir, "luaotfload-database.lua", }, - { srcdir, "luaotfload-diagnostics.lua", }, - { srcdir, "luaotfload-features.lua", }, - { srcdir, "luaotfload-init.lua", }, - { srcdir, "luaotfload-letterspace.lua", }, - { srcdir, "luaotfload-loaders.lua", }, - { srcdir, "luaotfload-log.lua", }, - { srcdir, "luaotfload-main.lua", }, - { srcdir, "luaotfload-parsers.lua", }, - { srcdir, "luaotfload-resolvers.lua", }, - { srcdir, "luaotfload-tool.lua", }, - - --- generated files - { builddir, "luaotfload-characters.lua", }, - { builddir, "luaotfload-glyphlist.lua", }, - - --- scripts - { scriptdir, "mkcharacters", }, - { scriptdir, "mkglyphlist", }, - { scriptdir, "mkimport", }, - { scriptdir, "mkstatus", }, - { scriptdir, "mktests", }, - - --- fontloader runtimes - { rtdir, "fontloader-basics-gen.lua", }, - { rtdir, "fontloader-reference.lua", }, - - --- fontloader constituents - { miscdir, "fontloader-basics-nod.lua", }, - { miscdir, "fontloader-data-con.lua", }, - { miscdir, "fontloader-font-afk.lua", }, - { miscdir, "fontloader-font-onr.lua", }, - { miscdir, "fontloader-font-one.lua", }, - { miscdir, "fontloader-font-cid.lua", }, - { miscdir, "fontloader-font-con.lua", }, - { miscdir, "fontloader-font-def.lua", }, - { miscdir, "fontloader-font-ini.lua", }, - { miscdir, "fontloader-font-map.lua", }, - { miscdir, "fontloader-font-oti.lua", }, - { miscdir, "fontloader-font-gbn.lua", }, - { miscdir, "fontloader-font-def.lua", }, - { miscdir, "fontloader-fonts-demo-vf-1.lua", }, - { miscdir, "fontloader-fonts-enc.lua", }, - { miscdir, "fontloader-fonts-ext.lua", }, - { miscdir, "fontloader-fonts.lua", }, - { miscdir, "fontloader-font-lua.lua", }, - { miscdir, "fontloader-fonts-syn.lua", }, - { miscdir, "fontloader-font-tfm.lua", }, - { miscdir, "fontloader-font-otr.lua", }, - { miscdir, "fontloader-font-cff.lua", }, - { miscdir, "fontloader-font-ttf.lua", }, - { miscdir, "fontloader-font-dsp.lua", }, - { miscdir, "fontloader-font-oup.lua", }, - { miscdir, "fontloader-font-otl.lua", }, - { miscdir, "fontloader-font-oto.lua", }, - { miscdir, "fontloader-font-otj.lua", }, - { miscdir, "fontloader-font-ota.lua", }, - { miscdir, "fontloader-font-ots.lua", }, - { miscdir, "fontloader-font-osd.lua", }, - { miscdir, "fontloader-font-ocl.lua", }, - { miscdir, "fontloader-font-otc.lua", }, - - --- lua libraries - { miscdir, "fontloader-languages.lua", }, - { miscdir, "fontloader-l-boolean.lua", }, - { miscdir, "fontloader-l-file.lua", }, - { miscdir, "fontloader-l-function.lua", }, - { miscdir, "fontloader-l-io.lua", }, - { miscdir, "fontloader-l-lpeg.lua", }, - { miscdir, "fontloader-l-lua.lua", }, - { miscdir, "fontloader-l-math.lua", }, - { miscdir, "fontloader-l-string.lua", }, - { miscdir, "fontloader-l-table.lua", }, - { miscdir, "fontloader-math.lua", }, - { miscdir, "fontloader-mplib.lua", }, - { miscdir, "fontloader-preprocessor.lua", }, - { miscdir, "fontloader-swiglib.lua", }, - { miscdir, "fontloader-swiglib-test.lua", }, - { miscdir, "fontloader-util-str.lua", }, - { miscdir, "fontloader-util-fil.lua", }, - -} --[[local names]] - ------------------------------------------------------------------------ --- helpers ------------------------------------------------------------------------ - -local die = function (...) - io.stderr:write "[fatal error]: " - io.stderr:write (stringformat (...)) - io.stderr:write "\naborting.\n" - os.exit (1) -end - -local logcmd = "git log -1 \z - --format=\"return {\z - %n revision = [[%H]],\z - %n timestamp = [[%cd]],\z - %n committer = [[%cn <%ce>]],\z - %n}\" \z - --date=iso" -local describecmd = "git describe --all" - -local readpipe = function (cmd) - local chan = iopopen (cmd) - if not chan then - die ("this script needs to be run inside \z - the luaotfload git repository") - end - local data = chan:read "*all" - chan:close () - return data -end - -local git_info = function () - --io.write (logcmd) - --io.write "\n" - local desc = readpipe (describecmd) - if not desc then die "cannot parse git information" end - desc = string.fullstrip (desc) - local desc = string.explode (desc, "/")[2] or desc - if not desc then die "cannot parse sanitized git information" end - local data = readpipe (logcmd) - if data and type (data) == "string" and data ~= "" then - data = load (data) - if not data then - die "cannot parse git information" - end - data = data () - data.description = desc - return data - end - die "cannot read from pipe" -end - ------------------------------------------------------------------------ --- functionality ------------------------------------------------------------------------ - -local hash_file = function (fname) - if not lfs.isfile (fname) then - die ("cannot find %s.", fname) - end - local raw = ioloaddata (fname) - if not raw then - die ("cannot read from %s.", fname) - end - return md5sumhexa (raw) -end - -local hash_all -hash_all = function (list, acc) - if acc == nil then - local base = table.fastcopy (names) - return hash_all (table.append (base, list), { }) - end - - local finfo = list[#list] - list[#list] = nil - if finfo then - local fpath, fname - if type (finfo) == "table" then - local d, f = finfo [1], finfo [2] - if lfs.isdir (d) then - fpath = file.join (d, f) - else - fpath = f - end - fname = f - else - fpath = finfo - end - if verbose then - iowrite "· md5(" - iowrite (fpath) - end - local sum = hash_file (fpath) - if verbose then - iowrite ") = \"" - iowrite (sum) - iowrite "\"\n" - end - acc[#acc+1] = { fname, sum } - return hash_all (list, acc) - end - return acc -end - -local handle_argv = function (argv) - local ret = { files = { }, loader = nil } - local argc = #argv - if argc < 1 then return ret end - local argoff = 1 - if argv [1] == "-v" then - verbose = true - if argc == 1 then return ret end - argoff = 2 - end - local aux aux = function (acc, i) - if i > argc then return acc else - local cur = argv[i] - if type (cur) == "string" then - local loader = stringmatch (cur, "--fontloader=(.+)$") - if loader then - cur = loader - acc.loader = file.basename (cur) - end - if lfs.isfile (cur) then - local files = acc.files - files[#files + 1] = cur - end - else - die ("file not found: %s", tostring (cur)) - end - return aux (acc, i + 1) - end - end - return aux (ret, argoff) -end - -local add_files -add_files = function (lst, acc) - if lst == nil then return end - if acc == nil then return add_files (lst, { }) end - local len = #lst - if len == 0 then return acc end - local cur = lst[len] - local fname = file.basename (cur) - local path = file.dirname (cur) - acc[#acc + 1] = { path, fname } - lst[len] = nil - return add_files (lst, acc) -end - -local main = function () - local raw_extra = handle_argv (arg) - local cuit_extra = add_files (raw_extra.files) - local hashes = hash_all (cuit_extra) - local notes = git_info () - notes.loader = raw_extra.loader - local serialized = table.serialize ({ notes = notes, - hashes = hashes }, true) - local success = io.savedata (filelist, serialized) - if success == false then - die ("could not write to %s.", filelist) - end - return 0 -end - -return main () - ---- vim:ft=lua:ts=2:et:sw=2 diff --git a/Master/texmf-dist/scripts/luaotfload/mktests b/Master/texmf-dist/scripts/luaotfload/mktests deleted file mode 100755 index ad8c4f5c594..00000000000 --- a/Master/texmf-dist/scripts/luaotfload/mktests +++ /dev/null @@ -1,362 +0,0 @@ -#!/usr/bin/env texlua ------------------------------------------------------------------------ --- FILE: mktests --- USAGE: ./mktests --- DESCRIPTION: test the behavior of Luaotfload --- REQUIREMENTS: Luatex > 0.76, Luaotfload --- AUTHOR: Philipp Gesang (Phg), <phg42.2a@gmail.com> ------------------------------------------------------------------------ --- ---===================================================================-- --- NOTE --- this is a stub, to be completed long-term --- suggestions welcome ---===================================================================-- - - -local tests = { } -local lpeg = require "lpeg" -local lpegmatch = lpeg.match - -config = { luaotfload = { } } -luatexbase = { } - -kpse.set_program_name "luatex" - -require "lualibs" -require "luaotfload-basics-gen.lua" -require "luaotfload-log.lua" - -fonts = { names = { } } -- for db; normally provided by the fontloaders - -local require_init = { } - -local loadmodule = function (name) - local v = require ("luaotfload-" .. name) - if v then - local mod = { } - local tv = type (v) - if tv == "table" then - mod.name = name - mod.init = v.init - require_init [#require_init + 1] = mod - elseif tv == "function" then - mod.name = name - mod.init = v - require_init [#require_init + 1] = mod - end - end -end - -require "alt_getopt" - -loadmodule "log.lua" --- this populates the luaotfload.log.* namespace -loadmodule "parsers" --- fonts.conf, configuration, and request syntax -loadmodule "configuration" --- configuration file handling -loadmodule "database" -loadmodule "resolvers" --- Font lookup - -do --- init_modules - --- NB we don’t command the logger at this point. - local todo = #require_init - local ret = true - for i = 1, todo do - local mod = require_init[i] - local name = mod.name - local init = mod.init - if type (init) ~= "function" then - error ("luaotfload broken; module " - .. name .. " missing initializers!") - end - local v = mod.init () - if v == true then - --- evaluated well - elseif type (v) == "table" then - luaotfload[name] = v - else - error ("luaotfload broken; initialization of module " - .. name .. " returned " .. tostring (v) .. ".") - return false - end - end -end - -local names = fonts.names - ------------------------------------------------------------------------ ---- helper functions ------------------------------------------------------------------------ - -local pprint_resolve = function (input, output, result) - texio.write_nl (string.format ("[%s] “%s” -> “%s”", - result == true and "passed" or "failed", - input, - output)) -end - -local pprint_result = function (name, failed, total) - if failed == 0 then - texio.write_nl (string.format ("[%s] all %d passed", name, total)) - else - texio.write_nl (string.format ("[%s] %d of %d failed", - name, - failed, - total)) - end -end - -local pprint_spec = function (spec) - return string.format ("%s/%s*%.2fpt", - spec.specification, - spec.style or "regular", - spec.optsize or 0) -end - ------------------------------------------------------------------------ ---- parser tests ------------------------------------------------------------------------ - -local test_config_input = [==[ - - -[foo] -bar = baz -xyzzy = no -buzz - -[lavernica "brutalitops"] -# It’s a locomotive that runs on us. - laan-ev = zip zop zooey ; jib-jab -Crouton = "Fibrosis \"\\ # " - -]==] - -local test_config_output = { - { section = { title = "foo" }, - variables = { bar = "baz", - xyzzy = false, - buzz = true } }, - { section = { title = "lavernica", - subtitle = "brutalitops" }, - variables = { ["laan-ev"] = "zip zop zooey", - crouton = "Fibrosis \"\\ # " } } -} - -local parse_config = function () - local parser = luaotfload.parsers.config - local result = lpegmatch (parser, test_config_input) - --- compare values recursively - local aux aux = function (t1, t2) - --- cheaply non-tail recursive - local k1 = table.keys (t1) - local k2 = table.keys (t2) - if #k1 ~= #k2 then - return false - end - for i = 1, #k1 do - local k = k1[i] - local v1 = t1[k] - local v2 = t2[k] - if type (v1) == "table" then - if type (v2) ~= "table" or not aux (v1, v2) then - return false - end - elseif v1 ~= v2 then - return false - end - end - return true - end - return aux (result, test_config_output) and 0 or 1, 1 -end - -tests["parse_config"] = parse_config - ------------------------------------------------------------------------ ---- font tests ------------------------------------------------------------------------ - ---- test sets - -local infer_regular_style = { - --- inferring which one is the correct style for “regular”; can be - --- obscured by synonyms like “book” etc. - { "Iwona", "Iwona-Regular.otf" }, -- trivial case - { "DejaVu Serif", "DejaVuSerif.ttf" }, - { "DejaVu Sans", "DejaVuSans.ttf" }, - { "Adobe Garamond Pro", "agaramondpro_regular.otf" }, - { "Garamond Premier Pro", "GaramondPremrPro.otf" }, - { "CMU Serif", "cmunrm.otf" }, - { "CMU Sans Serif", "cmunss.otf" }, - { "Minion Pro", "MinionPro-Regular.otf" }, - --- Below test will succeed only if we match for the - --- splainname (= sanitized tfmdata.fullname) field - --- explicitly. - { "Minion Pro Italic", "MinionPro-It.otf" }, -} - -local choose_optical_size = { - { { name = "Latin Modern Roman", optsize = 1 }, "lmroman5-regular.otf" }, - { { name = "Latin Modern Roman", optsize = 10 }, "lmroman10-regular.otf" }, - { { name = "Latin Modern Roman", optsize = 12 }, "lmroman12-regular.otf" }, - { { name = "Latin Modern Roman", optsize = 42 }, "lmroman17-regular.otf" }, - { { name = "EB Garamond", optsize = 1 }, "EBGaramond08-Regular.otf" }, - { { name = "EB Garamond", optsize = 8 }, "EBGaramond08-Regular.otf" }, - { { name = "EB Garamond", optsize = 12 }, "EBGaramond12-Regular.otf" }, - { { name = "EB Garamond", optsize = 42 }, "EBGaramond12-Regular.otf" }, - { { name = "Garamond Premier Pro", optsize = 1 }, "GaramondPremrPro-Capt.otf" }, - { { name = "Garamond Premier Pro", optsize = 10 }, "GaramondPremrPro.otf" }, - { { name = "Garamond Premier Pro", optsize = 15 }, "GaramondPremrPro-Subh.otf" }, - { { name = "Garamond Premier Pro", optsize = 42 }, "GaramondPremrPro-Disp.otf" }, -} - -local choose_style = { - { { name = "DejaVu Sans", style = "regular" }, "DejaVuSans.ttf" }, - { { name = "DejaVu Sans", style = "italic" }, "DejaVuSans-Oblique.ttf" }, - { { name = "DejaVu Sans", style = "bold" }, "DejaVuSans-Bold.ttf" }, - { { name = "DejaVu Sans", style = "bolditalic" }, "DejaVuSans-BoldOblique.ttf" }, - { { name = "Linux Libertine O", style = "regular" }, "LinLibertine_R.otf" }, - { { name = "Linux Libertine O", style = "italic" }, "LinLibertine_RI.otf" }, - { { name = "Linux Libertine O", style = "bold" }, "LinLibertine_RB.otf" }, - { { name = "Linux Libertine O", style = "bolditalic" }, "LinLibertine_RBI.otf" }, - { { name = "Liberation Serif", style = "regular" }, "LiberationSerif-Regular.ttf" }, - { { name = "Liberation Serif", style = "italic" }, "LiberationSerif-Italic.ttf" }, - { { name = "Liberation Serif", style = "bold" }, "LiberationSerif-Bold.ttf" }, - { { name = "Liberation Serif", style = "bolditalic" }, "LiberationSerif-BoldItalic.ttf" }, - { { name = "CMU Sans Serif", style = "regular" }, "cmunss.otf" }, -- no “regular” but “medium” - { { name = "CMU Sans Serif", style = "italic" }, "cmunsi.otf" }, -- no “italic” but “oblique” - { { name = "CMU Sans Serif", style = "bold" }, "cmunsx.otf" }, - { { name = "CMU Sans Serif", style = "bolditalic" }, "cmunso.otf" }, - --[[-- - Minion Pro Italic is exceptionally weird regarding identifiers in - that the postscript fontname and both info.fontname and - info.fullname are given as “minionproit”. Now its english fullname - (field 18) is “minionproital”. Only the value “fullname” in the root of - the tfmdata structure (not the one returned by fontloader.info()!) - accurately yields “Minion Pro Italic”. - - To complete the picture, the file naming isn’t very consistent either: - we find the suffixes “Regular” and “Bold”, but “It” and “BoldIt”. What - the hell were the designers smoking? - - Also, the full Minion Pro set comes with different optical sizes which - for monetary reasons cannot considered here. - --]]-- - { { name = "Minion Pro", style = "regular" }, "MinionPro-Regular.otf" }, - { { name = "Minion Pro", style = "italic" }, "MinionPro-It.otf" }, - { { name = "Minion Pro", style = "bold" }, "MinionPro-Bold.otf" }, - { { name = "Minion Pro", style = "bolditalic" }, "MinionPro-BoldIt.otf" }, -} - ---- this needs a database built with --formats=+pfa,pfb,afm - -local resolve_t1_font = { - { { name = "URW Gothic L", style = "regular" }, "a010013l.pfb" }, --> “book” --- { { name = "URW Gothic L", style = "italic" }, "a010033l.pfb" }, --> “book oblique” --- { { name = "URW Gothic L", style = "bold" }, "a010015l.pfb" }, --> “demi” --- { { name = "URW Gothic L", style = "bolditalic" }, "a010035l.pfb" }, --> “demi oblique” - { { name = "Century Schoolbook L", style = "regular" }, "c059013l.pfb" }, - { { name = "Century Schoolbook L", style = "italic" }, "c059033l.pfb" }, - { { name = "Century Schoolbook L", style = "bold" }, "c059016l.pfb" }, - { { name = "Century Schoolbook L", style = "bolditalic" }, "c059036l.pfb" }, - { { name = "Nimbus Roman No9 L", style = "regular" }, "n021003l.pfb" }, - { { name = "Nimbus Roman No9 L", style = "italic" }, "n021023l.pfb" }, - { { name = "Nimbus Roman No9 L", style = "bold" }, "n021004l.pfb" }, --- medium, actually - { { name = "Nimbus Roman No9 L", style = "bolditalic" }, "n021024l.pfb" }, -} - -local translate_style = { - regular = "r", - italic = "i", - bold = "b", - bolditalic = "bi", -} - -local font_name_tests = { - infer_regular_style, - choose_optical_size, - choose_style, - resolve_t1_font, -} - -local default_spec = { - name = false, - lookup = "name", - specification = false, - optsize = 0, -} - -local resolve_font_name = function () - local failed, total = 0, 0 - for nset = 1, #font_name_tests do - local set = font_name_tests[nset] - - for ntest = 1, #set do - local test = set[ntest] - local input, output = test[1], test[2] - - if type (input) == "string" then - local input_spec = table.copy (default_spec) - input_spec.name = input - input_spec.specification = input_spec.lookup .. ":" .. input - local result = fonts.names.lookup_font_name (input_spec) == output - total = total + 1 - if not result then - failed = failed + 1 - end - pprint_resolve (input, output, result) - - else - local input_spec, output = test[1], test[2] - input_spec.specification = (input_spec.lookup - or default_spec.lookup) - .. ":" .. input_spec.name - input_spec.optsize = input_spec.optsize or default_spec.optsize - input_spec.style = translate_style [input_spec.style] - local result = fonts.names.lookup_font_name (input_spec) == output - total = total + 1 - if not result then - failed = failed + 1 - end - pprint_resolve (pprint_spec (input_spec), output, result) - end - - end - end - return failed, total -end - -tests ["resolve_font_name"] = resolve_font_name - - ------------------------------------------------------------------------ ---- runner ------------------------------------------------------------------------ - -local main = function () - local failed, total = 0, 0 - config.actions.apply_defaults () - for name, test in next, tests do - texio.write_nl ("[" .. name .. "]") - local newfailed, newtotal = test () - total = total + 1 - pprint_result (name, newfailed, newtotal) - failed = failed + newfailed - total = total + newtotal - end - - if failed == 0 then - texio.write_nl (string.format ("[report] all %d tests passed.", total)) - else - texio.write_nl (string.format ("[report] %d of %d tests failed (%d %%).", - failed, - total, - failed / total * 100)) - end - texio.write_nl "" - os.exit (0) -end - -return main () - ---- vim:ft=lua:ts=2:et:sw=2 |