Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Postscript with new TT font

by ksublondie (Friar)
on Feb 09, 2011 at 20:56 UTC ( [id://887284]=perlquestion: print w/replies, xml ) Need Help??

ksublondie has asked for the wisdom of the Perl Monks concerning the following question:

This may be a stupid question, but for the life of me, I can't figure this out. I need some fresh eyes to fill in the gaps.

I have a perl/CGI program on a unix server. I need to create postscript content using a true-type font and print the content to a networked printer (instead of a local printer for security reasons). I've found modules that will open TTL files (PostScript::Font::TTtoType42 and PostScript::TTF) and modules that will allow me to create postscript content (PostScript::Simple, PostScript::TextBlock, PostScript::Report) which I can then send to a printer. But HOW do I use those font modules in the postscript modules??? All the ps modules take text input for the font type (according to the documentation). I can't figure out how to actually use the TTL files once I've opened them.

I've tried installing a few of them, but got stuck during the install. I would hate to spend hours figuring out the install if I'm not even sure the modules are what I want in the first place.

Thanks in advance...

Replies are listed 'Best First'.
Re: Postscript with new TT font
by Anonyrnous Monk (Hermit) on Feb 09, 2011 at 21:32 UTC
    I need to create postscript content using a true-type font

    The general idea would be to convert the true-type font to Type42 format, and then embed it into the Postscript file.

    (The requirement to embed the font holds for any "non-standard" font, whether it be true-type/Type42 or standard PS Type1. There are a certain number of predefined standard fonts a printer must have to call itself PS compatible, but it may also come with additional fonts).

    You can convert the TT font with PostScript::Font::TTtoType42, either as shown in the synopsis of the module, or by using the script ttfwrapper that comes with the module. For example:

    $ ttfwrapper verdana.ttf > verdana.t42

    Then - in its absolutely most simple case - write a Postscript file something like this

    %!PS ... embedded font goes here ... /Verdana findfont 30 scalefont setfont 100 100 moveto (Some text in Verdana font) show showpage

    and insert the entire PS code for the .t42 font (as generated by ttfwrapper) where indicated.  You then have a sample stand-alone PS file which would print a line of text in a non-standard font.  Of course, use your correct font name instead of "Verdana"... (you can find the name as an entry /FontName (such as /FontName /Verdana def) near the beginning of the font file).

    Essentially, a font file is a set of Postscript instructions that, when executed, define everything required, like drawing routines for the glyphs, the encoding vector, etc.

    If you use a module (like PostScript::Simple) to generate the Postscript code, you'll also have to find some way to embed the font (I haven't used the module, so I'd have to check the docs just like you...).  In case of doubt, when there's no dedicated procedure for doing so, you can always insert the font(s) after the PS output has been generated.  In its most simple case, insert the fonts at the beginning — or see "Resource Management" in the Document Structuring Conventions (DSC) for more sophisticated techniques.

      Thanks for filling in the gaps. You've gotten me down the right direction. Thanks!
Re: Postscript with new TT font
by jethro (Monsignor) on Feb 09, 2011 at 22:12 UTC
    How is printing to a networked printer more secure than to a local printer?
      This is actually an internal application that is going to be printing checks. I don't want anyone to print to any ol' printer on the network either accidentally or intentionally. All print jobs need to go to this one printer and one printer only.
        The way we used to do it at my old job, the payroll computer was not networked, it sat in a locked room, it used dialup to connect to timesheet server once a day for 5 minutes max...
        So in your initial post you meant to say "... and print the content to a local printer (instead of a networked printer..." and not the other way round. Thought so.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://887284]
Approved by petdance
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-24 17:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found