summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/font-pat.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/font-pat.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/font-pat.lua145
1 files changed, 64 insertions, 81 deletions
diff --git a/Master/texmf-dist/tex/context/base/font-pat.lua b/Master/texmf-dist/tex/context/base/font-pat.lua
index 6aba4d47e3d..b91502c74e5 100644
--- a/Master/texmf-dist/tex/context/base/font-pat.lua
+++ b/Master/texmf-dist/tex/context/base/font-pat.lua
@@ -6,63 +6,31 @@ if not modules then modules = { } end modules ['font-pat'] = {
license = "see context related readme files"
}
-local match, lower, find = string.match, string.lower, string.find
+local match, lower = string.match, string.lower
-local trace_loading = false trackers.register("otf.loading", function(v) trace_loading = v end)
-
--- this will become a per font patch file
---
-- older versions of latin modern didn't have the designsize set
-- so for them we get it from the name
+-- reporter moved to elsewhere
-local patches = fonts.otf.enhancers.patches
+local fonts = fonts
+local otf = fonts.handlers.otf
+local patches = otf.enhancers.patches
+local register = patches.register
+local report = patches.report
local function patch(data,filename)
if data.design_size == 0 then
local ds = match(file.basename(lower(filename)),"(%d+)")
if ds then
- if trace_loading then
- logs.report("load otf","patching design size (%s)",ds)
- end
+ report("design size (%s)",ds)
data.design_size = tonumber(ds) * 10
end
end
- local uni_to_ind = data.map.map
- if not uni_to_ind[0x391] then
- -- beware, this is a hack, features for latin often don't apply to greek
- -- but lm has not much features anyway (and only greek for math)
- if trace_loading then
- logs.report("load otf","adding 13 greek capitals")
- end
- uni_to_ind[0x391] = uni_to_ind[0x41]
- uni_to_ind[0x392] = uni_to_ind[0x42]
- uni_to_ind[0x395] = uni_to_ind[0x45]
- uni_to_ind[0x397] = uni_to_ind[0x48]
- uni_to_ind[0x399] = uni_to_ind[0x49]
- uni_to_ind[0x39A] = uni_to_ind[0x4B]
- uni_to_ind[0x39C] = uni_to_ind[0x4D]
- uni_to_ind[0x39D] = uni_to_ind[0x4E]
- uni_to_ind[0x39F] = uni_to_ind[0x4F]
- uni_to_ind[0x3A1] = uni_to_ind[0x52]
- uni_to_ind[0x3A4] = uni_to_ind[0x54]
- uni_to_ind[0x3A7] = uni_to_ind[0x58]
- uni_to_ind[0x396] = uni_to_ind[0x5A]
- end
- -- better make this into a feature
- --
- -- local glyphs = data.glyphs
- -- for i=0x300,0x36F do
- -- local c = glyphs[uni_to_ind[i]]
- -- if c and c.width == 0 then
- -- local boundingbox = c.boundingbox
- -- c.width = boundingbox[3] - boundingbox[1]
- -- end
- -- end
end
-patches["^lmroman"] = patch
-patches["^lmsans"] = patch
-patches["^lmtypewriter"] = patch
+register("after","migrate metadata","^lmroman", patch)
+register("after","migrate metadata","^lmsans", patch)
+register("after","migrate metadata","^lmtypewriter",patch)
-- for some reason (either it's a bug in the font, or it's
-- a problem in the library) the palatino arabic fonts don't
@@ -74,18 +42,18 @@ local function patch(data,filename)
for k=1,#gpos do
local v = gpos[k]
if not v.features and v.type == "gpos_mark2mark" then
- if trace_loading then
- logs.report("load otf","patching mkmk feature (name: %s)", v.name or "?")
- end
+ report("mkmk feature (name: %s)", v.name or "?")
v.features = {
{
scripts = {
- {
- langs = { "ARA ", "FAR ", "URD ", "dflt" },
- script = "arab",
- },
+ arab = {
+ ["ARA "] = true,
+ ["FAR "] = true,
+ ["URD "] = true,
+ ["dflt"] = true,
+ }
},
- tag = "mkmk"
+ tag = "mkmk",
}
}
end
@@ -93,34 +61,49 @@ local function patch(data,filename)
end
end
-patches["palatino.*arabic"] = patch
+register("after","rehash features","palatino.*arabic",patch)
-local function patch_domh(data,filename,threshold)
- local m = data.math
- if m then
- local d = m.DisplayOperatorMinHeight or 0
- if d < threshold then
- if trace_loading then
- logs.report("load otf","patching DisplayOperatorMinHeight(%s -> %s)",d,threshold)
- end
- m.DisplayOperatorMinHeight = threshold
- end
- end
- if tex.luatexversion < 48 then
- for _, g in next, data.glyphs do
- local name = g.name
- if find(name,"^integral$") or find(name,"^integral%.vsize") then
- local width, italic = g.width or 0, g.italic_correction or 0
- local newwidth = width - italic
- if trace_loading then
- logs.report("load otf","patching width of %s: %s (width) - %s (italic) = %s",name,width,italic,newwidth)
- end
- g.width = newwidth
- end
- end
- end
-end
-
-patches["cambria"] = function(data,filename) patch_domh(data,filename,2800) end
-patches["cambmath"] = function(data,filename) patch_domh(data,filename,2800) end
-patches["asana"] = function(data,filename) patch_domh(data,filename,1350) end
+-- -- this code is now in lm-math.lfg
+--
+-- local function patch(data,filename)
+-- local uni_to_ind = data.map.map
+-- if not uni_to_ind[0x391] then
+-- -- beware, this is a hack, features for latin often don't apply to greek
+-- -- but lm has not much features anyway (and only greek for math)
+-- report("adding 13 greek capitals")
+-- uni_to_ind[0x391] = uni_to_ind[0x41]
+-- uni_to_ind[0x392] = uni_to_ind[0x42]
+-- uni_to_ind[0x395] = uni_to_ind[0x45]
+-- uni_to_ind[0x397] = uni_to_ind[0x48]
+-- uni_to_ind[0x399] = uni_to_ind[0x49]
+-- uni_to_ind[0x39A] = uni_to_ind[0x4B]
+-- uni_to_ind[0x39C] = uni_to_ind[0x4D]
+-- uni_to_ind[0x39D] = uni_to_ind[0x4E]
+-- uni_to_ind[0x39F] = uni_to_ind[0x4F]
+-- uni_to_ind[0x3A1] = uni_to_ind[0x52]
+-- uni_to_ind[0x3A4] = uni_to_ind[0x54]
+-- uni_to_ind[0x3A7] = uni_to_ind[0x58]
+-- uni_to_ind[0x396] = uni_to_ind[0x5A]
+-- end
+-- end
+--
+-- register("after","prepare glyphs","^lmroman", patch)
+-- register("after","prepare glyphs","^lmsans", patch)
+-- register("after","prepare glyphs","^lmtypewriter",patch)
+--
+-- -- this code is now in cambria-math.lfg and asana-math.lfg
+--
+-- local function patch_domh(data,filename,threshold)
+-- local m = data.metadata.math
+-- if m then
+-- local d = m.DisplayOperatorMinHeight or 0
+-- if d < threshold then
+-- report("DisplayOperatorMinHeight(%s -> %s)",d,threshold)
+-- m.DisplayOperatorMinHeight = threshold
+-- end
+-- end
+-- end
+--
+-- register("after","check math parameters","cambria", function(data,filename) patch_domh(data,filename,2800) end)
+-- register("after","check math parameters","cambmath",function(data,filename) patch_domh(data,filename,2800) end)
+-- register("after","check math parameters","asana", function(data,filename) patch_domh(data,filename,1350) end)