summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/context/lua/mtx-fonts.lua1
-rw-r--r--scripts/context/lua/mtxrun.lua18
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua18
-rwxr-xr-xscripts/context/stubs/unix/mtxrun18
-rw-r--r--tex/context/base/font-afm.lua2
-rw-r--r--tex/context/base/font-ctx.lua46
-rw-r--r--tex/context/base/font-ini.mkiv43
-rw-r--r--tex/context/base/font-otf.lua2
-rw-r--r--tex/context/base/font-syn.lua184
-rw-r--r--tex/context/base/font-tfm.lua23
-rw-r--r--tex/context/base/luat-dum.lua5
-rw-r--r--tex/context/base/mult-sys.tex1
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua32
13 files changed, 288 insertions, 105 deletions
diff --git a/scripts/context/lua/mtx-fonts.lua b/scripts/context/lua/mtx-fonts.lua
index 94e0063f9..7c4b36711 100644
--- a/scripts/context/lua/mtx-fonts.lua
+++ b/scripts/context/lua/mtx-fonts.lua
@@ -129,6 +129,7 @@ local function list_specifications(t,info)
entry.weight or "<noweight>",
entry.style or "<nostyle>",
entry.width or "<nowidth>",
+ entry.variant or "<novariant>",
entry.fontname,
entry.filename,
subfont(entry.subfont),
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index 220d12b55..6e5d1a848 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -11962,10 +11962,7 @@ else
end
-if is_mkii_stub then
- -- execute mkii script
- ok = runners.execute_script(filename,false,true)
-elseif environment.argument("selfmerge") then
+if environment.argument("selfmerge") then
-- embed used libraries
utils.merger.selfmerge(own.name,own.libs,own.list)
elseif environment.argument("selfclean") then
@@ -11977,9 +11974,14 @@ elseif environment.argument("selfupdate") then
elseif environment.argument("ctxlua") or environment.argument("internal") then
-- run a script by loading it (using libs)
ok = runners.execute_script(filename,true)
-elseif environment.argument("script") or environment.argument("s") or environment.argument("scripts") then
+elseif environment.argument("script") or environment.argument("scripts") then
-- run a script by loading it (using libs), pass args
- ok = runners.execute_ctx_script(filename)
+ if is_mkii_stub then
+ -- execute mkii script
+ ok = runners.execute_script(filename,false,true)
+ else
+ ok = runners.execute_ctx_script(filename)
+ end
elseif environment.argument("execute") then
-- execute script
ok = runners.execute_script(filename)
@@ -12016,6 +12018,9 @@ elseif environment.argument("help") or filename=='help' or filename == "" then
-- execute script
elseif filename:find("^bin:") then
ok = runners.execute_program(filename)
+elseif is_mkii_stub then
+ -- execute mkii script
+ ok = runners.execute_script(filename,false,true)
else
ok = runners.execute_ctx_script(filename)
if not ok then
@@ -12029,5 +12034,4 @@ end
if ok == false then ok = 1 elseif ok == true then ok = 0 end
-
os.exit(ok)
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index 220d12b55..6e5d1a848 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -11962,10 +11962,7 @@ else
end
-if is_mkii_stub then
- -- execute mkii script
- ok = runners.execute_script(filename,false,true)
-elseif environment.argument("selfmerge") then
+if environment.argument("selfmerge") then
-- embed used libraries
utils.merger.selfmerge(own.name,own.libs,own.list)
elseif environment.argument("selfclean") then
@@ -11977,9 +11974,14 @@ elseif environment.argument("selfupdate") then
elseif environment.argument("ctxlua") or environment.argument("internal") then
-- run a script by loading it (using libs)
ok = runners.execute_script(filename,true)
-elseif environment.argument("script") or environment.argument("s") or environment.argument("scripts") then
+elseif environment.argument("script") or environment.argument("scripts") then
-- run a script by loading it (using libs), pass args
- ok = runners.execute_ctx_script(filename)
+ if is_mkii_stub then
+ -- execute mkii script
+ ok = runners.execute_script(filename,false,true)
+ else
+ ok = runners.execute_ctx_script(filename)
+ end
elseif environment.argument("execute") then
-- execute script
ok = runners.execute_script(filename)
@@ -12016,6 +12018,9 @@ elseif environment.argument("help") or filename=='help' or filename == "" then
-- execute script
elseif filename:find("^bin:") then
ok = runners.execute_program(filename)
+elseif is_mkii_stub then
+ -- execute mkii script
+ ok = runners.execute_script(filename,false,true)
else
ok = runners.execute_ctx_script(filename)
if not ok then
@@ -12029,5 +12034,4 @@ end
if ok == false then ok = 1 elseif ok == true then ok = 0 end
-
os.exit(ok)
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index 220d12b55..6e5d1a848 100755
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -11962,10 +11962,7 @@ else
end
-if is_mkii_stub then
- -- execute mkii script
- ok = runners.execute_script(filename,false,true)
-elseif environment.argument("selfmerge") then
+if environment.argument("selfmerge") then
-- embed used libraries
utils.merger.selfmerge(own.name,own.libs,own.list)
elseif environment.argument("selfclean") then
@@ -11977,9 +11974,14 @@ elseif environment.argument("selfupdate") then
elseif environment.argument("ctxlua") or environment.argument("internal") then
-- run a script by loading it (using libs)
ok = runners.execute_script(filename,true)
-elseif environment.argument("script") or environment.argument("s") or environment.argument("scripts") then
+elseif environment.argument("script") or environment.argument("scripts") then
-- run a script by loading it (using libs), pass args
- ok = runners.execute_ctx_script(filename)
+ if is_mkii_stub then
+ -- execute mkii script
+ ok = runners.execute_script(filename,false,true)
+ else
+ ok = runners.execute_ctx_script(filename)
+ end
elseif environment.argument("execute") then
-- execute script
ok = runners.execute_script(filename)
@@ -12016,6 +12018,9 @@ elseif environment.argument("help") or filename=='help' or filename == "" then
-- execute script
elseif filename:find("^bin:") then
ok = runners.execute_program(filename)
+elseif is_mkii_stub then
+ -- execute mkii script
+ ok = runners.execute_script(filename,false,true)
else
ok = runners.execute_ctx_script(filename)
if not ok then
@@ -12029,5 +12034,4 @@ end
if ok == false then ok = 1 elseif ok == true then ok = 0 end
-
os.exit(ok)
diff --git a/tex/context/base/font-afm.lua b/tex/context/base/font-afm.lua
index 60da808bb..2b5438142 100644
--- a/tex/context/base/font-afm.lua
+++ b/tex/context/base/font-afm.lua
@@ -710,7 +710,7 @@ function tfm.read_from_afm(specification)
local tfmtable = afm.afm_to_tfm(specification)
if tfmtable then
tfmtable.name = specification.name
- tfmtable = tfm.scale(tfmtable, specification.size)
+ tfmtable = tfm.scale(tfmtable, specification.size, specification.relativeid)
local afmdata = tfmtable.shared.afmdata
local filename = afmdata and afmdata.luatex and afmdata.luatex.filename
if not filename then
diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua
index 166da7dec..48f99efba 100644
--- a/tex/context/base/font-ctx.lua
+++ b/tex/context/base/font-ctx.lua
@@ -8,7 +8,7 @@ if not modules then modules = { } end modules ['font-ctx'] = {
-- needs a cleanup: merge of replace, lang/script etc
-local texsprint, count = tex.sprint, tex.count
+local texsprint, count, texsetcount = tex.sprint, tex.count, tex.setcount
local format, concat, gmatch, match, find, lower, gsub = string.format, table.concat, string.gmatch, string.match, string.find, string.lower, string.gsub
local tostring, next, type = tostring, next, type
local lpegmatch = lpeg.match
@@ -329,14 +329,24 @@ end
local n = 0
-function define.command_2(global,cs,str,size,classfeatures,fontfeatures,classfallbacks,fontfallbacks,mathsize,textsize)
+-- we can also move rscale to here (more consistent)
+
+function define.command_2(global,cs,str,size,classfeatures,fontfeatures,classfallbacks,fontfallbacks,mathsize,textsize,relativeid)
+ if trace_defining then
+ logs.report("define font","memory usage before: %s",statistics.memused())
+ end
-- name is now resolved and size is scaled cf sa/mo
local lookup, name, sub, method, detail = get_specification(str or "")
-- asome settings can be overloaded
- if lookup and lookup ~= "" then specification.lookup = lookup end
+ if lookup and lookup ~= "" then
+ specification.lookup = lookup
+ end
+ if relativeid and relativeid ~= "" then -- experimental hook
+ local id = tonumber(relativeid) or 0
+ specification.relativeid = id > 0 and id
+ end
specification.name = name
specification.size = size
---~ specification.sub = sub
specification.sub = (sub and sub ~= "" and sub) or specification.sub
specification.mathsize = mathsize
specification.textsize = textsize
@@ -349,9 +359,6 @@ function define.command_2(global,cs,str,size,classfeatures,fontfeatures,classfal
elseif classfeatures and classfeatures ~= "" then
specification.method, specification.detail = "*", classfeatures
end
- if trace_defining then
- logs.report("define font","memory usage before: %s",statistics.memused())
- end
if fontfallbacks and fontfallbacks ~= "" then
specification.fallbacks = fontfallbacks
elseif classfallbacks and classfallbacks ~= "" then
@@ -360,6 +367,7 @@ function define.command_2(global,cs,str,size,classfeatures,fontfeatures,classfal
local tfmdata = define.read(specification,size) -- id not yet known
if not tfmdata then
logs.report("define font","unable to define %s as \\%s",name,cs)
+ texsetcount("global","lastfontid",-1)
elseif type(tfmdata) == "number" then
if trace_defining then
logs.report("define font","reusing %s with id %s as \\%s (features: %s/%s, fallbacks: %s/%s)",name,tfmdata,cs,classfeatures,fontfeatures,classfallbacks,fontfallbacks)
@@ -367,6 +375,7 @@ function define.command_2(global,cs,str,size,classfeatures,fontfeatures,classfal
tex.definefont(global,cs,tfmdata)
-- resolved (when designsize is used):
texsprint(ctxcatcodes,format("\\def\\somefontsize{%isp}",fontdata[tfmdata].size))
+ texsetcount("global","lastfontid",tfmdata)
else
-- local t = os.clock(t)
local id = font.define(tfmdata)
@@ -383,6 +392,7 @@ function define.command_2(global,cs,str,size,classfeatures,fontfeatures,classfal
--~ if specification.fallbacks then
--~ fonts.collections.prepare(specification.fallbacks)
--~ end
+ texsetcount("global","lastfontid",id)
end
if trace_defining then
logs.report("define font","memory usage after: %s",statistics.memused())
@@ -390,6 +400,28 @@ function define.command_2(global,cs,str,size,classfeatures,fontfeatures,classfal
statistics.stoptiming(fonts)
end
+local enable_auto_r_scale = false
+
+experiments.register("fonts.autorscale", function(v)
+ enable_auto_r_scale = v
+end)
+
+local calculate_scale = fonts.tfm.calculate_scale
+
+function fonts.tfm.calculate_scale(tfmtable, scaledpoints, relativeid)
+ local scaledpoints, delta = calculate_scale(tfmtable, scaledpoints, relativeid)
+ if enable_auto_r_scale and relativeid then -- for the moment this is rather context specific
+ local relativedata = fontdata[relativeid]
+ local id_x_height = relativedata and relativedata.parameters and relativedata.parameters.x_height
+ local tf_x_height = id_x_height and tfmtable.parameters and tfmtable.parameters.x_height * delta
+ if tf_x_height then
+ scaledpoints = (id_x_height/tf_x_height) * scaledpoints
+ delta = scaledpoints/(tfmtable.units or 1000)
+ end
+ end
+ return scaledpoints, delta
+end
+
--~ table.insert(readers.sequence,1,'vtf')
--~ function readers.vtf(specification)
diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv
index 77ede86ea..5e3cca258 100644
--- a/tex/context/base/font-ini.mkiv
+++ b/tex/context/base/font-ini.mkiv
@@ -562,6 +562,22 @@
%D We could instead have used dirty grouping tricks, but this
%D one works too.
+% \enableexperiments[fonts.autorscale]
+%
+% \starttypescript[mscore]
+% \definetypeface [mscore] [rm] [serif] [mscoretimes] [default]
+% \definetypeface [mscore] [ss] [sans] [mscorearial] [default] [rscale=auto] % 0.860]
+% \definetypeface [mscore] [tt] [mono] [mscorecourier] [default] [rscale=auto] % 1.065]
+% \definetypeface [mscore] [mm] [math] [times] [default] [rscale=auto] % 1.020]
+% \stoptypescript
+%
+% \starttext
+% \setupbodyfont[mscore,12pt]
+% \startTEXpage
+% test \ss test \tt test
+% \stopTEXpage
+% \stoptext
+
\let\defaultrelativefontsize \plusone
\let\localrelativefontsize \plusone
\def\localabsolutefontsize {\fontbody}
@@ -571,6 +587,17 @@
\def\saverelativefontsize#1#2% #1=rm|ss|.. #2=waarde
{\setxvalue{\fontclass#1\s!rscale}{#2}}
+\def\checkrelativefontid
+ {\ifcsname\??tf\fontclass\s!rname\endcsname
+ \@EA\let\@EA\relativefontid\csname\??tf\fontclass\s!rname\endcsname
+ \else
+ \@EA\xdef\csname\??tf\fontclass\s!rname\endcsname{\the\lastfontid}%
+ \let\relativefontid\empty
+ \fi}
+
+% \def\checkrelativefontid
+% {\let\relativefontid\minusone}
+
\def\checkrelativefontsize#1%
{\edef\relativefontsize
{\ifcsname\fontclass#1\s!rscale\endcsname
@@ -579,7 +606,13 @@
\csname\defaultfontclass#1\s!rscale\endcsname
\else
\defaultrelativefontsize
- \fi\fi}}
+ \fi\fi}%
+ \ifx\relativefontsize\v!auto
+ \let\relativefontsize\plusone
+ \checkrelativefontid
+ \else
+ \let\relativefontid\minusone
+ \fi}
% \letvalue{\s!default\s!rscale}\defaultrelativefontsize
%
@@ -646,7 +679,8 @@
\newcount\scaledfontmode
\newdimen\scaledfontsize
-\newtoks\everydefinefont
+\newtoks \everydefinefont
+\newcount\lastfontid
\def\currentfontbodysize
{\ifcsname\??ft\s!default\somefontsize\endcsname
@@ -655,6 +689,8 @@
\somefontsize
\fi}
+\let\relativefontid\empty
+
\def\lowleveldefinefont#1#2% #2 = cs
{%
\ctxlua{fonts.define.command_1("\luaescapestring{#1}")}% the escapestring catches at \somedimen
@@ -698,7 +734,8 @@
"\@@fontclassfallbacks",
"\@@fontfallbacks",
0\currentmathsize,
- \number\dimexpr\textface\relax
+ \number\dimexpr\textface\relax,
+ "\relativefontid" % experiment
)}%
\edef\somefontspec{at \somefontsize}% we need the resolved designsize (for fallbacks)
\expandafter\let\expandafter\lastrawfontcall\csname#2\endcsname
diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua
index 6ff3d4086..7ba9a21b6 100644
--- a/tex/context/base/font-otf.lua
+++ b/tex/context/base/font-otf.lua
@@ -1817,7 +1817,7 @@ function tfm.read_from_open_type(specification)
end
end
end
- tfmtable = tfm.scale(tfmtable,s)
+ tfmtable = tfm.scale(tfmtable,s,specification.relativeid)
-- here we resolve the name; file can be relocated, so this info is not in the cache
local filename = (otfdata and otfdata.luatex and otfdata.luatex.filename) or specification.filename
if not filename then
diff --git a/tex/context/base/font-syn.lua b/tex/context/base/font-syn.lua
index c2c96f33e..d6c49b459 100644
--- a/tex/context/base/font-syn.lua
+++ b/tex/context/base/font-syn.lua
@@ -38,7 +38,7 @@ fonts.names.data = fonts.names.data or { }
local names = fonts.names
local filters = fonts.names.filters
-names.version = 1.102
+names.version = 1.103
names.basename = "names"
names.saved = false
names.loaded = false
@@ -70,7 +70,7 @@ local weights = Cs ( -- not extra
+ P("heavy")
+ P("ultra")
+ P("black")
- + P("bol")
+ + P("bol") -- / "bold"
+ P("regular") / "normal"
)
@@ -94,15 +94,22 @@ local widths = Cs(
+ P("book") / "normal"
)
+local variants = Cs( -- fax casual
+ P("smallcaps")
+ + P("oldstyle")
+ + P("caps") / "smallcaps"
+)
+
local any = P(1)
local analysed_table
local analyser = Cs (
(
- weights / function(s) analysed_table[1] = s return "" end
- + styles / function(s) analysed_table[2] = s return "" end
- + widths / function(s) analysed_table[3] = s return "" end
+ weights / function(s) analysed_table[1] = s return "" end
+ + styles / function(s) analysed_table[2] = s return "" end
+ + widths / function(s) analysed_table[3] = s return "" end
+ + variants / function(s) analysed_table[4] = s return "" end
+ any
)^0
)
@@ -110,27 +117,30 @@ local analyser = Cs (
local splitter = lpeg.splitat("-")
function names.splitspec(askedname)
- local name, weight, style, width = lpegmatch(splitter,askedname)
- weight = weight and lpegmatch(weights,weight) or weight
- style = style and lpegmatch(styles, style) or style
- width = width and lpegmatch(widths, width) or width
+ local name, weight, style, width, variant = lpegmatch(splitter,askedname)
+ weight = weight and lpegmatch(weights, weight) or weight
+ style = style and lpegmatch(styles, style) or style
+ width = width and lpegmatch(widths, width) or width
+ variant = variant and lpegmatch(variants,variant) or variant
if trace_names then
- logs.report("fonts","requested name '%s' split in name '%s', weight '%s', style '%s' and width '%s'",askedname,name or '',weight or '',style or '',width or '')
+ logs.report("fonts","requested name '%s' split in name '%s', weight '%s', style '%s', width '%s' and variant '%s'",
+ askedname,name or '',weight or '',style or '',width or '',variant or '')
end
- if not weight or not weight or not width then
- weight, style, width = weight or "normal", style or "normal", width or "normal"
+ if not weight or not weight or not width or not variant then
+ weight, style, width, variant = weight or "normal", style or "normal", width or "normal", variant or "normal"
if trace_names then
- logs.report("fonts","request '%s' normalized to '%s-%s-%s-%s'",askedname,name,weight,style,width)
+ logs.report("fonts","request '%s' normalized to '%s-%s-%s-%s-%s'",
+ askedname,name,weight,style,width,variant)
end
end
- return name or askedname, weight, style, width
+ return name or askedname, weight, style, width, variant
end
local function analysespec(somename)
if somename then
analysed_table = { }
local name = lpegmatch(analyser,somename)
- return name, analysed_table[1], analysed_table[2],analysed_table[3]
+ return name, analysed_table[1], analysed_table[2], analysed_table[3], analysed_table[4]
end
end
@@ -332,13 +342,17 @@ local function check_name(data,result,filename,suffix,subfont)
weight = weight and cleanname(weight)
italicangle = (italicangle == 0) and nil
-- analyse
- local a_name, a_weight, a_style, a_width = analysespec(fullname or fontname or familyname)
+ local a_name, a_weight, a_style, a_width, a_variant = analysespec(fullname or fontname or familyname)
-- check
local width = a_width
+ local variant = a_variant
local style = modifiers and gsub(modifiers,"[^%a]","")
if not style and italicangle then
style = "italic"
end
+ if not variant or variant == "" then
+ variant = "normal"
+ end
if not weight or weight == "" then
weight = a_weight
end
@@ -364,6 +378,7 @@ local function check_name(data,result,filename,suffix,subfont)
weight = weight,
style = style,
width = width,
+ variant = variant,
minsize = result.design_range_bottom or 0,
maxsize = result.design_range_top or 0,
designsize = result.design_size or 0,
@@ -378,18 +393,23 @@ local function cleanupkeywords()
for i=1,#specifications do
local s = specifications[i]
-- fix (sofar styles are taken from the name, and widths from the specification)
- local b_variant, b_weight, b_style, b_width = analysespec(s.weight)
- local c_variant, c_weight, c_style, c_width = analysespec(s.style)
- local d_variant, d_weight, d_style, d_width = analysespec(s.width)
- local e_variant, e_weight, e_style, e_width = analysespec(s.fullname or "")
- local weight = b_weight or c_weight or d_weight or e_weight or "normal"
- local style = b_style or c_style or d_style or e_style or "normal"
- local width = b_width or c_width or d_width or e_width or "normal"
- local variant = b_variant or c_variant or d_variant or e_variant or "normal"
- if weight then weights [weight ] = (weights [weight ] or 0) + 1 end
- if style then styles [style ] = (styles [style ] or 0) + 1 end
- if width then widths [width ] = (widths [width ] or 0) + 1 end
- if variant then variants[variant] = (variants[variant] or 0) + 1 end
+ local _, b_weight, b_style, b_width, b_variant = analysespec(s.weight)
+ local _, c_weight, c_style, c_width, c_variant = analysespec(s.style)
+ local _, d_weight, d_style, d_width, d_variant = analysespec(s.width)
+ local _, e_weight, e_style, e_width, e_variant = analysespec(s.variant)
+ local _, f_weight, f_style, f_width, f_variant = analysespec(s.fullname or "")
+ local weight = b_weight or c_weight or d_weight or e_weight or f_weight or "normal"
+ local style = b_style or c_style or d_style or e_style or f_style or "normal"
+ local width = b_width or c_width or d_width or e_width or f_width or "normal"
+ local variant = b_variant or c_variant or d_variant or e_variant or f_variant or "normal"
+ if not weight or weight == "" then weight = "normal" end
+ if not style or style == "" then style = "normal" end
+ if not width or width == "" then width = "normal" end
+ if not variant or variant == "" then variant = "normal" end
+ weights [weight ] = (weights [weight ] or 0) + 1
+ styles [style ] = (styles [style ] or 0) + 1
+ widths [width ] = (widths [width ] or 0) + 1
+ variants[variant] = (variants[variant] or 0) + 1
if weight ~= s.weight then
s.fontweight = s.weight
end
@@ -404,16 +424,17 @@ local function collectstatistics()
local data = names.data
local specifications = data.specifications
if specifications then
- local weights, styles, widths = { }, { }, { }
+ local weights, styles, widths, variants = { }, { }, { }, { }
for i=1,#specifications do
local s = specifications[i]
- local weight, style, width = s.weight, s.style, s.width
- if weight then weights[weight] = (weights[weight] or 0) + 1 end
- if style then styles [style ] = (styles [style ] or 0) + 1 end
- if width then widths [width ] = (widths [width ] or 0) + 1 end
+ local weight, style, width, variant = s.weight, s.style, s.width, s.variant
+ if weight then weights [weight ] = (weights [weight ] or 0) + 1 end
+ if style then styles [style ] = (styles [style ] or 0) + 1 end
+ if width then widths [width ] = (widths [width ] or 0) + 1 end
+ if variant then variants[variant] = (variants[variant] or 0) + 1 end
end
local stats = data.statistics
- stats.weights, stats.styles, stats.widths, stats.fonts = weights, styles, widths, #specifications
+ stats.weights, stats.styles, stats.widths, stats.variants, stats.fonts = weights, styles, widths, variants, #specifications
end
end
@@ -480,7 +501,7 @@ local function checkduplicate(where) -- fails on "Romantik" but that's a border
for _, m in next, mapping do
for k, v in next, m do
local s = specifications[v]
- local hash = format("%s-%s-%s-%s",s.familyname,s.weight or "*",s.style or "*",s.width or "*")
+ local hash = format("%s-%s-%s-%s-%s",s.familyname,s.weight or "*",s.style or "*",s.width or "*",s.variant or "*")
local h = loaded[hash]
if h then
local ok = true
@@ -919,6 +940,31 @@ end
-- specified search
+local function s_collect_weight_style_width_variant(found,done,all,weight,style,width,variant,family)
+ if family then
+ for i=1,#family do
+ local f = family[i]
+ if f and weight == f.weight and style == f.style and width == f.width and variant == f.variant then
+ found[#found+1], done[f] = f, true
+ if not all then return end
+ end
+ end
+ end
+end
+local function m_collect_weight_style_width_variant(found,done,all,weight,style,width,variant,families,sorted,strictname)
+ for i=1,#sorted do
+ local k = sorted[i]
+ local family = families[k]
+ for i=1,#family do
+ local f = family[i]
+ if not done[f] and weight == f.weight and style == f.style and width == f.width and variant == f.variant and find(f.fontname,strictname) then
+ found[#found+1], done[f] = f, true
+ if not all then return end
+ end
+ end
+ end
+end
+
local function s_collect_weight_style_width(found,done,all,weight,style,width,family)
if family then
for i=1,#family do
@@ -1088,23 +1134,32 @@ local function m_collect(found,done,all,families,sorted,strictname)
end
end
-local function collect(stage,found,done,name,weight,style,width,all)
+local function collect(stage,found,done,name,weight,style,width,variant,all)
local data = names.data
local families, sorted = data.families, data.sorted_families
strictname = "^".. name -- to be checked
local family = families[name]
if trace_names then
- logs.report("fonts","resolving name '%s', weight '%s', style '%s', width '%s'",name or "?",tostring(weight),tostring(style),tostring(width))
+ logs.report("fonts","resolving name '%s', weight '%s', style '%s', width '%s', variant '%s'",
+ name or "?",tostring(weight),tostring(style),tostring(width),tostring(variant))
end
---~ print(name,table.serialize(family))
+ --~ print(name,table.serialize(family))
if weight and weight ~= "" then
if style and style ~= "" then
if width and width ~= "" then
- if trace_names then
- logs.report("fonts","resolving stage %s, name '%s', weight '%s', style '%s', width '%s'",stage,name,weight,style,width)
+ if variant and variant ~= "" then
+ if trace_names then
+ logs.report("fonts","resolving stage %s, name '%s', weight '%s', style '%s', width '%s', variant '%s'",stage,name,weight,style,width,variant)
+ end
+ s_collect_weight_style_width_variant(found,done,all,weight,style,width,variant,family)
+ m_collect_weight_style_width_variant(found,done,all,weight,style,width,variant,families,sorted,strictname)
+ else
+ if trace_names then
+ logs.report("fonts","resolving stage %s, name '%s', weight '%s', style '%s', width '%s'",stage,name,weight,style,width)
+ end
+ s_collect_weight_style_width(found,done,all,weight,style,width,family)
+ m_collect_weight_style_width(found,done,all,weight,style,width,families,sorted,strictname)
end
- s_collect_weight_style_width(found,done,all,weight,style,width,family)
- m_collect_weight_style_width(found,done,all,weight,style,width,families,sorted,strictname)
else
if trace_names then
logs.report("fonts","resolving stage %s, name '%s', weight '%s', style '%s'",stage,name,weight,style)
@@ -1148,23 +1203,28 @@ local function collect(stage,found,done,name,weight,style,width,all)
end
end
-function heuristic(name,weight,style,width,all) -- todo: fallbacks
+function heuristic(name,weight,style,width,variant,all) -- todo: fallbacks
local found, done = { }, { }
- weight, style = weight or "", style or ""
+--~ print(name,weight,style,width,variant)
+ weight, style, width, variant = weight or "normal", style or "normal", width or "normal", variant or "normal"
name = cleanname(name)
- collect(1,found,done,name,weight,style,width,all)
+ collect(1,found,done,name,weight,style,width,variant,all)
-- still needed ?
- if #found == 0 and width ~= "" then
- width = ""
- collect(2,found,done,name,weight,style,width,all)
+ if #found == 0 and variant ~= "normal" then -- not weight
+ variant = "normal"
+ collect(4,found,done,name,weight,style,width,variant,all)
+ end
+ if #found == 0 and width ~= "normal" then
+ width = "normal"
+ collect(2,found,done,name,weight,style,width,variant,all)
end
- if #found == 0 and weight ~= "" then -- not style
- weight = ""
- collect(3,found,done,name,weight,style,width,all)
+ if #found == 0 and weight ~= "normal" then -- not style
+ weight = "normal"
+ collect(3,found,done,name,weight,style,width,variant,all)
end
- if #found == 0 and style ~= "" then -- not weight
- style = ""
- collect(4,found,done,name,weight,style,width,all)
+ if #found == 0 and style ~= "normal" then -- not weight
+ style = "normal"
+ collect(4,found,done,name,weight,style,width,variant,all)
end
--
local nf = #found
@@ -1186,13 +1246,13 @@ function heuristic(name,weight,style,width,all) -- todo: fallbacks
end
end
-function names.specification(askedname,weight,style,width,reload,all)
+function names.specification(askedname,weight,style,width,variant,reload,all)
if askedname and askedname ~= "" and names.enabled then
askedname = lower(askedname) -- or cleanname
names.load(reload)
- local found = heuristic(askedname,weight,style,width,all)
+ local found = heuristic(askedname,weight,style,width,variant,all)
if not found and is_reloaded() then
- found = heuristic(askedname,weight,style,width,all)
+ found = heuristic(askedname,weight,style,width,variant,all)
if not filename then
found = foundname(askedname) -- old method
end
@@ -1201,21 +1261,21 @@ function names.specification(askedname,weight,style,width,reload,all)
end
end
-function names.collect(askedname,weight,style,width,reload,all)
+function names.collect(askedname,weight,style,width,variant,reload,all)
if askedname and askedname ~= "" and names.enabled then
askedname = lower(askedname) -- or cleanname
names.load(reload)
- local list = heuristic(askedname,weight,style,width,true)
+ local list = heuristic(askedname,weight,style,width,variant,true)
if not list or #list == 0 and is_reloaded() then
- list = heuristic(askedname,weight,style,width,true)
+ list = heuristic(askedname,weight,style,width,variant,true)
end
return list
end
end
function names.collectspec(askedname,reload,all)
- local name, weight, style, width = names.splitspec(askedname)
- return names.collect(name,weight,style,width,reload,all)
+ local name, weight, style, width, variant = names.splitspec(askedname)
+ return names.collect(name,weight,style,width,variant,reload,all)
end
function names.resolvespec(askedname,sub)
diff --git a/tex/context/base/font-tfm.lua b/tex/context/base/font-tfm.lua
index c5140ff7c..2f96de44f 100644
--- a/tex/context/base/font-tfm.lua
+++ b/tex/context/base/font-tfm.lua
@@ -228,12 +228,27 @@ local charactercache = { }
-- a virtual font has italic correction make sure to set the
-- has_italic flag. Some more flags will be added in the future.
-function tfm.do_scale(tfmtable, scaledpoints)
- -- tfm.prepare_base_kerns(tfmtable) -- optimalization
+
+function tfm.calculate_scale(tfmtable, scaledpoints, relativeid)
if scaledpoints < 0 then
scaledpoints = (- scaledpoints/1000) * tfmtable.designsize -- already in sp
end
local delta = scaledpoints/(tfmtable.units or 1000) -- brr, some open type fonts have 2048
+ return scaledpoints, delta
+end
+
+function tfm.do_scale(tfmtable, scaledpoints, relativeid)
+ -- tfm.prepare_base_kerns(tfmtable) -- optimalization
+ local scaledpoints, delta = tfm.calculate_scale(tfmtable, scaledpoints, relativeid)
+ if enable_auto_r_scale and relativeid then -- for the moment this is rather context specific
+ local relativedata = fontdata[relativeid]
+ local id_x_height = relativedata and relativedata.parameters and relativedata.parameters.x_height
+ local tf_x_height = id_x_height and tfmtable.parameters and tfmtable.parameters.x_height * delta
+ if tf_x_height then
+ scaledpoints = (id_x_height/tf_x_height) * scaledpoints
+ delta = scaledpoints/(tfmtable.units or 1000)
+ end
+ end
local hdelta, vdelta = delta, delta
local t = { }
-- unicoded unique descriptions shared cidinfo characters changed parameters indices
@@ -628,8 +643,8 @@ end
function tfm.cleanup(tfmdata) -- we need a cleanup callback, now we miss the last one
end
-function tfm.scale(tfmtable, scaledpoints)
- local t, factor = tfm.do_scale(tfmtable, scaledpoints)
+function tfm.scale(tfmtable, scaledpoints, relativeid)
+ local t, factor = tfm.do_scale(tfmtable, scaledpoints, relativeid)
t.factor = factor
t.ascender = factor*(tfmtable.ascender or 0)
t.descender = factor*(tfmtable.descender or 0)
diff --git a/tex/context/base/luat-dum.lua b/tex/context/base/luat-dum.lua
index dd5ade7a9..ceda2d923 100644
--- a/tex/context/base/luat-dum.lua
+++ b/tex/context/base/luat-dum.lua
@@ -23,6 +23,11 @@ trackers = {
enable = dummyfunction,
disable = dummyfunction,
}
+experiments = {
+ register = dummyfunction,
+ enable = dummyfunction,
+ disable = dummyfunction,
+}
storage = {
register = dummyfunction,
shared = { },
diff --git a/tex/context/base/mult-sys.tex b/tex/context/base/mult-sys.tex
index 9653356d7..701cb23dd 100644
--- a/tex/context/base/mult-sys.tex
+++ b/tex/context/base/mult-sys.tex
@@ -217,6 +217,7 @@
\definesystemconstant {mapping}
\definesystemconstant {language}
\definesystemconstant {patterns}
+\definesystemconstant {rname}
\definesystemconstant {rscale}
\definesystemconstant {handling}
\definesystemconstant {features}
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index 5b3ecc9d0..b6e57ed2a 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts-merged.lua
-- parent file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts.lua
--- merge date : 02/01/10 11:23:44
+-- merge date : 02/02/10 23:13:26
do -- begin closure to overcome local limits and interference
@@ -1922,6 +1922,11 @@ trackers = {
enable = dummyfunction,
disable = dummyfunction,
}
+experiments = {
+ register = dummyfunction,
+ enable = dummyfunction,
+ disable = dummyfunction,
+}
storage = {
register = dummyfunction,
shared = { },
@@ -3559,12 +3564,27 @@ local charactercache = { }
-- a virtual font has italic correction make sure to set the
-- has_italic flag. Some more flags will be added in the future.
-function tfm.do_scale(tfmtable, scaledpoints)
- -- tfm.prepare_base_kerns(tfmtable) -- optimalization
+
+function tfm.calculate_scale(tfmtable, scaledpoints, relativeid)
if scaledpoints < 0 then
scaledpoints = (- scaledpoints/1000) * tfmtable.designsize -- already in sp
end
local delta = scaledpoints/(tfmtable.units or 1000) -- brr, some open type fonts have 2048
+ return scaledpoints, delta
+end
+
+function tfm.do_scale(tfmtable, scaledpoints, relativeid)
+ -- tfm.prepare_base_kerns(tfmtable) -- optimalization
+ local scaledpoints, delta = tfm.calculate_scale(tfmtable, scaledpoints, relativeid)
+ if enable_auto_r_scale and relativeid then -- for the moment this is rather context specific
+ local relativedata = fontdata[relativeid]
+ local id_x_height = relativedata and relativedata.parameters and relativedata.parameters.x_height
+ local tf_x_height = id_x_height and tfmtable.parameters and tfmtable.parameters.x_height * delta
+ if tf_x_height then
+ scaledpoints = (id_x_height/tf_x_height) * scaledpoints
+ delta = scaledpoints/(tfmtable.units or 1000)
+ end
+ end
local hdelta, vdelta = delta, delta
local t = { }
-- unicoded unique descriptions shared cidinfo characters changed parameters indices
@@ -3959,8 +3979,8 @@ end
function tfm.cleanup(tfmdata) -- we need a cleanup callback, now we miss the last one
end
-function tfm.scale(tfmtable, scaledpoints)
- local t, factor = tfm.do_scale(tfmtable, scaledpoints)
+function tfm.scale(tfmtable, scaledpoints, relativeid)
+ local t, factor = tfm.do_scale(tfmtable, scaledpoints, relativeid)
t.factor = factor
t.ascender = factor*(tfmtable.ascender or 0)
t.descender = factor*(tfmtable.descender or 0)
@@ -7121,7 +7141,7 @@ function tfm.read_from_open_type(specification)
end
end
end
- tfmtable = tfm.scale(tfmtable,s)
+ tfmtable = tfm.scale(tfmtable,s,specification.relativeid)
-- here we resolve the name; file can be relocated, so this info is not in the cache
local filename = (otfdata and otfdata.luatex and otfdata.luatex.filename) or specification.filename
if not filename then