From 8e11d447440b44990432ac838953a8cde4ef914f Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Sun, 16 Feb 2020 10:59:14 +0100 Subject: 2020-02-11 16:39:00 --- tex/context/base/mkiv/lpdf-emb.lua | 48 +++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 14 deletions(-) (limited to 'tex/context/base/mkiv/lpdf-emb.lua') diff --git a/tex/context/base/mkiv/lpdf-emb.lua b/tex/context/base/mkiv/lpdf-emb.lua index 8db2ecaf1..4ffcfd8a8 100644 --- a/tex/context/base/mkiv/lpdf-emb.lua +++ b/tex/context/base/mkiv/lpdf-emb.lua @@ -1721,6 +1721,12 @@ do -- Acrobat X pro only seems to see the image mask but other viewers are doing it ok. Acrobat -- reader crashes. We really need to add a notdef! + local files = utilities.files + local openfile = files.open + local closefile = files.close + local setposition = files.setposition + local readstring = files.readstring + function methods.png(filename,details) local properties = details.properties local pngshapes = properties.indexdata[1] @@ -1732,23 +1738,37 @@ do local nofglyphs = 0 local scale = 10 * parameters.size/parameters.designsize local factor = bpfactor / scale - local units = parameters.units / 1000 + -- local units = parameters.units -- / 1000 + local units = 1000 + local filehandle = openfile(details.filename,true) local function pngtopdf(glyph,data) - -- local width = data.width - local info = graphics.identifiers.png(glyph.data,"string") - info.enforcecmyk = pngshapes.enforcecmyk - local image = lpdf.injectors.png(info,"string") - embedimage(image) - nofglyphs = nofglyphs + 1 - local width = (data.width or 0) * factor - local xoffset = (glyph.x or 0) / units - local yoffset = (glyph.y or 0) / units - local name = f_glyph(nofglyphs) - xforms[name] = pdfreference(image.objnum) - local pdf = f_image_xy(width,xoffset,yoffset,name) - return pdf, width + -- local info = graphics.identifiers.png(glyph.data,"string") + local offset = glyph.o + local size = glyph.s + local pdfdata = nil + if offset and size then + setposition(filehandle,offset) + local blob = readstring(filehandle,size) + local info = graphics.identifiers.png(blob,"string") + info.enforcecmyk = pngshapes.enforcecmyk + local image = lpdf.injectors.png(info,"string") + local width = (data.width or 0) * factor + if image then + embedimage(image) + nofglyphs = nofglyphs + 1 + local xoffset = (glyph.x or 0) / units + local yoffset = (glyph.y or 0) / units + local name = f_glyph(nofglyphs) + xforms[name] = pdfreference(image.objnum) + pdfdata = f_image_xy(width,xoffset,yoffset,name) + end + end + return pdfdata or f_stream(width), width end local function closepng() + if filehandle then + closefile(filehandle) + end pngshapes = nil end local function getresources() -- cgit v1.2.3