Back to index

lightning-sunbird  0.9+nobinonly
nsPostScriptObj.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ex: set tabstop=8 softtabstop=2 shiftwidth=2 expandtab: */
00003 /* ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is mozilla.org code.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 1998
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
00025  *   Ken Herron <kherron@fastmail.us>
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either of the GNU General Public License Version 2 or later (the "GPL"),
00029  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK *****
00040  *
00041  * This Original Code has been modified by IBM Corporation. Modifications made by IBM 
00042  * described herein are Copyright (c) International Business Machines Corporation, 2000.
00043  * Modifications to Mozilla code or documentation identified per MPL Section 3.3
00044  *
00045  * Date             Modified by     Description of modification
00046  * 04/20/2000       IBM Corp.      OS/2 VisualAge build.
00047  * 10/09/2000       IPLabs Linux Team      True Unicode glyps support added.
00048  */
00049 
00050 #include "gfx-config.h"
00051  
00052 #define FORCE_PR_LOG /* Allow logging in the release build */
00053 #define PR_LOGGING 1
00054 #include "prlog.h"
00055 
00056 #include "nscore.h"
00057 #include "nsIAtom.h"
00058 #include "nsPostScriptObj.h"
00059 #include "isotab.c"
00060 #include "nsFont.h"
00061 #include "nsIImage.h"
00062 #include "nsAFMObject.h"
00063 
00064 #include "nsIServiceManager.h"
00065 #include "nsICharsetConverterManager.h"
00066 #include "nsIUnicodeEncoder.h"
00067 #include "nsIUnicodeDecoder.h"
00068 #include "nsReadableUtils.h"
00069 
00070 #include "nsICharsetAlias.h"
00071 #include "nsNetUtil.h"
00072 #include "nsIPersistentProperties2.h"
00073 #include "nsCRT.h"
00074 #include "nsFontMetricsPS.h"
00075 #include "nsPaperPS.h"
00076 
00077 #ifndef NS_BUILD_ID
00078 #include "nsBuildID.h"
00079 #endif /* !NS_BUILD_ID */
00080 
00081 #include "nsPrintfCString.h"
00082 
00083 #include "prenv.h"
00084 #include "prprf.h"
00085 #include "prerror.h"
00086 
00087 #include <errno.h>
00088 #include <sys/wait.h>
00089 
00090 #ifdef PR_LOGGING
00091 static PRLogModuleInfo *nsPostScriptObjLM = PR_NewLogModule("nsPostScriptObj");
00092 #endif /* PR_LOGGING */
00093 
00094 /* A private class to format floating-point values into strings. This
00095  * is used to write floating-point values into the postscript document.
00096  * printf()-based functions can't be used because they may generate
00097  * locale-ized output, e.g. using a comma for the decimal point, which
00098  * isn't a valid postscript number.
00099  */
00100 class fpCString : public nsCAutoString {
00101   public:
00102     inline fpCString(float aValue) { AppendFloat(aValue); }
00103 };
00104 
00105 
00106 #define NS_PS_RED(x) (((float)(NS_GET_R(x))) / 255.0) 
00107 #define NS_PS_GREEN(x) (((float)(NS_GET_G(x))) / 255.0) 
00108 #define NS_PS_BLUE(x) (((float)(NS_GET_B(x))) / 255.0) 
00109 #define NS_PS_GRAY(x) (((float)(x)) / 255.0) 
00110 #define NS_RGB_TO_GRAY(r,g,b) ((int(r) * 77 + int(g) * 150 + int(b) * 29) / 256)
00111 #define NS_IS_BOLD(x) (((x) >= 401) ? 1 : 0) 
00112 
00113 static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
00114 static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
00115 
00116 /* 
00117  * global
00118  */
00119 static nsIUnicodeEncoder *gEncoder = nsnull;
00120 static nsHashtable *gU2Ntable = nsnull;
00121 static nsIPref *gPrefs = nsnull;
00122 static nsHashtable *gLangGroups = nsnull;
00123 
00124 static PRBool
00125 FreeU2Ntable(nsHashKey * aKey, void *aData, void *aClosure)
00126 {
00127   delete(int *) aData;
00128   return PR_TRUE;
00129 }
00130 
00131 static PRBool
00132 ResetU2Ntable(nsHashKey * aKey, void *aData, void *aClosure)
00133 {
00134   PS_LangGroupInfo *linfo = (PS_LangGroupInfo *)aData;
00135   if (linfo && linfo->mU2Ntable) {
00136     linfo->mU2Ntable->Reset(FreeU2Ntable, nsnull);
00137   }
00138   return PR_TRUE;
00139 }
00140 
00141 static PRBool
00142 FreeLangGroups(nsHashKey * aKey, void *aData, void *aClosure)
00143 {
00144   PS_LangGroupInfo *linfo = (PS_LangGroupInfo *) aData;
00145 
00146   NS_IF_RELEASE(linfo->mEncoder);
00147 
00148   if (linfo->mU2Ntable) {
00149     linfo->mU2Ntable->Reset(FreeU2Ntable, nsnull);
00150     delete linfo->mU2Ntable;
00151     linfo->mU2Ntable = nsnull;
00152   }
00153   delete linfo;
00154   linfo = nsnull;
00155   return PR_TRUE;
00156 }
00157 
00158 static void
00159 PrintAsDSCTextline(FILE *f, const char *text, int maxlen)
00160 {
00161   NS_ASSERTION(maxlen > 1, "bad max length");
00162 
00163   if (*text != '(') {
00164     // Format as DSC textline type
00165     fprintf(f, "%.*s", maxlen, text);
00166     return;
00167   }
00168 
00169   // Fallback: Format as DSC text type
00170   fprintf(f, "(");
00171 
00172   int len = maxlen - 2;
00173   while (*text && len > 0) {
00174     if (!isprint(*text)) {
00175       if (len < 4) break;
00176       fprintf(f, "\\%03o", *text);
00177       len -= 4;
00178     }
00179     else if (*text == '(' || *text == ')' || *text == '\\') {
00180       if (len < 2) break;
00181       fprintf(f, "\\%c", *text);
00182       len -= 2;
00183     }
00184     else {
00185       fprintf(f, "%c", *text);
00186       len--;
00187     }
00188     text++;
00189   }
00190   fprintf(f, ")");
00191 }
00192 
00197 nsPostScriptObj::nsPostScriptObj() :
00198   mPrintSetup(nsnull),
00199   mPrintContext(nsnull),
00200   mTitle(nsnull),
00201   mScriptFP(nsnull)
00202 {
00203   PR_LOG(nsPostScriptObjLM, PR_LOG_DEBUG, ("nsPostScriptObj::nsPostScriptObj()\n"));
00204 
00205   CallGetService(kPrefCID, &gPrefs);
00206 
00207   gLangGroups = new nsHashtable();
00208 }
00209 
00214 nsPostScriptObj::~nsPostScriptObj()
00215 {
00216   PR_LOG(nsPostScriptObjLM, PR_LOG_DEBUG, ("nsPostScriptObj::~nsPostScriptObj()\n"));
00217 
00218   if (mScriptFP)
00219     fclose(mScriptFP);
00220   if (mDocScript)
00221     mDocScript->Remove(PR_FALSE);
00222   finalize_translation();
00223 
00224   // Cleanup things allocated along the way
00225   if (nsnull != mTitle){
00226     nsMemory::Free(mTitle);
00227   }
00228 
00229   if (nsnull != mPrintContext){
00230     delete mPrintContext->prInfo;
00231     delete mPrintContext->prSetup;
00232     delete mPrintContext;
00233     mPrintContext = nsnull;
00234   }
00235 
00236   delete mPrintSetup;
00237   mPrintSetup = nsnull;
00238 
00239   NS_IF_RELEASE(gPrefs);
00240 
00241   if (gLangGroups) {
00242     gLangGroups->Reset(FreeLangGroups, nsnull);
00243     delete gLangGroups;
00244     gLangGroups = nsnull;
00245   }
00246 
00247   PR_LOG(nsPostScriptObjLM, PR_LOG_DEBUG, ("nsPostScriptObj::~nsPostScriptObj(): printing done."));
00248 }
00249 
00250 void 
00251 nsPostScriptObj::settitle(PRUnichar * aTitle)
00252 {
00253   if (aTitle) {
00254     mTitle = ToNewCString(nsDependentString(aTitle));
00255   }
00256 }
00257 
00262 nsresult 
00263 nsPostScriptObj::Init( nsIDeviceContextSpecPS *aSpec )
00264 {
00265   PRBool      isGray,
00266               isFirstPageFirst;
00267   int         landscape;
00268 
00269   PrintInfo* pi = new PrintInfo(); 
00270   mPrintSetup = new PrintSetup();
00271 
00272   if( (nsnull!=pi) && (nsnull!=mPrintSetup) ){
00273     memset(mPrintSetup, 0, sizeof(struct PrintSetup_));
00274     
00275     mPrintSetup->color = PR_TRUE;              // Image output 
00276     mPrintSetup->deep_color = PR_TRUE;         // 24 bit color output 
00277     mPrintSetup->reverse = 0;                  // Output order, 0 is acsending 
00278     mPrintSetup->num_copies = 1;
00279     if ( aSpec != nsnull ) {
00280       aSpec->GetGrayscale( isGray );
00281       if ( isGray == PR_TRUE ) {
00282         mPrintSetup->color = PR_FALSE; 
00283         mPrintSetup->deep_color = PR_FALSE; 
00284       }
00285 
00286       aSpec->GetFirstPageFirst( isFirstPageFirst );
00287       if ( isFirstPageFirst == PR_FALSE )
00288         mPrintSetup->reverse = 1;
00289     } else 
00290         return NS_ERROR_FAILURE;
00291 
00292     /* Open a temporary file for the document body */
00293     nsresult rv = mTempfileFactory.CreateTempFile(
00294        getter_AddRefs(mDocScript), &mScriptFP, "a+");
00295     NS_ENSURE_SUCCESS(rv, NS_ERROR_GFX_PRINTER_FILE_IO_ERROR);
00296 
00297     mPrintContext = new PSContext();
00298     memset(mPrintContext, 0, sizeof(struct PSContext_));
00299     memset(pi, 0, sizeof(struct PrintInfo_));
00300 
00301     /* Find PS paper size record by name */
00302     aSpec->GetPaperName(&(mPrintSetup->paper_name));
00303     nsPaperSizePS paper;
00304     if (!paper.Find(mPrintSetup->paper_name))
00305       return NS_ERROR_GFX_PRINTER_PAPER_SIZE_NOT_SUPPORTED;
00306 
00307     aSpec->GetLandscape( landscape );
00308     mPrintSetup->width = NS_MILLIMETERS_TO_TWIPS(paper.Width_mm());
00309     mPrintSetup->height = NS_MILLIMETERS_TO_TWIPS(paper.Height_mm());
00310 
00311     if (landscape) {
00312       nscoord temp = mPrintSetup->width;
00313       mPrintSetup->width = mPrintSetup->height;
00314       mPrintSetup->height = temp;
00315     }
00316 
00317 #ifdef DEBUG
00318     printf("\nPaper Width = %d twips (%gmm) Height = %d twips (%gmm)\n",
00319         mPrintSetup->width, paper.Width_mm(),
00320         mPrintSetup->height, paper.Height_mm());
00321 #endif
00322     mPrintSetup->header = "header";
00323     mPrintSetup->footer = "footer";
00324     mPrintSetup->sizes = nsnull;
00325 
00326     mPrintSetup->landscape = (landscape) ? PR_TRUE : PR_FALSE; // Rotated output 
00327     //mPrintSetup->landscape = PR_FALSE;
00328 
00329     mPrintSetup->underline = PR_TRUE;             // underline links 
00330     mPrintSetup->scale_images = PR_TRUE;          // Scale unsized images which are too big 
00331     mPrintSetup->scale_pre = PR_FALSE;                   // do the pre-scaling thing 
00332 
00333 
00334     mPrintSetup->rules = 1.0f;                               // Scale factor for rulers 
00335     mPrintSetup->n_up = 0;                     // cool page combining 
00336     mPrintSetup->bigger = 1;                   // Used to init sizes if sizesin NULL 
00337     mPrintSetup->prefix = "";                  // For text xlate, prepended to each line 
00338     mPrintSetup->eol = "";                    // For text translation, line terminator 
00339     mPrintSetup->bullet = "+";                 // What char to use for bullets 
00340 
00341 #ifdef NOTYET
00342     URL_Struct_* url = new URL_Struct_;
00343     memset(url, 0, sizeof(URL_Struct_));
00344     mPrintSetup->url = url;                    // url of doc being translated 
00345 #else
00346     mPrintSetup->url = nsnull;
00347 #endif
00348     mPrintSetup->completion = nsnull;          // Called when translation finished 
00349     mPrintSetup->carg = nsnull;                // Data saved for completion routine 
00350     mPrintSetup->status = 0;                   // Status of URL on completion 
00351 
00352     mTitle = nsnull;
00353 
00354     pi->doc_title = mTitle;
00355 
00356     mPrintContext->prInfo = pi;
00357 
00358     // begin the document
00359     initialize_translation(mPrintSetup);
00360 
00361     mPageNumber = 1;                  // we are on the first page
00362 
00363     // read the printer properties file
00364     NS_LoadPersistentPropertiesFromURISpec(getter_AddRefs(mPrinterProps),
00365       NS_LITERAL_CSTRING("resource:/res/unixpsfonts.properties"));
00366 
00367     return NS_OK;
00368     } else {
00369     return NS_ERROR_FAILURE;
00370     }
00371 }
00372 
00373 void
00374 nsPostScriptObj::SetNumCopies(int aNumCopies)
00375 {
00376   NS_PRECONDITION(mPrintSetup, "mPrintSetup must not be NULL");
00377   mPrintSetup->num_copies = aNumCopies;
00378 }
00379 
00384 void 
00385 nsPostScriptObj::finalize_translation()
00386 {
00387   if (mPrintContext) {
00388     free(mPrintContext->prSetup);
00389     mPrintContext->prSetup = nsnull;
00390   }
00391 }
00392 
00397 void 
00398 nsPostScriptObj::initialize_translation(PrintSetup* pi)
00399 {
00400   PrintSetup *dup = (PrintSetup *)malloc(sizeof(PrintSetup));
00401   *dup = *pi;
00402   mPrintContext->prSetup = dup;
00403 }
00404 
00409 void 
00410 nsPostScriptObj::write_prolog(FILE *aHandle, PRBool aFTPEnable)
00411 {
00412   int i;
00413   FILE *f = aHandle;
00414 
00415   nscoord paper_width = mPrintContext->prSetup->width;
00416   nscoord paper_height = mPrintContext->prSetup->height;
00417   const char *orientation;
00418 
00419   if (paper_height < paper_width) {
00420     // prSetup->width and height have been swapped, indicating landscape.
00421     // The bounding box etc. must be in terms of the default PS coordinate
00422     // system.
00423     nscoord temp = paper_width;
00424     paper_width = paper_height;
00425     paper_height = temp;
00426     orientation = "Landscape";
00427   }
00428   else
00429     orientation = "Portrait";
00430 
00431   float fWidth = NSTwipsToFloatPoints(paper_width);
00432   float fHeight = NSTwipsToFloatPoints(paper_height);
00433 
00434   fprintf(f, "%%!PS-Adobe-3.0\n");
00435   fprintf(f, "%%%%BoundingBox: 0 0 %s %s\n",
00436     fpCString(NSToCoordRound(fWidth)).get(),
00437     fpCString(NSToCoordRound(fHeight)).get());
00438   fprintf(f, "%%%%HiResBoundingBox: 0 0 %s %s\n",
00439     fpCString(fWidth).get(),
00440     fpCString(fHeight).get());
00441 
00442   fprintf(f, "%%%%Creator: Mozilla PostScript module (%s/%lu)\n",
00443              "rv:" MOZILLA_VERSION, (unsigned long)NS_BUILD_ID);
00444   fprintf(f, "%%%%DocumentData: Clean8Bit\n");
00445   fprintf(f, "%%%%DocumentPaperSizes: %s\n", mPrintSetup->paper_name);
00446   fprintf(f, "%%%%Orientation: %s\n", orientation);
00447   fprintf(f, "%%%%Pages: %d\n", (int) mPageNumber - 1);
00448 
00449   fprintf(f, "%%%%PageOrder: %s\n",
00450       mPrintContext->prSetup->reverse ? "Descend" : "Ascend");
00451 
00452   if (nsnull != mPrintContext->prInfo->doc_title) {
00453     // DSC spec: max line length is 255 characters
00454     fprintf(f, "%%%%Title: ");
00455     PrintAsDSCTextline(f, mPrintContext->prInfo->doc_title, 230);
00456     fprintf(f, "\n");
00457   }
00458 
00459   fprintf(f, "%%%%EndComments\n");
00460 
00461   // general comments: Mozilla-specific 
00462   fputs("% MozillaCharsetName: iso-8859-1\n\n", f);
00463     
00464     // now begin prolog 
00465   fprintf(f, "%%%%BeginProlog\n");
00466 
00467   // Tell the printer what size paper it should use
00468   fprintf(f,
00469     "/setpagedevice where\n"                     // Test for the feature
00470     "{ pop 2 dict\n"
00471     "  dup /PageSize [ %s %s ] put\n"            // Paper dimensions
00472     "  dup /Policies 1 dict\n"
00473     "    dup /PageSize 3 put\n"                  // Select the nearest page size to fit
00474     "  put\n"
00475     "  setpagedevice\n"                          // Install settings
00476     "} if\n", 
00477     fpCString(NSTwipsToFloatPoints(paper_width)).get(),
00478     fpCString(NSTwipsToFloatPoints(paper_height)).get());
00479 
00480   fprintf(f, "[");
00481   for (i = 0; i < 256; i++){
00482          if (*isotab[i] == '\0'){
00483       fprintf(f, " /.notdef");
00484     }else{
00485            fprintf(f, " /%s", isotab[i]);
00486     }
00487 
00488     if (( i % 6) == 5){
00489       fprintf(f, "\n");
00490     }
00491   }
00492 
00493   fprintf(f, "] /isolatin1encoding exch def\n");
00494 
00495   // Procedure to reencode a font
00496   fprintf(f, "%s",
00497       "/Mfr {\n"
00498       "  findfont dup length dict\n"
00499       "  begin\n"
00500       "    {1 index /FID ne {def} {pop pop} ifelse} forall\n"
00501       "    /Encoding isolatin1encoding def\n"
00502       "    currentdict\n"
00503       "  end\n"
00504       "  definefont pop\n"
00505       "} bind def\n");
00506 
00507   // Procedure to select and scale a font, using selectfont if available. See
00508   // Adobe Technical note 5048. Note msf args are backwards from selectfont.
00509   fprintf(f, "%s",
00510     "/Msf /selectfont where\n"
00511     "  { pop { exch selectfont } }\n"
00512     "  { { findfont exch scalefont setfont } }\n"
00513     "  ifelse\n"
00514     "  bind def\n");
00515 
00516   // Procedure to stroke a rectangle. Coordinates are rounded
00517   // to device pixel boundaries. See Adobe Technical notes 5111 and
00518   // 5126 and the "Scan Conversion" section of the PS Language
00519   // Reference for background.
00520   fprintf(f, "%s",
00521     "/Mrect { % x y w h Mrect -\n"
00522     "  2 index add\n"              // x y w h+y
00523     "  4 1 roll\n"          // h+y x y w
00524     "  2 index add\n"              // h+y x y w+x
00525     "  4 1 roll\n"          // w+x h+y x y
00526     "  transform round .1 add exch round .1 add exch itransform\n"
00527     "  4 -2 roll\n"         // x' y' w+x h+x
00528     "  transform round .1 sub exch round .1 sub exch itransform\n"
00529     "  2 index sub\n"              // x' y' w'+x h'
00530     "  4 1 roll\n"          // h' x' y' w'+x
00531     "  2 index sub\n"              // h' x' y' w'
00532     "  4 1 roll\n"          // w' h' x' y'
00533     "  moveto\n"            // w' h'
00534     "  dup 0 exch rlineto\n"       // w' h'
00535     "  exch 0 rlineto\n"    // h'
00536     "  neg 0 exch rlineto\n"       // -
00537     "  closepath\n"
00538     "} bind def\n"
00539 
00540     // Setstrokeadjust, or null if not supported
00541     "/Msetstrokeadjust /setstrokeadjust where\n"
00542     "  { pop /setstrokeadjust } { /pop } ifelse\n"
00543     "  load def\n"
00544 
00545     "\n"
00546     );
00547 
00548   if (aFTPEnable) {
00549     fprintf(f, "%%%%EndProlog\n");
00550     return;
00551   }
00552 
00553   for(i = 0;i < NUM_AFM_FONTS; i++){
00554     fprintf(f, 
00555       "/F%d /%s Mfr\n"
00556       "/f%d { dup /csize exch def /F%d Msf } bind def\n",
00557       i, gSubstituteFonts[i].mPSName, i, i);
00558   }
00559 
00560   fprintf(f, "%s",
00561     // Unicode glyph dictionary
00562     "/UniDict\n"
00563     "1051 dict dup begin\n"
00564     "16#0020  /space def\n"
00565     "16#0021  /exclam def\n"
00566     "16#0022  /quotedbl def\n"
00567     "16#0023  /numbersign def\n"
00568     "16#0024  /dollar def\n"
00569     "16#0025  /percent def\n"
00570     "16#0026  /ampersand def\n"
00571     "16#0027  /quotesingle def\n"
00572     "16#0028  /parenleft def\n"
00573     "16#0029  /parenright def\n"
00574     "16#002A  /asterisk def\n"
00575     "16#002B  /plus def\n"
00576     "16#002C  /comma def\n"
00577     "16#002D  /hyphen def\n"
00578     "16#002E  /period def\n"
00579     "16#002F  /slash def\n"
00580     "16#0030  /zero def\n"
00581     "16#0031  /one def\n"
00582     "16#0032  /two def\n"
00583     "16#0033  /three def\n"
00584     "16#0034  /four def\n"
00585     "16#0035  /five def\n"
00586     "16#0036  /six def\n"
00587     "16#0037  /seven def\n"
00588     "16#0038  /eight def\n"
00589     "16#0039  /nine def\n"
00590     "16#003A  /colon def\n"
00591     "16#003B  /semicolon def\n"
00592     "16#003C  /less def\n"
00593     "16#003D  /equal def\n"
00594     "16#003E  /greater def\n"
00595     "16#003F  /question def\n"
00596     "16#0040  /at def\n"
00597     "16#0041  /A def\n"
00598     "16#0042  /B def\n"
00599     "16#0043  /C def\n"
00600     "16#0044  /D def\n"
00601     "16#0045  /E def\n"
00602     "16#0046  /F def\n"
00603     "16#0047  /G def\n"
00604     "16#0048  /H def\n"
00605     "16#0049  /I def\n"
00606     "16#004A  /J def\n"
00607     "16#004B  /K def\n"
00608     "16#004C  /L def\n"
00609     "16#004D  /M def\n"
00610     "16#004E  /N def\n"
00611     "16#004F  /O def\n"
00612     "16#0050  /P def\n"
00613     "16#0051  /Q def\n"
00614     "16#0052  /R def\n"
00615     "16#0053  /S def\n"
00616     "16#0054  /T def\n"
00617     "16#0055  /U def\n"
00618     "16#0056  /V def\n"
00619     "16#0057  /W def\n"
00620     "16#0058  /X def\n"
00621     "16#0059  /Y def\n"
00622     "16#005A  /Z def\n"
00623     "16#005B  /bracketleft def\n"
00624     "16#005C  /backslash def\n"
00625     "16#005D  /bracketright def\n"
00626     "16#005E  /asciicircum def\n"
00627     "16#005F  /underscore def\n"
00628     "16#0060  /grave def\n"
00629     "16#0061  /a def\n"
00630     "16#0062  /b def\n"
00631     "16#0063  /c def\n"
00632     "16#0064  /d def\n"
00633     "16#0065  /e def\n"
00634     "16#0066  /f def\n"
00635     "16#0067  /g def\n"
00636     "16#0068  /h def\n"
00637     "16#0069  /i def\n"
00638     "16#006A  /j def\n"
00639     "16#006B  /k def\n"
00640     "16#006C  /l def\n"
00641     "16#006D  /m def\n"
00642     "16#006E  /n def\n"
00643     "16#006F  /o def\n"
00644     "16#0070  /p def\n"
00645     "16#0071  /q def\n"
00646     "16#0072  /r def\n"
00647     "16#0073  /s def\n"
00648     "16#0074  /t def\n"
00649     "16#0075  /u def\n"
00650     "16#0076  /v def\n"
00651     "16#0077  /w def\n"
00652     "16#0078  /x def\n"
00653     "16#0079  /y def\n"
00654     "16#007A  /z def\n"
00655     "16#007B  /braceleft def\n"
00656     "16#007C  /bar def\n"
00657     "16#007D  /braceright def\n"
00658     "16#007E  /asciitilde def\n"
00659     "16#00A0  /space def\n"
00660     "16#00A1  /exclamdown def\n"
00661     "16#00A2  /cent def\n"
00662     "16#00A3  /sterling def\n"
00663     "16#00A4  /currency def\n"
00664     "16#00A5  /yen def\n"
00665     "16#00A6  /brokenbar def\n"
00666     "16#00A7  /section def\n"
00667     "16#00A8  /dieresis def\n"
00668     "16#00A9  /copyright def\n"
00669     "16#00AA  /ordfeminine def\n"
00670     "16#00AB  /guillemotleft def\n"
00671     "16#00AC  /logicalnot def\n"
00672     "16#00AD  /hyphen def\n"
00673     "16#00AE  /registered def\n"
00674     "16#00AF  /macron def\n"
00675     "16#00B0  /degree def\n"
00676     "16#00B1  /plusminus def\n"
00677     "16#00B2  /twosuperior def\n"
00678     "16#00B3  /threesuperior def\n"
00679     "16#00B4  /acute def\n"
00680     "16#00B5  /mu def\n"
00681     "16#00B6  /paragraph def\n"
00682     "16#00B7  /periodcentered def\n"
00683     "16#00B8  /cedilla def\n"
00684     "16#00B9  /onesuperior def\n"
00685     "16#00BA  /ordmasculine def\n"
00686     "16#00BB  /guillemotright def\n"
00687     "16#00BC  /onequarter def\n"
00688     "16#00BD  /onehalf def\n"
00689     "16#00BE  /threequarters def\n"
00690     "16#00BF  /questiondown def\n"
00691     "16#00C0  /Agrave def\n"
00692     "16#00C1  /Aacute def\n"
00693     "16#00C2  /Acircumflex def\n"
00694     "16#00C3  /Atilde def\n"
00695     "16#00C4  /Adieresis def\n"
00696     "16#00C5  /Aring def\n"
00697     "16#00C6  /AE def\n"
00698     "16#00C7  /Ccedilla def\n"
00699     "16#00C8  /Egrave def\n"
00700     "16#00C9  /Eacute def\n"
00701     "16#00CA  /Ecircumflex def\n"
00702     "16#00CB  /Edieresis def\n"
00703     "16#00CC  /Igrave def\n"
00704     "16#00CD  /Iacute def\n"
00705     "16#00CE  /Icircumflex def\n"
00706     "16#00CF  /Idieresis def\n"
00707     "16#00D0  /Eth def\n"
00708     "16#00D1  /Ntilde def\n"
00709     "16#00D2  /Ograve def\n"
00710     "16#00D3  /Oacute def\n"
00711     "16#00D4  /Ocircumflex def\n"
00712     "16#00D5  /Otilde def\n"
00713     "16#00D6  /Odieresis def\n"
00714     "16#00D7  /multiply def\n"
00715     "16#00D8  /Oslash def\n"
00716     "16#00D9  /Ugrave def\n"
00717     "16#00DA  /Uacute def\n"
00718     "16#00DB  /Ucircumflex def\n"
00719     "16#00DC  /Udieresis def\n"
00720     "16#00DD  /Yacute def\n"
00721     "16#00DE  /Thorn def\n"
00722     "16#00DF  /germandbls def\n"
00723     "16#00E0  /agrave def\n"
00724     "16#00E1  /aacute def\n"
00725     "16#00E2  /acircumflex def\n"
00726     "16#00E3  /atilde def\n"
00727     "16#00E4  /adieresis def\n"
00728     "16#00E5  /aring def\n"
00729     "16#00E6  /ae def\n"
00730     "16#00E7  /ccedilla def\n"
00731     "16#00E8  /egrave def\n"
00732     "16#00E9  /eacute def\n"
00733     "16#00EA  /ecircumflex def\n"
00734     "16#00EB  /edieresis def\n"
00735     "16#00EC  /igrave def\n"
00736     "16#00ED  /iacute def\n"
00737     "16#00EE  /icircumflex def\n"
00738     "16#00EF  /idieresis def\n"
00739     "16#00F0  /eth def\n"
00740     "16#00F1  /ntilde def\n"
00741     "16#00F2  /ograve def\n"
00742     "16#00F3  /oacute def\n"
00743     "16#00F4  /ocircumflex def\n"
00744     "16#00F5  /otilde def\n"
00745     "16#00F6  /odieresis def\n"
00746     "16#00F7  /divide def\n"
00747     "16#00F8  /oslash def\n"
00748     "16#00F9  /ugrave def\n"
00749     "16#00FA  /uacute def\n"
00750     "16#00FB  /ucircumflex def\n"
00751     "16#00FC  /udieresis def\n"
00752     "16#00FD  /yacute def\n"
00753     "16#00FE  /thorn def\n"
00754     "16#00FF  /ydieresis def\n"
00755     "16#0100  /Amacron def\n"
00756     "16#0101  /amacron def\n"
00757     "16#0102  /Abreve def\n"
00758     "16#0103  /abreve def\n"
00759     "16#0104  /Aogonek def\n"
00760     "16#0105  /aogonek def\n"
00761     "16#0106  /Cacute def\n"
00762     "16#0107  /cacute def\n"
00763     "16#0108  /Ccircumflex def\n"
00764     "16#0109  /ccircumflex def\n"
00765     "16#010A  /Cdotaccent def\n"
00766     "16#010B  /cdotaccent def\n"
00767     "16#010C  /Ccaron def\n"
00768     "16#010D  /ccaron def\n"
00769     "16#010E  /Dcaron def\n"
00770     "16#010F  /dcaron def\n"
00771     "16#0110  /Dcroat def\n"
00772     "16#0111  /dcroat def\n"
00773     "16#0112  /Emacron def\n"
00774     "16#0113  /emacron def\n"
00775     "16#0114  /Ebreve def\n"
00776     "16#0115  /ebreve def\n"
00777     "16#0116  /Edotaccent def\n"
00778     "16#0117  /edotaccent def\n"
00779     "16#0118  /Eogonek def\n"
00780     "16#0119  /eogonek def\n"
00781     "16#011A  /Ecaron def\n"
00782     "16#011B  /ecaron def\n"
00783     "16#011C  /Gcircumflex def\n"
00784     "16#011D  /gcircumflex def\n"
00785     "16#011E  /Gbreve def\n"
00786     "16#011F  /gbreve def\n"
00787     "16#0120  /Gdotaccent def\n"
00788     "16#0121  /gdotaccent def\n"
00789     "16#0122  /Gcommaaccent def\n"
00790     "16#0123  /gcommaaccent def\n"
00791     "16#0124  /Hcircumflex def\n"
00792     "16#0125  /hcircumflex def\n"
00793     "16#0126  /Hbar def\n"
00794     "16#0127  /hbar def\n"
00795     "16#0128  /Itilde def\n"
00796     "16#0129  /itilde def\n"
00797     "16#012A  /Imacron def\n"
00798     "16#012B  /imacron def\n"
00799     "16#012C  /Ibreve def\n"
00800     "16#012D  /ibreve def\n"
00801     "16#012E  /Iogonek def\n"
00802     "16#012F  /iogonek def\n"
00803     "16#0130  /Idotaccent def\n"
00804     "16#0131  /dotlessi def\n"
00805     "16#0132  /IJ def\n"
00806     "16#0133  /ij def\n"
00807     "16#0134  /Jcircumflex def\n"
00808     "16#0135  /jcircumflex def\n"
00809     "16#0136  /Kcommaaccent def\n"
00810     "16#0137  /kcommaaccent def\n"
00811     "16#0138  /kgreenlandic def\n"
00812     "16#0139  /Lacute def\n"
00813     "16#013A  /lacute def\n"
00814     "16#013B  /Lcommaaccent def\n"
00815     "16#013C  /lcommaaccent def\n"
00816     "16#013D  /Lcaron def\n"
00817     "16#013E  /lcaron def\n"
00818     "16#013F  /Ldot def\n"
00819     "16#0140  /ldot def\n"
00820     "16#0141  /Lslash def\n"
00821     "16#0142  /lslash def\n"
00822     "16#0143  /Nacute def\n"
00823     "16#0144  /nacute def\n"
00824     "16#0145  /Ncommaaccent def\n"
00825     "16#0146  /ncommaaccent def\n"
00826     "16#0147  /Ncaron def\n"
00827     "16#0148  /ncaron def\n"
00828     "16#0149  /napostrophe def\n"
00829     "16#014A  /Eng def\n"
00830     "16#014B  /eng def\n"
00831     "16#014C  /Omacron def\n"
00832     "16#014D  /omacron def\n"
00833     "16#014E  /Obreve def\n"
00834     "16#014F  /obreve def\n"
00835     "16#0150  /Ohungarumlaut def\n"
00836     "16#0151  /ohungarumlaut def\n"
00837     "16#0152  /OE def\n"
00838     "16#0153  /oe def\n"
00839     "16#0154  /Racute def\n"
00840     "16#0155  /racute def\n"
00841     "16#0156  /Rcommaaccent def\n"
00842     "16#0157  /rcommaaccent def\n"
00843     "16#0158  /Rcaron def\n"
00844     "16#0159  /rcaron def\n"
00845     "16#015A  /Sacute def\n"
00846     "16#015B  /sacute def\n"
00847     "16#015C  /Scircumflex def\n"
00848     "16#015D  /scircumflex def\n"
00849     "16#015E  /Scedilla def\n"
00850     "16#015F  /scedilla def\n"
00851     "16#0160  /Scaron def\n"
00852     "16#0161  /scaron def\n"
00853     "16#0162  /Tcommaaccent def\n"
00854     "16#0163  /tcommaaccent def\n"
00855     "16#0164  /Tcaron def\n"
00856     "16#0165  /tcaron def\n"
00857     "16#0166  /Tbar def\n"
00858     "16#0167  /tbar def\n"
00859     "16#0168  /Utilde def\n"
00860     "16#0169  /utilde def\n"
00861     "16#016A  /Umacron def\n"
00862     "16#016B  /umacron def\n"
00863     "16#016C  /Ubreve def\n"
00864     "16#016D  /ubreve def\n"
00865     "16#016E  /Uring def\n"
00866     "16#016F  /uring def\n"
00867     "16#0170  /Uhungarumlaut def\n"
00868     "16#0171  /uhungarumlaut def\n"
00869     "16#0172  /Uogonek def\n"
00870     "16#0173  /uogonek def\n"
00871     "16#0174  /Wcircumflex def\n"
00872     "16#0175  /wcircumflex def\n"
00873     "16#0176  /Ycircumflex def\n"
00874     "16#0177  /ycircumflex def\n"
00875     "16#0178  /Ydieresis def\n"
00876     "16#0179  /Zacute def\n"
00877     "16#017A  /zacute def\n"
00878     "16#017B  /Zdotaccent def\n"
00879     "16#017C  /zdotaccent def\n"
00880     "16#017D  /Zcaron def\n"
00881     "16#017E  /zcaron def\n"
00882     "16#017F  /longs def\n"
00883     "16#0192  /florin def\n"
00884     "16#01A0  /Ohorn def\n"
00885     "16#01A1  /ohorn def\n"
00886     "16#01AF  /Uhorn def\n"
00887     "16#01B0  /uhorn def\n"
00888     "16#01E6  /Gcaron def\n"
00889     "16#01E7  /gcaron def\n"
00890     "16#01FA  /Aringacute def\n"
00891     "16#01FB  /aringacute def\n"
00892     "16#01FC  /AEacute def\n"
00893     "16#01FD  /aeacute def\n"
00894     "16#01FE  /Oslashacute def\n"
00895     "16#01FF  /oslashacute def\n"
00896     "16#0218  /Scommaaccent def\n"
00897     "16#0219  /scommaaccent def\n"
00898     "16#021A  /Tcommaaccent def\n"
00899     "16#021B  /tcommaaccent def\n"
00900     "16#02BC  /afii57929 def\n"
00901     "16#02BD  /afii64937 def\n"
00902     "16#02C6  /circumflex def\n"
00903     "16#02C7  /caron def\n"
00904     "16#02C9  /macron def\n"
00905     "16#02D8  /breve def\n"
00906     "16#02D9  /dotaccent def\n"
00907     "16#02DA  /ring def\n"
00908     "16#02DB  /ogonek def\n"
00909     "16#02DC  /tilde def\n"
00910     "16#02DD  /hungarumlaut def\n"
00911     "16#0300  /gravecomb def\n"
00912     "16#0301  /acutecomb def\n"
00913     "16#0303  /tildecomb def\n"
00914     "16#0309  /hookabovecomb def\n"
00915     "16#0323  /dotbelowcomb def\n"
00916     "16#0384  /tonos def\n"
00917     "16#0385  /dieresistonos def\n"
00918     "16#0386  /Alphatonos def\n"
00919     "16#0387  /anoteleia def\n"
00920     "16#0388  /Epsilontonos def\n"
00921     "16#0389  /Etatonos def\n"
00922     "16#038A  /Iotatonos def\n"
00923     "16#038C  /Omicrontonos def\n"
00924     "16#038E  /Upsilontonos def\n"
00925     "16#038F  /Omegatonos def\n"
00926     "16#0390  /iotadieresistonos def\n"
00927     "16#0391  /Alpha def\n"
00928     "16#0392  /Beta def\n"
00929     "16#0393  /Gamma def\n"
00930     "16#0394  /Delta def\n"
00931     "16#0395  /Epsilon def\n"
00932     "16#0396  /Zeta def\n"
00933     "16#0397  /Eta def\n"
00934     "16#0398  /Theta def\n"
00935     "16#0399  /Iota def\n"
00936     "16#039A  /Kappa def\n"
00937     "16#039B  /Lambda def\n"
00938     "16#039C  /Mu def\n"
00939     "16#039D  /Nu def\n"
00940     "16#039E  /Xi def\n"
00941     "16#039F  /Omicron def\n"
00942     "16#03A0  /Pi def\n"
00943     "16#03A1  /Rho def\n"
00944     "16#03A3  /Sigma def\n"
00945     "16#03A4  /Tau def\n"
00946     "16#03A5  /Upsilon def\n"
00947     "16#03A6  /Phi def\n"
00948     "16#03A7  /Chi def\n"
00949     "16#03A8  /Psi def\n"
00950     "16#03A9  /Omega def\n"
00951     "16#03AA  /Iotadieresis def\n"
00952     "16#03AB  /Upsilondieresis def\n"
00953     "16#03AC  /alphatonos def\n"
00954     "16#03AD  /epsilontonos def\n"
00955     "16#03AE  /etatonos def\n"
00956     "16#03AF  /iotatonos def\n"
00957     "16#03B0  /upsilondieresistonos def\n"
00958     "16#03B1  /alpha def\n"
00959     "16#03B2  /beta def\n"
00960     "16#03B3  /gamma def\n"
00961     "16#03B4  /delta def\n"
00962     "16#03B5  /epsilon def\n"
00963     "16#03B6  /zeta def\n"
00964     "16#03B7  /eta def\n"
00965     "16#03B8  /theta def\n"
00966     "16#03B9  /iota def\n"
00967     "16#03BA  /kappa def\n"
00968     "16#03BB  /lambda def\n"
00969     "16#03BC  /mu def\n"
00970     "16#03BD  /nu def\n"
00971     "16#03BE  /xi def\n"
00972     "16#03BF  /omicron def\n"
00973     "16#03C0  /pi def\n"
00974     "16#03C1  /rho def\n"
00975     "16#03C2  /sigma1 def\n"
00976     "16#03C3  /sigma def\n"
00977     "16#03C4  /tau def\n"
00978     "16#03C5  /upsilon def\n"
00979     "16#03C6  /phi def\n"
00980     "16#03C7  /chi def\n"
00981     "16#03C8  /psi def\n"
00982     "16#03C9  /omega def\n"
00983     "16#03CA  /iotadieresis def\n"
00984     "16#03CB  /upsilondieresis def\n"
00985     "16#03CC  /omicrontonos def\n"
00986     );
00987   fprintf(f, "%s",
00988     "16#03CD  /upsilontonos def\n"
00989     "16#03CE  /omegatonos def\n"
00990     "16#03D1  /theta1 def\n"
00991     "16#03D2  /Upsilon1 def\n"
00992     "16#03D5  /phi1 def\n"
00993     "16#03D6  /omega1 def\n"
00994     "16#0401  /afii10023 def\n"
00995     "16#0402  /afii10051 def\n"
00996     "16#0403  /afii10052 def\n"
00997     "16#0404  /afii10053 def\n"
00998     "16#0405  /afii10054 def\n"
00999     "16#0406  /afii10055 def\n"
01000     "16#0407  /afii10056 def\n"
01001     "16#0408  /afii10057 def\n"
01002     "16#0409  /afii10058 def\n"
01003     "16#040A  /afii10059 def\n"
01004     "16#040B  /afii10060 def\n"
01005     "16#040C  /afii10061 def\n"
01006     "16#040E  /afii10062 def\n"
01007     "16#040F  /afii10145 def\n"
01008     "16#0410  /afii10017 def\n"
01009     "16#0411  /afii10018 def\n"
01010     "16#0412  /afii10019 def\n"
01011     "16#0413  /afii10020 def\n"
01012     "16#0414  /afii10021 def\n"
01013     "16#0415  /afii10022 def\n"
01014     "16#0416  /afii10024 def\n"
01015     "16#0417  /afii10025 def\n"
01016     "16#0418  /afii10026 def\n"
01017     "16#0419  /afii10027 def\n"
01018     "16#041A  /afii10028 def\n"
01019     "16#041B  /afii10029 def\n"
01020     "16#041C  /afii10030 def\n"
01021     "16#041D  /afii10031 def\n"
01022     "16#041E  /afii10032 def\n"
01023     "16#041F  /afii10033 def\n"
01024     "16#0420  /afii10034 def\n"
01025     "16#0421  /afii10035 def\n"
01026     "16#0422  /afii10036 def\n"
01027     "16#0423  /afii10037 def\n"
01028     "16#0424  /afii10038 def\n"
01029     "16#0425  /afii10039 def\n"
01030     "16#0426  /afii10040 def\n"
01031     "16#0427  /afii10041 def\n"
01032     "16#0428  /afii10042 def\n"
01033     "16#0429  /afii10043 def\n"
01034     "16#042A  /afii10044 def\n"
01035     "16#042B  /afii10045 def\n"
01036     "16#042C  /afii10046 def\n"
01037     "16#042D  /afii10047 def\n"
01038     "16#042E  /afii10048 def\n"
01039     "16#042F  /afii10049 def\n"
01040     "16#0430  /afii10065 def\n"
01041     "16#0431  /afii10066 def\n"
01042     "16#0432  /afii10067 def\n"
01043     "16#0433  /afii10068 def\n"
01044     "16#0434  /afii10069 def\n"
01045     "16#0435  /afii10070 def\n"
01046     "16#0436  /afii10072 def\n"
01047     "16#0437  /afii10073 def\n"
01048     "16#0438  /afii10074 def\n"
01049     "16#0439  /afii10075 def\n"
01050     "16#043A  /afii10076 def\n"
01051     "16#043B  /afii10077 def\n"
01052     "16#043C  /afii10078 def\n"
01053     "16#043D  /afii10079 def\n"
01054     "16#043E  /afii10080 def\n"
01055     "16#043F  /afii10081 def\n"
01056     "16#0440  /afii10082 def\n"
01057     "16#0441  /afii10083 def\n"
01058     "16#0442  /afii10084 def\n"
01059     "16#0443  /afii10085 def\n"
01060     "16#0444  /afii10086 def\n"
01061     "16#0445  /afii10087 def\n"
01062     "16#0446  /afii10088 def\n"
01063     "16#0447  /afii10089 def\n"
01064     "16#0448  /afii10090 def\n"
01065     "16#0449  /afii10091 def\n"
01066     "16#044A  /afii10092 def\n"
01067     "16#044B  /afii10093 def\n"
01068     "16#044C  /afii10094 def\n"
01069     "16#044D  /afii10095 def\n"
01070     "16#044E  /afii10096 def\n"
01071     "16#044F  /afii10097 def\n"
01072     "16#0451  /afii10071 def\n"
01073     "16#0452  /afii10099 def\n"
01074     "16#0453  /afii10100 def\n"
01075     "16#0454  /afii10101 def\n"
01076     "16#0455  /afii10102 def\n"
01077     "16#0456  /afii10103 def\n"
01078     "16#0457  /afii10104 def\n"
01079     "16#0458  /afii10105 def\n"
01080     "16#0459  /afii10106 def\n"
01081     "16#045A  /afii10107 def\n"
01082     "16#045B  /afii10108 def\n"
01083     "16#045C  /afii10109 def\n"
01084     "16#045E  /afii10110 def\n"
01085     "16#045F  /afii10193 def\n"
01086     "16#0462  /afii10146 def\n"
01087     "16#0463  /afii10194 def\n"
01088     "16#0472  /afii10147 def\n"
01089     "16#0473  /afii10195 def\n"
01090     "16#0474  /afii10148 def\n"
01091     "16#0475  /afii10196 def\n"
01092     "16#0490  /afii10050 def\n"
01093     "16#0491  /afii10098 def\n"
01094     "16#04D9  /afii10846 def\n"
01095     "16#05B0  /afii57799 def\n"
01096     "16#05B1  /afii57801 def\n"
01097     "16#05B2  /afii57800 def\n"
01098     "16#05B3  /afii57802 def\n"
01099     "16#05B4  /afii57793 def\n"
01100     "16#05B5  /afii57794 def\n"
01101     "16#05B6  /afii57795 def\n"
01102     "16#05B7  /afii57798 def\n"
01103     "16#05B8  /afii57797 def\n"
01104     "16#05B9  /afii57806 def\n"
01105     "16#05BB  /afii57796 def\n"
01106     "16#05BC  /afii57807 def\n"
01107     "16#05BD  /afii57839 def\n"
01108     "16#05BE  /afii57645 def\n"
01109     "16#05BF  /afii57841 def\n"
01110     "16#05C0  /afii57842 def\n"
01111     "16#05C1  /afii57804 def\n"
01112     "16#05C2  /afii57803 def\n"
01113     "16#05C3  /afii57658 def\n"
01114     "16#05D0  /afii57664 def\n"
01115     "16#05D1  /afii57665 def\n"
01116     "16#05D2  /afii57666 def\n"
01117     "16#05D3  /afii57667 def\n"
01118     "16#05D4  /afii57668 def\n"
01119     "16#05D5  /afii57669 def\n"
01120     "16#05D6  /afii57670 def\n"
01121     "16#05D7  /afii57671 def\n"
01122     "16#05D8  /afii57672 def\n"
01123     "16#05D9  /afii57673 def\n"
01124     "16#05DA  /afii57674 def\n"
01125     "16#05DB  /afii57675 def\n"
01126     "16#05DC  /afii57676 def\n"
01127     "16#05DD  /afii57677 def\n"
01128     "16#05DE  /afii57678 def\n"
01129     "16#05DF  /afii57679 def\n"
01130     "16#05E0  /afii57680 def\n"
01131     "16#05E1  /afii57681 def\n"
01132     "16#05E2  /afii57682 def\n"
01133     "16#05E3  /afii57683 def\n"
01134     "16#05E4  /afii57684 def\n"
01135     "16#05E5  /afii57685 def\n"
01136     "16#05E6  /afii57686 def\n"
01137     "16#05E7  /afii57687 def\n"
01138     "16#05E8  /afii57688 def\n"
01139     "16#05E9  /afii57689 def\n"
01140     "16#05EA  /afii57690 def\n"
01141     "16#05F0  /afii57716 def\n"
01142     "16#05F1  /afii57717 def\n"
01143     "16#05F2  /afii57718 def\n"
01144     "16#060C  /afii57388 def\n"
01145     "16#061B  /afii57403 def\n"
01146     "16#061F  /afii57407 def\n"
01147     "16#0621  /afii57409 def\n"
01148     "16#0622  /afii57410 def\n"
01149     "16#0623  /afii57411 def\n"
01150     "16#0624  /afii57412 def\n"
01151     "16#0625  /afii57413 def\n"
01152     "16#0626  /afii57414 def\n"
01153     "16#0627  /afii57415 def\n"
01154     "16#0628  /afii57416 def\n"
01155     "16#0629  /afii57417 def\n"
01156     "16#062A  /afii57418 def\n"
01157     "16#062B  /afii57419 def\n"
01158     "16#062C  /afii57420 def\n"
01159     "16#062D  /afii57421 def\n"
01160     "16#062E  /afii57422 def\n"
01161     "16#062F  /afii57423 def\n"
01162     "16#0630  /afii57424 def\n"
01163     "16#0631  /afii57425 def\n"
01164     "16#0632  /afii57426 def\n"
01165     "16#0633  /afii57427 def\n"
01166     "16#0634  /afii57428 def\n"
01167     "16#0635  /afii57429 def\n"
01168     "16#0636  /afii57430 def\n"
01169     "16#0637  /afii57431 def\n"
01170     "16#0638  /afii57432 def\n"
01171     "16#0639  /afii57433 def\n"
01172     "16#063A  /afii57434 def\n"
01173     "16#0640  /afii57440 def\n"
01174     "16#0641  /afii57441 def\n"
01175     "16#0642  /afii57442 def\n"
01176     "16#0643  /afii57443 def\n"
01177     "16#0644  /afii57444 def\n"
01178     "16#0645  /afii57445 def\n"
01179     "16#0646  /afii57446 def\n"
01180     "16#0647  /afii57470 def\n"
01181     "16#0648  /afii57448 def\n"
01182     "16#0649  /afii57449 def\n"
01183     "16#064A  /afii57450 def\n"
01184     "16#064B  /afii57451 def\n"
01185     "16#064C  /afii57452 def\n"
01186     "16#064D  /afii57453 def\n"
01187     "16#064E  /afii57454 def\n"
01188     "16#064F  /afii57455 def\n"
01189     "16#0650  /afii57456 def\n"
01190     "16#0651  /afii57457 def\n"
01191     "16#0652  /afii57458 def\n"
01192     "16#0660  /afii57392 def\n"
01193     "16#0661  /afii57393 def\n"
01194     "16#0662  /afii57394 def\n"
01195     "16#0663  /afii57395 def\n"
01196     "16#0664  /afii57396 def\n"
01197     "16#0665  /afii57397 def\n"
01198     "16#0666  /afii57398 def\n"
01199     "16#0667  /afii57399 def\n"
01200     "16#0668  /afii57400 def\n"
01201     "16#0669  /afii57401 def\n"
01202     "16#066A  /afii57381 def\n"
01203     "16#066D  /afii63167 def\n"
01204     "16#0679  /afii57511 def\n"
01205     "16#067E  /afii57506 def\n"
01206     "16#0686  /afii57507 def\n"
01207     "16#0688  /afii57512 def\n"
01208     "16#0691  /afii57513 def\n"
01209     "16#0698  /afii57508 def\n"
01210     "16#06A4  /afii57505 def\n"
01211     "16#06AF  /afii57509 def\n"
01212     "16#06BA  /afii57514 def\n"
01213     "16#06D2  /afii57519 def\n"
01214     "16#06D5  /afii57534 def\n"
01215     "16#1E80  /Wgrave def\n"
01216     "16#1E81  /wgrave def\n"
01217     "16#1E82  /Wacute def\n"
01218     "16#1E83  /wacute def\n"
01219     "16#1E84  /Wdieresis def\n"
01220     "16#1E85  /wdieresis def\n"
01221     "16#1EF2  /Ygrave def\n"
01222     "16#1EF3  /ygrave def\n"
01223     "16#200C  /afii61664 def\n"
01224     "16#200D  /afii301 def\n"
01225     "16#200E  /afii299 def\n"
01226     "16#200F  /afii300 def\n"
01227     "16#2012  /figuredash def\n"
01228     "16#2013  /endash def\n"
01229     "16#2014  /emdash def\n"
01230     "16#2015  /afii00208 def\n"
01231     "16#2017  /underscoredbl def\n"
01232     "16#2018  /quoteleft def\n"
01233     "16#2019  /quoteright def\n"
01234     "16#201A  /quotesinglbase def\n"
01235     "16#201B  /quotereversed def\n"
01236     "16#201C  /quotedblleft def\n"
01237     "16#201D  /quotedblright def\n"
01238     "16#201E  /quotedblbase def\n"
01239     "16#2020  /dagger def\n"
01240     "16#2021  /daggerdbl def\n"
01241     "16#2022  /bullet def\n"
01242     "16#2024  /onedotenleader def\n"
01243     "16#2025  /twodotenleader def\n"
01244     "16#2026  /ellipsis def\n"
01245     "16#202C  /afii61573 def\n"
01246     "16#202D  /afii61574 def\n"
01247     "16#202E  /afii61575 def\n"
01248     "16#2030  /perthousand def\n"
01249     "16#2032  /minute def\n"
01250     "16#2033  /second def\n"
01251     "16#2039  /guilsinglleft def\n"
01252     "16#203A  /guilsinglright def\n"
01253     "16#203C  /exclamdbl def\n"
01254     "16#2044  /fraction def\n"
01255     "16#2070  /zerosuperior def\n"
01256     "16#2074  /foursuperior def\n"
01257     "16#2075  /fivesuperior def\n"
01258     "16#2076  /sixsuperior def\n"
01259     "16#2077  /sevensuperior def\n"
01260     "16#2078  /eightsuperior def\n"
01261     "16#2079  /ninesuperior def\n"
01262     "16#207D  /parenleftsuperior def\n"
01263     "16#207E  /parenrightsuperior def\n"
01264     "16#207F  /nsuperior def\n"
01265     "16#2080  /zeroinferior def\n"
01266     "16#2081  /oneinferior def\n"
01267     "16#2082  /twoinferior def\n"
01268     "16#2083  /threeinferior def\n"
01269     "16#2084  /fourinferior def\n"
01270     "16#2085  /fiveinferior def\n"
01271     "16#2086  /sixinferior def\n"
01272     "16#2087  /seveninferior def\n"
01273     "16#2088  /eightinferior def\n"
01274     "16#2089  /nineinferior def\n"
01275     "16#208D  /parenleftinferior def\n"
01276     "16#208E  /parenrightinferior def\n"
01277     "16#20A1  /colonmonetary def\n"
01278     "16#20A3  /franc def\n"
01279     "16#20A4  /lira def\n"
01280     "16#20A7  /peseta def\n"
01281     "16#20AA  /afii57636 def\n"
01282     "16#20AB  /dong def\n"
01283     "16#20AC  /Euro def\n"
01284     "16#2105  /afii61248 def\n"
01285     "16#2111  /Ifraktur def\n"
01286     "16#2113  /afii61289 def\n"
01287     "16#2116  /afii61352 def\n"
01288     "16#2118  /weierstrass def\n"
01289     "16#211C  /Rfraktur def\n"
01290     "16#211E  /prescription def\n"
01291     "16#2122  /trademark def\n"
01292     "16#2126  /Omega def\n"
01293     "16#212E  /estimated def\n"
01294     "16#2135  /aleph def\n"
01295     "16#2153  /onethird def\n"
01296     "16#2154  /twothirds def\n"
01297     "16#215B  /oneeighth def\n"
01298     "16#215C  /threeeighths def\n"
01299     "16#215D  /fiveeighths def\n"
01300     "16#215E  /seveneighths def\n"
01301     "16#2190  /arrowleft def\n"
01302     "16#2191  /arrowup def\n"
01303     "16#2192  /arrowright def\n"
01304     "16#2193  /arrowdown def\n"
01305     "16#2194  /arrowboth def\n"
01306     "16#2195  /arrowupdn def\n"
01307     "16#21A8  /arrowupdnbse def\n"
01308     "16#21B5  /carriagereturn def\n"
01309     "16#21D0  /arrowdblleft def\n"
01310     "16#21D1  /arrowdblup def\n"
01311     "16#21D2  /arrowdblright def\n"
01312     "16#21D3  /arrowdbldown def\n"
01313     "16#21D4  /arrowdblboth def\n"
01314     "16#2200  /universal def\n"
01315     "16#2202  /partialdiff def\n"
01316     "16#2203  /existential def\n"
01317     "16#2205  /emptyset def\n"
01318     "16#2206  /Delta def\n"
01319     "16#2207  /gradient def\n"
01320     "16#2208  /element def\n"
01321     "16#2209  /notelement def\n"
01322     "16#220B  /suchthat def\n"
01323     "16#220F  /product def\n"
01324     "16#2211  /summation def\n"
01325     "16#2212  /minus def\n"
01326     "16#2215  /fraction def\n"
01327     "16#2217  /asteriskmath def\n"
01328     "16#2219  /periodcentered def\n"
01329     "16#221A  /radical def\n"
01330     "16#221D  /proportional def\n"
01331     "16#221E  /infinity def\n"
01332     "16#221F  /orthogonal def\n"
01333     "16#2220  /angle def\n"
01334     "16#2227  /logicaland def\n"
01335     "16#2228  /logicalor def\n"
01336     "16#2229  /intersection def\n"
01337     "16#222A  /union def\n"
01338     "16#222B  /integral def\n"
01339     "16#2234  /therefore def\n"
01340     "16#223C  /similar def\n"
01341     "16#2245  /congruent def\n"
01342     "16#2248  /approxequal def\n"
01343     "16#2260  /notequal def\n"
01344     "16#2261  /equivalence def\n"
01345     "16#2264  /lessequal def\n"
01346     "16#2265  /greaterequal def\n"
01347     "16#2282  /propersubset def\n"
01348     "16#2283  /propersuperset def\n"
01349     "16#2284  /notsubset def\n"
01350     "16#2286  /reflexsubset def\n"
01351     "16#2287  /reflexsuperset def\n"
01352     "16#2295  /circleplus def\n"
01353     "16#2297  /circlemultiply def\n"
01354     "16#22A5  /perpendicular def\n"
01355     "16#22C5  /dotmath def\n"
01356     "16#2302  /house def\n"
01357     "16#2310  /revlogicalnot def\n"
01358     "16#2320  /integraltp def\n"
01359     "16#2321  /integralbt def\n"
01360     "16#2329  /angleleft def\n"
01361     "16#232A  /angleright def\n"
01362     "16#2500  /SF100000 def\n"
01363     "16#2502  /SF110000 def\n"
01364     "16#250C  /SF010000 def\n"
01365     "16#2510  /SF030000 def\n"
01366     "16#2514  /SF020000 def\n"
01367     "16#2518  /SF040000 def\n"
01368     "16#251C  /SF080000 def\n"
01369     "16#2524  /SF090000 def\n"
01370     "16#252C  /SF060000 def\n"
01371     "16#2534  /SF070000 def\n"
01372     "16#253C  /SF050000 def\n"
01373     "16#2550  /SF430000 def\n"
01374     "16#2551  /SF240000 def\n"
01375     "16#2552  /SF510000 def\n"
01376     "16#2553  /SF520000 def\n"
01377     "16#2554  /SF390000 def\n"
01378     "16#2555  /SF220000 def\n"
01379     "16#2556  /SF210000 def\n"
01380     "16#2557  /SF250000 def\n"
01381     "16#2558  /SF500000 def\n"
01382     "16#2559  /SF490000 def\n"
01383     "16#255A  /SF380000 def\n"
01384     "16#255B  /SF280000 def\n"
01385     "16#255C  /SF270000 def\n"
01386     "16#255D  /SF260000 def\n"
01387     "16#255E  /SF360000 def\n"
01388     "16#255F  /SF370000 def\n"
01389     "16#2560  /SF420000 def\n"
01390     "16#2561  /SF190000 def\n"
01391     "16#2562  /SF200000 def\n"
01392     "16#2563  /SF230000 def\n"
01393     "16#2564  /SF470000 def\n"
01394     "16#2565  /SF480000 def\n"
01395     "16#2566  /SF410000 def\n"
01396     "16#2567  /SF450000 def\n"
01397     "16#2568  /SF460000 def\n"
01398     "16#2569  /SF400000 def\n"
01399     "16#256A  /SF540000 def\n"
01400     "16#256B  /SF530000 def\n"
01401     "16#256C  /SF440000 def\n"
01402     "16#2580  /upblock def\n"
01403     "16#2584  /dnblock def\n"
01404     "16#2588  /block def\n"
01405     "16#258C  /lfblock def\n"
01406     "16#2590  /rtblock def\n"
01407     "16#2591  /ltshade def\n"
01408     "16#2592  /shade def\n"
01409     "16#2593  /dkshade def\n"
01410     "16#25A0  /filledbox def\n"
01411     );
01412   fprintf(f, "%s",
01413     "16#25A1  /H22073 def\n"
01414     "16#25AA  /H18543 def\n"
01415     "16#25AB  /H18551 def\n"
01416     "16#25AC  /filledrect def\n"
01417     "16#25B2  /triagup def\n"
01418     "16#25BA  /triagrt def\n"
01419     "16#25BC  /triagdn def\n"
01420     "16#25C4  /triaglf def\n"
01421     "16#25CA  /lozenge def\n"
01422     "16#25CB  /circle def\n"
01423     "16#25CF  /H18533 def\n"
01424     "16#25D8  /invbullet def\n"
01425     "16#25D9  /invcircle def\n"
01426     "16#25E6  /openbullet def\n"
01427     "16#263A  /smileface def\n"
01428     "16#263B  /invsmileface def\n"
01429     "16#263C  /sun def\n"
01430     "16#2640  /female def\n"
01431     "16#2642  /male def\n"
01432     "16#2660  /spade def\n"
01433     "16#2663  /club def\n"
01434     "16#2665  /heart def\n"
01435     "16#2666  /diamond def\n"
01436     "16#266A  /musicalnote def\n"
01437     "16#266B  /musicalnotedbl def\n"
01438     "16#F6BE  /dotlessj def\n"
01439     "16#F6BF  /LL def\n"
01440     "16#F6C0  /ll def\n"
01441     "16#F6C1  /Scedilla def\n"
01442     "16#F6C2  /scedilla def\n"
01443     "16#F6C3  /commaaccent def\n"
01444     "16#F6C4  /afii10063 def\n"
01445     "16#F6C5  /afii10064 def\n"
01446     "16#F6C6  /afii10192 def\n"
01447     "16#F6C7  /afii10831 def\n"
01448     "16#F6C8  /afii10832 def\n"
01449     "16#F6C9  /Acute def\n"
01450     "16#F6CA  /Caron def\n"
01451     "16#F6CB  /Dieresis def\n"
01452     "16#F6CC  /DieresisAcute def\n"
01453     "16#F6CD  /DieresisGrave def\n"
01454     "16#F6CE  /Grave def\n"
01455     "16#F6CF  /Hungarumlaut def\n"
01456     "16#F6D0  /Macron def\n"
01457     "16#F6D1  /cyrBreve def\n"
01458     "16#F6D2  /cyrFlex def\n"
01459     "16#F6D3  /dblGrave def\n"
01460     "16#F6D4  /cyrbreve def\n"
01461     "16#F6D5  /cyrflex def\n"
01462     "16#F6D6  /dblgrave def\n"
01463     "16#F6D7  /dieresisacute def\n"
01464     "16#F6D8  /dieresisgrave def\n"
01465     "16#F6D9  /copyrightserif def\n"
01466     "16#F6DA  /registerserif def\n"
01467     "16#F6DB  /trademarkserif def\n"
01468     "16#F6DC  /onefitted def\n"
01469     "16#F6DD  /rupiah def\n"
01470     "16#F6DE  /threequartersemdash def\n"
01471     "16#F6DF  /centinferior def\n"
01472     "16#F6E0  /centsuperior def\n"
01473     "16#F6E1  /commainferior def\n"
01474     "16#F6E2  /commasuperior def\n"
01475     "16#F6E3  /dollarinferior def\n"
01476     "16#F6E4  /dollarsuperior def\n"
01477     "16#F6E5  /hypheninferior def\n"
01478     "16#F6E6  /hyphensuperior def\n"
01479     "16#F6E7  /periodinferior def\n"
01480     "16#F6E8  /periodsuperior def\n"
01481     "16#F6E9  /asuperior def\n"
01482     "16#F6EA  /bsuperior def\n"
01483     "16#F6EB  /dsuperior def\n"
01484     "16#F6EC  /esuperior def\n"
01485     "16#F6ED  /isuperior def\n"
01486     "16#F6EE  /lsuperior def\n"
01487     "16#F6EF  /msuperior def\n"
01488     "16#F6F0  /osuperior def\n"
01489     "16#F6F1  /rsuperior def\n"
01490     "16#F6F2  /ssuperior def\n"
01491     "16#F6F3  /tsuperior def\n"
01492     "16#F6F4  /Brevesmall def\n"
01493     "16#F6F5  /Caronsmall def\n"
01494     "16#F6F6  /Circumflexsmall def\n"
01495     "16#F6F7  /Dotaccentsmall def\n"
01496     "16#F6F8  /Hungarumlautsmall def\n"
01497     "16#F6F9  /Lslashsmall def\n"
01498     "16#F6FA  /OEsmall def\n"
01499     "16#F6FB  /Ogoneksmall def\n"
01500     "16#F6FC  /Ringsmall def\n"
01501     "16#F6FD  /Scaronsmall def\n"
01502     "16#F6FE  /Tildesmall def\n"
01503     "16#F6FF  /Zcaronsmall def\n"
01504     "16#F721  /exclamsmall def\n"
01505     "16#F724  /dollaroldstyle def\n"
01506     "16#F726  /ampersandsmall def\n"
01507     "16#F730  /zerooldstyle def\n"
01508     "16#F731  /oneoldstyle def\n"
01509     "16#F732  /twooldstyle def\n"
01510     "16#F733  /threeoldstyle def\n"
01511     "16#F734  /fouroldstyle def\n"
01512     "16#F735  /fiveoldstyle def\n"
01513     "16#F736  /sixoldstyle def\n"
01514     "16#F737  /sevenoldstyle def\n"
01515     "16#F738  /eightoldstyle def\n"
01516     "16#F739  /nineoldstyle def\n"
01517     "16#F73F  /questionsmall def\n"
01518     "16#F760  /Gravesmall def\n"
01519     "16#F761  /Asmall def\n"
01520     "16#F762  /Bsmall def\n"
01521     "16#F763  /Csmall def\n"
01522     "16#F764  /Dsmall def\n"
01523     "16#F765  /Esmall def\n"
01524     "16#F766  /Fsmall def\n"
01525     "16#F767  /Gsmall def\n"
01526     "16#F768  /Hsmall def\n"
01527     "16#F769  /Ismall def\n"
01528     "16#F76A  /Jsmall def\n"
01529     "16#F76B  /Ksmall def\n"
01530     "16#F76C  /Lsmall def\n"
01531     "16#F76D  /Msmall def\n"
01532     "16#F76E  /Nsmall def\n"
01533     "16#F76F  /Osmall def\n"
01534     "16#F770  /Psmall def\n"
01535     "16#F771  /Qsmall def\n"
01536     "16#F772  /Rsmall def\n"
01537     "16#F773  /Ssmall def\n"
01538     "16#F774  /Tsmall def\n"
01539     "16#F775  /Usmall def\n"
01540     "16#F776  /Vsmall def\n"
01541     "16#F777  /Wsmall def\n"
01542     "16#F778  /Xsmall def\n"
01543     "16#F779  /Ysmall def\n"
01544     "16#F77A  /Zsmall def\n"
01545     "16#F7A1  /exclamdownsmall def\n"
01546     "16#F7A2  /centoldstyle def\n"
01547     "16#F7A8  /Dieresissmall def\n"
01548     "16#F7AF  /Macronsmall def\n"
01549     "16#F7B4  /Acutesmall def\n"
01550     "16#F7B8  /Cedillasmall def\n"
01551     "16#F7BF  /questiondownsmall def\n"
01552     "16#F7E0  /Agravesmall def\n"
01553     "16#F7E1  /Aacutesmall def\n"
01554     "16#F7E2  /Acircumflexsmall def\n"
01555     "16#F7E3  /Atildesmall def\n"
01556     "16#F7E4  /Adieresissmall def\n"
01557     "16#F7E5  /Aringsmall def\n"
01558     "16#F7E6  /AEsmall def\n"
01559     "16#F7E7  /Ccedillasmall def\n"
01560     "16#F7E8  /Egravesmall def\n"
01561     "16#F7E9  /Eacutesmall def\n"
01562     "16#F7EA  /Ecircumflexsmall def\n"
01563     "16#F7EB  /Edieresissmall def\n"
01564     "16#F7EC  /Igravesmall def\n"
01565     "16#F7ED  /Iacutesmall def\n"
01566     "16#F7EE  /Icircumflexsmall def\n"
01567     "16#F7EF  /Idieresissmall def\n"
01568     "16#F7F0  /Ethsmall def\n"
01569     "16#F7F1  /Ntildesmall def\n"
01570     "16#F7F2  /Ogravesmall def\n"
01571     "16#F7F3  /Oacutesmall def\n"
01572     "16#F7F4  /Ocircumflexsmall def\n"
01573     "16#F7F5  /Otildesmall def\n"
01574     "16#F7F6  /Odieresissmall def\n"
01575     "16#F7F8  /Oslashsmall def\n"
01576     "16#F7F9  /Ugravesmall def\n"
01577     "16#F7FA  /Uacutesmall def\n"
01578     "16#F7FB  /Ucircumflexsmall def\n"
01579     "16#F7FC  /Udieresissmall def\n"
01580     "16#F7FD  /Yacutesmall def\n"
01581     "16#F7FE  /Thornsmall def\n"
01582     "16#F7FF  /Ydieresissmall def\n"
01583     "16#F8E5  /radicalex def\n"
01584     "16#F8E6  /arrowvertex def\n"
01585     "16#F8E7  /arrowhorizex def\n"
01586     "16#F8E8  /registersans def\n"
01587     "16#F8E9  /copyrightsans def\n"
01588     "16#F8EA  /trademarksans def\n"
01589     "16#F8EB  /parenlefttp def\n"
01590     "16#F8EC  /parenleftex def\n"
01591     "16#F8ED  /parenleftbt def\n"
01592     "16#F8EE  /bracketlefttp def\n"
01593     "16#F8EF  /bracketleftex def\n"
01594     "16#F8F0  /bracketleftbt def\n"
01595     "16#F8F1  /bracelefttp def\n"
01596     "16#F8F2  /braceleftmid def\n"
01597     "16#F8F3  /braceleftbt def\n"
01598     "16#F8F4  /braceex def\n"
01599     "16#F8F5  /integralex def\n"
01600     "16#F8F6  /parenrighttp def\n"
01601     "16#F8F7  /parenrightex def\n"
01602     "16#F8F8  /parenrightbt def\n"
01603     "16#F8F9  /bracketrighttp def\n"
01604     "16#F8FA  /bracketrightex def\n"
01605     "16#F8FB  /bracketrightbt def\n"
01606     "16#F8FC  /bracerighttp def\n"
01607     "16#F8FD  /bracerightmid def\n"
01608     "16#F8FE  /bracerightbt def\n"
01609     "16#FB00  /ff def\n"
01610     "16#FB01  /fi def\n"
01611     "16#FB02  /fl def\n"
01612     "16#FB03  /ffi def\n"
01613     "16#FB04  /ffl def\n"
01614     "16#FB1F  /afii57705 def\n"
01615     "16#FB2A  /afii57694 def\n"
01616     "16#FB2B  /afii57695 def\n"
01617     "16#FB35  /afii57723 def\n"
01618     "16#FB4B  /afii57700 def\n"
01619     "end\n"
01620     "def\n"
01621     );
01622 
01623   fprintf(f, "%s",
01624     "10 dict dup begin\n"
01625     "  /FontType 3 def\n"
01626     "  /FontMatrix [.001 0 0 .001 0 0 ] def\n"
01627     "  /FontBBox [0 0 100 100] def\n"
01628     "  /Encoding 256 array def\n"
01629     "  0 1 255 {Encoding exch /.notdef put} for\n"
01630     "  Encoding 97 /openbox put\n"
01631     "  /CharProcs 2 dict def\n"
01632     "  CharProcs begin\n"
01633     "    /.notdef { } def\n"
01634     "    /openbox\n"
01635     "      { newpath\n"
01636     "          90 30 moveto  90 670 lineto\n"
01637     "          730 670 lineto  730 30 lineto\n"
01638     "        closepath\n"
01639     "        60 setlinewidth\n"
01640     "        stroke } def\n"
01641     "  end\n"
01642     "  /BuildChar\n"
01643     "    { 1000 0 0\n"
01644     "  0 750 750\n"
01645     "        setcachedevice\n"
01646     "  exch begin\n"
01647     "        Encoding exch get\n"
01648     "        CharProcs exch get\n"
01649     "  end\n"
01650     "  exec\n"
01651     "    } def\n"
01652     "end\n"
01653     "/NoglyphFont exch definefont pop\n"
01654     "\n"
01655 
01656     "/mbshow {                       % num\n"
01657     "    8 array                     % num array\n"
01658     "    -1                          % num array counter\n"
01659     "    {\n"
01660     "        dup 7 ge { exit } if\n"
01661     "        1 add                   % num array counter\n"
01662     "        2 index 16#100 mod      % num array counter mod\n"
01663     "        3 copy put pop          % num array counter\n"
01664     "        2 index 16#100 idiv     % num array counter num\n"
01665     "        dup 0 le\n"
01666     "        {\n"
01667     "            pop exit\n"
01668     "        } if\n"
01669     "        4 -1 roll pop\n"
01670     "        3 1 roll\n"
01671     "    } loop                      % num array counter\n"
01672     "    3 -1 roll pop               % array counter\n"
01673     "    dup 1 add string            % array counter string\n"
01674     "    0 1 3 index\n"
01675     "    {                           % array counter string index\n"
01676     "        2 index 1 index sub     % array counter string index sid\n"
01677     "        4 index 3 2 roll get    % array counter string sid byte\n"
01678     "        2 index 3 1 roll put    % array counter string\n"
01679     "    } for\n"
01680     "    show pop pop\n"
01681     "} def\n"
01682     );
01683 
01684   fprintf(f, "%s",
01685     "/draw_undefined_char\n"
01686     "{\n"
01687     "  csize /NoglyphFont Msf (a) show\n"
01688     "} bind def\n"
01689     "\n"
01690     "/real_unicodeshow\n"
01691     "{\n"
01692     "  /ccode exch def\n"
01693     "  /Unicodedict where {\n"
01694     "    pop\n"
01695     "    Unicodedict ccode known {\n"
01696     "      /cwidth {currentfont /ScaleMatrix get 0 get} def \n"
01697     "      /cheight cwidth def \n"
01698     "      gsave\n"
01699     "      currentpoint translate\n"
01700     "      cwidth 1056 div cheight 1056 div scale\n"
01701     "      2 -2 translate\n"
01702     "      ccode Unicodedict exch get\n"
01703     "      cvx exec\n"
01704     "      grestore\n"
01705     "      currentpoint exch cwidth add exch moveto\n"
01706     "      true\n"
01707     "    } {\n"
01708     "      false\n"
01709     "    } ifelse\n"
01710     "  } {\n"
01711     "    false\n"
01712     "  } ifelse\n"
01713     "} bind def\n"
01714     "\n"
01715     "/real_unicodeshow_native\n"
01716     "{\n"
01717     "  /ccode exch def\n"
01718     "  /NativeFont where {\n"
01719     "    pop\n"
01720     "    NativeFont findfont /FontName get /Courier eq {\n"
01721     "      false\n"
01722     "    } {\n"
01723     "      csize NativeFont Msf\n"
01724     "      /Unicode2NativeDict where {\n"
01725     "        pop\n"
01726     "        Unicode2NativeDict ccode known {\n"
01727     "          Unicode2NativeDict ccode get show\n"
01728     "          true\n"
01729     "        } {\n"
01730     "          false\n"
01731     "        } ifelse\n"
01732     "      } {\n"
01733     "    false\n"
01734     "      } ifelse\n"
01735     "    } ifelse\n"
01736     "  } {\n"
01737     "    false\n"
01738     "  } ifelse\n"
01739     "} bind def\n"
01740     "\n"
01741     "/real_glyph_unicodeshow\n"
01742     "{\n"
01743     "  /ccode exch def\n"
01744     "      /UniDict where {\n"
01745     "        pop\n"
01746     "        UniDict ccode known {\n"
01747     "          UniDict ccode get glyphshow\n"
01748     "          true\n"
01749     "        } {\n"
01750     "          false\n"
01751     "        } ifelse\n"
01752     "      } {\n"
01753     "    false\n"
01754     "      } ifelse\n"
01755     "} bind def\n"
01756     "/real_unicodeshow_cid\n"
01757     "{\n"
01758     "  /ccode exch def\n"
01759     "  /UCS2Font where {\n"
01760     "    pop\n"
01761     "    UCS2Font findfont /FontName get /Courier eq {\n"
01762     "      false\n"
01763     "    } {\n"
01764     "      csize UCS2Font Msf\n"
01765     "      ccode mbshow\n"
01766     "      true\n"
01767     "    } ifelse\n"
01768     "  } {\n"
01769     "    false\n"
01770     "  } ifelse\n"
01771     "} bind def\n"
01772     "\n"
01773     "/unicodeshow \n"
01774     "{\n"
01775     "  /cfont currentfont def\n"
01776     "  /str exch def\n"
01777     "  /i 0 def\n"
01778     "  str length /ls exch def\n"
01779     "  {\n"
01780     "    i 1 add ls ge {exit} if\n"
01781     "    str i get /c1 exch def\n"
01782     "    str i 1 add get /c2 exch def\n"
01783     "    /c c2 256 mul c1 add def\n"
01784     "    c2 1 ge \n"
01785     "    {\n"
01786     "      c unicodeshow1\n"
01787     "      {\n"
01788     "        % do nothing\n"
01789     "      } {\n"
01790     "        c real_unicodeshow_cid       % try CID \n"
01791     "        {\n"
01792     "          % do nothing\n"
01793     "        } {\n"
01794     "          c unicodeshow2\n"
01795     "          {\n"
01796     "            % do nothing\n"
01797     "          } {\n"
01798     "            draw_undefined_char\n"
01799     "          } ifelse\n"
01800     "        } ifelse\n"
01801     "      } ifelse\n"
01802     "    } {\n"
01803     "      % ascii\n"
01804     "      cfont setfont\n"
01805     "      str i 1 getinterval show\n"
01806     "    } ifelse\n"
01807     "    /i i 2 add def\n"
01808     "  } loop\n"
01809     "}  bind def\n"
01810     "\n"
01811 
01812     "/u2nadd {Unicode2NativeDict 3 1 roll put} bind def\n"
01813     "\n"
01814 
01815     "/Unicode2NativeDictdef 0 dict def\n"
01816     "/default_ls {\n"
01817     "  /Unicode2NativeDict Unicode2NativeDictdef def\n"
01818     "  /UCS2Font   /Courier def\n"
01819     "  /NativeFont /Courier def\n"
01820     "  /unicodeshow1 { real_glyph_unicodeshow } bind def\n"
01821     "  /unicodeshow2 { real_unicodeshow_native } bind def\n"
01822     "} bind def\n"
01823     );
01824 
01825   // setup prolog for each langgroup
01826   initlanggroup(f);
01827 
01828   fprintf(f, "%%%%EndProlog\n");
01829 }
01830 
01837 nsresult
01838 nsPostScriptObj::write_script(FILE *aDestHandle)
01839 {
01840   NS_PRECONDITION(aDestHandle, "Handle must not be NULL");
01841   char buf[BUFSIZ];
01842   size_t readAmt;
01843 
01844   rewind(mScriptFP);
01845   while ((readAmt = fread(buf, 1, sizeof buf, mScriptFP))) {
01846     size_t writeAmt = fwrite(buf, 1, readAmt, aDestHandle);
01847     if (readAmt != writeAmt)
01848       break;
01849   }
01850   return ferror(mScriptFP) || ferror(aDestHandle) ?
01851     NS_ERROR_GFX_PRINTER_FILE_IO_ERROR : NS_OK;
01852 }
01853 
01854 
01859 void 
01860 nsPostScriptObj::begin_page()
01861 {
01862   fprintf(mScriptFP, "%%%%Page: %d %d\n", mPageNumber, mPageNumber);
01863   fprintf(mScriptFP, "%%%%BeginPageSetup\n");
01864   if(mPrintSetup->num_copies > 1) {
01865     fprintf(mScriptFP, 
01866       "/setpagedevice where\n"
01867       "{ pop 1 dict dup /NumCopies %d put setpagedevice }\n"
01868       "{ userdict /#copies %d put } ifelse\n",
01869       mPrintSetup->num_copies, mPrintSetup->num_copies);
01870   }
01871   fprintf(mScriptFP,"/pagelevel save def\n");
01872   // Rescale the coordinate system from points to twips.
01873   scale(1.0 / TWIPS_PER_POINT_FLOAT, 1.0 / TWIPS_PER_POINT_FLOAT);
01874   // Rotate and shift the coordinate system for landscape
01875   if (mPrintContext->prSetup->landscape){
01876     fprintf(mScriptFP, "90 rotate 0 -%d translate\n",
01877        mPrintContext->prSetup->height);
01878   }
01879 
01880   // Try to turn on automatic stroke adjust
01881   fputs("true Msetstrokeadjust\n", mScriptFP);
01882   fprintf(mScriptFP, "%%%%EndPageSetup\n");
01883 
01884   // need to reset all U2Ntable
01885   gLangGroups->Enumerate(ResetU2Ntable, nsnull);
01886 }
01887 
01892 void 
01893 nsPostScriptObj::end_page()
01894 {
01895   fputs("pagelevel restore showpage\n", mScriptFP);
01896   mPageNumber++;
01897 }
01898 
01903 nsresult 
01904 nsPostScriptObj::end_document()
01905 {
01906   PR_LOG(nsPostScriptObjLM, PR_LOG_DEBUG, ("nsPostScriptObj::end_document()\n"));
01907   NS_PRECONDITION(mScriptFP, "No script file handle");
01908 
01909   // Finish up the document.
01910   fprintf(mScriptFP, "%%%%Trailer\n");
01911   fprintf(mScriptFP, "%%%%EOF\n");
01912 
01913   PR_LOG(nsPostScriptObjLM, PR_LOG_DEBUG, ("postscript generation completed.\n"));
01914   
01915   return ferror(mScriptFP) ?  NS_ERROR_GFX_PRINTER_FILE_IO_ERROR : NS_OK;
01916 }
01917 
01922 void 
01923 nsPostScriptObj::show(const char* txt, int len, const char *align)
01924 {
01925   fputc('(', mScriptFP);
01926 
01927   while (len-- > 0) {
01928     switch (*txt) {
01929            case '(':
01930            case ')':
01931            case '\\':
01932              fputc('\\', mScriptFP);
01933              // Fall through
01934            default:
01935              fputc(*txt, mScriptFP);     
01936              break;
01937          }
01938          txt++;
01939   }
01940   fprintf(mScriptFP, ") %sshow\n", align);
01941 }
01942 
01947 void 
01948 nsPostScriptObj::preshow(const PRUnichar* txt, int len)
01949 {
01950   unsigned char highbyte;
01951   PRUnichar uch;
01952 
01953   char outbuffer[6];
01954   PRUnichar inbuffer[2];
01955   nsresult res = NS_OK;
01956 
01957   if (gEncoder && gU2Ntable) {
01958     while (len-- > 0) {
01959       uch = *txt;
01960       highbyte = (uch >> 8 ) & 0xff;
01961       if (highbyte > 0) {
01962        inbuffer[0] = uch;
01963        inbuffer[1] = 0;
01964 
01965        PRInt32 *ncode = nsnull;
01966        nsStringKey key(inbuffer, 1);
01967 
01968        ncode = (PRInt32 *) gU2Ntable->Get(&key);
01969 
01970        if (ncode && *ncode) {
01971        } else {
01972          PRInt32 insize, outsize;
01973          outsize = 6;
01974          insize = 1;
01975           // example, 13327 (USC2 0x340f) -> 14913679 (gb18030 0xe3908f)
01976          res = gEncoder->Convert(inbuffer, &insize, outbuffer, &outsize);
01977          if (NS_SUCCEEDED(res) && outsize > 1) {
01978             int i;
01979             PRInt32 code = 0;
01980             for(i=1;i<=outsize;i++) {
01981               code += (outbuffer[i - 1] & 0xff) << (8 * (outsize - i));
01982             }
01983             if (code) {
01984              ncode = new PRInt32;
01985              *ncode = code;
01986              gU2Ntable->Put(&key, ncode);
01987              fprintf(mScriptFP, "%d <%x> u2nadd\n", uch, code);
01988             }
01989          }
01990        }
01991       }
01992       txt++;
01993     }
01994   }
01995 }
01996 
02001 void 
02002 nsPostScriptObj::show(const PRUnichar* txt, int len,
02003                       const char *align, int aType)
02004 {
02005   unsigned char highbyte, lowbyte;
02006   PRUnichar uch;
02007  
02008   if (aType == 1) {
02009     int i;
02010     fputc('<', mScriptFP);
02011     for (i=0; i < len; i++) {
02012       if (i == 0)
02013         fprintf(mScriptFP, "%04x", txt[i]);
02014       else
02015         fprintf(mScriptFP, " %04x", txt[i]);
02016     }
02017     fputs("> show\n", mScriptFP);
02018     return;
02019   }
02020  
02021   fputc('(', mScriptFP);
02022 
02023   while (len-- > 0) {
02024     switch (*txt) {
02025         case 0x0028:     // '('
02026             fputs("\\050\\000", mScriptFP);
02027                   break;
02028         case 0x0029:     // ')' 
02029             fputs("\\051\\000", mScriptFP);
02030                   break;
02031         case 0x005c:     // '\\'
02032             fputs("\\134\\000", mScriptFP);
02033                   break;
02034            default:
02035           uch = *txt;
02036           highbyte = (uch >> 8 ) & 0xff;
02037           lowbyte = ( uch & 0xff );
02038 
02039           // we output all unicode chars in the 2x3 digits oct format for easier post-processing
02040           // Our 'show' command will always treat the second 3 digit oct as high 8-bits of unicode, independent of Endians
02041           if ( lowbyte < 8 )
02042            fprintf(mScriptFP, "\\00%o", lowbyte  & 0xff);
02043           else if ( lowbyte < 64  && lowbyte >= 8)
02044            fprintf(mScriptFP, "\\0%o", lowbyte & 0xff);
02045           else
02046            fprintf(mScriptFP, "\\%o", lowbyte & 0xff);      
02047 
02048           if ( highbyte < 8  )
02049            fprintf(mScriptFP, "\\00%o", highbyte & 0xff);
02050           else if ( highbyte < 64  && highbyte >= 8)
02051             fprintf(mScriptFP, "\\0%o", highbyte & 0xff);
02052           else
02053            fprintf(mScriptFP, "\\%o", highbyte & 0xff);      
02054          
02055          break;
02056          }
02057          txt++;
02058   }
02059   fprintf(mScriptFP, ") %sunicodeshow\n", align);
02060 }
02061 
02062 #if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
02063 void 
02064 nsPostScriptObj::show(const PRUnichar* aTxt, int aLen,
02065                       const nsAFlatString& aCharList, PRUint16 aSubFontIdx)
02066 {
02067   int i;
02068   fputc('<', mScriptFP);
02069 
02070   const PRUint16 subFontSize = nsPSFontGenerator::kSubFontSize;
02071 
02072   // the character repertoire of a subfont (255 characters max)
02073   const nsAString& repertoire = 
02074         Substring(aCharList, aSubFontIdx * subFontSize,
02075                   PR_MIN(subFontSize, 
02076                   aCharList.Length() - aSubFontIdx * subFontSize));
02077 
02078   for (i = 0; i < aLen; i++) {
02079     // XXX This is a little inefficient, but printing is not perf. critical. 
02080     NS_ASSERTION(repertoire.FindChar(aTxt[i]) != kNotFound,
02081         "character is not covered by this subfont");
02082       
02083     // Type 1 encoding vector has 256 slots, but the 0-th slot is 
02084     // reserved for /.notdef so that we use the 1st through 255th slots
02085     // for actual characters (hence '+ 1')
02086     fprintf(mScriptFP, "%02x", repertoire.FindChar(aTxt[i]) + 1); 
02087   }
02088   fputs("> show\n", mScriptFP);
02089 }
02090 #endif
02091 
02096 void 
02097 nsPostScriptObj::moveto(nscoord x, nscoord y)
02098 {
02099   fprintf(mScriptFP, "%d %d moveto\n", x, y);
02100 }
02101 
02106 void 
02107 nsPostScriptObj::lineto(nscoord aX, nscoord aY)
02108 {
02109   fprintf(mScriptFP, "%d %d lineto\n", aX, aY);
02110 }
02111 
02119 void 
02120 nsPostScriptObj::arc(nscoord aWidth, nscoord aHeight,
02121   float aStartAngle,float aEndAngle)
02122 {
02123   // Arc definition
02124   fprintf(mScriptFP,
02125       "%s %s matrix currentmatrix currentpoint translate\n"
02126       " 3 1 roll scale newpath 0 0 1 %s %s arc setmatrix\n",
02127       fpCString(aWidth * 0.5).get(), fpCString(aHeight * 0.5).get(),
02128       fpCString(aStartAngle).get(), fpCString(aEndAngle).get());
02129 }
02130 
02135 void 
02136 nsPostScriptObj::box(nscoord aX, nscoord aY, nscoord aW, nscoord aH)
02137 {
02138   fprintf(mScriptFP, "%d %d %d %d Mrect ", aX, aY, aW, aH);
02139 }
02140 
02145 void 
02146 nsPostScriptObj::box_subtract(nscoord aX, nscoord aY, nscoord aW, nscoord aH)
02147 {
02148   fprintf(mScriptFP,
02149     "%d %d moveto 0 %d rlineto %d 0 rlineto 0 %d rlineto closepath ",
02150     aX, aY, aH, aW, -aH);
02151 }
02152 
02157 void 
02158 nsPostScriptObj::clip()
02159 {
02160   fputs(" clip\n", mScriptFP);
02161 }
02162 
02167 void 
02168 nsPostScriptObj::eoclip()
02169 {
02170   fputs(" eoclip\n", mScriptFP);
02171 }
02172 
02177 void 
02178 nsPostScriptObj::clippath()
02179 {
02180   fputs(" clippath\n", mScriptFP);
02181 }
02182 
02187 void 
02188 nsPostScriptObj::newpath()
02189 {
02190   fputs(" newpath\n", mScriptFP);
02191 }
02192 
02197 void 
02198 nsPostScriptObj::closepath()
02199 {
02200   fputs(" closepath\n", mScriptFP);
02201 }
02202 
02207 void 
02208 nsPostScriptObj::initclip()
02209 {
02210   fputs(" initclip\n", mScriptFP);
02211 }
02212 
02217 void 
02218 nsPostScriptObj::line(nscoord aX1, nscoord aY1,
02219   nscoord aX2, nscoord aY2, nscoord aThick)
02220 {
02221   fprintf(mScriptFP, "gsave %d setlinewidth\n ", aThick);
02222   fprintf(mScriptFP, " %d %d moveto %d %d lineto\n", aX1, aY1, aX2, aY2);
02223   stroke();
02224   fprintf(mScriptFP, "grestore\n");
02225 }
02226 
02231 void
02232 nsPostScriptObj::stroke()
02233 {
02234   fputs(" stroke\n", mScriptFP);
02235 }
02236 
02241 void
02242 nsPostScriptObj::fill()
02243 {
02244   fputs(" fill\n", mScriptFP);
02245 }
02246 
02251 void
02252 nsPostScriptObj::graphics_save()
02253 {
02254   fputs(" gsave\n", mScriptFP);
02255 }
02256 
02261 void
02262 nsPostScriptObj::graphics_restore()
02263 {
02264   fputs(" grestore\n", mScriptFP);
02265 }
02266 
02267 
02273 void
02274 nsPostScriptObj::scale(float aX, float aY)
02275 {
02276   fprintf(mScriptFP, "%s %s scale\n",
02277       fpCString(aX).get(), fpCString(aY).get());
02278 }
02279 
02284 void 
02285 nsPostScriptObj::translate(nscoord x, nscoord y)
02286 {
02287     fprintf(mScriptFP, "%d %d translate\n", x, y);
02288 }
02289 
02290 
02321 void
02322 nsPostScriptObj::draw_image(nsIImage *anImage,
02323     const nsRect& sRect, const nsRect& iRect, const nsRect& dRect)
02324 {
02325   // If a final image dimension is 0 pixels, just return (see bug 191684)
02326   if ((0 == dRect.width) || (0 == dRect.height)) {
02327     return;
02328   }
02329 
02330   anImage->LockImagePixels(PR_FALSE);
02331   PRUint8 *theBits = anImage->GetBits();
02332 
02333   anImage->LockImagePixels(PR_TRUE);
02334   PRUint8 *theAlphaBits = anImage->GetAlphaBits();
02335   PRUint8 alphaDepth = anImage->GetAlphaDepth();
02336 
02337   // Image data is unavailable, or it has no height or width.
02338   // There's nothing to print, so just return.
02339   if (!theBits || (0 == iRect.width) || (0 == iRect.height)) {
02340     anImage->UnlockImagePixels(PR_FALSE);
02341     return;
02342   }
02343 
02344   // Save the current graphic state and define a PS variable that
02345   // can hold one line of pixel data.
02346   fprintf(mScriptFP, "gsave\n/rowdata %d string def\n",
02347      mPrintSetup->color ? iRect.width * 3 : iRect.width);
02348  
02349   // Translate the coordinate origin to the corner of the rectangle where
02350   // the image should appear, set up a clipping region, and scale the
02351   // coordinate system to the image's final size.
02352   translate(dRect.x, dRect.y);
02353   box(0, 0, dRect.width, dRect.height);
02354   clip();
02355   fprintf(mScriptFP, "%d %d scale\n", dRect.width, dRect.height);
02356 
02357   // Describe how the pixel data is to be interpreted: pixels per row,
02358   // rows, and bits per pixel (per component in color).
02359   fprintf(mScriptFP, "%d %d 8 ", iRect.width, iRect.height);
02360 
02361   // Output the transformation matrix for the image. This is a bit tricky
02362   // to understand. PS image-drawing operations involve two transformation
02363   // matrices: (1) A Transformation matrix associated with the image
02364   // describes how to map the pixel data (width x height) onto a unit square,
02365   // and (2) the document's TM maps the unit square to the desired size and
02366   // position. The image TM is technically an inverse TM, i.e. it describes
02367   // how to map the unit square onto the pixel array.
02368   //
02369   // sRect and dRect define the same rectangle, only in different coordinate
02370   // systems. Following the translate & scale operations above, the origin
02371   // is at [sRect.x, sRect.y]. The "real" origin of image space is thus at
02372   // [-sRect.x, -sRect.y] and the pixel data should start at
02373   // [-sRect.x + iRect.x, -sRect.y + iRect.y]. These are negated because the
02374   // TM is supposed to be an inverse TM.
02375   nscoord tmTX = sRect.x - iRect.x;
02376   nscoord tmTY = sRect.y - iRect.y;
02377 
02378   // In document space, the target rectangle is [dRect.width,
02379   // dRect.height]; in image space it's [sRect.width, sRect.height]. So
02380   // the proper scale factor is [1/sRect.width, 1/sRect.height], but
02381   // again, the output should be an inverse TM so these are inverted.
02382   nscoord tmSX = sRect.width;
02383   nscoord tmSY = sRect.height;
02384 
02385   // If the image is being stretched and clipped, it's possible that only
02386   // a fraction of a pixel is supposed to be visible, resulting in a 
02387   // dimension of zero after rounding. 0 isn't a valid scaling factor.
02388   // But something should appear on the page, unlike the case where dRect
02389   // or iRect is zero-sized, so force the dimension to 1. See bug 236801.
02390   if (0 == tmSX)
02391     tmSX = 1;
02392   if (0 == tmSY)
02393     tmSY = 1;
02394 
02395   // If the image data is in the wrong order, invert the TM, causing
02396   // the image to be drawn inverted.
02397   if (!anImage->GetIsRowOrderTopToBottom()) {
02398     tmTY += tmSY;
02399     tmSY = -tmSY;
02400   }
02401   fprintf(mScriptFP, "[ %d 0 0 %d %d %d ]\n", tmSX, tmSY, tmTX, tmTY);
02402 
02403   // Output the data-reading procedure and the appropriate image command.
02404   fputs(" { currentfile rowdata readhexstring pop }", mScriptFP);
02405   if (mPrintSetup->color)
02406     fputs(" false 3 colorimage\n", mScriptFP);
02407   else
02408     fputs(" image\n", mScriptFP);
02409 
02410   // Output the image data. The entire image is written, even
02411   // if it's partially clipped in the document.
02412   int outputCount = 0;
02413   PRInt32 bytesPerRow = anImage->GetLineStride();
02414   PRInt32 bytesPerAlphaRow = anImage->GetAlphaLineStride();
02415 
02416   for (nscoord y = 0; y < iRect.height; y++) {
02417     // calculate the starting point for this row of pixels
02418     PRUint8 *row = theBits                // Pixel buffer start
02419       + y * bytesPerRow;                  // Rows already output
02420     PRUint8 *alphaRow = theAlphaBits + y * bytesPerAlphaRow;
02421 
02422     for (nscoord x = 0; x < iRect.width; x++) {
02423       PRUint8 *pixel = row + (x * 3);
02424       PRUint8 alpha = 255;
02425       // we don't need to worry about 1-bit alpha because
02426       // nsImageGTK::LockImagePixels whitens the transparent portions
02427       if (alphaDepth == 8)
02428         alpha = alphaRow[x];
02429       PRUint8 p[3];
02430 
02431       if (alpha == 0) {
02432         p[0] = p[1] = p[2] = 0xff;
02433       } else if (alpha == 255) {
02434         p[0] = pixel[0];
02435         p[1] = pixel[1];
02436         p[2] = pixel[2];
02437       } else {
02438         MOZ_BLEND(p[0], 255, pixel[0], alpha);
02439         MOZ_BLEND(p[1], 255, pixel[1], alpha);
02440         MOZ_BLEND(p[2], 255, pixel[2], alpha);
02441       }
02442 
02443       if (mPrintSetup->color)
02444         outputCount += fprintf(mScriptFP, "%02x%02x%02x", p[0], p[1], p[2]);
02445       else
02446         outputCount +=
02447           fprintf(mScriptFP, "%02x", NS_RGB_TO_GRAY(p[0], p[1], p[2]));
02448       if (outputCount >= 72) {
02449         fputc('\n', mScriptFP);
02450         outputCount = 0;
02451       }
02452     }
02453   }
02454   anImage->UnlockImagePixels(PR_FALSE);
02455 
02456   // Free the PS data buffer and restore the previous graphics state.
02457   fputs("\n/undef where { pop /rowdata where { /rowdata undef } if } if\n", mScriptFP);
02458   fputs("grestore\n", mScriptFP);
02459 }
02460 
02461 
02466 void
02467 nsPostScriptObj::setcolor(nscolor aColor)
02468 {
02469 float greyBrightness;
02470 
02471   /* For greyscale postscript, find the average brightness of red, green, and
02472    * blue.  Using this average value as the brightness for red, green, and
02473    * blue is a simple way to make the postscript greyscale instead of color.
02474    */
02475 
02476   if(mPrintSetup->color == PR_FALSE ) {
02477     greyBrightness=NS_PS_GRAY(NS_RGB_TO_GRAY(NS_GET_R(aColor),
02478                                              NS_GET_G(aColor),
02479                                              NS_GET_B(aColor)));
02480     fprintf(mScriptFP, "%s setgray\n", fpCString(greyBrightness).get());
02481   } else {
02482     fprintf(mScriptFP, "%s %s %s setrgbcolor\n",
02483       fpCString(NS_PS_RED(aColor)).get(),
02484       fpCString(NS_PS_GREEN(aColor)).get(),
02485       fpCString(NS_PS_BLUE(aColor)).get());
02486   }
02487 
02488 }
02489 
02490 
02491 void nsPostScriptObj::setfont(const nsCString& aFontName, PRUint32 aHeight,
02492                               PRInt32 aSubFont)
02493 {
02494   fprintf(mScriptFP, "%d /%s.Set%d Msf\n", aHeight, aFontName.get(),
02495           aSubFont);
02496 }
02497 
02502 void 
02503 nsPostScriptObj::setscriptfont(PRInt16 aFontIndex,const nsString &aFamily,nscoord aHeight, PRUint8 aStyle, 
02504                                                                               PRUint8 aVariant, PRUint16 aWeight, PRUint8 decorations)
02505 {
02506 int postscriptFont = 0;
02507 
02508   fprintf(mScriptFP, "%d", aHeight);
02509  
02510   if( aFontIndex >= 0) {
02511     postscriptFont = aFontIndex;
02512   } else {
02513   
02514 
02515   //#ifdef NOTNOW
02516   //XXX:PS Add bold, italic and other settings here
02517        switch(aStyle){
02518          case NS_FONT_STYLE_NORMAL :
02519                 if (NS_IS_BOLD(aWeight)) {
02520                   postscriptFont = 1;   // TIMES NORMAL BOLD
02521       }else{
02522         postscriptFont = 0; // Times ROMAN Normal
02523                 }
02524          break;
02525 
02526          case NS_FONT_STYLE_ITALIC:
02527                 if (NS_IS_BOLD(aWeight)) {                
02528                   postscriptFont = 2; // TIMES BOLD ITALIC
02529       }else{                  
02530                   postscriptFont = 3; // TIMES ITALIC
02531                 }
02532          break;
02533 
02534          case NS_FONT_STYLE_OBLIQUE:
02535                 if (NS_IS_BOLD(aWeight)) {       
02536         postscriptFont = 6;   // HELVETICA OBLIQUE
02537       }else{  
02538         postscriptFont = 7;   // HELVETICA OBLIQUE
02539                 }
02540            break;
02541        }
02542     //#endif
02543    }
02544    fprintf(mScriptFP, " f%d\n", postscriptFont);
02545 
02546 
02547 #if 0
02548      // The style of font (normal, italic, oblique)
02549   PRUint8 style;
02550 
02551   // The variant of the font (normal, small-caps)
02552   PRUint8 variant;
02553 
02554   // The weight of the font (0-999)
02555   PRUint16 weight;
02556 
02557   // The decorations on the font (underline, overline,
02558   // line-through). The decorations can be binary or'd together.
02559   PRUint8 decorations;
02560 
02561   // The size of the font, in nscoord units
02562   nscoord size; 
02563 #endif
02564 
02565 }
02566 
02571 void 
02572 nsPostScriptObj::comment(const char *aTheComment)
02573 {
02574   fprintf(mScriptFP, "%%%s\n", aTheComment);
02575 }
02576 
02581 void
02582 nsPostScriptObj::setlanggroup(nsIAtom * aLangGroup)
02583 {
02584   gEncoder = nsnull;
02585   gU2Ntable = nsnull;
02586 
02587   if (aLangGroup == nsnull) {
02588     fputs("default_ls\n", mScriptFP);
02589     return;
02590   }
02591   nsAutoString langstr;
02592   aLangGroup->ToString(langstr);
02593 
02594   /* already exist */
02595   nsStringKey key(langstr);
02596   PS_LangGroupInfo *linfo = (PS_LangGroupInfo *) gLangGroups->Get(&key);
02597 
02598   if (linfo) {
02599     nsCAutoString str; str.AssignWithConversion(langstr);
02600     fprintf(mScriptFP, "%s_ls\n", str.get());
02601     gEncoder = linfo->mEncoder;
02602     gU2Ntable = linfo->mU2Ntable;
02603     return;
02604   } else {
02605     fputs("default_ls\n", mScriptFP);
02606   }
02607 }
02608 
02609 PRBool
02610 nsPostScriptObj::GetUnixPrinterSetting(const nsCAutoString& aKey, char** aVal)
02611 {
02612 
02613   if (!mPrinterProps) {
02614     return nsnull;
02615   }
02616 
02617   nsAutoString oValue;
02618   nsresult res = mPrinterProps->GetStringProperty(aKey, oValue);
02619   if (NS_FAILED(res)) {
02620     return PR_FALSE;
02621   }
02622   *aVal = ToNewCString(oValue);
02623   return PR_TRUE;
02624 }
02625 
02626 
02627 typedef struct _unixPrinterFallbacks_t {
02628     const char *key;
02629     const char *val;
02630 } unixPrinterFallbacks_t;
02631 
02632 static const unixPrinterFallbacks_t unixPrinterFallbacks[] = {
02633   {"print.postscript.nativefont.ja", "Ryumin-Light-EUC-H"},
02634   {"print.postscript.nativecode.ja", "euc-jp"},
02635   {nsnull, nsnull}
02636 };
02637 
02638 PRBool
02639 GetUnixPrinterFallbackSetting(const nsCAutoString& aKey, char** aVal)
02640 {
02641   const unixPrinterFallbacks_t *p;
02642   const char* key = aKey.get();
02643   for (p=unixPrinterFallbacks; p->key; p++) {
02644     if (strcmp(key, p->key) == 0) {
02645       *aVal = nsCRT::strdup(p->val);
02646       return PR_TRUE;
02647     }
02648   }
02649   return PR_FALSE;
02650 }
02651 
02652 
02653 const char* kNativeFontPrefix  = "print.postscript.nativefont.";
02654 const char* kUnicodeFontPrefix = "print.postscript.unicodefont.";
02655 
02656 struct PrefEnumClosure {
02657   FILE *handle;                    // Output file handle
02658   nsPostScriptObj *psObj;   // Renderer
02659 };
02660 
02661 /* make <langgroup>_ls define for each LangGroup here */
02662 static void PrefEnumCallback(const char *aName, void *aClosure)
02663 {
02664   nsPostScriptObj *psObj = ((PrefEnumClosure *)aClosure)->psObj;
02665   FILE *f = ((PrefEnumClosure *)aClosure)->handle;
02666   nsAutoString lang; lang.AssignWithConversion(aName);
02667 
02668 
02669   if (strstr(aName, kNativeFontPrefix)) {
02670     NS_ASSERTION(strlen(kNativeFontPrefix) == 28, "Wrong hard-coded size.");
02671     lang.Cut(0, 28);
02672   } else if (strstr(aName, kUnicodeFontPrefix)) {
02673     NS_ASSERTION(strlen(kNativeFontPrefix) == 29, "Wrong hard-coded size.");
02674     lang.Cut(0, 29);
02675   }
02676   nsStringKey key(lang);
02677 
02678   PS_LangGroupInfo *linfo = (PS_LangGroupInfo *) gLangGroups->Get(&key);
02679 
02680   if (linfo) {
02681     /* already exist */
02682     return;
02683   }
02684 
02685   /* define new language group */
02686   nsXPIDLCString psnativefont;
02687   nsXPIDLCString psnativecode;
02688   nsXPIDLCString psunicodefont;
02689   int psfontorder = 0;
02690   PRBool use_prefsfile = PR_FALSE;
02691   PRBool use_vendorfile = PR_FALSE;
02692 
02693   //
02694   // Try to get the info from the user's prefs file
02695   //
02696   nsCAutoString namepsnativefont(kNativeFontPrefix);
02697   namepsnativefont.AppendWithConversion(lang);
02698   gPrefs->CopyCharPref(namepsnativefont.get(), getter_Copies(psnativefont));
02699 
02700   nsCAutoString namepsnativecode("print.postscript.nativecode.");
02701   namepsnativecode.AppendWithConversion(lang);
02702   gPrefs->CopyCharPref(namepsnativecode.get(), getter_Copies(psnativecode));
02703   if (((psnativefont)&&(*psnativefont)) && ((psnativecode)&&(*psnativecode))) {
02704     use_prefsfile = PR_TRUE;
02705   } else {
02706     psnativefont.Adopt(0);
02707     psnativecode.Adopt(0);
02708   }
02709 
02710   //
02711   // if not found look for info from the printer vendor
02712   //
02713   if (use_prefsfile != PR_TRUE) {
02714     psObj->GetUnixPrinterSetting(namepsnativefont, getter_Copies(psnativefont));
02715     psObj->GetUnixPrinterSetting(namepsnativecode, getter_Copies(psnativecode));
02716     if ((psnativefont) && (psnativecode)) {
02717       use_vendorfile = PR_TRUE;
02718     } else {
02719       psnativefont.Adopt(0);
02720       psnativecode.Adopt(0);
02721     }
02722   }
02723   if (!use_prefsfile && !use_vendorfile) {
02724     GetUnixPrinterFallbackSetting(namepsnativefont, getter_Copies(psnativefont));
02725     GetUnixPrinterFallbackSetting(namepsnativecode, getter_Copies(psnativecode));
02726   }
02727 
02728   /* psnativefont and psnativecode both should be set */
02729   if (!psnativefont || !psnativecode) {
02730     psnativefont.Adopt(0);
02731     psnativecode.Adopt(0);
02732   } else {
02733     nsCAutoString namepsfontorder("print.postscript.fontorder.");
02734     namepsfontorder.AppendWithConversion(lang);
02735     if (use_prefsfile) {
02736       gPrefs->GetIntPref(namepsfontorder.get(), &psfontorder);
02737     }
02738     else if (use_vendorfile) {
02739       nsXPIDLCString psfontorder_str;
02740       psObj->GetUnixPrinterSetting(namepsfontorder, getter_Copies(psfontorder_str));
02741       if (psfontorder_str) {
02742         psfontorder = atoi(psfontorder_str);
02743       }
02744     }
02745   }
02746 
02747   /* check UCS fonts */
02748   nsCAutoString namepsunicodefont(kUnicodeFontPrefix);
02749   namepsunicodefont.AppendWithConversion(lang);
02750   if (use_prefsfile) {
02751     gPrefs->CopyCharPref(namepsunicodefont.get(), getter_Copies(psunicodefont));
02752   } else if (use_vendorfile) {
02753     psObj->GetUnixPrinterSetting(namepsunicodefont, getter_Copies(psunicodefont));
02754   }
02755 
02756   nsresult res = NS_OK;
02757 
02758   if (psnativefont || psunicodefont) {
02759     linfo = new PS_LangGroupInfo;
02760     linfo->mEncoder = nsnull;
02761     linfo->mU2Ntable = nsnull;
02762 
02763     if (psnativecode) {
02764       nsAutoString str;
02765       nsCOMPtr<nsICharsetConverterManager> ccMain =
02766         do_GetService(kCharsetConverterManagerCID, &res);
02767       
02768       if (NS_SUCCEEDED(res)) {
02769         res = ccMain->GetUnicodeEncoder(psnativecode.get(), &linfo->mEncoder);
02770       }
02771     }
02772 
02773     gLangGroups->Put(&key, (void *) linfo);
02774 
02775     nsCAutoString langstrC; langstrC.AssignWithConversion(lang);
02776     if (psnativefont && linfo->mEncoder) {
02777       fprintf(f, "/Unicode2NativeDict%s 0 dict def\n", langstrC.get());
02778     }
02779 
02780     fprintf(f, "/%s_ls {\n", langstrC.get());
02781     fprintf(f, "  /NativeFont /%s def\n",
02782       (psnativefont && linfo->mEncoder) ? psnativefont.get() : "Courier");
02783     fprintf(f, "  /UCS2Font /%s def\n",
02784                 psunicodefont ? psunicodefont.get() : "Courier");
02785     if (psnativefont && linfo->mEncoder) {
02786       fprintf(f, "  /Unicode2NativeDict Unicode2NativeDict%s def\n",
02787                   langstrC.get());
02788     }
02789 
02790     if (psfontorder) {
02791       fprintf(f, "  /unicodeshow1 { real_unicodeshow_native } bind def\n");
02792       fprintf(f, "  /unicodeshow2 { real_unicodeshow } bind def\n");
02793     } else {
02794       fprintf(f, "  /unicodeshow1 { real_unicodeshow } bind def\n");
02795       fprintf(f, "  /unicodeshow2 { real_unicodeshow_native } bind def\n");
02796     }
02797 
02798     fprintf(f, "} bind def\n");
02799 
02800     if (linfo->mEncoder) {
02801       linfo->mEncoder->SetOutputErrorBehavior(
02802                   linfo->mEncoder->kOnError_Replace, nsnull, '?');
02803       linfo->mU2Ntable = new nsHashtable();
02804     }
02805   }
02806 }
02807 
02812 void
02813 nsPostScriptObj::initlanggroup(FILE *aHandle)
02814 {
02815   PrefEnumClosure closure;
02816   closure.handle = aHandle;
02817   closure.psObj = this;
02818 
02819   /* check langgroup of preference */
02820   gPrefs->EnumerateChildren(kNativeFontPrefix,
02821       PrefEnumCallback, (void *) &closure);
02822 
02823   gPrefs->EnumerateChildren(kUnicodeFontPrefix,
02824       PrefEnumCallback, (void *) &closure);
02825 }
02826 
02827 
02833 nsresult
02834 nsPostScriptObj::render_eps(const nsRect& aRect, nsEPSObjectPS &anEPS)
02835 {
02836   FILE     *bfile = mScriptFP;
02837   nsresult  rv;
02838 
02839   NS_PRECONDITION(nsnull != bfile, "No document body file handle");
02840 
02841   /* Set up EPSF state. See Adobe spec #5002 section 3.2 */
02842   fputs(
02843     "/b4_Inc_state save def\n"
02844     "/dict_count countdictstack def\n"
02845     "/op_count count 1 sub def\n"
02846     "userdict begin\n"
02847     "/showpage { } def\n"
02848     "0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin\n"
02849     "10 setmiterlimit [ ] 0 setdash newpath\n"
02850     "/languagelevel where\n"
02851     "{pop languagelevel\n"
02852     "  1 ne\n"
02853     "  {false setstrokeadjust false setoverprint\n"
02854     "  } if\n"
02855     "} if\n",
02856     bfile);
02857 
02858   /* Set up a clipping region around the EPS rectangle */
02859   box(aRect.x, aRect.y, aRect.width, aRect.height);
02860   clip();
02861 
02862   /* translate to the lower left corner of the rectangle */
02863   translate(aRect.x, aRect.y + aRect.height);
02864 
02865   /* Rescale */
02866   scale(
02867     aRect.width / (anEPS.GetBoundingBoxURX() - anEPS.GetBoundingBoxLLX()),
02868     -(aRect.height / (anEPS.GetBoundingBoxURY() - anEPS.GetBoundingBoxLLY()))
02869   );
02870 
02871   /* Translate to the EPSF origin. Can't use translate() here because
02872   * it takes integers.
02873   */
02874   fprintf(bfile, "%s %s translate\n",
02875     fpCString(-anEPS.GetBoundingBoxLLX()).get(),
02876     fpCString(-anEPS.GetBoundingBoxLLY()).get()
02877   );
02878 
02879   /* embeding EPS file content */
02880   comment("%BeginDocument: Mozilla-Internal");
02881   rv = anEPS.WriteTo(bfile);
02882   comment("%EndDocument");
02883 
02884   /* Restore previous state */
02885   fputs(
02886     "count op_count sub { pop } repeat\n"
02887     "countdictstack dict_count sub { end } repeat\n"
02888     "b4_Inc_state restore\n",
02889     bfile);
02890 
02891   return rv;
02892 }