[comp.lang.postscript] Obliquing fonts

capslock@well.sf.ca.us (Allen Crider) (05/23/91)

I'm trying to oblique a roman font. I know the pointsize and I know the 
obliquing angle. The only example of obliquing type I have seen is in
the Blue book (Tutorial and Cookbook) in which they give an example of
a font obliqued 30 degrees:
 [12 0 6.93 12 0 0] makefont
 "The 6.93 in our last matrix above is the product of 12xtan30, so our
characters are obliqued by thirty degrees." Says the Blue Book.

I tried doing this in C:
f = 12 * tan(30);

and get 76.864, not 6.93.
Since I wasn't around when they passed out the trigonometry, maybe some
kind soul could guide me to the best way to figure out the correct value
to put in that matrix. Thanks

carl@hamlet.caltech.edu (Lydick, Carl) (05/23/91)

In article <24968@well.sf.ca.us>, capslock@well.sf.ca.us (Allen Crider) writes...
>I'm trying to oblique a roman font. I know the pointsize and I know the 
>obliquing angle. The only example of obliquing type I have seen is in
>the Blue book (Tutorial and Cookbook) in which they give an example of
>a font obliqued 30 degrees:
> [12 0 6.93 12 0 0] makefont
> "The 6.93 in our last matrix above is the product of 12xtan30, so our
>characters are obliqued by thirty degrees." Says the Blue Book.
> 
>I tried doing this in C:
>f = 12 * tan(30);
> 
>and get 76.864, not 6.93.
>Since I wasn't around when they passed out the trigonometry, maybe some
>kind soul could guide me to the best way to figure out the correct value
>to put in that matrix. Thanks

PostScript uses degrees.  C's tan() uses radians.  Tan(30 degrees) = 1/sqrt(3),
which is, in fact, about 6.93.
--------------------------------------------------------------------------------
Carl J Lydick	HEPnet/NSI: SOL1::CARL	Internet: CARL@SOL1.GPS.CALTECH.EDU

piet@cs.ruu.nl (Piet van Oostrum) (05/23/91)

>>>>> carl@hamlet.caltech.edu (Lydick, Carl) (LC) writes:

LC> In article <24968@well.sf.ca.us>, capslock@well.sf.ca.us (Allen Crider) writes...
>I'm trying to oblique a roman font. I know the pointsize and I know the 
>obliquing angle. The only example of obliquing type I have seen is in
>the Blue book (Tutorial and Cookbook) in which they give an example of
>a font obliqued 30 degrees:
> [12 0 6.93 12 0 0] makefont
> "The 6.93 in our last matrix above is the product of 12xtan30, so our
>characters are obliqued by thirty degrees." Says the Blue Book.
> 
>I tried doing this in C:
>f = 12 * tan(30);
> 
>and get 76.864, not 6.93.
>Since I wasn't around when they passed out the trigonometry, maybe some
>kind soul could guide me to the best way to figure out the correct value
>to put in that matrix. Thanks

LC> PostScript uses degrees.  C's tan() uses radians.  Tan(30 degrees) = 1/sqrt(3),
LC> which is, in fact, about 6.93.

Well, nitpicking: It is 6.93 after multiplying by 12:

Emacs Calc Mode v1.07 by Dave Gillespie
     30
 tan 0.57735026919
     12
   * 6.92820323028

Moreover he gave tan an int, whereas it needs a double (apparently he used
no ANSI style prototypes) so the result was very much implementation
dependent.

Just using a calculator would have been easier.
-- 
Piet* van Oostrum, Dept of Computer Science, Utrecht University,
Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands.
Telephone: +31 30 531806   Uucp:   uunet!mcsun!ruuinf!piet
Telefax:   +31 30 513791   Internet:  piet@cs.ruu.nl   (*`Pete')

bamford@cbnewsd.att.com (harold.e.bamford) (05/23/91)

In article <24968@well.sf.ca.us> capslock@well.sf.ca.us (Allen Crider) writes:
> "The 6.93 in our last matrix above is the product of 12xtan30, so our
>characters are obliqued by thirty degrees." Says the Blue Book.
>
>I tried doing this in C:
>f = 12 * tan(30);
>
>and get 76.864, not 6.93.

Using 30 degrees: 12 * tan(30) = 12 * 0.57735 = 6.9282

Using 30 radians: 12 * tan(30 = 12 * -6.40533 = -76.8639

Postscript angles are in degrees, not radians.

-- Harold

lee@leo (Bill Lee) (05/28/91)

In article <24968@well.sf.ca.us> capslock@well.sf.ca.us (Allen Crider) writes:
>I'm trying to oblique a roman font. I know the pointsize and I know the 
>obliquing angle. The only example of obliquing type I have seen is in
>the Blue book (Tutorial and Cookbook) in which they give an example of
>a font obliqued 30 degrees:
> [12 0 6.93 12 0 0] makefont
> "The 6.93 in our last matrix above is the product of 12xtan30, so our
>characters are obliqued by thirty degrees." Says the Blue Book.
>
>I tried doing this in C:
>f = 12 * tan(30);
>
>and get 76.864, not 6.93.
>Since I wasn't around when they passed out the trigonometry, maybe some
>kind soul could guide me to the best way to figure out the correct value
>to put in that matrix. Thanks

Here's a procedure that I use to achieve just what you're looking for.

Bill Lee		lee@shell.com
Shell Oil Co.

-------------------------cut here--------------------------------------------
%* _________________________ Oblique __________________________________________
%* Procedure to modify the (normally) rectangular coordinate system of the
%* page to a non-right angle. When used, all x and y dimensions are
%* measured parallel to the new x and y axese. This results in squares
%* becoming parallelograms, circles becoming ellipses, etc. It also means that
%* moving off into the page will often run off the edge of the paper, so
%* be careful of the positining on the page.
%*
%*	angle Oblique
%*		where angle is the off-vertical of the Y axis in degrees.
%*		A positive angle is clockwise rotation of the Y axis 
%*		relative to existing axis.

/Oblique {
  /angle exch def
  [ 1 0 angle sin angle cos 0 0 ] concat
  } def