[comp.lang.postscript] unAdobe & unMac

paul@frcs.UUCP (Paul Nash) (09/26/90)

A while back I went through a great period of Angst regarding 
font formats in general and Mac to PC conversion in particular.
A number of people responded, and have solved all my problems
(well, those relating to fonts, anyway). Robert Elliot stands
out among those, and I would like to thank him especially.

In response to a number of requests for unAdobe for the MAC
(which Robert sent to me) and my own unMac for the PC, I
have posted both to the net. If anyone has not seen either
within a few days of seeing this, _and wants them_, please
mail me _AND SAY THAT YOU SAW THIS POSTING_. I will ignore
any other requests, as I assume that they crossed my posting.

If I get a lot of ``I _still_ haven't go it'' mail, I will
repost, otherwise I will just mail individuals to save
bandwidth. Sorry about the bandwidth waste with this note, but
I know how much I struggled until I got the info from Robert.

Thanks again :-)

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 Paul Nash			 Flagship Wide Area Networks (Pty) Ltd
  paul@frcs.UUCP			  ...!ddsw1!proxima!frcs!paul

paul@frcs.UUCP (Paul Nash) (09/28/90)

paul@frcs.UUCP (Paul Nash) writes:

>In response to a number of requests for unAdobe for the MAC
>(which Robert sent to me) and my own unMac for the PC, I
>have posted both to the net.

However, I have finally managed to lay my hands on a genuine
PostScript printer, and found that the generated fonts did 
not work :-(. I have fixed the bugs in unMac, so here is
the new, improved, unMac version 1.1.

Just to recap (for those who tuned in late), unMac is a PC
program to convert PostScribble fonts in Mac format into 
straight ASCII format. The fonts are stored in the resource
fork of the Mac file, which can be copied off with the 
Dayna `dosmount' utility. This program converts such a 
DOS version of a resource fork into an ASCII file. It works
on a Qume Scripten, with various Adobe (TM) fonts.

/*
   An extremely quick and nasty hack to convert the DOS version of a MAC
   resource containing an Adobe font (whew!) copied with ``dosmount'',
   into something that I can download to a laser printer from anything.

   Copyright (c) Flagship, 1990. Use at your own risk.
*/

#include <stdio.h>
#include <stdlib.h>

main ( int argc, char *argv[] )
{
   FILE *inf, *outf;
   int  i;
   int ch;
   
   union LENGTH {
      char c[4];
      long l;
   } length;

   union BIT {
      char c[2];
      int i;
   } bit;

   
   if ( argc != 3 ) {
      fprintf( stderr, "Wrong! UnMac macresource pcfont\n" );
      exit( -1 );
   }
   if ( ( inf = fopen( argv[1], "rb" ) ) == NULL ) {
      fprintf( stderr, "Can't open input %s\n", argv[1] );
      exit( -2 );
   }
   if ( ( outf = fopen( argv[2], "w" ) ) == NULL ) {
      fprintf( stderr, "Can't open output %s\n", argv[2] );
      fclose( inf );
      exit( -2 );
   }

   
   printf( "OK, reading MAC resource %s, writing PC postscript %s\n",
      argv[1], argv[2] );
   fseek( inf, 0x100L, SEEK_SET );	/* skip the first bit */
   while ( 1 == 1 ) {
      for ( i = 3; i >= 0; i-- )
         length.c[i] = (char) fgetc( inf );
      for ( i = 1; i >= 0; i-- )
         bit.c[i] = (char) fgetc( inf );
      printf( "Reading bit 0x%02X, length %li (0x%04lX)\n",
	 bit.i, length.l, length.l );
      if ( bit.i == 0x500 || length.l == 2 ) {
	 printf( "Finished!\n" );
	 break;
      }
      if ( length.l < 2 ) {
	 printf( "Fuck off! I can't go _backwards_ ...\n" );
	 exit( -2 );
      }
      length.l -=2;
      i = 0;
      while ( length.l-- > 0 ) {
	 ch = fgetc( inf );
	 if ( bit.i == 256 ) {
	    if ( ch == '\r' ) fputc( '\n' , outf );
            else fputc( ch, outf );
	 }
	 else if ( bit.i == 512 ) {
	    fprintf( outf, "%02X", ch );
	    if ( ++i > 38 ) {
	       fputc( '\n', outf );
	       i = 0;
	    }
	 }
	 else {
	    printf( "Shit! unknown ``bit'' type -- aborting\n" );
	    exit( -1 );
	 }
      }
      fputc( '\n', outf ); fputc( '\n', outf );
   }
   fclose( inf ); fclose( outf );
   return 0;
}

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 Paul Nash			 Flagship Wide Area Networks (Pty) Ltd
  paul@frcs.UUCP			  ...!ddsw1!proxima!frcs!paul