diff options
author | Hans Hagen <pragma@wxs.nl> | 2020-02-16 10:59:14 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2020-02-16 10:59:14 +0100 |
commit | 8e11d447440b44990432ac838953a8cde4ef914f (patch) | |
tree | f30b2ff2d8a10f1aff50e1522d968618a97f067c /tex/context/base/mkiv/lpdf-emb.lua | |
parent | 43fc66771a0c9d27cc0b7fe7a69392ea313bd0ca (diff) | |
download | context-8e11d447440b44990432ac838953a8cde4ef914f.tar.gz |
2020-02-11 16:39:00
Diffstat (limited to 'tex/context/base/mkiv/lpdf-emb.lua')
-rw-r--r-- | tex/context/base/mkiv/lpdf-emb.lua | 48 |
1 files changed, 34 insertions, 14 deletions
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() |