ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* lpdf.registerfontmethod
@ 2023-07-07  2:51 Max Chernoff
  2023-07-07 12:05 ` lpdf.registerfontmethod Hans Hagen via ntg-context
  0 siblings, 1 reply; 2+ messages in thread
From: Max Chernoff @ 2023-07-07  2:51 UTC (permalink / raw)
  To: ntg-context

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-pdf.cld
   https://github.com/gucci-on-fleek/unnamed-emoji/blob/master/source/unnamed-emoji.lua

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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: lpdf.registerfontmethod
  2023-07-07  2:51 lpdf.registerfontmethod Max Chernoff
@ 2023-07-07 12:05 ` Hans Hagen via ntg-context
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen via ntg-context @ 2023-07-07 12:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Hans Hagen

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-07 12:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-07  2:51 lpdf.registerfontmethod Max Chernoff
2023-07-07 12:05 ` lpdf.registerfontmethod Hans Hagen via ntg-context

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).