diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-04-16 13:20:40 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-04-16 13:20:40 +0200 |
commit | 218228536ed709be8ab2dde4a00dc27249ceed8a (patch) | |
tree | 71b331e3d99ebd89fefcc1cb369d233c5c7fbdc1 /tex/context/base/mkiv/font-def.lua | |
parent | ea2466fe69bd082d379e95e1567f3de0b76de243 (diff) | |
download | context-218228536ed709be8ab2dde4a00dc27249ceed8a.tar.gz |
2017-04-16 12:47:00
Diffstat (limited to 'tex/context/base/mkiv/font-def.lua')
-rw-r--r-- | tex/context/base/mkiv/font-def.lua | 71 |
1 files changed, 66 insertions, 5 deletions
diff --git a/tex/context/base/mkiv/font-def.lua b/tex/context/base/mkiv/font-def.lua index 6765be9d3..c8394badf 100644 --- a/tex/context/base/mkiv/font-def.lua +++ b/tex/context/base/mkiv/font-def.lua @@ -11,8 +11,9 @@ if not modules then modules = { } end modules ['font-def'] = { local lower, gsub = string.lower, string.gsub local tostring, next = tostring, next local lpegmatch = lpeg.match -local suffixonly, removesuffix = file.suffix, file.removesuffix +local suffixonly, removesuffix, basename = file.suffix, file.removesuffix, file.basename local formatters = string.formatters +local sortedhash, sortedkeys = table.sortedhash, table.sortedkeys local allocate = utilities.storage.allocate @@ -203,9 +204,9 @@ function resolvers.name(specification) features.normal = normal end normal.instance = instance -if not callbacks.supported.glyph_stream_provider then - normal.variableshapes = true -- for the moment -end + if not callbacks.supported.glyph_stream_provider then + normal.variableshapes = true -- for the moment + end end -- local suffix = lower(suffixonly(resolved)) @@ -313,6 +314,65 @@ local function checkembedding(tfmdata) tfmdata.embedding = embedding end +local function checkfeatures(tfmdata) + local resources = tfmdata.resources + local shared = tfmdata.shared + if resources and shared then + local features = resources.features + local usedfeatures = shared.features + if features and usedfeatures then + local usedlanguage = usedfeatures.language or "dflt" + local usedscript = usedfeatures.script or "dflt" + local function check(what) + if what then + local foundlanguages = { } + for feature, scripts in next, what do + if usedscript == "auto" or scripts["*"] then + -- ok + elseif not scripts[usedscript] then + -- report_defining("font %!font:name!, feature %a, no script %a", + -- tfmdata,feature,usedscript) + else + for script, languages in next, scripts do + if languages["*"] then + -- ok + elseif not languages[usedlanguage] then + report_defining("font %!font:name!, feature %a, script %a, no language %a", + tfmdata,feature,script,usedlanguage) + end + end + end + for script, languages in next, scripts do + for language in next, languages do + foundlanguages[language] = true + end + end + end + if false then + foundlanguages["*"] = nil + foundlanguages = sortedkeys(foundlanguages) + for feature, scripts in sortedhash(what) do + for script, languages in next, scripts do + if not languages["*"] then + for i=1,#foundlanguages do + local language = foundlanguages[i] + if not languages[language] then + report_defining("font %!font:name!, feature %a, script %a, no language %a", + tfmdata,feature,script,language) + end + end + end + end + end + end + end + end + check(features.gsub) + check(features.gpos) + end + end +end + function definers.loadfont(specification) local hash = constructors.hashinstance(specification) -- todo: also hash by instance / factors @@ -347,6 +407,7 @@ function definers.loadfont(specification) checkembedding(tfmdata) -- todo: general postprocessor loadedfonts[hash] = tfmdata designsizes[specification.hash] = tfmdata.parameters.designsize + checkfeatures(tfmdata) end end if not tfmdata then @@ -458,7 +519,7 @@ function definers.read(specification,size,id) -- id can be optional, name can al local parameters = tfmdata.parameters or { } report_defining("using %a font with id %a, name %a, size %a, bytes %a, encoding %a, fullname %a, filename %a", properties.format or "unknown", id, properties.name, parameters.size, properties.encodingbytes, - properties.encodingname, properties.fullname, file.basename(properties.filename)) + properties.encodingname, properties.fullname, basename(properties.filename)) end statistics.stoptiming(fonts) return tfmdata |