lpdf.registerfontmethod
Hi Hans, In lpdf-emb.lmt, there's a commented-out definition of lpdf.registerfontmethod that I'd like to use. I've uncommented this in my installation and it's worked pretty well for me, so can you please uncomment/enable this by default in the distribution? If you want further background, this is how I'm using it: lpdf.registerfontmethod("rawpdf", function(filename, details) return details.properties.indexdata[1], 0.001, function(char) return char.code, char.width / t3_to_sp end, function() end, function() end end) local function make_glyph(codepoint, unicode, width, height, code) local spec <const> = { width = width * t3_to_sp, height = height * t3_to_sp, depth = 0, unicode = { utf8.codepoint(unicode or "", 1, -1, true) }, code = width .. " 0 d0 " .. code, } local tfmdata <const> = fonts.hashes.identifiers[font.current()] tfmdata.characters[codepoint] = spec fonts.dropins.swapone( "rawpdf", tfmdata, { code = spec }, codepoint ) fonts.constructors.addcharacters( font.current(), { characters = { [codepoint] = spec } } ) end I specifically need something that writes out a raw PDF stream. I'm using this to write a 4000+ page PDF file to be included by pdfTeX, so I can't have any XObject indirection or similar, otherwise the number of objects skyrockets and pdfTeX (+qpdf) gets really slow. If you're curious, the actual code where I'm using this is here: https://github.com/gucci-on-fleek/unnamed-emoji/blob/master/source/svg-to-pd... https://github.com/gucci-on-fleek/unnamed-emoji/blob/master/source/unnamed-e... I know that what I'm doing in the .cld file is wildly unsupported, but I'm the only one who will ever need to run that. I am planning on distributing the .lua file though, so I'd like to get this change in the distribution. I'm also open to using a different interface instead if you don't want to publicly-expose lpdf.registerfontmethod. Thanks, -- Max
On 7/7/2023 4:51 AM, Max Chernoff wrote:
Hi Hans,
In lpdf-emb.lmt, there's a commented-out definition of lpdf.registerfontmethod that I'd like to use. I've uncommented this in my installation and it's worked pretty well for me, so can you please uncomment/enable this by default in the distribution?
I'll check it but no time today. btw ... as you like low level hacking ... pdftex has a mechanism called pgc (pdf glyph containers) and these are used when no pk font is found (which also means: no map entry) \pdffont ... = \pdfscale 1000 \pdfglyph 1 100 0 0 100 100 ... pdf code ... \pdfendglyph \pdfendfont of course one needs a matching tfm file. I searched my disk but it looks like i removed all the test files of those times. It was some playground for Thanh and me in the good old pdftex dev days but the outlines from mp at that time were not good enough to use in these containers. (It was when the mp to pdf conmverter showed up in context mkii.) One or these now obsolete sub projects; it was kind of fun anyway. Other experiments, like with saving positions (which originally was a context feature that involved betweeen run dvi parsing with dvipos) did make it into a stable feature eventually (read: documented). The code is still there (in write3.c) but I bet that there is no documentation. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
participants (2)
-
Hans Hagen
-
Max Chernoff