[comp.lang.postscript] Rounding Corners On Helvetica Fonts.

SW@harlqn.UUCP (ScriptWorks Users) (06/30/89)

In article <2277@basser.oz> jaa@basser.oz (James Ashton) writes:
>In article <5665@rpi.edu> kibo@pawl.rpi.edu (James 'Kibo' Parry) writes:
>>	Does anyone have a good way for rounding the corners/ends of letters
>>in a font?  (I.e. to change Helvetica into an approximation of Helvetica
>>Rounded, etc.)  I suppose a routine that knocked pixels off of corners
>>would work, if anyone has bothered to program such a thing...
>
>If you mean can you do this in postscript, the answer is no.  It is true
>that some fonts (like those in the Courier family) are described as
>strokes and somewhere in their font dictionaries (I'd love to know where)
>is the linecap, linejoin, miterlimit and linewidth information.
>By changing these four parameters you could create a reasonable new
>font.  For example you could change linecap and linejoin from 1 to 2
>for the Courier family fonts and have a Square Courier family.  In your
>example you'd change linecap and linejoin from 2 to 1 if only Helvetica 
>was defined as a stroked font.  Sadly it is an outline font, meaning
>the outline shape of the glyphs is given instead of the centre paths.
>PostScript insulates the user from the output device's bit map as much
>as possible and so there is no (even faintly easy) way for you to go
>around turning off the `corner' pixels either.
>
>						James Ashton.

In fact the answer to the request is that YES you can.  Try sending the
following bit of PostScript to your printer.
If the following doesn't work on the LaserWriter then my apologies,
as I only had time to test it on ScriptWorks.

Andy Cave.

------------------------------ CUT HERE ------------------------------


%! DEFINE A NEW UNDERLINE FONT.
%% COPYRIGHT HARLEQUIN LTD 1987,1988.
%% AUTHOR: A.CAVE.
%% RUNS ON SCRIPTWORKS VERISON 5.15 UPWARDS.

% STACK: oldfontname newfontname
/define-stroked-font {
 /NewFont exch def
% Space for new font's dictionary.
 NewFont 16 dict def
 NewFont load begin
 /BaseFont exch def
% Copy over old font - except for FID entry.
  BaseFont findfont {
   1 index /FID eq
    { pop pop }
    { def }
   ifelse
  } forall
% Temporary.
  /s (1) def
% Change font type to user defined font.
  /FontType 3 def
% Add the BuildChar routine.
  /BuildChar {
    exch begin
     s exch 0 exch put
% Use base font definition.
     BaseFont findfont 1000 scalefont setfont
% Find the string width of the original.
      s stringwidth 2 copy
      currentfont /FontBBox get aload pop
     setcachedevice
% Fill and then stroke the font with circular line caps.
     1 setlinecap 1 setlinejoin
     currentfont /FontInfo get /UnderlineThickness get 1.75 div setlinewidth
     0 0 moveto s false charpath gsave fill grestore stroke
% Underline the font.
     0 setlinecap 1 setlinejoin
     pop currentfont /FontInfo get /UnderlinePosition get dup 0 exch moveto
     lineto stroke
    end
  } bind def
 end
 NewFont dup load definefont pop
} bind def

/Helvetica /Helvetica-Stroked define-stroked-font

/Helvetica-Stroked findfont 64 scalefont setfont
300 100 moveto
90 rotate
(Harlequin's ScriptWorks) show
showpage

------------------------------ CUT HERE ------------------------------

jaa@basser.oz (James Ashton) (07/04/89)

In article <1863@harlqn.UUCP> SW@uucp (ScriptWorks Users) writes:
>In article <2277@basser.oz> jaa@basser.oz (James Ashton) writes:
>>In article <5665@rpi.edu> kibo@pawl.rpi.edu (James 'Kibo' Parry) writes:
>>>	Does anyone have a good way for rounding the corners/ends of letters
>>>in a font?  (I.e. to change Helvetica into an approximation of Helvetica
>>>Rounded, etc.)  I suppose a routine that knocked pixels off of corners
>>>would work, if anyone has bothered to program such a thing...
>>
>>If you mean can you do this in postscript, the answer is no...
>
>In fact the answer to the request is that YES you can.  Try sending the
>following bit of PostScript to your printer.
>If the following doesn't work on the LaserWriter then my apologies,
>as I only had time to test it on ScriptWorks.

Well it does work on LaserWriters and I have to admit that it does the
job quite neatly.  The only trouble with it is that the resulting font
is much bolder than the original.  Using this method, the more the
corners are to be rounded, the bolder the characters become.  If (as I
mentioned in my original posting) Helvetica was a stroked font then
this could be avoided.  My guess is that the original requester wants
the rounding done without the enlarging effect and, if this is the
case, my claim that it cannot be done stands.  The only way around
would be to write some routine to `shrink paths'.  This is theoretically
possible in PostScript except that using pathforall with a path
created by charpath is disallowed for security reasons. :-(  Also
I would not like to have to write the routine as it is a non trivial
thing to do.

						James Ashton.