summaryrefslogtreecommitdiff
path: root/src/fontloader/misc/fontloader-font-con.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/fontloader/misc/fontloader-font-con.lua')
-rw-r--r--src/fontloader/misc/fontloader-font-con.lua122
1 files changed, 72 insertions, 50 deletions
diff --git a/src/fontloader/misc/fontloader-font-con.lua b/src/fontloader/misc/fontloader-font-con.lua
index 72fbb5c..55d7793 100644
--- a/src/fontloader/misc/fontloader-font-con.lua
+++ b/src/fontloader/misc/fontloader-font-con.lua
@@ -170,8 +170,8 @@ constructors.setfactor()
function constructors.scaled(scaledpoints, designsize) -- handles designsize in sp as well
if scaledpoints < 0 then
+ local factor = constructors.factor
if designsize then
- local factor = constructors.factor
if designsize > factor then -- or just 1000 / when? mp?
return (- scaledpoints/1000) * designsize -- sp's
else
@@ -191,10 +191,9 @@ in the process; numbers are of course copies. Here 65536 equals 1pt. (Due to
excessive memory usage in CJK fonts, we no longer pass the boundingbox.)</p>
--ldx]]--
--- The scaler is only used for otf and afm and virtual fonts. If
--- a virtual font has italic correction make sure to set the
--- hasitalics flag. Some more flags will be added in
--- the future.
+-- The scaler is only used for otf and afm and virtual fonts. If a virtual font has italic
+-- correction make sure to set the hasitalics flag. Some more flags will be added in the
+-- future.
--[[ldx--
<p>The reason why the scaler was originally split, is that for a while we experimented
@@ -426,6 +425,7 @@ function constructors.scale(tfmdata,specification)
local vdelta = delta
--
target.designsize = parameters.designsize -- not really needed so it might become obsolete
+ target.units = units
target.units_per_em = units -- just a trigger for the backend
--
local direction = properties.direction or tfmdata.direction or 0 -- pointless, as we don't use omf fonts at all
@@ -562,26 +562,27 @@ function constructors.scale(tfmdata,specification)
target.mathparameters = nil -- nop
end
--
- local italickey = "italic"
- local useitalics = true -- something context
- --
- -- some context specific trickery (this will move to a plugin)
+ -- Here we support some context specific trickery (this might move to a plugin). During the
+ -- transition to opentype the engine had troubles with italics so we had some additional code
+ -- for fixing that. In node mode (text) we don't care much if italics gets passed because
+ -- the engine does nothign with them then.
--
if hasmath then
- -- the latest luatex can deal with it itself so we now disable this
- -- mechanism here
- --
- -- if properties.mathitalics then
- -- italickey = "italic_correction"
- -- if trace_defining then
- -- report_defining("math italics disabled for font %a, fullname %a, filename %a",name,fullname,filename)
- -- end
- -- end
- autoitalicamount = false -- new
- elseif properties.textitalics then
- italickey = "italic_correction"
- useitalics = false
- if properties.delaytextitalics then
+ local mathitalics = properties.mathitalics
+ if mathitalics == false then
+ if trace_defining then
+ report_defining("%s italics %s for font %a, fullname %a, filename %a","math",hasitalics and "ignored" or "disabled",name,fullname,filename)
+ end
+ hasitalics = false
+ autoitalicamount = false
+ end
+ else
+ local textitalics = properties.textitalics
+ if textitalics == false then
+ if trace_defining then
+ report_defining("%s italics %s for font %a, fullname %a, filename %a","text",hasitalics and "ignored" or "disabled",name,fullname,filename)
+ end
+ hasitalics = false
autoitalicamount = false
end
end
@@ -590,8 +591,7 @@ function constructors.scale(tfmdata,specification)
--
if trace_defining then
report_defining("defining tfm, name %a, fullname %a, filename %a, hscale %a, vscale %a, math %a, italics %a",
- name,fullname,filename,hdelta,vdelta,
- hasmath and "enabled" or "disabled",useitalics and "enabled" or "disabled")
+ name,fullname,filename,hdelta,vdelta,hasmath and "enabled" or "disabled",hasitalics and "enabled" or "disabled")
end
--
constructors.beforecopyingcharacters(target,tfmdata)
@@ -606,15 +606,15 @@ function constructors.scale(tfmdata,specification)
local c = changed[unicode]
if c then
description = descriptions[c] or descriptions[unicode] or character
- character = characters[c] or character
- index = description.index or c
+ character = characters[c] or character
+ index = description.index or c
else
description = descriptions[unicode] or character
- index = description.index or unicode
+ index = description.index or unicode
end
else
description = descriptions[unicode] or character
- index = description.index or unicode
+ index = description.index or unicode
end
local width = description.width
local height = description.height
@@ -699,24 +699,8 @@ function constructors.scale(tfmdata,specification)
end
end
--
- if autoitalicamount then
- local vi = description.italic
- if not vi then
- local vi = description.boundingbox[3] - description.width + autoitalicamount
- if vi > 0 then -- < 0 indicates no overshoot or a very small auto italic
- chr[italickey] = vi*hdelta
- end
- elseif vi ~= 0 then
- chr[italickey] = vi*hdelta
- end
- elseif hasitalics then
- local vi = description.italic
- if vi and vi ~= 0 then
- chr[italickey] = vi*hdelta
- end
- end
- -- to be tested
if hasmath then
+ --
-- todo, just operate on descriptions.math
local vn = character.next
if vn then
@@ -753,8 +737,13 @@ function constructors.scale(tfmdata,specification)
chr.horiz_variants = t
end
end
+ -- todo also check mathitalics (or that one can go away)
end
- local va = character.top_accent
+ local vi = character.vert_italic
+ if vi and vi ~= 0 then
+ chr.vert_italic = vi*hdelta
+ end
+ local va = character.accent
if va then
chr.top_accent = vdelta*va
end
@@ -777,6 +766,27 @@ function constructors.scale(tfmdata,specification)
chr.mathkern = kerns -- singular -> should be patched in luatex !
end
end
+ if hasitalics then
+ local vi = character.italic
+ if vi and vi ~= 0 then
+ chr.italic = vi*hdelta
+ end
+ end
+ elseif autoitalicamount then -- itlc feature
+ local vi = description.italic
+ if not vi then
+ local vi = description.boundingbox[3] - description.width + autoitalicamount
+ if vi > 0 then -- < 0 indicates no overshoot or a very small auto italic
+ chr.italic = vi*hdelta
+ end
+ elseif vi ~= 0 then
+ chr.italic = vi*hdelta
+ end
+ elseif hasitalics then -- unlikely
+ local vi = character.italic
+ if vi and vi ~= 0 then
+ chr.italic = vi*hdelta
+ end
end
if haskerns then
local vk = character.kerns
@@ -843,6 +853,8 @@ function constructors.scale(tfmdata,specification)
targetcharacters[unicode] = chr
end
--
+ properties.setitalics = hasitalics -- for postprocessing
+ --
constructors.aftercopyingcharacters(target,tfmdata)
--
constructors.trytosharefont(target,tfmdata)
@@ -895,12 +907,21 @@ function constructors.finalize(tfmdata)
parameters.slantfactor = tfmdata.slant or 0
end
--
- if not parameters.designsize then
- parameters.designsize = tfmdata.designsize or (factors.pt * 10)
+ local designsize = parameters.designsize
+ if designsize then
+ parameters.minsize = tfmdata.minsize or designsize
+ parameters.maxsize = tfmdata.maxsize or designsize
+ else
+ designsize = factors.pt * 10
+ parameters.designsize = designsize
+ parameters.minsize = designsize
+ parameters.maxsize = designsize
end
+ parameters.minsize = tfmdata.minsize or parameters.designsize
+ parameters.maxsize = tfmdata.maxsize or parameters.designsize
--
if not parameters.units then
- parameters.units = tfmdata.units_per_em or 1000
+ parameters.units = tfmdata.units or tfmdata.units_per_em or 1000
end
--
if not tfmdata.descriptions then
@@ -976,6 +997,7 @@ function constructors.finalize(tfmdata)
tfmdata.auto_protrude = nil
tfmdata.extend = nil
tfmdata.slant = nil
+ tfmdata.units = nil
tfmdata.units_per_em = nil
--
tfmdata.cache = nil