From 4f053696e1813fde4bd6cebbb77ff2a1e1f6800b Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 29 Oct 2015 07:14:40 +0100 Subject: [fontloader] sync with Context as of 2015-10-29 --- src/fontloader/misc/fontloader-font-con.lua | 114 ++++++++++++++++------------ 1 file changed, 65 insertions(+), 49 deletions(-) (limited to 'src/fontloader/misc/fontloader-font-con.lua') diff --git a/src/fontloader/misc/fontloader-font-con.lua b/src/fontloader/misc/fontloader-font-con.lua index 72fbb5c..383a403 100644 --- a/src/fontloader/misc/fontloader-font-con.lua +++ b/src/fontloader/misc/fontloader-font-con.lua @@ -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.)

--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--

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,23 +699,6 @@ 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 @@ -754,7 +737,7 @@ function constructors.scale(tfmdata,specification) end end end - local va = character.top_accent + local va = character.accent if va then chr.top_accent = vdelta*va end @@ -777,6 +760,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 +847,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 +901,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 +991,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 -- cgit v1.2.3