tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Heirloom Troff for NetBSD (was: Removing ARCNET stuffs)



Valery Ushakov <uwe%stderr.spb.ru@localhost> wrote:
 |On Tue, Jun 09, 2015 at 18:04:52 +0000, David Holland wrote:
 |> On Tue, Jun 09, 2015 at 04:51:09PM +0200, carsten.kunze%arcor.de@localhost wrote:
 |>> "James K. Lowden" <jklowden%schemamania.org@localhost> wrote:

 |>> It does product PDF directly, if you pipe the output of dpost(1) to
 |>> e.g. "ps2pdf - <PDF filename>" :-)

 |>> Drawback is that ghostscript has a GNU license.

 |I spent a bit of time last year looking at writing a gropdf backend
 |using http://libharu.org/ which is ZLib-licensed.

That is an interesting pointer, thanks for mentioning that!

 |IIRC, it was mostly trivial with one nasty exception - C <name>
 |command that emits named char at the current point.  The porblem is
 |that C does NOT change current position.  And in PDF you can't
 |save/restore it, so to be able to move back to where C started you
 |must know the width of that character, so suddenly your postprocessor
 |needs to know about gory details of font metrics.  I checked gropdf
 |that comes with newer groff and it does indeed read the metrics, which
 |is rather gross.  For my quick-and-dirty proof of concept I hacked
 |libharu to accept negative scaling and did:
 |
 |    $page->ShowText($text);
 |
 |    $page->SetHorizontalScalling(-100); # backwards
 |    $page->SetTextRenderingMode(PDF::Haru::HPDF_INVISIBLE);
 |    $page->ShowText($text);
 |    $page->SetTextRenderingMode(PDF::Haru::HPDF_FILL);
 |    $page->SetHorizontalScalling(100);
 |
 |which gives the right visual result, but messes us things like
 |text-extraction.
 |
 |Obviously, groff does know the width and, from a quick look at the
 |sources, it should be trivial to emit it as part of C command, but
 |that would be a change in groff_out(5) format.
 |
 |So I'd say adding a PDF backend based on libharu should be sufficienly
 |easy, provided it's given a bit more info that the formatter already
 |does know.  The license seems suitable too.
 |
 |My perl script that handles only text was under 200 lines, not
 |counting maps for font names and character names.  I haven't looked at
 |the graphics part, but unless there are similar warts in the
 |intermediate format there shouldn't be many problems.

I'm far from being able to say anything about S-roff and PDF (i
yet thought about MuPDF, but indeed that is GPL3!) -- not to talk
about adding actual support --, but i will surely come back to
this post of yours at that time.  

--steffen


Home | Main Index | Thread Index | Old Index