From bb150cd0680f87de4522fbad6069b5dcc5db523b Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 5 May 2013 22:18:03 +0200 Subject: issue warning for incompletely supported Indic scripts --- luaotfload-features.lua | 26 +++++++++++++++++++++++--- luaotfload.dtx | 29 +++++++++++++++++++---------- 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/luaotfload-features.lua b/luaotfload-features.lua index 0665804..941373d 100644 --- a/luaotfload-features.lua +++ b/luaotfload-features.lua @@ -6,9 +6,9 @@ if not modules then modules = { } end modules ["features"] = { license = "see context related readme files" } -local format, insert = string.format, table.insert -local type, next = type, next -local lpegmatch = lpeg.match +local format, insert = string.format, table.insert +local type, next = type, next +local lpegmatch = lpeg.match ---[[ begin included font-ltx.lua ]] --- this appears to be based in part on luatex-fonts-def.lua @@ -97,6 +97,21 @@ defaults.tibt = defaults.khmr defaults.lao = defaults.thai +--[[doc-- + + As discussed, we will issue a warning because of incomplete support + when one of the scripts below is requested. + + Reference: https://github.com/lualatex/luaotfload/issues/31 + +--doc]]-- + +local support_incomplete = table.tohash({ + "deva", "beng", "guru", "gujr", + "orya", "taml", "telu", "knda", + "mlym", "sinh", +}, true) + --[[doc-- Which features are active by default depends on the script requested. --doc]]-- @@ -105,6 +120,11 @@ Which features are active by default depends on the script requested. local set_default_features = function (speclist) speclist = speclist or { } local script = speclist.script or "dflt" + if support_incomplete[script] then + report("log", 0, "load", + "support for the requested script: “%s” may be incomplete", + script) + end report("log", 0, "load", "auto-selecting default features for script: %s", diff --git a/luaotfload.dtx b/luaotfload.dtx index d8d1863..7e737b8 100644 --- a/luaotfload.dtx +++ b/luaotfload.dtx @@ -1,8 +1,12 @@ % \iffalse meta-comment % -% Copyright (C) 2009-2013 by Elie Roux -% and Khaled Hosny -% (Support: .) +% Copyright (C) 2009-2013 +% by Elie Roux +% and Khaled Hosny +% and Philipp Gesang +% +% Home: https://github.com/lualatex/luaotfload +% Support: . % % This work is under the CC0 license. % @@ -47,9 +51,13 @@ \preamble This is a generated file. -Copyright (C) 2009-2013 by by Elie Roux - and Khaled Hosny - (Support: .) +Copyright (C) 2009-2013 + by Elie Roux + and Khaled Hosny + and Philipp Gesang + + Home: https://github.com/lualatex/luaotfload + Support: . This work is under the CC0 license. @@ -119,7 +127,7 @@ and the derived files citecolor=\primarycolor, pdftitle={The luaotfload package}, pdfsubject={OpenType layout system for Plain TeX and LaTeX}, - pdfauthor={Elie Roux & Khaled Hosny}, + pdfauthor={Elie Roux & Khaled Hosny & Philipp Gesang}, pdfkeywords={luatex, lualatex, unicode, opentype} ]{hyperref} \usepackage{fontspec} @@ -196,9 +204,10 @@ and the derived files % \GetFileInfo{luaotfload.drv} % % \title{The \identifier{luaotfload} package} -% \date{2013/04/16 v2.2} -% \author{Elie Roux and Khaled Hosny\\ -% Support: \email{lualatex-dev@tug.org}} +% \date{2013/05/05 v2.2} +% \author{Elie Roux · Khaled Hosny · Philipp Gesang\\ +% Home: https://github.com/lualatex/luaotfload\\ +% Support: \email{lualatex-dev@tug.org}} % % \maketitle % -- cgit v1.2.3 From 15ff8e6e3b942aa9df98ea1df572eaee6d9f292b Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 5 May 2013 22:45:52 +0200 Subject: activate lookup cache by default --- luaotfload-database.lua | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 8faeba2..beef5b1 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -383,25 +383,20 @@ Even if we find a matching font eventually, the next time the user compiles Eir document E will have to stand through the delay again. Thus, some caching of results -- even between runs -- is in order. -We’ll just store successful lookups in the database in a record of -the respective lookup type. +We’ll just store successful name: lookups in a separate cache file. type lookup_cache = (string, (string * num)) dict -TODO: +Complete, needs testing: × 1) add cache to dbobj × 2) wrap lookups in cached versions × 3) make caching optional (via the config table) for debugging × 4) make names_update() cache aware (nil if “force”) × 5) add logging × 6) add cache control to luaotfload-tool - × 7) incr db version - 8) wishlist: save cache only at the end of a run - 9) ??? - n) PROFIT!!! + × 7) incr db version (now 2.203) + × 8) save cache only at the end of a run -The name lookup requires both the “name” and some other -keys, so we’ll concatenate them. The spec is modified in place (ugh), so we’ll have to catalogue what fields actually influence its behavior. @@ -416,20 +411,11 @@ Idk what the “spec” resolver is for. * name: contains both the name resolver from luatex-fonts and resolve() below -The following fields of a resolved spec need to be cached: ---doc]]-- -local cache_fields = { - "forced", "hash", "lookup", "name", "resolved", "sub", -} - ---[[doc-- From my reading of font-def.lua, what a resolver does is basically rewrite the “name” field of the specification record with the resolution. Also, the fields “resolved”, “sub”, “force” etc. influence the outcome. -We’ll just cache a deep copy of the entire spec as it leaves the -resolver, lest we want to worry if we caught all the details. --doc]]-- --- 'a -> 'a -> table -> (string * int|boolean * boolean) @@ -459,12 +445,8 @@ resolve_cached = function (_, _, specification) names.lookups[request] = entry --- obviously, the updated cache needs to be stored. - --- for the moment, we write the entire db to disk - --- whenever the cache is updated. --- TODO this should trigger a save only once the --- document is compiled (finish_pdffile callback?) - --- TODO we should speed up writing by separating - --- the cache from the db report("both", 5, "cache", "saving updated cache") save_lookups() return filename, subfont, true -- cgit v1.2.3 From 241b75b723615faf6be374bfe32506211a01307e Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 6 May 2013 10:41:24 +0200 Subject: fix unsupported style modifiers --- luaotfload-database.lua | 2 +- luaotfload-features.lua | 11 ++++++----- tests/systemfonts.tex | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index beef5b1..b7446c9 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -98,7 +98,7 @@ local writable_path if caches then writable_path = caches.getwritablepath("names","") if not writable_path then - error("Impossible to find a suitable writeable cache...") + luaotfload.error("Impossible to find a suitable writeable cache...") end names.path.dir = writable_path names.path.path = filejoin(writable_path, names.path.basename) diff --git a/luaotfload-features.lua b/luaotfload-features.lua index 941373d..cac6598 100644 --- a/luaotfload-features.lua +++ b/luaotfload-features.lua @@ -352,13 +352,14 @@ local handle_slashed = function (modifiers) local mod = modifiers[i] if type(mod) == "table" and mod[1] == "optsize" then --> optical size optsize = tonumber(mod[2]) - elseif supported[mod] then - style = supported[mod] - elseif stylename == false then + elseif mod == false then + --- ignore report("log", 0, "load", "unsupported font option: %s", v) - elseif not stringis_empty(v) then - style = stringgsub(v, "[^%a%d]", "") + elseif supported[mod] then + style = supported[mod] + elseif not stringis_empty(mod) then + style = stringgsub(mod, "[^%a%d]", "") end end return style, optsize diff --git a/tests/systemfonts.tex b/tests/systemfonts.tex index 0e842db..af08509 100644 --- a/tests/systemfonts.tex +++ b/tests/systemfonts.tex @@ -21,6 +21,8 @@ \font\lmbi ={Latin Modern Roman/BI:+liga} at 10pt \font\lms ={Latin Modern Roman Slanted:+liga} at 10pt \font\lmltn ={Latin Modern Roman:script=latn} at 10pt +%% get this font here: +%% http://sourceforge.net/projects/arabeyes/files/kacst_fonts/kacst_one_5.0.tar.bz2/download \font\arab ={KacstOne:mode=node;script=arab} at 10pt \termesr fi fl ffi ffl ff\par -- cgit v1.2.3 From 1bd7bd84c9a73105fce7909f14628746328ed823 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 6 May 2013 11:48:23 +0200 Subject: reduce verbosity of most db related tasks --- luaotfload-database.lua | 33 +++++++----------- luaotfload-features.lua | 91 +++++++++++++++++++------------------------------ luaotfload-override.lua | 8 ----- 3 files changed, 47 insertions(+), 85 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index b7446c9..576341f 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -134,11 +134,10 @@ This is a sketch of the luaotfload db: // preliminary additions of v2.2: basenames : (string, int) hash; // where int is the index in mappings barenames : (string, int) hash; // where int is the index in mappings - request_cache : lookup_cache; // see below } and fontentry = { familyname : string; - filename : (string * bool); + filename : (string * int); // int: subfont fontname : string; fullname : string; names : { @@ -189,21 +188,15 @@ mtx-fonts has in names.tma: width : string; } - --doc]]-- local fontnames_init = function (keep_cache) --- returns dbobj return { mappings = { }, status = { }, - --- adding filename mapping increases the - --- size of the serialized db on my system - --- (5840 font files) by a factor of 1.09 - --- if we store only the indices in the - --- mappings table barenames = { }, basenames = { }, --- fullnames = { }, +-- fullnames = { }, // -> status version = names.version, } end @@ -262,18 +255,21 @@ local update_names local fonts_loaded = false local fonts_reloaded = false +--- limit output when approximate font matching (luaotfload-tool -F) +local fuzzy_limit = 1 --- display closest only + --- unit -> dbobj load_names = function ( ) local starttime = os.gettimeofday() local foundname, data = load_lua_file(names.path.path) if data then - report("info", 1, "db", + report("both", 2, "db", "Font names database loaded", "%s", foundname) report("info", 3, "db", "Loading took %0.f ms", 1000*(os.gettimeofday()-starttime)) else - report("info", 1, "db", + report("both", 0, "db", [[Font names database not found, generating new one. This can take several minutes; please be patient.]]) data = update_names(fontnames_init(false)) @@ -287,7 +283,7 @@ end load_lookups = function ( ) local foundname, data = load_lua_file(names.path.lookup_path) if data then - report("both", 1, "cache", + report("both", 3, "cache", "Lookup cache loaded (%s)", foundname) else report("both", 1, "cache", @@ -297,8 +293,6 @@ load_lookups = function ( ) return data end -local fuzzy_limit = 1 --- display closest only - local style_synonyms = { set = { } } do style_synonyms.list = { @@ -664,15 +658,12 @@ resolve = function (_,_,specification) -- the 1st two parameters are used by Con if not fonts_reloaded then --- last straw: try reloading the database return reload_db( - "unresolved font name: “" .. name .. "”", + "unresolved font name: ‘" .. name .. "’", resolve, nil, nil, specification ) end --- else, fallback to requested name - --- specification.name is empty with absolute paths, looks - --- like a bug in the specification parser will change into an overload @@ -36,11 +36,6 @@ local stringlower = string.lower local stringgsub = string.gsub local stringis_empty = string.is_empty ---- this parses the optional flags after the slash ---- the original behavior is that multiple slashes ---- are valid but they might cancel prior settings ---- example: {name:Antykwa Torunska/I/B} -> bold - --- TODO an option to dump the default features for a script would make --- a nice addition to luaotfload-tool @@ -113,7 +108,10 @@ local support_incomplete = table.tohash({ }, true) --[[doc-- -Which features are active by default depends on the script requested. + + Which features are active by default depends on the script + requested. + --doc]]-- --- (string, string) dict -> (string, string) dict @@ -187,31 +185,24 @@ end --- according to my reconstruction, the correct chaining --- of the lookups for each category is as follows: --- ---- | File -> ( db/filename lookup; ---- db/basename lookup; ---- kpse.find_file() ) ---- | Name -> ( names.resolve() ) ---- | Path -> ( db/filename lookup; ---- db/basename lookup; ---- kpse.find_file(); ---- fullpath lookup ) ---- | Anon -> ( names.resolve(); (* most general *) ---- db/filename lookup; ---- db/basename lookup; ---- kpse.find_file(); ---- fullpath lookup ) +--- | File -> ( db/filename lookup ) --- ---- the database should be generated only if the chain has ---- been completed, and then only once. +--- | Name -> ( db/name lookup, +--- db/filename lookup ) --- ---- caching of successful lookups is essential. we need ---- an additional subtable "cached" in the database. it ---- should be nil’able by issuing luaotfload-tool --flush or ---- something. if a cache miss is followed by a successful ---- lookup, then it will be counted as new addition to the ---- cache. we also need a config option to ignore caching. +--- | Path -> ( db/filename lookup, +--- fullpath lookup ) --- ---- also everything has to be finished by tomorrow at noon. +--- | Anon -> ( kpse.find_file(), // <- for tfm, ofm +--- db/name lookup, +--- db/filename lookup, +--- fullpath lookup ) +--- +--- caching of successful lookups is essential. we now +--- as of v2.2 have an experimental lookup cache that is +--- stored in a separate file. it pertains only to name: +--- lookups, and is described in more detail in +--- luaotfload-database.lua. --- ----------------------------------------------------------------------- @@ -251,7 +242,7 @@ local decimal = digit^1 * (dot * digit^0)^-1 The slash notation: called “modifiers” (Kew) or “font options” (Robertson, Goosens) we only support the shorthands for italic / bold / bold italic - shapes, the rest is ignored. + shapes, as well as setting optical size, the rest is ignored. --doc]]-- local style_modifier = (P"BI" + P"IB" + P"bi" + P"ib" + S"biBI") / stringlower @@ -314,15 +305,15 @@ local specification = (prefixed + unprefixed) local font_request = Ct(path_lookup * (colon^-1 * features)^-1 + specification * (colon * features)^-1) --- lpeg.print(font_request) ---- new parser: 632 rules + lpeg.print(font_request) +--- new parser: 657 rules --- old parser: 230 rules local import_values = { --- That’s what the 1.x parser did, not quite as graciously, --- with an array of branch expressions. -- "style", "optsize",--> from slashed notation; handled otherwise - "lookup", "sub" --[[‽]], "mode", + "lookup", "sub", "mode", } local lookup_types = { "anon", "file", "name", "path" } @@ -346,6 +337,7 @@ local supported = { gr = false, } +--- (string | (string * string) | bool) list -> (string * number) local handle_slashed = function (modifiers) local style, optsize for i=1, #modifiers do @@ -441,11 +433,15 @@ local otf = fonts.handlers.otf local registerotffeature = otf.features.register local setmetatableindex = table.setmetatableindex --- In the userdata interface we can not longer tweak the loaded font as --- conveniently as before. For instance, instead of pushing extra data in --- in the table using the original structure, we now have to operate on --- the mkiv representation. And as the fontloader interface is modelled --- after fontforge we cannot change that one too much either. +--[[HH-- + + In the userdata interface we can not longer tweak the loaded font as + conveniently as before. For instance, instead of pushing extra data in + in the table using the original structure, we now have to operate on + the mkiv representation. And as the fontloader interface is modelled + after fontforge we cannot change that one too much either. + +--HH]]-- local types = { substitution = "gsub_single", @@ -709,24 +705,7 @@ local anum_specification = { --- below the specifications as given in the removed font-otc.lua --- the rest was identical to what this file had from the beginning --- both make the “anum.tex” test pass anyways --- ---local anum_specification = { --- { --- type = "substitution", --- features = { arab = { urd = true, dflt = true } }, --- data = anum_arabic, --- flags = noflags, -- { }, --- valid = valid, --- }, --- { --- type = "substitution", --- features = { arab = { urd = true } }, --- data = anum_persian, --- flags = noflags, -- { }, --- valid = valid, --- }, ---} --- + otf.addfeature("anum",anum_specification) registerotffeature { diff --git a/luaotfload-override.lua b/luaotfload-override.lua index d796b0e..863187f 100644 --- a/luaotfload-override.lua +++ b/luaotfload-override.lua @@ -81,12 +81,4 @@ logs.names_report = function (mode, lvl, ...) end end -if containers then - --- This will vanish as soon as Hans fixes it in data-con - --- https://github.com/lualatex/luaotfload/issues/17 - - containers.cleanname = function (name) - return (string.gsub(string.lower(name),"[^%w%d\128\255]+","-")) - end -end -- vim:tw=71:sw=4:ts=4:expandtab -- cgit v1.2.3 From 8c013800865dbd0c3cdea6312d664fcf2bc61bed Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 6 May 2013 11:51:35 +0200 Subject: =?UTF-8?q?don=E2=80=99t=20print=20parser=20stats?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luaotfload-features.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luaotfload-features.lua b/luaotfload-features.lua index 76ccc53..f91aee7 100644 --- a/luaotfload-features.lua +++ b/luaotfload-features.lua @@ -305,7 +305,7 @@ local specification = (prefixed + unprefixed) local font_request = Ct(path_lookup * (colon^-1 * features)^-1 + specification * (colon * features)^-1) - lpeg.print(font_request) +-- lpeg.print(font_request) --- new parser: 657 rules --- old parser: 230 rules -- cgit v1.2.3