Back to index

tetex-bin  3.0
ps2pk.c
Go to the documentation of this file.
00001 /*
00002  * NAME
00003  *     ps2pk - creates a PK font from a type1 PostScript font
00004  * SYNOPSIS:
00005  *     pk2pk [options] type1 [pkname]
00006  * DESCRIPTION
00007  *     This program renders a given type1 PostScript font at a given
00008  *     pointsize (default 10.0 points) and resolution (default 300dpi)
00009  *      into a TeX PK font.
00010  *
00011  *      To generate the PK font pk2ps needs a valid type1 fontname (for
00012  *      example Utopia-Regular.pfa) and its corresponding AFMfile
00013  *     (Utopia-Regular.afm). The program accepts both the MSDOS binary
00014  *     type1 format (Utopia-Regula.pfb) and its UNIX ASCII equivalent
00015  *     (Utopia-Regula.pfa). The resulting PK font does contain all
00016  *     characters for which the C-code is non negative. This can be
00017  *     overruled by specifying an explicit <encoding> via the -e<encoding>
00018  *     option. Character codes in AMF files are specified as integer values
00019  *     after the C, for example Utopia-Regular.afm provides:
00020  *        C 251 ; WX 601 ; N germandbls ; B 22 -12 573 742 ;
00021  *        C  -1 ; WX 380 ; N onesuperior ; B 81 272 307 680 ;
00022  *
00023  *     The `germandbls' has code 251 and `onesuperior' -1 which means
00024  *     that this character is not part of the default AdobeStandard-
00025  *     Encoding scheme. To get this `onesuperior' you have to add it to
00026  *     an encoding vector as described in the PostScript manuals. But of
00027  *     course it is better to use standard encodings, like the one provided
00028  *     with the new psfonts. This `TeXBase1Encoding' encoding does contain
00029  *     all names of characters as defined in the 256 character TeX fonts.
00030  *
00031  *     The location of files for ps2pk, since version 1.5, has been
00032  *     improved using PostScript resource databases. These databases
00033  *     can be created using Adobe's mkpsres(1) utility. On UNIX the
00034  *     default name is PSres.upr and can be found in directories like
00035  *     /usr/lib/DPS depending on the machine you are using. The
00036  *     following example of an UPR file contains three resources
00037  *        PS-Resources-1.0
00038  *        Encoding
00039  *        FontAFM
00040  *        FontOutline
00041  *        .
00042  *        //usr/local/tex/fonts/type1faces
00043  *        Encoding
00044  *        ECEncoding=EC.enc
00045  *        .
00046  *        FontAFM
00047  *        Courier=ResidentFonts/Courier.pfa
00048  *        .
00049  *        FontOutline
00050  *        Courier=ResidentFonts/Courier.afm
00051  *        .
00052  *
00053  *     When this UPR is in the PSRESOURCEPATH ps2pk can make an EC encoded
00054  *     PK font for Courier with:
00055  *
00056  *        ps2pk -eECEncoding Courier
00057  *
00058  *     It is also possible without the UPR file but then you have to
00059  *     set T1INPUTS to the directories containing the files you need,
00060  *     for example:
00061  *
00062  *        setenv T1INPUTS /usr/local/tex/fonts/type1faces//
00063  *
00064  *     and to run ps2pk by providing the proper filenames:
00065  *
00066  *        ps2pk -eEC.enc Courier.pfa
00067  *
00068  *     In both cases the result will be the PK font Courier10.300pk.
00069  *     
00070  *     PostScript resource databases eliminate the need for recursive
00071  *     directory search, this is done by mkpsres(1) instead. And all
00072  *     resources can be stored in one directory per computer keeping 
00073  *     maintenance easy. Another advantage is the mapping of internal
00074  *     PostScript names, which are case sensitive and not restricted to
00075  *     MSDOS limitations, to external platform dependant filenames in
00076  *     a very natural way. On a MSDOS computer psres.dpr (the equivalent
00077  *     of PSres.upr) could be:
00078  *        PS-Resources-1.0
00079  *        Encoding
00080  *        FontAFM
00081  *        FontOutline
00082  *        .
00083  *        Encoding
00084  *        TeXBase1Encoding=c:\emtex\dvips\8r.enc
00085  *        .
00086  *        FontAFM
00087  *        Courier=c:\psfonts\com_____.pfb
00088  *        .
00089  *        FontOutline
00090  *        Courier=c:\psfonts\afm\com_____.afm
00091  *        .
00092  *
00093  *     Given this psres.dpr resource database
00094  *
00095  *        ps2pk -eTeXBase1Encoding Courier
00096  *
00097  *     will create Courier10.300pk. Unfortunately MSDOS will abbreviate
00098  *     this name to COURIER1.300. Mkpsres(1) is an improved version
00099  *     of Adobe's makepsres(1) that runs on UNIX and MSDOS. This program
00100  *     will treat PFB fonts and PFM fonts correctly and recognize
00101  *     filenames ending with ".enc" as encoding vectors.
00102  *
00103  *     If the name of <type1font> does not contain an explicit extension
00104  *     or directory separator it is considered as the name of a resource.
00105  *     Otherwise as a filename. You can not mix up resource names and file-
00106  *     names. Filenames must have an extension!
00107  *
00108  * OPTIONS AND ARGUMENTS
00109  *       -a<AFM>        The name of the AFM resource or file can be
00110  *                   overruled with this option.
00111  *       -e<encoding>   The encoding scheme (default the encoding from the 
00112  *                      AFM file is used).
00113  *      -E<extension>       The extension factor (real value, default 1.0).
00114  *      -O           Create old checksums (for compatibility)
00115  *      -P<pointsize>       The desired pointsize (real value, default 10.0
00116  *                   points). PK fonts created with a value different
00117  *                   to 10.0 will cause dvips warnings `dvips: Design
00118  *                   size mismatch in font ...'.
00119  *      -R<baseres>  The base resolution (integer value, default 300
00120  *                   dpi). Only used for creating METAFONT compatible 
00121  *                   identification strings in PK postamble.
00122  *      -S<slant>    The slant (real value, default 0.0).
00123  *      -X<xres>     The resolution (integer value) in the X direction 
00124  *                   (default 300 dpi).
00125  *      -Y<yres>     The resolution (integer value) in the Y direction 
00126  *                   (defaults to the value of <xres>).
00127  *      -d           Debug stat() calls during recursive path searching
00128  *      -v           Verbose flag. (Tells what the program is doing.)
00129  *     
00130  *      type1font    The name of the PostScript type 1 font. When no
00131  *                      explicit AFMfile is given via the -a option the
00132  *                      name of the AFMfile will be constructed from this
00133  *                      name by removing the extension (if supplied) and
00134  *                      adding ".afm". 
00135  *      [pkname]     The name of the resulting PK font can be overruled
00136  *                   with this name. The default name of the PK font is
00137  *                   derived from the basename of the type1 font, the
00138  *                   pointsize and <xres>. For example:
00139  *                      ps2pk -P17.28 Utopia-Regular
00140  *                   will result in:
00141  *                          Utopia-Regular17.300pk
00142  *
00143  * ENVIRONMENTS
00144  *
00145  *   PSRESOURCEPATH
00146  *     The path used for locating PS resource database files (PSres.upr
00147  *     on UNIX and psres.dpr on MSDOS). The default of the path will be
00148  *     shown by running ps2pk with the -v flag and a non-existant resource
00149  *     name.
00150  *
00151  *   T1INPUTS
00152  *     The path used for locating PS type1 fonts, their AFM files and
00153  *     encoding vectors. Path may contain '//' (UNIX) or '!!' (MSDOS) to
00154  *     force ps2pk to look into subdirectories. Using PSRESOURCEPATH
00155  *     instead of T1INPUTS avoids recursion. The default of the path will
00156  *     be shown by running ps2pk with the -v flag and a non-existant
00157  *     filename.
00158  *     
00159  * ACKNOWLEDGEMENTS
00160  *     This program uses the type1 hinting and rendering software IBM 
00161  *     has donated to the X-consortium.
00162  *
00163  *      Since version 1.5 the lookup of PS resources as described in
00164  *      `Programming the Display PostScript System with X (Appendix A:
00165  *      Locating PostScript Resources)' from Adobe Systems is used.
00166  * SEE ALSO
00167  *     ``METAFONT: The Program'', Donald Knuth.
00168  *     ``The GFtoPK processor'', belonging to the METAFONTware.
00169  *     afm2tfm(1)
00170  *      mkpsres(1)
00171  *     mtpk(1)
00172  *     pk2bm(1)
00173  *     pkfonts(1)
00174  * VERSIONS
00175  *     1.1 (May 1992)
00176  *     1.3 (August 1992)
00177  *     1.4 (December 1994)
00178  *     1.5 (Januari 1996)
00179  * AUTHOR
00180  *     Piet Tutelaers
00181  *     rcpt@urc.tue.nl
00182  */
00183 
00184 #include <ctype.h>
00185 #include <stdio.h>
00186 #include <stdlib.h>
00187 #include <string.h>
00188 /* PostScript Resource lookup functions */
00189 /* 
00190 #include "PSres.h"   
00191 */
00192 #include "basics.h"  /* basic definitions and fatal() */
00193 #include "filenames.h"      /* newname(), extension(), ps_resource() */
00194 #include "psearch.h" /* path search functions */
00195 #include "pkout.h"   /* PK output functions */
00196 
00197 /* begin interface to type 1 software */
00198 #include "ffilest.h"
00199 
00200 FontScalableRec vals;
00201 FontEntryRec entry;
00202 #define Succesful    85
00203 
00204 extern int  Type1OpenScalable ();
00205 extern int  Type1RegisterFontFileFunctions();
00206 extern void Type1CloseFont();
00207 
00208 /* end interface to type 1 software */
00209 
00210 char *encfile = NULL, *afmfile;
00211 
00212 char ps2pk_args[MAXSTRLEN] = "none";      /* essential ps2pk arguments */
00213 typedef char *encoding[256];
00214 void getenc(char **, char **, encoding, int [256]);
00215 
00216 #define POINTSPERINCH 72.27
00217 #define DEFAULTRES 300
00218 #define DEFAULTPOINTSIZE 10.0
00219 
00220 double pointsize = 0.0; /* wanted pointsize */
00221 int W, H,             /* width and height of character glyph */
00222     base_resolution = DEFAULTRES,
00223     x_resolution = 0, 
00224     y_resolution = 0;
00225 
00226 int verbose = 0, debug = 0;
00227 
00228 /* Provide old (-O flag) and new (default) checksum function */
00229 typedef unsigned int UINT32;
00230 UINT32 checksum(encoding, int [256]);
00231 UINT32 old_checksum(encoding, int [256]);
00232 UINT32 (*pchecksum)(encoding, int [256]) = checksum;
00233 
00234 main(argc, argv)
00235 int argc; char *argv[];
00236 {  char *argp, c;
00237    int done, i;
00238    char *myname = "ps2pk", *psname, *psbasename, *afmname = NULL,
00239        *encname = NULL, *psfile = NULL, *psfilebn, pkname[80],
00240        *t1inputs, *psrespath, *resourcedb, *AFM_fontname = NULL,
00241        *encodingscheme = NULL;
00242 
00243    FontPtr fontptr;
00244    unsigned char glyphcode[1]; /* must be an array */
00245    CharInfoRec *glyphs[1];
00246    unsigned int count;
00247    int charcode, rc = -1, charno;
00248    char comment[256];
00249    long cs;
00250    encoding ev;
00251    int WX[256];
00252 
00253    float efactor = 1.0, slant = 0.0;
00254    
00255    /* proto's */
00256    int next_pixel();
00257    void print_pixmap();
00258    void first_pixel(CharInfoRec *);
00259    INT32 TFMwidth(int);
00260    int h_escapement(int);
00261    void add_option(char *, char *);
00262 
00263    while (--argc > 0 && (*++argv)[0] == '-') {
00264       done=0;
00265       while ((!done) && (c = *++argv[0]))  /* allow -bcK like options */
00266         switch (c) {
00267         case 'a':
00268            if (*++argv[0] == '\0') {
00269               argc--; argv++;
00270            }
00271            afmname = argv[0]; 
00272            done = 1;
00273            break;
00274         case 'd':
00275            debug = 1;
00276            break;
00277         case 'e':
00278            if (*++argv[0] == '\0') {
00279               argc--; argv++;
00280            }
00281            encname = argv[0]; 
00282            add_option("-e", encname);
00283            done = 1;
00284            break;
00285         case 'E':
00286            if (*++argv[0] == '\0') {
00287               argc--; argv++;
00288            }
00289            efactor = atof(argv[0]);
00290            add_option("-E", argv[0]);
00291            done = 1;
00292            break;
00293         case 'O':
00294            pchecksum = old_checksum;
00295            add_option("-O", "");
00296            break;
00297         case 'P':
00298            if (*++argv[0] == '\0') {
00299               argc--; argv++;
00300            }
00301            pointsize = atof(argv[0]); 
00302            add_option("-P", argv[0]);
00303            done = 1;
00304            break;
00305         case 'R':
00306            if (*++argv[0] == '\0') {
00307               argc--; argv++;
00308            }
00309            base_resolution = atoi(argv[0]); 
00310            add_option("-R", argv[0]);
00311            done = 1;
00312            break;
00313         case 'S':
00314            if (*++argv[0] == '\0') {
00315               argc--; argv++;
00316            }
00317            slant = atof(argv[0]);
00318            add_option("-S", argv[0]);
00319            done = 1;
00320            break;
00321         case 'X':
00322            if (*++argv[0] == '\0') {
00323               argc--; argv++;
00324            }
00325            x_resolution = atoi(argv[0]); done = 1;
00326            if (y_resolution == 0) y_resolution = x_resolution;
00327            add_option("-X", argv[0]);
00328            break;
00329         case 'Y':
00330            if (*++argv[0] == '\0') {
00331               argc--; argv++;
00332            }
00333            y_resolution = atoi(argv[0]); done = 1;
00334            if (x_resolution == 0) x_resolution = y_resolution;
00335            add_option("-Y", argv[0]);
00336            break;
00337         case 'v':
00338            verbose = 1;
00339            break;
00340         default:
00341            fatal("%s: %c illegal option\n", myname, c);
00342         }
00343       }
00344 
00345    if (argc < 1 || argc >2) {
00346       msg  ("Ps2pk: version 1.5 (1992-96)\n");
00347       msg  ("Usage: %s [ options ] type1font [pkname]\n", myname);
00348       msg  ("options: -d -v -e<enc> -X<xres> -E<expansion> -S<slant>\n");
00349       fatal("options: -O -P<pointsize> -Y<yres> -a<AFM> -R<baseres>\n");
00350    }
00351 
00352    psname = argv[0]; argc--; argv++;
00353 
00354 #ifdef KPATHSEA
00355    kpse_set_progname(myname);
00356 #endif
00357 
00358 #ifndef KPATHSEA
00359    if (ps_resource(psname)) {
00360       /* if psname does neither contain a DIRSEP or `.' character
00361        * then find the filename of this resource in one of the PS
00362        * resource database(s) available in PSRESOURCEPATH.
00363        */
00364       char **names, **files; int i, count;
00365 
00366       psrespath = path(PSRESOURCEPATH, getenv("PSRESOURCEPATH"));
00367       if (verbose) msg("PSRESOURCEPATH := %s\n", psrespath);
00368 
00369       count = ListPSResourceFiles(psrespath, NULL,
00370        "FontOutline", psname, &names, &files);
00371       if (count == 0)
00372         fatal("No FontOutline resource found for %s\n", psname);
00373       if (verbose && count > 1) {
00374         msg("More than one FontOutline resource for %s\n", psname);
00375         for (i = 0; i < count; i++) msg("\t<%s>\n", files[i]);
00376       }
00377       psfile = files[0];
00378       if (verbose) msg("Resource <%s>\n", psfile);
00379       psbasename = psname;
00380    }
00381    
00382    if (psfile != NULL) {
00383       char **names, **files; int count;
00384 
00385       if (afmname == NULL || ps_resource(afmname)) {
00386         if (afmname == NULL) afmname = psname;
00387          count = ListPSResourceFiles(psrespath, NULL,
00388           "FontAFM", afmname, &names, &files);
00389          if (count == 0)
00390            fatal("No FontAFM resource found for %s\n", afmname);
00391          if (verbose && count > 1) {
00392            msg("More than one FontAFM resource for %s\n", afmname);
00393            for (i = 0; i < count; i++) msg("\t<%s>\n", files[i]);
00394         }
00395          afmfile = files[0];
00396          if (verbose) msg("Resource <%s>\n", afmfile);
00397       }
00398       else fatal("%s: invalid resource name\n", afmname);
00399 
00400       if (encname != NULL) {
00401         if (!ps_resource(encname)) 
00402             fatal("%s: invalid Encoding resource\n", encname);
00403          count = ListPSResourceFiles(psrespath, NULL,
00404            "Encoding", encname, &names, &files);
00405          if (count == 0)
00406            fatal("No Encoding resource found for %s\n", encname);
00407          if (verbose && count > 1) {
00408            msg("More than one Encoding resource for %s\n", encname);
00409            for (i = 0; i < count; i++) msg("\t<%s>\n", files[i]);
00410          }
00411          encfile = files[0];
00412          if (verbose) msg("Resource <%s>\n", encfile);
00413       }
00414    }
00415    else { /* No PS resource database or no resource for type1font */
00416 #endif   
00417 #ifdef KPATHSEA
00418      psfile = kpse_find_file(psname,kpse_type1_format,0);
00419      if (!psfile) {
00420        /* kpse_find_file does not look for alternate suffixes */
00421        char *altname = newname(psname, ".pfb");
00422        psfile = kpse_find_file(altname, kpse_type1_format, 0);
00423        free(altname);
00424      }
00425      if (!psfile)
00426        fatal("%s: PS file %s not found!\n", program_invocation_name,
00427             psname);
00428      if (afmname == NULL)
00429        afmname = newname(psname, ".afm");
00430      afmfile = kpse_find_file(afmname,kpse_afm_format,0);
00431      if (!afmfile)
00432        fatal("%s: AFM file %s not found!\n", program_invocation_name,
00433             afmname);
00434      
00435      if (encname) {
00436        encfile = kpse_find_file(encname,kpse_enc_format,0);
00437        if (!encfile)
00438         fatal("%s: enc file %s not found!\n", program_invocation_name,
00439               encname);
00440      }
00441      else
00442        encfile = NULL;
00443      printf("psfile = %s\n", psfile);
00444      printf("afmfile = %s\n", afmfile);
00445      if (encfile) printf("encfile = %s\n", encfile);
00446 #else
00447      t1inputs = path(T1INPUTS, getenv("T1INPUTS"));
00448      if (verbose) msg("T1INPUTS := %s\n", t1inputs);
00449      
00450      psfile = search_file(t1inputs, psname, FATAL);
00451      if (verbose) msg("Font file <%s>\n", psfile);
00452      
00453      if (afmname ==  NULL) afmname = newname(psfile, ".afm");
00454      afmfile = search_file(t1inputs, afmname, FATAL);
00455      if (verbose) msg("AFM file <%s>\n", afmfile);
00456      
00457      /* get encoding when -e<enc> provided */
00458      if (encname) {
00459        encfile = search_file(t1inputs, encname, FATAL);
00460        if (verbose) msg("Encoding file <%s>\n", encfile);
00461      }
00462 #endif
00463      psbasename = basename(psname, extension(psname));
00464 #ifndef KPATHSEA
00465    }
00466 #endif
00467    psfilebn = basename(psfile, NULL);
00468 
00469    if (pointsize == 0.0) pointsize = DEFAULTPOINTSIZE;
00470    if (x_resolution == 0) x_resolution = DEFAULTRES;
00471    if (y_resolution == 0) y_resolution = x_resolution;
00472    if (verbose)
00473       msg("Loading encoding vector from %s ...",
00474         encname? encname: basename(afmfile, NULL));
00475    getenc(&AFM_fontname, &encodingscheme, ev, WX);
00476    if (efactor != 1.0)
00477       for (i=0; i < 256; i++) {
00478          if (ev[i] == NULL) continue;
00479          WX[i] = WX[i] * efactor + 0.5;
00480       }
00481    if (verbose) msg(" done\n");
00482    
00483    if (argc == 1) strcpy(pkname,  argv[0]);
00484    else 
00485       sprintf(pkname, "%s%d.%dpk", psbasename,
00486          (int) (pointsize + 0.5), x_resolution);
00487     
00488    /* next values are needed! */
00489    vals.x =     x_resolution;
00490    vals.y =     y_resolution;
00491    vals.point = 10.0 * pointsize + 0.5; /* DECIPOINTS */
00492    vals.pixel = pointsize * y_resolution / POINTSPERINCH + 0.5;
00493    
00494    if (verbose) msg("Checking type1 font %s ...", psfilebn);
00495    Type1RegisterFontFileFunctions();
00496    if (verbose) msg(" done\n");
00497 
00498        /* next line prevents UNIX core dumps */
00499    entry.name.name = "-adobe-utopia-medium-r-normal--0-0-0-0-p-0-iso8859-1";
00500    if (verbose)
00501       msg("Creating character glyphs for %s ...", psfilebn);
00502    rc = Type1OpenScalable(ev, &fontptr, 0, &entry, 
00503             psfile, &vals, 0, 0, efactor, slant);
00504    if (rc != Succesful) 
00505       fatal("Type1OpenScalable error (result: %d) on %s \n",  rc, psfile);
00506    if (verbose) msg(" done\n");
00507 
00508    pk_open(pkname);
00509    sprintf(comment, "%s rendered at %f points", psbasename, pointsize);
00510    cs = pchecksum(ev, WX);
00511    pk_preamble(comment, pointsize, cs, x_resolution, y_resolution);
00512    charno = 0;
00513    if (verbose) msg("Creating %s from %s\n", pkname, psfilebn);
00514    for (charcode = 0; charcode < 256; charcode++) {
00515       if (ev[charcode] == NULL) continue;
00516       glyphcode[0] = charcode;
00517       (fontptr->get_glyphs)(fontptr, 1, glyphcode, 0, &count, glyphs);
00518       if (count > 0) {
00519          if (debug) {
00520             msg("'%03o ", charcode); charno++;
00521             if (charno == 8) { 
00522                msg("%c", '\n'); charno = 0;
00523             }
00524          }
00525         first_pixel(glyphs[0]); /* assigns W and H */
00526          pk_char(charcode,                   /* charcode */
00527             TFMwidth(WX[charcode]),                 /* TFMwidth */
00528             h_escapement(WX[charcode]),             /* h_escapement */
00529             W, H,                            /* width and height */
00530             - glyphs[0]->metrics.leftSideBearing,  /* h_offset */
00531             glyphs[0]->metrics.ascent,             /* v_offset */
00532             next_pixel);                     /* pixel generator */
00533       }
00534    }
00535    if (debug) msg("%c", '\n');
00536    ps2pk_postamble(psbasename, encodingscheme,
00537               base_resolution, x_resolution, y_resolution, pointsize,
00538              ps2pk_args);
00539    pk_close();
00540    exit(0);
00541 }
00542 
00543 /*
00544  * The checksum should garantee that our PK file belongs to the correct TFM
00545  * file! Exactly the same as the afm2tfm (dvips5487) calculation.
00546  */
00547 UINT32 old_checksum(encoding ev, int width[256])
00548 {
00549    int i, leftbit ;
00550    UINT32 s1 = 0, s2 = 0;
00551    char *p ;
00552 
00553    for (i=0; i<256; i++) {
00554       if (ev[i] == NULL) continue;
00555       s1 = (s1<<1) ^ width[i];                   /* left shift */
00556       for (p=ev[i]; *p; p++)
00557         s2 = s2 * 3 + *p ;
00558    }
00559    return (s1<<1) ^ s2 ;
00560 }
00561 
00562 /*
00563  * The new checksum algorithm.
00564  */
00565 UINT32 checksum(encoding ev, int width[256])
00566 {
00567    int i, leftbit ;
00568    UINT32 s1 = 0, s2 = 0;
00569    char *p ;
00570 
00571    for (i=0; i<256; i++) {
00572       if (ev[i] == NULL) continue;
00573       s1 = ((s1<<1) ^ (s1>>31)) ^ width[i];   /* cyclic left shift */
00574       for (p=ev[i]; *p; p++)
00575         s2 = s2 * 3 + *p ;
00576    }
00577    return (s1<<1) ^ s2 ;
00578 }
00579 
00580 static int row, col;
00581 static int data, bitno;
00582 static unsigned char *p_data;
00583 
00584 int next_pixel()
00585 {  int pixel;
00586 
00587    while (row < H) {
00588        if (col++ < W) { 
00589            if (bitno == 0) { data = *p_data++; bitno = 8; }
00590            pixel = data & 0x80? BLACK: WHITE; 
00591            data <<= 1; bitno--; return pixel;
00592        }
00593        col = 0; row++; bitno = 0;
00594    }
00595    fatal("Not that many pixels!\n");
00596 } 
00597 
00598 void first_pixel(CharInfoRec *G)
00599 {
00600    row = col = 0;
00601    p_data = (unsigned char *) G->bits;
00602    W = G->metrics.rightSideBearing - G->metrics.leftSideBearing;
00603    H = G->metrics.ascent + G->metrics.descent;
00604    bitno = 0; 
00605 }
00606 
00607 void print_pixmap()
00608 {  int c, r;
00609    unsigned char *save_p_data;
00610 
00611    save_p_data = p_data;
00612    if (W*H == 0) return; /* easy */
00613    for (r = 0; r < H; r++) {
00614       for (c = 0; c < W; c++)
00615         if (next_pixel() == BLACK) msg("%c", 'X');
00616         else msg("%c", '.');
00617       msg("%c", '\n');
00618    }
00619    /* reset data for scanning pixmap */
00620    p_data = save_p_data;
00621    bitno = 0; row = 0; col = 0;
00622 }
00623 
00624 /* Next function computes the width as a fix_word. A fix_word is 
00625    an integer representation for fractions. The decimal point is 
00626    left from bit 20. (The method is `stolen' from afm2tfm.) */
00627  
00628 INT32 TFMwidth(int wx)
00629 {  
00630    return (((wx  / 1000) << 20) +
00631            (((wx % 1000) << 20) + 500) / 1000) ;
00632 }
00633 
00634 static float HXU = -1.0; /* horizontal pixels per design unit */
00635 
00636 /* the horizontal escapent is the number of pixels to next origin */
00637 int h_escapement(int wx)
00638 {
00639    if (HXU == -1.0) 
00640       HXU = (pointsize * x_resolution) / 72270.0;
00641    return wx * HXU +  0.5;
00642 }
00643 
00644 /* add ps2pk option to string */
00645 void add_option(char *option, char *value) {
00646    static char *p_args = NULL;
00647 
00648    if (p_args == NULL) {
00649       p_args = ps2pk_args;
00650       sprintf(p_args, "%s%s", option, value);
00651    }
00652    else
00653       sprintf(p_args, " %s%s", option, value);
00654    p_args+= strlen(p_args);
00655 }
00656 
00657 /* Next stuff is needed by type1 rendering functions */
00658 
00659 int CheckFSFormat(format, fmask, bit, byte, scan, glyph, image)
00660        int format,fmask,*bit,*byte,*scan,*glyph,*image;
00661 {
00662        *bit = *byte = 1;
00663        *glyph = *scan = *image = 1;
00664        return Successful;
00665  
00666 }
00667  
00668 long MakeAtom(p, len, foo)
00669        char *p;
00670        unsigned int len;
00671        Bool foo;
00672 {
00673        return (long)p;
00674 }
00675 
00676 GetClientResolutions(resP)
00677        int *resP;
00678 {
00679        *resP = 0;
00680 }
00681 
00682 char *Xalloc(size_t size)
00683 {  char *p;
00684    p = malloc(size);
00685    if (p == NULL) fatal("Out of memory\n");
00686    return p;
00687 }
00688  
00689 void Xfree(void *p)
00690 {
00691        free(p);
00692 }
00693 
00694 #ifdef WIN32
00695 void FontDefaultFormat(int *bit, int *byte, 
00696                      CharInfoRec *glyphs, int *scan) { ; }
00697 void FontFileRegisterRenderer(FontRendererRec *foo) { ; }
00698 void FontParseXLFDName(char *scaledName, FontScalablePtr Vals, int foo ) { ; }
00699 FontComputeInfoAccelerators(FontInfoPtr foo) { ; }
00700 #else
00701 void FontDefaultFormat() { ; }
00702  
00703 void FontFileRegisterRenderer() { ; }
00704  
00705 GenericGetBitmaps() { ; }
00706 GenericGetExtents() { ; }
00707  
00708 void FontParseXLFDName() { ; }
00709 FontComputeInfoAccelerators() { ; }
00710 #endif