diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2016-04-18 20:53:29 +0200 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2016-04-18 20:53:29 +0200 |
commit | a119b257eb5ad1a9ce9a9015d082f28fd2a3527e (patch) | |
tree | be6f43d38271684cd8f7e3ce855f69aef3db43ee /src | |
parent | c8734018b81eb2120372493a3767617eeaf0299c (diff) | |
parent | 0ed66c28f6f48c8250a903bed9abf6aee6d8dd39 (diff) | |
download | luaotfload-a119b257eb5ad1a9ce9a9015d082f28fd2a3527e.tar.gz |
Merge pull request #331 from phi-gamma/master
current progress on 2.7
Diffstat (limited to 'src')
-rw-r--r-- | src/fontloader/misc/fontloader-font-gbn.lua | 24 | ||||
-rw-r--r-- | src/fontloader/misc/fontloader-font-ots.lua | 52 | ||||
-rw-r--r-- | src/fontloader/misc/fontloader-font-oup.lua | 23 | ||||
-rw-r--r-- | src/fontloader/runtime/fontloader-reference.lua | 71 | ||||
-rw-r--r-- | src/luaotfload-configuration.lua | 36 | ||||
-rw-r--r-- | src/luaotfload-database.lua | 8 | ||||
-rw-r--r-- | src/luaotfload-features.lua | 21 | ||||
-rwxr-xr-x | src/luaotfload-tool.lua | 49 | ||||
-rw-r--r-- | src/luaotfload.sty | 2 |
9 files changed, 188 insertions, 98 deletions
diff --git a/src/fontloader/misc/fontloader-font-gbn.lua b/src/fontloader/misc/fontloader-font-gbn.lua index a645a97..daa072b 100644 --- a/src/fontloader/misc/fontloader-font-gbn.lua +++ b/src/fontloader/misc/fontloader-font-gbn.lua @@ -20,6 +20,7 @@ local nuts = nodes.nuts -- context abstraction of direct nodes local traverse_id = nuts.traverse_id local remove_node = nuts.remove +local free_node = nuts.free local glyph_code = nodes.nodecodes.glyph local disc_code = nodes.nodecodes.disc @@ -30,11 +31,13 @@ local tonut = nuts.tonut local getfont = nuts.getfont local getchar = nuts.getchar local getid = nuts.getid +local getboth = nuts.getboth local getprev = nuts.getprev local getnext = nuts.getnext local getdisc = nuts.getdisc local setchar = nuts.setchar local setlink = nuts.setlink +local setprev = nuts.setprev -- from now on we apply ligaturing and kerning here because it might interfere with complex -- opentype discretionary handling where the base ligature pass expect some weird extra @@ -136,7 +139,26 @@ function nodes.handlers.nodepass(head) end if redundant then for i=1,#redundant do - remove_node(nuthead,redundant[i],true) + local r = redundant[i] + local p, n = getboth(r) + if r == nuthead then + nuthead = n + setprev(n) + else + setlink(p,n) + end + if b > 0 then + for i=1,b do + local bi = basefonts[i] + if r == bi[1] then + bi[1] = n + end + if r == bi[2] then + bi[2] = n + end + end + end + free_node(r) end end for d in traverse_id(disc_code,nuthead) do diff --git a/src/fontloader/misc/fontloader-font-ots.lua b/src/fontloader/misc/fontloader-font-ots.lua index c3e1f48..6911872 100644 --- a/src/fontloader/misc/fontloader-font-ots.lua +++ b/src/fontloader/misc/fontloader-font-ots.lua @@ -696,6 +696,9 @@ end function handlers.gsub_ligature(head,start,dataset,sequence,ligature) local current = getnext(start) + if not current then + return head, start, false, nil + end local stop = nil local startchar = getchar(start) if marks[startchar] then @@ -756,6 +759,28 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature) -- kind of weird break elseif id == disc_code then + -- tricky .. we also need to do pre here + local replace = getfield(current,"replace") + if replace then + -- of{f-}{}{f}e o{f-}{}{f}fe o{-}{}{ff}e (oe and ff ligature) + -- we can end up here when we have a start run .. testruns start at a disc but + -- so here we have the other case: char + disc + while replace do + local char, id = ischar(replace,currentfont) + if char then + local lg = ligature[char] -- can there be multiple in a row? maybe in a bad font + if lg then + ligature = lg + replace = getnext(replace) + else + return head, start, false, false + end + else + return head, start, false, false + end + end + stop = current + end lastdisc = current current = getnext(current) else @@ -1281,6 +1306,7 @@ function chainprocs.gsub_ligature(head,start,stop,dataset,sequence,currentlookup local nofreplacements = 1 local skipmark = currentlookup.flags[1] -- sequence.flags? while current do + -- todo: ischar ... can there really be disc nodes here? local id = getid(current) if id == disc_code then if not discfound then @@ -2755,6 +2781,8 @@ local function kernrun(disc,k_run,font,attr,...) next = false end -- + -- we need to get rid of this nest mess some day .. has to be done otherwise + -- if pre then if k_run(pre,"injections",nil,font,attr,...) then done = true @@ -2762,7 +2790,7 @@ local function kernrun(disc,k_run,font,attr,...) if prev then local nest = getprev(pre) setlink(prev,pre) - if k_run(prevmarks,"preinjections",pre,font,attr,...) then -- getnext(pre)) + if k_run(prevmarks,"preinjections",pre,font,attr,...) then -- or prev? done = true end setprev(pre,nest) @@ -2860,7 +2888,7 @@ local function comprun(disc,c_run,...) setdisc(disc,pre,post,replace) end -- - return getnext(disc), done + return getnext(disc), renewed end local function testrun(disc,t_run,c_run,...) @@ -3000,8 +3028,9 @@ local nesting = 0 local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlmode,handler) local done = false - local start = sweephead[head] - if start then + local sweep = sweephead[head] + if sweep then + start = sweep sweephead[head] = nil else start = head @@ -3027,8 +3056,11 @@ local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlm end elseif char == false then return head, done + elseif sweep then + -- else we loose the rest + return head, done else - -- weird + -- in disc component start = getnext(start) end end @@ -3113,8 +3145,9 @@ end local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlmode,handler) local done = false - local start = sweephead[head] - if start then + local sweep = sweephead[head] + if sweep then + start = sweep sweephead[head] = nil else start = head @@ -3154,8 +3187,11 @@ local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlm elseif char == false then -- whatever glyph return head, done + elseif sweep then + -- else we loose the rest + return head, done else - -- very unlikely + -- in disc component start = getnext(start) end end diff --git a/src/fontloader/misc/fontloader-font-oup.lua b/src/fontloader/misc/fontloader-font-oup.lua index 59530af..7edaaf6 100644 --- a/src/fontloader/misc/fontloader-font-oup.lua +++ b/src/fontloader/misc/fontloader-font-oup.lua @@ -9,7 +9,7 @@ if not modules then modules = { } end modules ['font-oup'] = { local next, type = next, type local P, R, S = lpeg.P, lpeg.R, lpeg.S local lpegmatch = lpeg.match -local insert, remove, copy = table.insert, table.remove, table.copy +local insert, remove, copy, unpack = table.insert, table.remove, table.copy, table.unpack local formatters = string.formatters local sortedkeys = table.sortedkeys @@ -737,8 +737,7 @@ local function stripredundant(fontdata) end function readers.getcomponents(fontdata) -- handy for resolving ligatures when names are missing - local resources = fontdata.resources - local descriptions = fontdata.descriptions + local resources = fontdata.resources if resources then local sequences = resources.sequences if sequences then @@ -761,7 +760,7 @@ function readers.getcomponents(fontdata) -- handy for resolving ligatures when n end end for i=1,#steps do - -- we actually had/have this in base mode + -- we actually had/have this in base mode local coverage = steps[i].coverage if coverage then for k, v in next, coverage do @@ -773,13 +772,25 @@ function readers.getcomponents(fontdata) -- handy for resolving ligatures when n end end if next(collected) then + -- remove self referring + -- for k, v in next, collected do + -- for i=1,#v do + -- local vi = v[i] + -- if vi == k then + -- -- report("removing self referring ligature @ slot %5X from collected (1)",k) + -- collected[k] = nil + -- end + -- end + -- end while true do local done = false for k, v in next, collected do for i=1,#v do local vi = v[i] if vi == k then + -- report("removing self referring ligature @ slot %5X from collected (2)",k) collected[k] = nil + break else local c = collected[vi] if c then @@ -787,7 +798,7 @@ function readers.getcomponents(fontdata) -- handy for resolving ligatures when n local t = { } local n = i - 1 for j=1,n do - t[j] = t[j] + t[j] = v[j] end for j=1,#c do n = n + 1 @@ -795,7 +806,7 @@ function readers.getcomponents(fontdata) -- handy for resolving ligatures when n end for j=i+1,#v do n = n + 1 - t[n] = t[j] + t[n] = v[j] end collected[k] = t break diff --git a/src/fontloader/runtime/fontloader-reference.lua b/src/fontloader/runtime/fontloader-reference.lua index 0d22a73..1595733 100644 --- a/src/fontloader/runtime/fontloader-reference.lua +++ b/src/fontloader/runtime/fontloader-reference.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/sources/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/sources/luatex-fonts.lua --- merge date : 04/17/16 11:56:26 +-- merge date : 04/18/16 18:53:40 do -- begin closure to overcome local limits and interference @@ -13503,7 +13503,7 @@ if not modules then modules={} end modules ['font-oup']={ local next,type=next,type local P,R,S=lpeg.P,lpeg.R,lpeg.S local lpegmatch=lpeg.match -local insert,remove,copy=table.insert,table.remove,table.copy +local insert,remove,copy,unpack=table.insert,table.remove,table.copy,table.unpack local formatters=string.formatters local sortedkeys=table.sortedkeys local sortedhash=table.sortedhash @@ -14169,7 +14169,6 @@ local function stripredundant(fontdata) end function readers.getcomponents(fontdata) local resources=fontdata.resources - local descriptions=fontdata.descriptions if resources then local sequences=resources.sequences if sequences then @@ -14210,6 +14209,7 @@ function readers.getcomponents(fontdata) local vi=v[i] if vi==k then collected[k]=nil + break else local c=collected[vi] if c then @@ -14217,7 +14217,7 @@ function readers.getcomponents(fontdata) local t={} local n=i-1 for j=1,n do - t[j]=t[j] + t[j]=v[j] end for j=1,#c do n=n+1 @@ -14225,7 +14225,7 @@ function readers.getcomponents(fontdata) end for j=i+1,#v do n=n+1 - t[n]=t[j] + t[n]=v[j] end collected[k]=t break @@ -18678,6 +18678,9 @@ function handlers.gsub_multiple(head,start,dataset,sequence,multiple) end function handlers.gsub_ligature(head,start,dataset,sequence,ligature) local current=getnext(start) + if not current then + return head,start,false,nil + end local stop=nil local startchar=getchar(start) if marks[startchar] then @@ -18736,6 +18739,24 @@ function handlers.gsub_ligature(head,start,dataset,sequence,ligature) elseif char==false then break elseif id==disc_code then + local replace=getfield(current,"replace") + if replace then + while replace do + local char,id=ischar(replace,currentfont) + if char then + local lg=ligature[char] + if lg then + ligature=lg + replace=getnext(replace) + else + return head,start,false,false + end + else + return head,start,false,false + end + end + stop=current + end lastdisc=current current=getnext(current) else @@ -20539,7 +20560,7 @@ local function comprun(disc,c_run,...) if renewed then setdisc(disc,pre,post,replace) end - return getnext(disc),done + return getnext(disc),renewed end local function testrun(disc,t_run,c_run,...) if trace_testruns then @@ -20605,8 +20626,9 @@ end local nesting=0 local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlmode,handler) local done=false - local start=sweephead[head] - if start then + local sweep=sweephead[head] + if sweep then + start=sweep sweephead[head]=nil else start=head @@ -20632,6 +20654,8 @@ local function c_run_single(head,font,attr,lookupcache,step,dataset,sequence,rlm end elseif char==false then return head,done + elseif sweep then + return head,done else start=getnext(start) end @@ -20696,8 +20720,9 @@ local function k_run_single(sub,injection,last,font,attr,lookupcache,step,datase end local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlmode,handler) local done=false - local start=sweephead[head] - if start then + local sweep=sweephead[head] + if sweep then + start=sweep sweephead[head]=nil else start=head @@ -20734,6 +20759,8 @@ local function c_run_multiple(head,font,attr,steps,nofsteps,dataset,sequence,rlm end elseif char==false then return head,done + elseif sweep then + return head,done else start=getnext(start) end @@ -23867,6 +23894,7 @@ local nodes=nodes local nuts=nodes.nuts local traverse_id=nuts.traverse_id local remove_node=nuts.remove +local free_node=nuts.free local glyph_code=nodes.nodecodes.glyph local disc_code=nodes.nodecodes.disc local tonode=nuts.tonode @@ -23874,11 +23902,13 @@ local tonut=nuts.tonut local getfont=nuts.getfont local getchar=nuts.getchar local getid=nuts.getid +local getboth=nuts.getboth local getprev=nuts.getprev local getnext=nuts.getnext local getdisc=nuts.getdisc local setchar=nuts.setchar local setlink=nuts.setlink +local setprev=nuts.setprev local n_ligaturing=node.ligaturing local n_kerning=node.kerning local ligaturing=nuts.ligaturing @@ -23968,7 +23998,26 @@ function nodes.handlers.nodepass(head) end if redundant then for i=1,#redundant do - remove_node(nuthead,redundant[i],true) + local r=redundant[i] + local p,n=getboth(r) + if r==nuthead then + nuthead=n + setprev(n) + else + setlink(p,n) + end + if b>0 then + for i=1,b do + local bi=basefonts[i] + if r==bi[1] then + bi[1]=n + end + if r==bi[2] then + bi[2]=n + end + end + end + free_node(r) end end for d in traverse_id(disc_code,nuthead) do diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua index f19b9bc..50ac0bd 100644 --- a/src/luaotfload-configuration.lua +++ b/src/luaotfload-configuration.lua @@ -189,13 +189,14 @@ local permissible_color_callbacks = { local default_config = { db = { - formats = "otf,ttf,ttc,dfont", - scan_local = false, - skip_read = false, - strip = true, - update_live = true, - compress = true, - max_fonts = 2^51, + formats = "otf,ttf,ttc,dfont", + scan_local = false, + skip_read = false, + strip = true, + update_live = true, + compress = true, + max_fonts = 2^51, + use_fontforge = false, }, run = { resolver = "cached", @@ -203,7 +204,6 @@ local default_config = { log_level = 0, color_callback = "post_linebreak_filter", fontloader = default_fontloader (), - use_fontforge = false, }, misc = { bisect = false, @@ -377,7 +377,7 @@ local set_fontforge = function () logreport ("log", 4, "db", "Database not present.") return true end - local use_ff = config.luaotfload.run.use_fontforge + local use_ff = config.luaotfload.db.use_fontforge if use_ff == true then if not _G.fontloader then logreport ("both", 0, "db", @@ -500,6 +500,7 @@ local option_spec = { out_t = number_t, --- TODO int_t from 5.3.x on transform = tointeger, }, + use_fontforge = { in_t = boolean_t, }, }, run = { live = { in_t = boolean_t, }, --- false for the tool, true for TeX run @@ -535,7 +536,6 @@ local option_spec = { return id end, }, - use_fontforge = { in_t = boolean_t, }, log_level = { in_t = number_t, out_t = number_t, --- TODO int_t from 5.3.x on @@ -669,13 +669,14 @@ local conf_footer = [==[ local formatters = { db = { - compress = { false, format_boolean }, - formats = { false, format_string }, - max_fonts = { false, format_integer }, - scan_local = { false, format_boolean }, - skip_read = { false, format_boolean }, - strip = { false, format_boolean }, - update_live = { false, format_boolean }, + compress = { false, format_boolean }, + formats = { false, format_string }, + max_fonts = { false, format_integer }, + scan_local = { false, format_boolean }, + skip_read = { false, format_boolean }, + strip = { false, format_boolean }, + update_live = { false, format_boolean }, + use_fontforge = { false, format_boolean }, }, default_features = { __default = { true, format_keyval }, @@ -698,7 +699,6 @@ local formatters = { fontloader = { false, format_string }, log_level = { false, format_integer }, resolver = { false, format_string }, - use_fontforge = { false, format_boolean }, }, } diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua index fd806e0..4944de1 100644 --- a/src/luaotfload-database.lua +++ b/src/luaotfload-database.lua @@ -1437,14 +1437,12 @@ local get_raw_info = function (metadata, basename) local fullname = metadata.fullname local validation_state = metadata.validation_state - if (validation_state and tablecontains (validation_state, "bad_ps_fontname")) - or not fontname - then + if not fontname or not fullname then --- Broken names table, e.g. avkv.ttf with UTF-16 strings; --- we put some dummies in place like the fontloader --- (font-otf.lua) does. logreport ("both", 3, "db", - "%s has invalid postscript font names, using dummies.", + "invalid names table of font %s, using dummies.", basename) fontname = "bad-fontname-" .. basename fullname = "bad-fullname-" .. basename @@ -2955,7 +2953,7 @@ local collect_font_filenames = function () local bisect = config.luaotfload.misc.bisect local max_fonts = config.luaotfload.db.max_fonts --- XXX revisit for lua 5.3 wrt integers - --tableappend (filenames, collect_font_filenames_texmf ()) + 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 ()) diff --git a/src/luaotfload-features.lua b/src/luaotfload-features.lua index 250fbc8..9817e0b 100644 --- a/src/luaotfload-features.lua +++ b/src/luaotfload-features.lua @@ -36,12 +36,11 @@ local config = config or { luaotfload = { run = { } } } local as_script = true local normalize = function () end -if config.luaotfload.run.live == true then +if config.luaotfload.run.live ~= false then normalize = handlers.otf.features.normalize as_script = false end - --HH A bit of tuning for definitions. if fonts.constructors then @@ -1247,6 +1246,10 @@ local handle_request = function (specification) --- investigated it any further (luatex-fonts-ext), so it will --- just stay here. specification.features.normal = normalize (request.features) + local subfont = tonumber (specification.sub) + if subfont and subfont >= 0 then + specification.sub = subfont + 1 + end return specification end @@ -1854,12 +1857,18 @@ otf.addfeature = add_otf_feature local install_extra_features = function (data, filename, raw) for feature, specification in next, extrafeatures do + local fontname + local subfont + local metadata = data.metadata + if metadata then + fontname = tostring (data.metadata.fontname) + subfont = tonumber (metadata.subfontindex) + end + if not fontname then fontname = "<unknown>" end + if not subfont then subfont = -1 end logreport ("both", 3, "features", "register synthetic feature “%s” for %s font “%s”(%d)", - feature, - data.format, - tostring (data.metadata and data.metadata.fontname or "<unknown>"), - data.subfont or -1) + feature, data.format, fontname, subfont) otf.features.register { name = feature, description = specification[2] } otf.enhancers.addfeature (data, feature, specification[1]) end diff --git a/src/luaotfload-tool.lua b/src/luaotfload-tool.lua index 9b8ffc3..4b4dc50 100755 --- a/src/luaotfload-tool.lua +++ b/src/luaotfload-tool.lua @@ -267,8 +267,6 @@ Usage: %s [OPTIONS...] -i --info display basic font metadata -I --inspect display detailed font metadata - -w --warnings display warnings generated by the - fontloader library --list=<criterion> output list of entries by field <criterion> --list=<criterion>:<value> restrict to entries with <criterion>=<value> @@ -455,29 +453,6 @@ local show_info_items = function (fontinfo) texiowrite_nl "" end -local p_eol = S"\n\r"^1 -local p_space = S" \t\v"^0 -local p_line = p_space * C((1 - p_eol)^1)^-1 -local p_lines = Ct(p_line * (p_eol^1 * p_line^-1)^0) - -local show_fontloader_warnings = function (ws) - local nws = #ws - print_heading(stringformat( - [[the fontloader emitted %d warnings]], - nws), 2) - texiowrite_nl "" - for i=1, nws do - local w = ws[i] - texiowrite_nl (stringformat("%d:", i)) - local lines = lpegmatch(p_lines, w) - for i=1, #lines do - local line = lines[i] - texiowrite_nl(" · " .. line) - end - texiowrite_nl "" - end -end - local p_spacechar = S" \n\r\t\v" local p_wordchar = (1 - p_spacechar) local p_whitespace = p_spacechar^1 @@ -657,11 +632,8 @@ local display_features = function (features) end end -local show_full_info = function (path, subfont, warnings) +local show_full_info = function (path, subfont) local rawinfo, warn = fonts.handlers.otf.readers.loadfont (path, subfont) - if warnings then - show_fontloader_warnings(warn) - end if not rawinfo then texiowrite_nl(stringformat([[cannot open font %s]], path)) return @@ -694,7 +666,7 @@ The font info knows two levels of detail: returned by readers.loadfont(). --doc]]-- -local show_font_info = function (basename, askedname, detail, warnings) +local show_font_info = function (basename, askedname, detail) local filenames = fonts.names.data().files local index = filenames.base[basename] local fullname = filenames.full[index] @@ -720,7 +692,7 @@ local show_font_info = function (basename, askedname, detail, warnings) if subfont then show_info_items(subfont) if detail == true then - show_full_info(fullname, subfont, warnings) + show_full_info(fullname, subfont) end else -- list all subfonts logreport (true, 1, "resolve", @@ -730,14 +702,14 @@ local show_font_info = function (basename, askedname, detail, warnings) [[Showing info for font no. %d]], n) show_info_items(shortinfo[subfont]) if detail == true then - show_full_info(fullname, subfont, warnings) + show_full_info(fullname, subfont) end end end else show_info_items(shortinfo) if detail == true then - show_full_info(fullname, subfont, warnings) + show_full_info(fullname, subfont) end end else @@ -1212,7 +1184,7 @@ actions.query = function (job) "Resolved file name %q", foundname) end if job.show_info then - show_font_info (foundname, query, job.full_info, job.warnings) + show_font_info (foundname, query, job.full_info) iowrite "\n" end else @@ -1437,7 +1409,6 @@ local process_cmdline = function ( ) -- unit -> jobspec local result = { -- jobspec force_reload = nil, full_info = false, - warnings = false, criterion = "", query = "", log_level = nil, @@ -1478,10 +1449,9 @@ local process_cmdline = function ( ) -- unit -> jobspec update = "u", verbose = 1, version = "V", - warnings = "w", } - local short_options = "bcDfFiIlLnpqRSuvVhw" + local short_options = "bcDfFiIlLnpqRSuvVh" local options, _, optarg = alt_getopt.get_ordered_opts (arg, short_options, long_options) @@ -1513,12 +1483,7 @@ local process_cmdline = function ( ) -- unit -> jobspec if lvl then lvl = tonumber(lvl) result.log_level = lvl - if lvl > 2 then - result.warnings = true - end end - elseif v == "w" then - result.warnings = true elseif v == "log" then local str = optarg[n] if str then diff --git a/src/luaotfload.sty b/src/luaotfload.sty index 7b6d4cf..b6f03af 100644 --- a/src/luaotfload.sty +++ b/src/luaotfload.sty @@ -2,7 +2,7 @@ %% %% by Elie Roux <elie.roux@telecom-bretagne.eu> %% and Khaled Hosny <khaledhosny@eglug.org> -%% and Philipp Gesang <philipp.gesang@alumni.uni-heidelberg.de> +%% and Philipp Gesang <phg@phi-gamma.net> %% and Dohyun Kim <nomosnomos@gmail.com> %% and David Carlisle <d.p.carlisle@gmail.com> %% |