From 352a2686282e95b2869728f8f321688f7e216d80 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Thu, 7 May 2020 11:47:12 +0200 Subject: 2020-05-07 11:00:00 --- tex/context/base/mkiv/font-shp.lua | 127 +++---------------------------------- 1 file changed, 10 insertions(+), 117 deletions(-) (limited to 'tex/context/base/mkiv/font-shp.lua') diff --git a/tex/context/base/mkiv/font-shp.lua b/tex/context/base/mkiv/font-shp.lua index 4d5254760..c3fea6d46 100644 --- a/tex/context/base/mkiv/font-shp.lua +++ b/tex/context/base/mkiv/font-shp.lua @@ -379,124 +379,17 @@ otf.loadstreamdata = loadstreamdata -- not public otf.loadshapes = loadshapes otf.getstreamhash = getstreamhash -- not public, might move to other namespace -local f_c = formatters["%.6N %.6N %.6N %.6N %.6N %.6N c"] -local f_l = formatters["%.6N %.6N l"] -local f_m = formatters["%.6N %.6N m"] - -local function segmentstopdf(segments,factor,bt,et) - local t = { } - local m = 0 - local n = #segments - local d = false - for i=1,n do - local s = segments[i] - local w = s[#s] - if w == "c" then - m = m + 1 - t[m] = f_c(s[1]*factor,s[2]*factor,s[3]*factor,s[4]*factor,s[5]*factor,s[6]*factor) - elseif w == "l" then - m = m + 1 - t[m] = f_l(s[1]*factor,s[2]*factor) - elseif w == "m" then - m = m + 1 - t[m] = f_m(s[1]*factor,s[2]*factor) - elseif w == "q" then - local p = segments[i-1] - local n = #p - local l_x = factor*p[n-2] - local l_y = factor*p[n-1] - local m_x = factor*s[1] - local m_y = factor*s[2] - local r_x = factor*s[3] - local r_y = factor*s[4] - m = m + 1 - t[m] = f_c ( - l_x + 2/3 * (m_x-l_x), l_y + 2/3 * (m_y-l_y), - r_x + 2/3 * (m_x-r_x), r_y + 2/3 * (m_y-r_y), - r_x, r_y - ) - end - end - m = m + 1 - t[m] = "h f" -- B* - if bt and et then - t[0] = bt - t[m+1] = et - return concat(t,"\n",0,m+1) - else - return concat(t,"\n") - end -end - -local function initialize(tfmdata,key,value) - if value then - local shapes = otf.loadoutlinedata(tfmdata) - if not shapes then - return - end - local glyphs = shapes.glyphs - if not glyphs then - return - end - local characters = tfmdata.characters - local parameters = tfmdata.parameters - local hfactor = parameters.hfactor * (7200/7227) - local factor = hfactor / 65536 - local getactualtext = otf.getactualtext - for unicode, char in next, characters do - if char.commands then - -- can't happen as we're doing this before other messing around - else - local shape = glyphs[char.index] - if shape then - local segments = shape.segments - if segments then - -- we need inline in order to support color - local bt, et = getactualtext(char.tounicode or char.unicode or unicode) - char.commands = { - { "pdf", "origin", segmentstopdf(segments,factor,bt,et) } - } - end - end - end - end - end -end - -otf.features.register { - name = "variableshapes", -- enforced for now - description = "variable shapes", - manipulators = { - base = initialize, - node = initialize, - } -} - --- In the end it is easier to just provide the new charstring (cff) and points (ttf). First --- of all we already have the right information so there is no need to patch the already complex --- backend code (we only need to make sure the cff is valid). Also, I prototyped support for --- these fonts using (converted to) normal postscript shapes, a functionality that was already --- present for a while for metafun. This solution even permits us to come up with usage of such --- fonts in unexpected ways. It also opens the road to shapes generated with metafun includes --- as real cff (or ttf) shapes instead of virtual in-line shapes. --- --- This is probably a prelude to writing a complete backend font inclusion plugin in lua. After --- all I already have most info. For this we just need to pass a list of used glyphs (or analyze --- them ourselves). - local streams = fonts.hashes.streams -if callbacks.supported.glyph_stream_provider then +-- we can now assume that luatex has this one - callback.register("glyph_stream_provider",function(id,index,mode) - if id > 0 then - local streams = streams[id].streams - -- print(id,index,streams[index]) - if streams then - return streams[index] or "" - end +callback.register("glyph_stream_provider",function(id,index,mode) + if id > 0 then + local streams = streams[id].streams + -- print(id,index,streams[index]) + if streams then + return streams[index] or "" end - return "" - end) - -end + end + return "" +end) -- cgit v1.2.3