Article View: comp.lang.postscript
Article #3160Re^3: PostScript downloadable font formats
From: Paul Nash
Date: Sat, 22 Sep 1990 07:29
Date: Sat, 22 Sep 1990 07:29
137 lines
4688 bytes
4688 bytes
A while back, I wrote:
>I have managed to copy the resource fork off from MAC to PC-DOS
>format, and am about to knock up some code to pull the resources
>into a suitable PostScript file. This would be (sort of) a DOS
>version of unAdobe.
>If anyone would like a copy (assuming that it all works!), send
>me mail and I will mail you, or, if there is enough interest,
>post to the net.
I have had a few requests, so here goes ...
The Mac Resource format (once it has been copied to a PC with
the DayneFile ``dosmount'' command) contains a number of
records. The first one is 0x100 bytes long (in all the fonts
that I have got). This is followed by the font itself, which
is spread over a number of records, each of the following
format:
length: 4 bytes
type: 2 bytes
data: length-2 bytes
The `type' field is 0x0100 for ASCII data (not translation
needed) and 0x0200 for hex data (translate into 2-byte
ascii codes). The last record has a length of 2, and
a type of 0x0500.
The program that follows reads the Mac resource once it
has been copied to a PC, and creates a font ready for
downloading. NOTE: This is not the same as the format
that downloadable fonts will come from a supplier in --
they should have the hex section in packed 8-bit hex.
NOTE2: I have tested the program and it seems to work.
However, I have not managed to lay my hands on a PostScribble
printer yet (Tuesday, I hope :-)), so I have not been
able to test the resulting fonts. I can see no reason why
they shouldn't work, though. If there is a problem, I
will post a follow-up immediately.
Your mileage might vary, but it seems to work. If anyone has
any problems, please let me know & I'll try to fix.
------------------------- CUT HERE ---------------------------
/*
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;
char 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 %i (0x%02X)\n",
bit.i, length.l, length.l );
if ( bit.i == 0x500 || length.l == 2 ) { /* last record */
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 = (char) fgetc( inf );
if ( bit.i == 256 ) { /* ascii */
if ( ch == '\r' ) fputc( '\n' , outf );
else fputc( ch, outf );
}
else if ( bit.i == 512 ) { /* hex */
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
Technical Details
Message-ID:
<78@frcs.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!sun-barr!olivea!orc!inews!iwarp.intel.com!gargoyle!ddsw1!olsa99!frcs!paulReferences:
<64@frcs.UUCP> <68@frcs.UUCP> <76@frcs.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!sun-barr!olivea!orc!inews!iwarp.intel.com!gargoyle!ddsw1!olsa99!frcs!paul From: paul@frcs.UUCP (Paul Nash) Newsgroups: comp.lang.postscript Subject: Re^3: PostScript downloadable font formats Keywords: postscript font download unadobe Message-ID: <78@frcs.UUCP> Date: 22 Sep 90 07:29:43 GMT References: <64@frcs.UUCP> <68@frcs.UUCP> <76@frcs.UUCP> Distribution: comp Organization: Flagship Wide Area Networks (Pty) Ltd Lines: 138