summaryrefslogtreecommitdiff
path: root/Xprint/ps
diff options
context:
space:
mode:
Diffstat (limited to 'Xprint/ps')
-rw-r--r--Xprint/ps/Ps.h95
-rw-r--r--Xprint/ps/PsArea.c138
-rw-r--r--Xprint/ps/PsAttVal.c99
-rw-r--r--Xprint/ps/PsAttr.c2
-rw-r--r--Xprint/ps/PsCache.c194
-rw-r--r--Xprint/ps/PsColor.c5
-rw-r--r--Xprint/ps/PsFonts.c698
-rw-r--r--Xprint/ps/PsGC.c32
-rw-r--r--Xprint/ps/PsInit.c90
-rw-r--r--Xprint/ps/PsLine.c1
-rw-r--r--Xprint/ps/PsMisc.c1
-rw-r--r--Xprint/ps/PsPixel.c1
-rw-r--r--Xprint/ps/PsPixmap.c14
-rw-r--r--Xprint/ps/PsPolygon.c4
-rw-r--r--Xprint/ps/PsPrint.c43
-rw-r--r--Xprint/ps/PsText.c334
-rw-r--r--Xprint/ps/PsWindow.c16
-rw-r--r--Xprint/ps/psout.c399
-rw-r--r--Xprint/ps/psout.h95
-rw-r--r--Xprint/ps/ttf2pt1wrap.c10
20 files changed, 1732 insertions, 539 deletions
diff --git a/Xprint/ps/Ps.h b/Xprint/ps/Ps.h
index d33f301fa..6bde70f47 100644
--- a/Xprint/ps/Ps.h
+++ b/Xprint/ps/Ps.h
@@ -7,6 +7,7 @@ Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
+documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
@@ -73,7 +74,6 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/Ps.h,v 1.13 2001/12/21 21:02:05 dawes Exp $ */
#ifndef _PS_H_
#define _PS_H_
@@ -113,6 +113,7 @@ typedef char *XPointer;
#include <X11/Xresource.h>
#include "attributes.h"
+
/*
* Public index variables from PsInit.c
*/
@@ -245,10 +246,66 @@ typedef DisplayListRec *DisplayListPtr;
typedef struct
{
XrmDatabase resDB;
- ColormapPtr CMap;
Bool (*DestroyWindow)(WindowPtr);
} PsScreenPrivRec, *PsScreenPrivPtr;
+typedef struct PsFontTypeInfoRec PsFontTypeInfoRec;
+
+/* Structure to hold information about one font on disk
+ * Notes:
+ * - multiple XLFD names can refer to the same |PsFontTypeInfoRec| (if
+ * they all use the same font on the disk)
+ * - the FreeType font download code uses multiple |PsFontTypeInfoRec|
+ * records for one font on disk if they differ in the encoding being
+ * used (this is an exception from the
+ * 'one-|PsFontTypeInfoRec|-per-font-on-disk'-design; maybe it it is better
+ * to rework that in a later step and add a new per-encoding structure).
+ */
+struct PsFontTypeInfoRec
+{
+ PsFontTypeInfoRec *next; /* Next record in list... */
+ char *adobe_ps_name; /* PostScript font name (from the
+ * "_ADOBE_POSTSCRIPT_FONTNAME" atom) */
+ char *download_ps_name; /* PostScript font name used for font download */
+ char *filename; /* File name of font */
+#ifdef XP_USE_FREETYPE
+ char *ft_download_encoding; /* encoding used for download */
+ PsFTDownloadFontType ft_download_font_type; /* PS font type used for download (e.g. Type1/Type3/CID/etc.) */
+#endif /* XP_USE_FREETYPE */
+ int is_iso_encoding; /* Is this font encoded in ISO Latin 1 ? */
+ int font_type; /* See PSFTI_FONT_TYPE_* below... */
+ Bool downloadableFont; /* Font can be downloaded */
+ Bool alreadyDownloaded[256]; /* Font has been downloaded (for 256 8bit "sub"-font) */
+};
+
+#define PSFTI_FONT_TYPE_OTHER (0)
+#define PSFTI_FONT_TYPE_PMF (1)
+#define PSFTI_FONT_TYPE_PS_TYPE1_PFA (2)
+#define PSFTI_FONT_TYPE_PS_TYPE1_PFB (3)
+#define PSFTI_FONT_TYPE_TRUETYPE (4)
+/* PSFTI_FONT_TYPE_FREETYPE is means the font is handled by the freetype engine */
+#define PSFTI_FONT_TYPE_FREETYPE (5)
+
+typedef struct PsFontInfoRec PsFontInfoRec;
+
+/* Structure which represents our context info for a single XLFD font
+ * Note that multiple |PsFontInfoRec| records can share the same
+ * |PsFontTypeInfoRec| record - the |PsFontInfoRec| records represent
+ * different appearances of the same font on disk(=|PsFontTypeInfoRec|)).
+ */
+struct PsFontInfoRec
+{
+ PsFontInfoRec *next; /* Next record in list... */
+ /* |font| and |font_fontPrivate| are used by |PsFindFontInfoRec()| to
+ * identify a font */
+ FontPtr font; /* The font this record is for */
+ pointer font_fontPrivate;
+ PsFontTypeInfoRec *ftir; /* Record about the font file on disk */
+ const char *dfl_name; /* XLFD for this font */
+ int size; /* Font size. Use |mtx| if |size==0| */
+ float mtx[4]; /* Transformation matrix (see |size|) */
+};
+
typedef struct
{
char *jobFileName;
@@ -259,6 +316,8 @@ typedef struct
ClientPtr getDocClient;
int getDocBufSize;
PsOutPtr pPsOut;
+ PsFontTypeInfoRec *fontTypeInfoRecords;
+ PsFontInfoRec *fontInfoRecords;
} PsContextPrivRec, *PsContextPrivPtr;
typedef struct
@@ -291,6 +350,7 @@ typedef struct
extern Bool InitializePsDriver(int ndx, ScreenPtr pScreen, int argc,
char **argv);
+static Bool PsDestroyContext(XpContextPtr pCon);
extern XpContextPtr PsGetContextFromWindow(WindowPtr win);
/*
@@ -314,6 +374,10 @@ extern int PsGetDocumentData(XpContextPtr pCon, ClientPtr client,
*/
extern Bool PsCreateGC(GCPtr pGC);
+static int PsGetDrawablePrivateStuff(DrawablePtr pDrawable, GC *gc,
+ unsigned long *valid, PsOutPtr *psOut,
+ ColormapPtr *cMap);
+extern PsContextPrivPtr PsGetPsContextPriv( DrawablePtr pDrawable );
extern int PsUpdateDrawableGC(GCPtr pGC, DrawablePtr pDrawable,
PsOutPtr *psOut, ColormapPtr *cMap);
extern void PsValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable);
@@ -366,9 +430,8 @@ extern void PsPutScaledImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
extern void PsPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
int x, int y, int w, int h, int leftPad, int format,
char *pImage);
-extern void PsPutImageMask(DrawablePtr pDrawable, GCPtr pGC, int depth,
- int x, int y, int w, int h, int leftPad, int format,
- char *pImage);
+extern void PsPutImageMask(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
+ int w, int h, int leftPad, int format, char *pImage);
extern RegionPtr PsCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
int srcx, int srcy, int width, int height,
int dstx, int dsty);
@@ -456,7 +519,19 @@ extern Bool PsUnrealizeFont(ScreenPtr pscr, FontPtr pFont);
extern char *PsGetFontName(FontPtr pFont);
extern int PsGetFontSize(FontPtr pFont, float *mtx);
extern char *PsGetPSFontName(FontPtr pFont);
+extern char *PsGetPSFaceOrFontName(FontPtr pFont);
extern int PsIsISOLatin1Encoding(FontPtr pFont);
+extern char *PsGetEncodingName(FontPtr pFont);
+extern PsFontInfoRec *PsGetFontInfoRec(DrawablePtr pDrawable, FontPtr pFont);
+extern void PsFreeFontInfoRecords(PsContextPrivPtr priv);
+extern PsFTDownloadFontType PsGetFTDownloadFontType(void);
+
+/*
+ * Functions in PsFTFonts.c
+ */
+
+extern char *PsGetFTFontFileName(FontPtr pFont);
+extern Bool PsIsFreeTypeFont(FontPtr pFont);
/*
* Functions in PsAttr.c
@@ -503,14 +578,4 @@ extern PsElmPtr PsCreateFillElementList(PixmapPtr pix, int *nElms);
extern PsElmPtr PsCloneFillElementList(int nElms, PsElmPtr elms);
extern void PsDestroyFillElementList(int nElms, PsElmPtr elms);
-/*
- * Functions in PsCache.c
- */
-
-#ifdef BM_CACHE
-extern int PsBmIsImageCached(int gWidth, int gHeight, char *pBuffer);
-extern int PsBmPutImageInCache(int gWidth, int gHeight, char *pBuffer);
-extern void PsBmClearImageCache(void);
-#endif
-
#endif /* _PS_H_ */
diff --git a/Xprint/ps/PsArea.c b/Xprint/ps/PsArea.c
index eed650ada..134686a87 100644
--- a/Xprint/ps/PsArea.c
+++ b/Xprint/ps/PsArea.c
@@ -228,7 +228,7 @@ error:
return;
}
-static void
+void
PsPutScaledImageIM(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
int w, int h, int leftPad, int format, int imageRes, char *pImage)
{
@@ -269,9 +269,9 @@ PsPutScaledImageIM(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
ColormapPtr cMap;
int pageRes, sw, sh;
#ifdef BM_CACHE
- long cache_id = 0;
+ long cache_id = 0;
#endif
-
+
if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return;
if (!imageRes) {
sw = w;
@@ -296,100 +296,100 @@ PsPutScaledImageIM(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
PsOut_BeginImageCache(psOut, cache_id);
#endif
- if( depth==24 )
- {
- PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3);
- if( format==XYPixmap )
+ if( depth==24 )
{
- int rowsiz = PixmapBytePad(w, depth);
- char *planes[3];
- planes[0] = pImage;
- planes[1] = &pImage[rowsiz*h];
- planes[2] = &pImage[rowsiz*h*2];
- for( r=0 ; r<h ; r++ )
+ PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3);
+ if( format==XYPixmap )
{
- char *pt[3];
- for( i=0 ; i<3 ; i++ ) pt[i] = &planes[i][rowsiz*r];
- for( c=0 ; c<w ; c++ )
+ int rowsiz = PixmapBytePad(w, depth);
+ char *planes[3];
+ planes[0] = pImage;
+ planes[1] = &pImage[rowsiz*h];
+ planes[2] = &pImage[rowsiz*h*2];
+ for( r=0 ; r<h ; r++ )
{
- for( i=0 ; i<3 ; i++ )
- { PsOut_OutImageBytes(psOut, 1, &pt[i][c]); pt[i]++; }
+ char *pt[3];
+ for( i=0 ; i<3 ; i++ ) pt[i] = &planes[i][rowsiz*r];
+ for( c=0 ; c<w ; c++ )
+ {
+ for( i=0 ; i<3 ; i++ )
+ { PsOut_OutImageBytes(psOut, 1, &pt[i][c]); pt[i]++; }
+ }
+ }
+ }
+ else if( format==ZPixmap )
+ {
+ int rowsiz = PixmapBytePad(w, depth);
+ for( r=0 ; r<h ; r++ )
+ {
+ char *pt = &pImage[rowsiz*r];
+ for( c=0 ; c<w ; c++,pt+=4 )
+ {
+ if( swap )
+ {
+ char tmp[4];
+ tmp[0] = pt[3]; tmp[1] = pt[2]; tmp[2] = pt[1]; tmp[3] = pt[0];
+ PsOut_OutImageBytes(psOut, 3, &tmp[1]);
+ }
+ else
+ PsOut_OutImageBytes(psOut, 3, &pt[1]);
+ }
}
}
+ else goto error;
+ PsOut_EndImage(psOut);
}
- else if( format==ZPixmap )
+ else if( depth==8 )
{
int rowsiz = PixmapBytePad(w, depth);
+ PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3);
for( r=0 ; r<h ; r++ )
{
char *pt = &pImage[rowsiz*r];
- for( c=0 ; c<w ; c++,pt+=4 )
+ for( c=0 ; c<w ; c++,pt++ )
{
+ int val = PsGetPixelColor(cMap, (int)(*pt)&0xFF);
+ char *ipt = (char *)&val;
if( swap )
{
char tmp[4];
- tmp[0] = pt[3]; tmp[1] = pt[2]; tmp[2] = pt[1]; tmp[3] = pt[0];
+ tmp[0] = ipt[3]; tmp[1] = ipt[2]; tmp[2] = ipt[1]; tmp[3] = ipt[0];
PsOut_OutImageBytes(psOut, 3, &tmp[1]);
}
else
- PsOut_OutImageBytes(psOut, 3, &pt[1]);
+ PsOut_OutImageBytes(psOut, 3, &ipt[1]);
}
}
+ PsOut_EndImage(psOut);
}
- else goto error;
- PsOut_EndImage(psOut);
- }
- else if( depth==8 )
- {
- int rowsiz = PixmapBytePad(w, depth);
- PsOut_BeginImageIM(psOut, 0, 0, x, y, w, h, sw, sh, 3);
- for( r=0 ; r<h ; r++ )
- {
- char *pt = &pImage[rowsiz*r];
- for( c=0 ; c<w ; c++,pt++ )
- {
- int val = PsGetPixelColor(cMap, (int)(*pt)&0xFF);
- char *ipt = (char *)&val;
- if( swap )
- {
- char tmp[4];
- tmp[0] = ipt[3]; tmp[1] = ipt[2]; tmp[2] = ipt[1]; tmp[3] = ipt[0];
- PsOut_OutImageBytes(psOut, 3, &tmp[1]);
- }
- else
- PsOut_OutImageBytes(psOut, 3, &ipt[1]);
- }
- }
- PsOut_EndImage(psOut);
- }
- else if( depth==1 )
- {
+ else if( depth==1 )
{
- int rowsiz = BitmapBytePad(w);
- int psrsiz = (w+7)/8;
- PsOut_BeginImageIM(psOut, PsGetPixelColor(cMap, pGC->bgPixel),
- PsGetPixelColor(cMap, pGC->fgPixel),
- x, y, w, h, sw, sh, 1);
- for( r=0 ; r<h ; r++ )
{
- char *pt = &pImage[rowsiz*r];
- for( i=0 ; i<psrsiz ; i++ )
+ int rowsiz = BitmapBytePad(w);
+ int psrsiz = (w+7)/8;
+ PsOut_BeginImageIM(psOut, PsGetPixelColor(cMap, pGC->bgPixel),
+ PsGetPixelColor(cMap, pGC->fgPixel),
+ x, y, w, h, sw, sh, 1);
+ for( r=0 ; r<h ; r++ )
{
- int iv_, iv = (int)pt[i]&0xFF;
- char c;
- if( swap )
- { for( j=0,iv_=0 ; j<8 ; j++ ) iv_ |= (((iv>>j)&1)<<(7-j)); }
- else
- iv_ = iv;
- c = iv_;
- PsOut_OutImageBytes(psOut, 1, &c);
+ char *pt = &pImage[rowsiz*r];
+ for( i=0 ; i<psrsiz ; i++ )
+ {
+ int iv_, iv = (int)pt[i]&0xFF;
+ char c;
+ if( swap )
+ { for( j=0,iv_=0 ; j<8 ; j++ ) iv_ |= (((iv>>j)&1)<<(7-j)); }
+ else
+ iv_ = iv;
+ c = iv_;
+ PsOut_OutImageBytes(psOut, 1, &c);
+ }
}
+ PsOut_EndImage(psOut);
}
- PsOut_EndImage(psOut);
}
- }
#ifdef BM_CACHE
- PsOut_EndImageCache(psOut);
+ PsOut_EndImageCache(psOut);
}
PsOut_ImageCache(psOut, x, y, cache_id, PsGetPixelColor(cMap, pGC->bgPixel),
PsGetPixelColor(cMap, pGC->fgPixel));
diff --git a/Xprint/ps/PsAttVal.c b/Xprint/ps/PsAttVal.c
index 4a7865af6..5ebd0d3b9 100644
--- a/Xprint/ps/PsAttVal.c
+++ b/Xprint/ps/PsAttVal.c
@@ -32,7 +32,6 @@ not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from said
copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsAttVal.c,v 1.4 2001/01/17 22:36:31 dawes Exp $ */
#include "Ps.h"
#include "AttrValid.h"
@@ -73,7 +72,16 @@ static XpOidList DefaultPlexes = {
};
static unsigned long ValidPrinterResolutionsCards[] = {
+ 75,
+ 100,
+ 120,
+ 150,
+ 180,
+ 200,
+ 240,
300,
+ 360,
+ 400,
600,
720,
940,
@@ -86,7 +94,20 @@ static XpOidCardList ValidPrinterResolutions = {
};
static unsigned long DefaultPrinterResolutionsCards[] = {
- 300
+ 75,
+ 100,
+ 120,
+ 150,
+ 180,
+ 200,
+ 240,
+ 300,
+ 360,
+ 400,
+ 600,
+ 720,
+ 940,
+ 1200
};
static XpOidCardList DefaultPrinterResolutions = {
DefaultPrinterResolutionsCards, XpNumber(DefaultPrinterResolutionsCards)
@@ -143,13 +164,6 @@ static XpOidDocFmtList DefaultEmbeddedFormatsSupported = {
DefaultEmbeddedFormatsSupportedFmts, XpNumber(DefaultEmbeddedFormatsSupportedFmts)
};
-/*
-** So filtered printers that accept other raw formats can be
-** used with this driver.
-**
-** Noah Roberts (jik-)
-*/
-#if 0
static XpOidDocFmt ValidRawFormatsSupportedFmts[] = {
{ "Postscript", "2", NULL }
@@ -157,7 +171,6 @@ static XpOidDocFmt ValidRawFormatsSupportedFmts[] = {
static XpOidDocFmtList ValidRawFormatsSupported = {
ValidRawFormatsSupportedFmts, XpNumber(ValidRawFormatsSupportedFmts)
};
-#endif
static XpOidDocFmt DefaultRawFormatsSupportedFmts[] = {
{ "Postscript", "2", NULL }
@@ -178,12 +191,74 @@ static XpOidList ValidInputTrays = {
};
static XpOid ValidMediumSizesOids[] = {
+ xpoid_val_medium_size_iso_a0,
+ xpoid_val_medium_size_iso_a1,
+ xpoid_val_medium_size_iso_a2,
+ xpoid_val_medium_size_iso_a3,
xpoid_val_medium_size_iso_a4,
+ xpoid_val_medium_size_iso_a5,
+ xpoid_val_medium_size_iso_a6,
+ xpoid_val_medium_size_iso_a7,
+ xpoid_val_medium_size_iso_a8,
+ xpoid_val_medium_size_iso_a9,
+ xpoid_val_medium_size_iso_a10,
+ xpoid_val_medium_size_iso_b0,
+ xpoid_val_medium_size_iso_b1,
+ xpoid_val_medium_size_iso_b2,
+ xpoid_val_medium_size_iso_b3,
+ xpoid_val_medium_size_iso_b4,
+ xpoid_val_medium_size_iso_b5,
+ xpoid_val_medium_size_iso_b6,
+ xpoid_val_medium_size_iso_b7,
+ xpoid_val_medium_size_iso_b8,
+ xpoid_val_medium_size_iso_b9,
+ xpoid_val_medium_size_iso_b10,
xpoid_val_medium_size_na_letter,
xpoid_val_medium_size_na_legal,
xpoid_val_medium_size_executive,
+ xpoid_val_medium_size_folio,
+ xpoid_val_medium_size_invoice,
+ xpoid_val_medium_size_ledger,
+ xpoid_val_medium_size_quarto,
+ xpoid_val_medium_size_iso_c3,
+ xpoid_val_medium_size_iso_c4,
+ xpoid_val_medium_size_iso_c5,
+ xpoid_val_medium_size_iso_c6,
xpoid_val_medium_size_iso_designated_long,
- xpoid_val_medium_size_na_number_10_envelope
+ xpoid_val_medium_size_na_10x13_envelope,
+ xpoid_val_medium_size_na_9x12_envelope,
+ xpoid_val_medium_size_na_number_10_envelope,
+ xpoid_val_medium_size_na_7x9_envelope,
+ xpoid_val_medium_size_na_9x11_envelope,
+ xpoid_val_medium_size_na_10x14_envelope,
+ xpoid_val_medium_size_na_number_9_envelope,
+ xpoid_val_medium_size_na_6x9_envelope,
+ xpoid_val_medium_size_na_10x15_envelope,
+ xpoid_val_medium_size_monarch_envelope,
+ xpoid_val_medium_size_a,
+ xpoid_val_medium_size_b,
+ xpoid_val_medium_size_c,
+ xpoid_val_medium_size_d,
+ xpoid_val_medium_size_e,
+ xpoid_val_medium_size_jis_b0,
+ xpoid_val_medium_size_jis_b1,
+ xpoid_val_medium_size_jis_b2,
+ xpoid_val_medium_size_jis_b3,
+ xpoid_val_medium_size_jis_b4,
+ xpoid_val_medium_size_jis_b5,
+ xpoid_val_medium_size_jis_b6,
+ xpoid_val_medium_size_jis_b7,
+ xpoid_val_medium_size_jis_b8,
+ xpoid_val_medium_size_jis_b9,
+ xpoid_val_medium_size_jis_b10,
+ xpoid_val_medium_size_hp_2x_postcard,
+ xpoid_val_medium_size_hp_european_edp,
+ xpoid_val_medium_size_hp_mini,
+ xpoid_val_medium_size_hp_postcard,
+ xpoid_val_medium_size_hp_tabloid,
+ xpoid_val_medium_size_hp_us_edp,
+ xpoid_val_medium_size_hp_us_government_legal,
+ xpoid_val_medium_size_hp_us_government_letter,
};
static XpOidList ValidMediumSizes = {
ValidMediumSizesOids, XpNumber(ValidMediumSizesOids)
@@ -205,7 +280,7 @@ XpValidatePoolsRec PsValidatePoolsRec = {
&ValidPrinterResolutions, &DefaultPrinterResolutions,
&ValidEmbeddedFormatsSupported, &DefaultEmbeddedFormatsSupported,
&ValidListfontsModes, &DefaultListfontsModes,
- NULL /* Any raw format specified (NR)*/, &DefaultRawFormatsSupported,
+ &ValidRawFormatsSupported, &DefaultRawFormatsSupported,
&ValidSetupProviso,
&DefaultDocumentFormat
};
diff --git a/Xprint/ps/PsAttr.c b/Xprint/ps/PsAttr.c
index f276c180f..8a5bee9e3 100644
--- a/Xprint/ps/PsAttr.c
+++ b/Xprint/ps/PsAttr.c
@@ -57,7 +57,6 @@ in this Software without prior written authorization from The Open Group.
* or other dealings in this Software without prior written authorization
* from said copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsAttr.c,v 1.4 2001/01/17 22:36:32 dawes Exp $ */
/*******************************************************************
**
@@ -76,6 +75,7 @@ in this Software without prior written authorization from The Open Group.
********************************************************************/
#include "Ps.h"
+#include "attributes.h"
char *
PsGetAttributes(
diff --git a/Xprint/ps/PsCache.c b/Xprint/ps/PsCache.c
index b688fbba1..8c9f4a926 100644
--- a/Xprint/ps/PsCache.c
+++ b/Xprint/ps/PsCache.c
@@ -79,21 +79,21 @@ in this Software without prior written authorization from The Open Group.
#include "fntfil.h"
#include "fntfilst.h"
-#define GET 0
-#define RESET 1
+#define GET 0
+#define RESET 1
struct bm_cache_list {
- struct bm_cache_list *next;
- struct bm_cache_list *prev;
+ struct bm_cache_list *next;
+ struct bm_cache_list *prev;
int height;
- long id;
+ long id;
char *pBuffer;
};
struct bm_cache_head {
- struct bm_cache_list *head;
- int width;
- struct bm_cache_head *next;
+ struct bm_cache_list *head;
+ int width;
+ struct bm_cache_head *next;
struct bm_cache_head *prev;
};
@@ -106,14 +106,14 @@ PsBmUniqueId(int func)
if(func == RESET)
{
- unique_id = 0;
- return 0;
+ unique_id = 0;
+ return 0;
}
else
- return ++unique_id;
+ return ++unique_id;
}
-int
+int
PsBmIsImageCached(
int gWidth,
int gHeight,
@@ -126,28 +126,28 @@ PsBmIsImageCached(
{
if(pList->width == gWidth)
{
- struct bm_cache_list *pItem = pList->head;
-
- while(pItem != NULL)
- {
- if(pItem->height == gHeight)
- {
- int length = 4*(gWidth/32+(gWidth%32!=0))*gHeight;
-
- if(!memcmp(pItem->pBuffer, pBuffer, sizeof(char)*length))
- {
- return_val = pItem->id;
- break;
- }
- }
- else if(pItem->height > gHeight)
- break;
-
- pItem = pItem->next;
- }
+ struct bm_cache_list *pItem = pList->head;
+
+ while(pItem != NULL)
+ {
+ if(pItem->height == gHeight)
+ {
+ int length = 4*(gWidth/32+(gWidth%32!=0))*gHeight;
+
+ if(!memcmp(pItem->pBuffer, pBuffer, sizeof(char)*length))
+ {
+ return_val = pItem->id;
+ break;
+ }
+ }
+ else if(pItem->height > gHeight)
+ break;
+
+ pItem = pItem->next;
+ }
}
- else if(pList->width > gWidth)
- break;
+ else if(pList->width > gWidth)
+ break;
pList = pList->next;
}
@@ -180,39 +180,39 @@ PsBmPutImageInCache(
while(pList != NULL)
{
if(pList->width == gWidth)
- {
- struct bm_cache_list *pItem = pList->head;
-
- while(pItem != NULL)
- {
- if(pItem->height >= gHeight)
- {
- pNew->next = pItem;
- pNew->prev = pItem->prev;
- if(pItem->prev != NULL)
- pItem->prev->next = pNew;
+ {
+ struct bm_cache_list *pItem = pList->head;
+
+ while(pItem != NULL)
+ {
+ if(pItem->height >= gHeight)
+ {
+ pNew->next = pItem;
+ pNew->prev = pItem->prev;
+ if(pItem->prev != NULL)
+ pItem->prev->next = pNew;
else
- pList->head = pNew;
+ pList->head = pNew;
pItem->prev = pNew;
- return_val = pNew->id;
+ return_val = pNew->id;
- break;
- }
- else if(pItem->next == NULL)
- {
- pNew->prev = pItem;
- pItem->next = pNew;
+ break;
+ }
+ else if(pItem->next == NULL)
+ {
+ pNew->prev = pItem;
+ pItem->next = pNew;
- return_val = pNew->id;
+ return_val = pNew->id;
- break;
- }
+ break;
+ }
- pItem = pItem->next;
- }
+ pItem = pItem->next;
+ }
- break;
+ break;
}
pList = pList->next;
@@ -223,50 +223,50 @@ PsBmPutImageInCache(
struct bm_cache_head *pNewList;
pNewList = (struct bm_cache_head *)malloc(sizeof(struct bm_cache_head));
-
+
pNewList->next = NULL;
pNewList->prev = NULL;
pNewList->width = gWidth;
pNewList->head = pNew;
-
+
if(bm_cache == NULL)
{
- bm_cache = pNewList;
- return_val = pNew->id;
+ bm_cache = pNewList;
+ return_val = pNew->id;
}
else
{
- pList = bm_cache;
+ pList = bm_cache;
- while(pList != NULL)
- {
- if(pList->width > gWidth)
- {
- pNewList->next = pList;
- pNewList->prev = pList->prev;
+ while(pList != NULL)
+ {
+ if(pList->width > gWidth)
+ {
+ pNewList->next = pList;
+ pNewList->prev = pList->prev;
- if(pList->prev != NULL)
- pList->prev->next = pNewList;
+ if(pList->prev != NULL)
+ pList->prev->next = pNewList;
else
- bm_cache = pNewList;
- pList->prev = pNewList;
+ bm_cache = pNewList;
+ pList->prev = pNewList;
- return_val = pNew->id;
+ return_val = pNew->id;
- break;
- }
- else if(pList->next == NULL)
+ break;
+ }
+ else if(pList->next == NULL)
{
- pNewList->prev = pList;
- pList->next = pNewList;
+ pNewList->prev = pList;
+ pList->next = pNewList;
- return_val = pNew->id;
+ return_val = pNew->id;
- break;
- }
+ break;
+ }
- pList = pList->next;
- }
+ pList = pList->next;
+ }
}
}
@@ -280,35 +280,35 @@ PsBmClearImageCacheItem(
{
if(pItem != NULL)
{
- if(pItem->pBuffer != NULL)
- free(pItem->pBuffer);
+ if(pItem->pBuffer != NULL)
+ free(pItem->pBuffer);
pItem->pBuffer = NULL;
- if(pItem->next)
- PsBmClearImageCacheItem(pItem->next);
+ if(pItem->next)
+ PsBmClearImageCacheItem(pItem->next);
pItem->next = NULL;
- free(pItem);
- pItem = NULL;
+ free(pItem);
+ pItem = NULL;
}
}
-static void
+static void
PsBmClearImageCacheList(
struct bm_cache_head *pList)
{
if(pList != NULL)
{
- if(pList->head)
- PsBmClearImageCacheItem(pList->head);
+ if(pList->head)
+ PsBmClearImageCacheItem(pList->head);
pList->head = NULL;
- if(pList->next)
- PsBmClearImageCacheList(pList->next);
+ if(pList->next)
+ PsBmClearImageCacheList(pList->next);
pList->next = NULL;
- free(pList);
- pList = NULL;
+ free(pList);
+ pList = NULL;
}
}
diff --git a/Xprint/ps/PsColor.c b/Xprint/ps/PsColor.c
index 6417410ee..da6c82c1d 100644
--- a/Xprint/ps/PsColor.c
+++ b/Xprint/ps/PsColor.c
@@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsColor.c,v 1.2 2001/10/28 03:32:56 tsi Exp $ */
#include "Ps.h"
#include "gcstruct.h"
@@ -86,6 +85,7 @@ PsCreateColormap(ColormapPtr pColor)
int i;
unsigned short rgb;
VisualPtr pVisual = pColor->pVisual;
+ Pixel pix;
if( pVisual->class==TrueColor )
{
@@ -120,9 +120,6 @@ PsDestroyColormap(ColormapPtr pColor)
void
PsInstallColormap(ColormapPtr pColor)
{
- PsScreenPrivPtr pPriv =
- (PsScreenPrivPtr)pColor->pScreen->devPrivates[PsScreenPrivateIndex].ptr;
- pPriv->CMap = pColor;
}
void
diff --git a/Xprint/ps/PsFonts.c b/Xprint/ps/PsFonts.c
index 1f87f7e76..6d0ba1a61 100644
--- a/Xprint/ps/PsFonts.c
+++ b/Xprint/ps/PsFonts.c
@@ -57,7 +57,6 @@ in this Software without prior written authorization from The Open Group.
* or other dealings in this Software without prior written authorization
* from said copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsFonts.c,v 1.6 2001/12/19 21:55:59 dawes Exp $ */
/*******************************************************************
**
@@ -80,9 +79,15 @@ in this Software without prior written authorization from The Open Group.
#include "dixfontstr.h"
#include "scrnintstr.h"
#include "fontxlfd.h"
+#include "fntfil.h"
+#include "fntfilst.h"
#include "Ps.h"
+#include <ctype.h>
+#include <limits.h>
+#include <sys/stat.h>
+
Bool
PsRealizeFont(
ScreenPtr pscr,
@@ -110,7 +115,7 @@ PsGetFontName(FontPtr pFont)
for( i=0 ; i<nprops ; i++ )
{
- if( (Atom)props[i].name == name )
+ if( (Atom)props[i].name==name )
{ value = props[i].value; break; }
}
if( !value ) return (char *)0;
@@ -145,12 +150,14 @@ PsGetPSFontName(FontPtr pFont)
int i;
int nprops = pFont->info.nprops;
FontPropPtr props = pFont->info.props;
- Atom name = MakeAtom("PRINTER_RESIDENT_FONT", 21, True);
+ /* "_ADOBE_POSTSCRIPT_FONTNAME" maps directly to a PMF OBJ_NAME attribute
+ * name - changing the name will break printer-builtin fonts. */
+ Atom name = MakeAtom("_ADOBE_POSTSCRIPT_FONTNAME", 26, True);
Atom value = (Atom)0;
for( i=0 ; i<nprops ; i++ )
{
- if( (Atom)props[i].name == name )
+ if( (Atom)props[i].name==name )
{ value = props[i].value; break; }
}
if( !value ) return (char *)0;
@@ -171,8 +178,8 @@ PsIsISOLatin1Encoding(FontPtr pFont)
for( i=0 ; i<nprops ; i++ )
{
- if( (Atom)props[i].name == reg ) rv = props[i].value;
- if( (Atom)props[i].name == enc ) ev = props[i].value;
+ if( (Atom)props[i].name==reg ) rv = props[i].value;
+ if( (Atom)props[i].name==enc ) ev = props[i].value;
}
if( rv ) rp = NameForAtom(rv);
if( ev ) ep = NameForAtom(ev);
@@ -184,3 +191,682 @@ PsIsISOLatin1Encoding(FontPtr pFont)
ep[0]!='1' ) return(0);
return(1);
}
+
+/* Return the encoding part of the XLFD (e.g. "*-iso8859-6.8x" etc.)*/
+char *PsGetEncodingName(FontPtr pFont)
+{
+ int i;
+ int nprops = pFont->info.nprops;
+ FontPropPtr props = pFont->info.props;
+ Atom fnt = MakeAtom("FONT", 4, True);
+ Atom reg = MakeAtom("CHARSET_REGISTRY", 16, True);
+ Atom enc = MakeAtom("CHARSET_ENCODING", 16, True);
+ Atom fv = 0, rv = 0, ev = 0;
+ char *fp = 0;
+ char *rp = 0;
+ char *ep = 0;
+ char *encname;
+
+ for( i=0 ; i<nprops ; i++ )
+ {
+ if( props[i].name==fnt ) fv = props[i].value;
+ if( props[i].name==reg ) rv = props[i].value;
+ if( props[i].name==enc ) ev = props[i].value;
+ }
+ if( fv ) fp = NameForAtom(fv);
+ if( rv ) rp = NameForAtom(rv);
+ if( ev ) ep = NameForAtom(ev);
+
+ if( (!rp) || (!ep) || (!fp))
+ return(0);
+
+ encname = fp;
+ encname += strlen(encname) - (strlen(rp) + strlen(ep) + 1);
+
+ return encname;
+}
+
+/* strstr(), case-insensitive */
+static
+char *str_case_str(const char *s, const char *find)
+{
+ size_t len;
+ char c,
+ sc;
+
+ if ((c = tolower(*find++)) != '\0')
+ {
+ len = strlen(find);
+ do
+ {
+ do
+ {
+ if ((sc = tolower(*s++)) == '\0')
+ return NULL;
+ } while (sc != c);
+ } while (strncasecmp(s, find, len) != 0);
+ s--;
+ }
+ return ((char *)s);
+}
+
+/* Check if the font path element is a directory which can be examined
+ * (for example the font may be from a font server
+ * (e.g. pFont->fpe->name == "tcp/:7100"))
+ */
+static
+Bool IsFPEaReadableDir(FontPtr pFont)
+{
+ const char *fpe_name = pFont->fpe->name;
+ if (!fpe_name)
+ return False;
+
+#define MODEL_FONTPATH_PREFIX "PRINTER:"
+#define MODEL_FONTPATH_PREFIX_LEN 8
+ /* Strip model-specific font path prefix if there is one... */
+ if (!strncmp(fpe_name, MODEL_FONTPATH_PREFIX, MODEL_FONTPATH_PREFIX_LEN))
+ fpe_name += MODEL_FONTPATH_PREFIX_LEN;
+
+ if (access(fpe_name, F_OK) == 0)
+ {
+ return True;
+ }
+
+ return False;
+}
+
+static
+char *getFontFilename(FontPtr pFont)
+{
+ FontDirectoryPtr dir;
+ const char *dlfnam;
+ FILE *file;
+ struct stat statb;
+ int count, i, status;
+ char buf[512];
+ char *front, *end, *fn;
+ char font_dir_fname[PATH_MAX], /* Full path of fonts.dir */
+ font_file_fname[PATH_MAX]; /* Name of font file (excluding path) */
+
+#ifdef XP_USE_FREETYPE
+ if( PsIsFreeTypeFont(pFont) )
+ {
+ const char *fontname = PsGetFTFontFileName(pFont);
+
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "getFontFilename: freetype font, file='%s'\n", fontname?fontname:"<NULL>");
+#endif /* DEBUG_gisburn */
+
+ if( !fontname )
+ return NULL;
+
+ return strdup(fontname);
+ }
+#endif /* XP_USE_FREETYPE */
+
+ if (!IsFPEaReadableDir(pFont))
+ {
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "getFontFilename: '%s' no valid font path on disk\n", pFont->fpe->name);
+#endif /* DEBUG_gisburn */
+ return NULL;
+ }
+
+ dir = pFont->fpe->private;
+ sprintf(font_dir_fname, "%s%s", dir->directory, "fonts.dir");
+
+ if (!(dlfnam = PsGetFontName(pFont)))
+ return NULL;
+
+ file = fopen(font_dir_fname, "r");
+ if (file)
+ {
+ if (fstat (fileno(file), &statb) == -1)
+ return NULL;
+
+ while( fgets(buf, sizeof(buf)-1, file) )
+ {
+ if ((fn = strstr(buf, " -")))
+ {
+ strcpy(font_file_fname, buf);
+ font_file_fname[fn - buf] = '\0';
+ fn++;
+ if ((front = str_case_str(fn, "normal-")))
+ {
+ fn[front - fn] = '\0';
+ if (str_case_str(dlfnam, fn))
+ {
+ char full_font_file_path[PATH_MAX];
+
+ fclose(file);
+
+ sprintf(full_font_file_path, "%s%s", dir->directory, font_file_fname);
+
+#ifdef xDEBUG_gisburn
+ fprintf(stderr, "getFontFilename: returning '%s'\n", full_font_file_path);
+#endif /* DEBUG_gisburn */
+ return strdup(full_font_file_path);
+ }
+ }
+ }
+ }
+ }
+ font_file_fname[0] = '\0';
+ fclose(file);
+
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "getFontFilename: returning NULL\n");
+#endif /* DEBUG_gisburn */
+
+ return NULL;
+}
+
+static
+PsFontTypeInfoRec *PsFindFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable);
+ PsFontTypeInfoRec *rec;
+ const char *psname;
+ char *font_filename;
+ char *encname;
+#ifdef XP_USE_FREETYPE
+ Bool is_freetypefont;
+#endif /* XP_USE_FREETYPE */
+
+#ifdef XP_USE_FREETYPE
+ is_freetypefont = PsIsFreeTypeFont(pFont);
+#endif /* XP_USE_FREETYPE */
+ encname = PsGetEncodingName(pFont);
+
+ /* First try: Search by PostScript font name */
+ psname = PsGetPSFontName(pFont);
+ if (psname)
+ {
+ for( rec = cPriv->fontTypeInfoRecords ; rec != NULL ; rec = rec->next )
+ {
+#ifdef XP_USE_FREETYPE
+ if (is_freetypefont)
+ {
+ if (rec->adobe_ps_name)
+ {
+ if ((rec->font_type == PSFTI_FONT_TYPE_FREETYPE) &&
+ (!strcmp(rec->adobe_ps_name, psname)) &&
+ (!strcmp(rec->ft_download_encoding, encname)))
+ {
+ return rec;
+ }
+ }
+ }
+ else
+#endif /* XP_USE_FREETYPE */
+ {
+ if (rec->adobe_ps_name)
+ {
+ if ((rec->font_type != PSFTI_FONT_TYPE_FREETYPE) &&
+ (!strcmp(rec->adobe_ps_name, psname)))
+ {
+ return rec;
+ }
+ }
+ }
+ }
+ }
+
+ /* Last attempt: Search by filename */
+ font_filename = getFontFilename(pFont);
+ if (font_filename)
+ {
+ for( rec = cPriv->fontTypeInfoRecords ; rec != NULL ; rec = rec->next )
+ {
+ if (rec->filename)
+ {
+#ifdef XP_USE_FREETYPE
+ if (is_freetypefont)
+ {
+ if ( (rec->font_type == PSFTI_FONT_TYPE_FREETYPE) &&
+ (!strcasecmp(rec->filename, font_filename)) &&
+ (!strcasecmp(rec->ft_download_encoding, encname)) )
+ {
+ free(font_filename);
+ return rec;
+ }
+ }
+ else
+#endif /* XP_USE_FREETYPE */
+ {
+ if ( (rec->font_type != PSFTI_FONT_TYPE_FREETYPE) &&
+ (!strcasecmp(rec->filename, font_filename)) )
+ {
+ free(font_filename);
+ return rec;
+ }
+ }
+ }
+ }
+
+ free(font_filename);
+ }
+
+ return NULL;
+}
+
+static
+void PsAddFontTypeInfoRec(DrawablePtr pDrawable, PsFontTypeInfoRec *add_rec)
+{
+ PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable);
+
+ /* ToDO: Always move the last used entry to the top that the list get's
+ * sorted in an efficient order... :-) */
+ add_rec->next = cPriv->fontTypeInfoRecords;
+ cPriv->fontTypeInfoRecords = add_rec;
+}
+
+static
+Bool strcaseendswith(const char *str, const char *suffix)
+{
+ const char *s;
+
+ s = str + strlen(str) - strlen(suffix);
+
+ if (!strcasecmp(s, suffix))
+ return True;
+
+ return False;
+}
+
+
+static
+int getFontFileType( const char *filename )
+{
+ int type;
+
+ /* Is this a Adobe PostScript Type 1 binary font (PFB) ? */
+ if( strcaseendswith(filename, ".pfb") )
+ {
+ type = PSFTI_FONT_TYPE_PS_TYPE1_PFB;
+ }
+ /* Is this a Adobe PostScript ASCII font (PFA) ? */
+ else if( strcaseendswith(filename, ".pfa") )
+ {
+ type = PSFTI_FONT_TYPE_PS_TYPE1_PFA;
+ }
+ /* Is this a PMF(=Printer Metrics File) ? */
+ else if( strcaseendswith(filename, ".pmf") )
+ {
+ type = PSFTI_FONT_TYPE_PMF;
+ }
+ /* Is this a TrueType font file ? */
+ else if( strcaseendswith(filename, ".ttf") ||
+ strcaseendswith(filename, ".ttc") ||
+ strcaseendswith(filename, ".otf") ||
+ strcaseendswith(filename, ".otc") )
+ {
+ type = PSFTI_FONT_TYPE_TRUETYPE;
+ }
+ else
+ {
+ type = PSFTI_FONT_TYPE_OTHER;
+ }
+
+#ifdef XP_USE_FREETYPE
+ {
+ XpContextPtr pCon;
+ char *downloadfonts;
+ pCon = XpGetPrintContext(requestingClient);
+ downloadfonts = XpGetOneAttribute(pCon, XPPrinterAttr, "xp-psddx-download-fonts");
+ if( downloadfonts )
+ {
+ /* Should we download PS Type1 fonts as PS Type1||Type3 ? */
+ if( (type == PSFTI_FONT_TYPE_PS_TYPE1_PFA) &&
+ (strstr(downloadfonts, "pfa") != NULL) )
+ {
+ type = PSFTI_FONT_TYPE_FREETYPE;
+ }
+
+ if( (type == PSFTI_FONT_TYPE_PS_TYPE1_PFB) &&
+ (strstr(downloadfonts, "pfb") != NULL) )
+ {
+ type = PSFTI_FONT_TYPE_FREETYPE;
+ }
+
+ /* Should we download TrueType fonts as PS Type1||Type3 ? */
+ if( (type == PSFTI_FONT_TYPE_TRUETYPE) &&
+ ((strstr(downloadfonts, "ttf") != NULL) ||
+ (strstr(downloadfonts, "ttc") != NULL) ||
+ (strstr(downloadfonts, "otf") != NULL) ||
+ (strstr(downloadfonts, "otc") != NULL)) )
+ {
+ type = PSFTI_FONT_TYPE_FREETYPE;
+ }
+ }
+ }
+#endif /* XP_USE_FREETYPE */
+
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "getFontFileType: '%s' is %d\n", filename, (int)type);
+#endif /* DEBUG_gisburn */
+ return type;
+}
+
+PsFTDownloadFontType PsGetFTDownloadFontType(void)
+{
+ PsFTDownloadFontType downloadfonttype;
+ XpContextPtr pCon;
+ char *psfonttype;
+
+ pCon = XpGetPrintContext(requestingClient);
+ psfonttype = XpGetOneAttribute(pCon, XPPrinterAttr, "xp-psddx-download-font-type");
+
+ if( !psfonttype || !strlen(psfonttype) )
+ {
+ return PsFontType1; /* Default download font type is PS Type1 */
+ }
+
+ if( !strcmp(psfonttype, "bitmap") )
+ {
+ downloadfonttype = PsFontBitmap;
+ }
+ else if( !strcmp(psfonttype, "pstype3") )
+ {
+ downloadfonttype = PsFontType3;
+ }
+ else if( !strcmp(psfonttype, "pstype1") )
+ {
+ downloadfonttype = PsFontType1;
+ }
+ else
+ {
+ FatalError("PS DDX: XPPrinterAttr/xp-psddx-download-freetype-font-type='%s' not implemented\n", psfonttype);
+ return 0; /* NO-OP, FatalError() will call |exit()| */
+ }
+
+ return downloadfonttype;
+}
+
+static
+PsFontTypeInfoRec *PsCreateFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ char *dlfnam;
+ PsFontTypeInfoRec *rec;
+ char *psname;
+
+ if (!(dlfnam = PsGetFontName(pFont)))
+ return NULL;
+
+ if (!(rec = (PsFontTypeInfoRec *)xalloc(sizeof(PsFontTypeInfoRec))))
+ return NULL;
+ memset(rec, 0, sizeof(PsFontTypeInfoRec));
+
+ rec->next = NULL;
+
+ if (rec->filename = getFontFilename(pFont))
+ {
+ rec->font_type = getFontFileType(rec->filename);
+ }
+ else
+ {
+ rec->filename = NULL;
+ rec->font_type = PSFTI_FONT_TYPE_OTHER;
+ }
+
+ rec->adobe_ps_name = PsGetPSFontName(pFont);
+#ifdef XP_USE_FREETYPE
+ rec->ft_download_encoding = PsGetEncodingName(pFont);
+ rec->ft_download_font_type = PsGetFTDownloadFontType();
+#endif /* XP_USE_FREETYPE */
+ rec->download_ps_name = NULL;
+
+#define SET_FONT_DOWNLOAD_STATUS(rec, downloaded) { int i; for (i = 0 ; i < 256 ; i++) { (rec)->alreadyDownloaded[i]=(downloaded); } }
+
+ /* Set some flags based on the font type */
+ switch( rec->font_type )
+ {
+ case PSFTI_FONT_TYPE_PS_TYPE1_PFA:
+ case PSFTI_FONT_TYPE_PS_TYPE1_PFB:
+ rec->downloadableFont = True;
+ SET_FONT_DOWNLOAD_STATUS(rec, False);
+ rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont);
+ break;
+
+ case PSFTI_FONT_TYPE_PMF:
+ rec->downloadableFont = True; /* This font is in printer's ROM */
+ SET_FONT_DOWNLOAD_STATUS(rec, True);
+ rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont);
+ break;
+
+ case PSFTI_FONT_TYPE_TRUETYPE:
+ /* Note: TrueType font download not implemented */
+ rec->downloadableFont = False;
+ SET_FONT_DOWNLOAD_STATUS(rec, False);
+ rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont);
+ break;
+
+#ifdef XP_USE_FREETYPE
+ case PSFTI_FONT_TYPE_FREETYPE:
+ if( rec->ft_download_font_type == PsFontType1 ||
+ rec->ft_download_font_type == PsFontType3 )
+ {
+ rec->downloadableFont = True;
+ }
+ else
+ {
+ rec->downloadableFont = False;
+ }
+
+ SET_FONT_DOWNLOAD_STATUS(rec, False);
+ rec->is_iso_encoding = False; /* Freetype--->PS Type1/Type3 uses always non-iso PS encoding for now */
+ break;
+#endif /* XP_USE_FREETYPE */
+
+ case PSFTI_FONT_TYPE_OTHER:
+ default:
+ rec->downloadableFont = False;
+ SET_FONT_DOWNLOAD_STATUS(rec, False);
+ rec->is_iso_encoding = PsIsISOLatin1Encoding(pFont);
+ break;
+ }
+
+#ifdef XP_USE_FREETYPE
+ if( (rec->font_type == PSFTI_FONT_TYPE_FREETYPE) )
+ {
+ char *s;
+ register int c;
+
+ if( rec->adobe_ps_name )
+ {
+ rec->download_ps_name = malloc(strlen(rec->adobe_ps_name) + strlen(rec->ft_download_encoding) + 2);
+ sprintf(rec->download_ps_name, "%s_%s", rec->adobe_ps_name, rec->ft_download_encoding);
+ }
+ else
+ {
+ /* Unfortunately not all TTF fonts have a PostScript font name (like
+ * Solaris TTF fonts in /usr/openwin/lib/locale/ko.UTF-8/X11/fonts/TrueType,
+ * /usr/openwin/lib/locale/ko/X11/fonts/TrueType) - in this case we
+ * have to generate a font name
+ */
+ char ftfontname[64];
+ static long myfontindex = 0L;
+ sprintf(ftfontname, "psfont_%lx", myfontindex++);
+
+ rec->download_ps_name = malloc(strlen(ftfontname) + strlen(rec->ft_download_encoding) + 2);
+ sprintf(rec->download_ps_name, "%s_%s", ftfontname, rec->ft_download_encoding);
+
+ fprintf(stderr, "PsCreateFontTypeInfoRec: Note: '%s' has no PS font name, using '%s' for now.\n", dlfnam, rec->download_ps_name);
+ }
+
+ /* Make sure the font name we use for download is a valid PS font name */
+ for( s = rec->download_ps_name ; *s != '\0'; s++ )
+ {
+ c = *s;
+
+ /* Check for allowed chars, invalid ones are replaced with a '_'
+ * (and check that the first char is not a digit) */
+ if( !(isalnum(c) || c == '.' || c == '_' || c == '-') || (s==rec->download_ps_name && isdigit(c)) )
+ {
+ *s = '_';
+ }
+ }
+ }
+ else
+#endif /* XP_USE_FREETYPE */
+ {
+ if( rec->adobe_ps_name )
+ {
+ rec->download_ps_name = strdup(rec->adobe_ps_name);
+ }
+ else
+ {
+ rec->download_ps_name = NULL;
+ }
+ }
+
+ /* Safeguard - only treat font as downloadable when we have a PS font name!! */
+ if (!rec->download_ps_name && rec->downloadableFont)
+ {
+ /* XXX: Log this message to the log when the logging service has been hook'ed up */
+ fprintf(stderr, "PsCreateFontTypeInfoRec: Safeguard: No PS font name for '%s'!\n", dlfnam);
+ rec->downloadableFont = False;
+ }
+
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "PsCreateFontTypeInfoRec: Created PsFontTypeInfoRec '%s' ('%s'/'%s')\n",
+ ((rec->filename) ?(rec->filename) :("<null>")),
+ ((rec->adobe_ps_name) ?(rec->adobe_ps_name):("<null>")),
+ ((rec->download_ps_name)?(rec->download_ps_name):("<null>")));
+#endif /* DEBUG_gisburn */
+
+ return rec;
+}
+
+static
+PsFontTypeInfoRec *PsGetFontTypeInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ PsFontTypeInfoRec *rec;
+ char *dlfnam;
+
+ if(!(dlfnam = PsGetFontName(pFont)))
+ return NULL;
+
+ rec = PsFindFontTypeInfoRec(pDrawable, pFont);
+ if (rec)
+ return rec;
+
+ rec = PsCreateFontTypeInfoRec(pDrawable, pFont);
+ if (!rec)
+ return NULL;
+
+ PsAddFontTypeInfoRec(pDrawable, rec);
+
+ return rec;
+}
+
+static
+void PsFreeFontTypeInfoRecords( PsContextPrivPtr priv )
+{
+ PsFontTypeInfoRec *curr, *next;
+ curr = priv->fontTypeInfoRecords;
+ while( curr != NULL )
+ {
+ if (curr->filename)
+ free(curr->filename); /* Free memory allocated by |strdup()| */
+
+ if (curr->download_ps_name)
+ free(curr->download_ps_name);
+
+ next = curr->next;
+ xfree(curr);
+ curr = next;
+ }
+}
+
+static
+PsFontInfoRec *PsFindFontInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable);
+ PsFontInfoRec *rec;
+
+ if (!pFont)
+ return NULL;
+
+ for( rec = cPriv->fontInfoRecords ; rec != NULL ; rec = rec->next )
+ {
+ if ((rec->font == pFont) &&
+ (rec->font_fontPrivate == pFont->fontPrivate))
+ return rec;
+ }
+
+ return NULL;
+}
+
+static
+void PsAddFontInfoRec(DrawablePtr pDrawable, PsFontInfoRec *add_rec)
+{
+ PsContextPrivRec *cPriv = PsGetPsContextPriv(pDrawable);
+
+ /* ToDO: Always move the last used entry to the top that the list get's
+ * sorted in an efficient order... :-) */
+ add_rec->next = cPriv->fontInfoRecords;
+ cPriv->fontInfoRecords = add_rec;
+}
+
+static
+PsFontInfoRec *PsCreateFontInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ PsFontInfoRec *rec;
+ PsFontTypeInfoRec *ftir;
+
+ if (!(ftir = PsGetFontTypeInfoRec(pDrawable, pFont)))
+ return NULL;
+
+ if (!(rec = (PsFontInfoRec *)xalloc(sizeof(PsFontInfoRec))))
+ return NULL;
+ memset(rec, 0, sizeof(PsFontInfoRec));
+
+ rec->font = pFont;
+ rec->font_fontPrivate = pFont->fontPrivate;
+ rec->ftir = ftir;
+ rec->next = NULL;
+ rec->dfl_name = PsGetFontName(pFont);
+ rec->size = PsGetFontSize(pFont, rec->mtx);
+
+#ifdef DEBUG_gisburn
+ fprintf(stderr, "PsCreateFontInfoRec: Created PsFontInfoRec '%s'\n",
+ ((rec->dfl_name)?(rec->dfl_name):("<null>")));
+#endif /* DEBUG_gisburn */
+
+ return rec;
+}
+
+PsFontInfoRec *PsGetFontInfoRec(DrawablePtr pDrawable, FontPtr pFont)
+{
+ PsFontInfoRec *rec;
+
+ rec = PsFindFontInfoRec(pDrawable, pFont);
+ if (rec)
+ return rec;
+
+ rec = PsCreateFontInfoRec(pDrawable, pFont);
+ if (!rec)
+ return NULL;
+
+ PsAddFontInfoRec(pDrawable, rec);
+
+ return rec;
+}
+
+void PsFreeFontInfoRecords( PsContextPrivPtr priv )
+{
+ PsFontInfoRec *curr, *next;
+ curr = priv->fontInfoRecords;
+ while( curr != NULL )
+ {
+ next = curr->next;
+ xfree(curr);
+ curr = next;
+ }
+
+ PsFreeFontTypeInfoRecords(priv);
+
+ priv->fontTypeInfoRecords = NULL;
+ priv->fontInfoRecords = NULL;
+}
diff --git a/Xprint/ps/PsGC.c b/Xprint/ps/PsGC.c
index ea441cff5..78c83930d 100644
--- a/Xprint/ps/PsGC.c
+++ b/Xprint/ps/PsGC.c
@@ -57,7 +57,6 @@ in this Software without prior written authorization from The Open Group.
* or other dealings in this Software without prior written authorization
* from said copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsGC.c,v 1.6tsi Exp $ */
/*******************************************************************
**
@@ -157,13 +156,19 @@ PsGetDrawablePrivateStuff(
if( pCon==NULL ) return FALSE;
else
{
+ Colormap c;
+ ColormapPtr cmap;
+
+ c = wColormap((WindowPtr)pDrawable);
+ cmap = (ColormapPtr)LookupIDByType(c, RT_COLORMAP);
+
cPriv = pCon->devPrivates[PsContextPrivateIndex].ptr;
sPriv = (PsScreenPrivPtr)
pDrawable->pScreen->devPrivates[PsScreenPrivateIndex].ptr;
*gc = cPriv->lastGC;
*valid = cPriv->validGC;
*psOut = cPriv->pPsOut;
- *cMap = sPriv->CMap;
+ *cMap = cmap;
return TRUE;
}
default:
@@ -171,6 +176,26 @@ PsGetDrawablePrivateStuff(
}
}
+PsContextPrivPtr
+PsGetPsContextPriv( DrawablePtr pDrawable )
+{
+ XpContextPtr pCon;
+ PsContextPrivPtr cPriv;
+
+ switch(pDrawable->type)
+ {
+ case DRAWABLE_PIXMAP:
+ return FALSE;
+ case DRAWABLE_WINDOW:
+ pCon = PsGetContextFromWindow((WindowPtr)pDrawable);
+ if (pCon != NULL)
+ {
+ return pCon->devPrivates[PsContextPrivateIndex].ptr;
+ }
+ }
+ return NULL;
+}
+
int
PsUpdateDrawableGC(
GCPtr pGC,
@@ -181,6 +206,7 @@ PsUpdateDrawableGC(
GC dGC;
unsigned long valid;
int i;
+ PsContextPrivPtr cPriv;
BoxPtr boxes;
if (!PsGetDrawablePrivateStuff(pDrawable, &dGC, &valid, psOut, cMap))
@@ -232,6 +258,8 @@ PsUpdateDrawableGC(
PsOut_Offset(*psOut, pDrawable->x, pDrawable->y);
PsOut_Clip(*psOut, pGC->clientClipType, (PsClipPtr)pGC->clientClip);
}
+ cPriv = ( PsGetContextFromWindow( (WindowPtr)pDrawable ) )
+ ->devPrivates[PsContextPrivateIndex].ptr;
break;
}
return TRUE;
diff --git a/Xprint/ps/PsInit.c b/Xprint/ps/PsInit.c
index a7a63343d..f2e064921 100644
--- a/Xprint/ps/PsInit.c
+++ b/Xprint/ps/PsInit.c
@@ -71,9 +71,8 @@ in this Software without prior written authorization from The Open Group.
** * Copyright: Copyright 1996 The Open Group, Inc.
** *
** *********************************************************
-**
+**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsInit.c,v 1.13tsi Exp $ */
#include <stdio.h>
#include <string.h>
@@ -84,6 +83,7 @@ in this Software without prior written authorization from The Open Group.
#include "Ps.h"
#include "mi.h"
+#include "micmap.h"
#include "AttrValid.h"
#include "../../mfb/mfb.h"
@@ -101,6 +101,10 @@ int PsContextPrivateIndex;
int PsPixmapPrivateIndex;
int PsWindowPrivateIndex;
+#ifdef GLXEXT
+extern void GlxWrapInitVisuals(miInitVisualsProcPtr *);
+#endif /* GLXEXT */
+
Bool
InitializePsDriver(ndx, pScreen, argc, argv)
int ndx;
@@ -109,12 +113,18 @@ InitializePsDriver(ndx, pScreen, argc, argv)
char **argv;
{
#if 0
+ int maxXres, maxYres, maxWidth, maxHeight;
+ int maxRes, maxDim, numBytes;
PsScreenPrivPtr pPriv;
#endif
+ char **printerNames;
+ int numPrinters;
int nVisuals;
int nDepths;
VisualPtr visuals;
DepthPtr depths;
+ VisualID defaultVisual;
+ int rootDepth;
/*
* Register this driver's InitContext function with the print
@@ -188,7 +198,7 @@ InitializePsDriver(ndx, pScreen, argc, argv)
visuals[1].vid = FakeClientID(0);
visuals[1].class = PseudoColor;
- visuals[1].bitsPerRGBValue = 0;
+ visuals[1].bitsPerRGBValue = 8;
visuals[1].ColormapEntries = 256;
visuals[1].nplanes = 8;
visuals[1].redMask = 0x0;
@@ -200,27 +210,35 @@ InitializePsDriver(ndx, pScreen, argc, argv)
depths[0].depth = 24;
depths[0].numVids = 1;
- depths[0].vids = &visuals[0].vid;
+ depths[0].vids = (VisualID *)xalloc(sizeof(VisualID));
+ depths[0].vids[0] = visuals[0].vid;
depths[1].depth = 8;
depths[1].numVids = 1;
- depths[1].vids = &visuals[1].vid;
+ depths[1].vids = (VisualID *)xalloc(sizeof(VisualID));
+ depths[1].vids[0] = visuals[1].vid;
-/* THE FOLLOWING CAUSES SERVER DEFAULT VISUAL TO BE 24 BIT */
-/* miScreenInit(pScreen, (pointer)0,
- pScreen->width, pScreen->height,
- pScreen->width / (pScreen->mmWidth / 25.40),
- pScreen->height / (pScreen->mmHeight / 25.40),
- 0, 24, nDepths,
- depths, visuals[1].vid, nVisuals, visuals); */
+ /* Defaul visual is 8bit PseudoColor */
+ defaultVisual = visuals[1].vid;
+ rootDepth = visuals[1].nplanes;
+
+#ifdef GLXEXT
+ {
+ miInitVisualsProcPtr proc = NULL;
+
+ GlxWrapInitVisuals(&proc);
+ /* GlxInitVisuals ignores the last three arguments. */
+ proc(&visuals, &depths, &nVisuals, &nDepths,
+ &rootDepth, &defaultVisual, 0, 0, 0);
+ }
+#endif /* GLXEXT */
-/* THE FOLLOWING CAUSES SERVER DEFAULT VISUAL TO BE 8 BIT */
miScreenInit(pScreen, (pointer)0,
- pScreen->width, pScreen->height,
- (int) (pScreen->width / (pScreen->mmWidth / 25.40)),
- (int) (pScreen->height / (pScreen->mmHeight / 25.40)),
- 0, 8, nDepths,
- depths, visuals[1].vid, nVisuals, visuals);
+ pScreen->width, pScreen->height,
+ (int) (pScreen->width / (pScreen->mmWidth / 25.40)),
+ (int) (pScreen->height / (pScreen->mmHeight / 25.40)),
+ 0, rootDepth, nDepths,
+ depths, defaultVisual, nVisuals, visuals);
if( cfbCreateDefColormap(pScreen)==FALSE ) return FALSE;
@@ -243,7 +261,7 @@ AllocatePsPrivates(ScreenPtr pScreen)
sizeof(PsWindowPrivRec));
PsContextPrivateIndex = XpAllocateContextPrivateIndex();
- XpAllocateContextPrivate(PsContextPrivateIndex,
+ XpAllocateContextPrivate(PsContextPrivateIndex,
sizeof(PsContextPrivRec));
PsPixmapPrivateIndex = AllocatePixmapPrivateIndex();
@@ -278,7 +296,7 @@ PsInitContext(pCon)
XpDriverFuncsPtr pFuncs;
PsContextPrivPtr pConPriv;
char *server, *attrStr;
-
+
/*
* Initialize the attribute store for this printer.
*/
@@ -304,18 +322,23 @@ PsInitContext(pCon)
pFuncs->GetMediumDimensions = PsGetMediumDimensions;
pFuncs->GetReproducibleArea = PsGetReproducibleArea;
pFuncs->SetImageResolution = PsSetImageResolution;
-
+
/*
* Set up the context privates
*/
pConPriv =
(PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
- pConPriv->jobFileName = (char *)NULL;
- pConPriv->pJobFile = (FILE *)NULL;
-
- pConPriv->getDocClient = (ClientPtr)NULL;
- pConPriv->getDocBufSize = 0;
+ memset(pConPriv, 0, sizeof(PsContextPrivRec));
+ pConPriv->jobFileName = (char *)NULL;
+ pConPriv->pJobFile = (FILE *)NULL;
+ pConPriv->dash = (unsigned char *)NULL;
+ pConPriv->validGC = 0;
+ pConPriv->getDocClient = (ClientPtr)NULL;
+ pConPriv->getDocBufSize = 0;
+ pConPriv->pPsOut = NULL;
+ pConPriv->fontInfoRecords = NULL;
+ pConPriv->fontTypeInfoRecords = NULL;
/*
* document-attributes-supported
@@ -323,15 +346,15 @@ PsInitContext(pCon)
server = XpGetOneAttribute( pCon, XPServerAttr, DOC_ATT_SUPP );
if ((attrStr = (char *) xalloc(strlen(server) +
strlen(DOC_ATT_SUPP) + strlen(DOC_ATT_VAL)
- + strlen(PAGE_ATT_VAL) + 6)) == NULL)
+ + strlen(PAGE_ATT_VAL) + 6)) == NULL)
{
return BadAlloc;
}
- sprintf(attrStr, "*%s:\t%s %s %s",
+ sprintf(attrStr, "*%s:\t%s %s %s",
DOC_ATT_SUPP, server, DOC_ATT_VAL, PAGE_ATT_VAL);
XpAugmentAttributes( pCon, XPPrinterAttr, attrStr);
xfree(attrStr);
-
+
/*
* job-attributes-supported
*/
@@ -344,7 +367,7 @@ PsInitContext(pCon)
sprintf(attrStr, "*%s:\t%s %s", JOB_ATT_SUPP, server, JOB_ATT_VAL);
XpAugmentAttributes(pCon, XPPrinterAttr, attrStr);
xfree(attrStr);
-
+
/*
* xp-page-attributes-supported
*/
@@ -375,7 +398,7 @@ PsDestroyContext(pCon)
{
PsContextPrivPtr pConPriv =
(PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
-
+
if( pConPriv->pJobFile!=(FILE *)NULL )
{
fclose(pConPriv->pJobFile);
@@ -388,6 +411,11 @@ PsDestroyContext(pCon)
pConPriv->jobFileName = (char *)NULL;
}
+ PsFreeFontInfoRecords(pConPriv);
+
+ /* Reset context to make sure we do not use any stale/invalid/obsolete data */
+ memset(pConPriv, 0, sizeof(PsContextPrivRec));
+
/*### free up visuals/depths ###*/
return Success;
diff --git a/Xprint/ps/PsLine.c b/Xprint/ps/PsLine.c
index dd01fcb65..23e105804 100644
--- a/Xprint/ps/PsLine.c
+++ b/Xprint/ps/PsLine.c
@@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsLine.c,v 1.5 2001/01/17 22:36:32 dawes Exp $ */
#include "Ps.h"
#include "gcstruct.h"
diff --git a/Xprint/ps/PsMisc.c b/Xprint/ps/PsMisc.c
index 3085888c7..86d862ce1 100644
--- a/Xprint/ps/PsMisc.c
+++ b/Xprint/ps/PsMisc.c
@@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsMisc.c,v 1.5 2001/01/17 22:36:32 dawes Exp $ */
#include "Xos.h" /* for SIGCLD on pre-POSIX systems */
#include <stdio.h>
diff --git a/Xprint/ps/PsPixel.c b/Xprint/ps/PsPixel.c
index 303b0d5ec..c2c360d2e 100644
--- a/Xprint/ps/PsPixel.c
+++ b/Xprint/ps/PsPixel.c
@@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsPixel.c,v 1.5 2001/01/17 22:36:32 dawes Exp $ */
#include <stdio.h>
diff --git a/Xprint/ps/PsPixmap.c b/Xprint/ps/PsPixmap.c
index a020aba22..616c2dbe8 100644
--- a/Xprint/ps/PsPixmap.c
+++ b/Xprint/ps/PsPixmap.c
@@ -57,7 +57,7 @@ in this Software without prior written authorization from The Open Group.
* or other dealings in this Software without prior written authorization
* from said copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsPixmap.c,v 1.4 2001/01/17 22:36:32 dawes Exp $ */
+
/*******************************************************************
**
** *********************************************************
@@ -79,6 +79,10 @@ in this Software without prior written authorization from The Open Group.
#include "Ps.h"
+#define _BitsPerPixel(d) (\
+ (1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
+ (PixmapWidthPaddingInfo[d].padRoundUp+1))
+
PixmapPtr
PsCreatePixmap(
ScreenPtr pScreen,
@@ -94,7 +98,7 @@ PsCreatePixmap(
pPixmap->drawable.class = 0;
pPixmap->drawable.pScreen = pScreen;
pPixmap->drawable.depth = depth;
- pPixmap->drawable.bitsPerPixel = BitsPerPixel(depth);
+ pPixmap->drawable.bitsPerPixel = _BitsPerPixel(depth);
pPixmap->drawable.id = 0;
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pPixmap->drawable.x = 0;
@@ -199,7 +203,7 @@ PsGetFreeDisplayBlock(PsPixmapPrivPtr priv)
return(disp);
}
-static void
+void
PsReplay(DisplayElmPtr elm, DrawablePtr pDrawable)
{
switch(elm->type)
@@ -488,8 +492,6 @@ PsCreateFillElementList(PixmapPtr pix, int *nElms)
case PolyFillArcCmd:
*nElms += elm->c.arcs.nArcs;
break;
- default:
- break;
}
}
}
@@ -552,8 +554,6 @@ PsCreateFillElementList(PixmapPtr pix, int *nElms)
*nElms += 1;
}
break;
- default:
- break;
}
}
}
diff --git a/Xprint/ps/PsPolygon.c b/Xprint/ps/PsPolygon.c
index d334c7778..a5b373775 100644
--- a/Xprint/ps/PsPolygon.c
+++ b/Xprint/ps/PsPolygon.c
@@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsPolygon.c,v 1.6 2001/01/17 22:36:32 dawes Exp $ */
#include "Ps.h"
#include "gcstruct.h"
@@ -176,7 +175,8 @@ PsFillPolygon(
}
else
{
- pts[0].x = pPoints[0].x; pts[0].y = pPoints[0].y;
+ i = 0;
+ pts[0].x = pPoints[i].x; pts[0].y = pPoints[i].y;
for( i=1 ; i<nPoints ; i++ )
{
pts[i].x = pts[i-1].x+pPoints[i].x;
diff --git a/Xprint/ps/PsPrint.c b/Xprint/ps/PsPrint.c
index 5e549836f..f0356d705 100644
--- a/Xprint/ps/PsPrint.c
+++ b/Xprint/ps/PsPrint.c
@@ -73,7 +73,6 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsPrint.c,v 1.10 2001/12/14 19:59:17 dawes Exp $ */
#include <stdio.h>
#include <string.h>
@@ -91,6 +90,7 @@ in this Software without prior written authorization from The Open Group.
#include "Ps.h"
#include "windowstr.h"
+#include "attributes.h"
#include "Oid.h"
/* static utility function to get document/page attributes */
@@ -206,6 +206,8 @@ PsEndJob(
unlink(priv->jobFileName);
xfree(priv->jobFileName);
priv->jobFileName = (char *)NULL;
+
+ PsFreeFontInfoRecords(priv);
return Success;
}
@@ -214,6 +216,7 @@ PsEndJob(
* Append any trailing information here
*/
PsOut_EndFile(priv->pPsOut, 0);
+ priv->pPsOut = NULL;
/* this is where we find out if we're out of space */
error = (fclose(priv->pJobFile) == EOF);
@@ -233,6 +236,8 @@ PsEndJob(
xfree(priv->jobFileName);
priv->jobFileName = (char *)NULL;
+ PsFreeFontInfoRecords(priv);
+
return BadAlloc;
}
@@ -265,10 +270,12 @@ PsEndJob(
xfree(priv->jobFileName);
priv->jobFileName = (char *)NULL;
+ PsFreeFontInfoRecords(priv);
+
#ifdef BM_CACHE
PsBmClearImageCache();
#endif
-
+
return r;
}
@@ -281,10 +288,13 @@ PsStartPage(
{
int iorient, iplex, icount, ires;
unsigned short iwd, iht;
+ register WindowPtr pChild;
PsContextPrivPtr pConPriv =
(PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
PsWindowPrivPtr pWinPriv =
(PsWindowPrivPtr)pWin->devPrivates[PsWindowPrivateIndex].ptr;
+ char s[80];
+ xEvent event;
/*
* Put a pointer to the context in the window private structure
@@ -298,9 +308,16 @@ PsStartPage(
* Start the page
*/
if (pConPriv->pPsOut == NULL) {
- pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile,
- iorient, icount, iplex, ires,
- (int)iwd, (int)iht, False);
+ char *title;
+
+ /* get job level attributes */
+ title = XpGetOneAttribute(pCon, XPJobAttr, "job-name");
+
+ pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile,
+ title, iorient, icount, iplex, ires,
+ (int)iwd, (int)iht, False);
+ pConPriv->fontInfoRecords = NULL;
+ pConPriv->fontTypeInfoRecords = NULL;
}
PsOut_BeginPage(pConPriv->pPsOut, iorient, icount, iplex, ires,
(int)iwd, (int)iht);
@@ -348,15 +365,22 @@ PsStartDoc(XpContextPtr pCon, XPDocumentType type)
{
int iorient, iplex, icount, ires;
unsigned short iwd, iht;
+ char *title;
PsContextPrivPtr pConPriv =
(PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+ /* get job level attributes */
+ title = XpGetOneAttribute(pCon, XPJobAttr, "job-name");
+
/* get document level attributes */
S_GetPageAttributes(pCon,&iorient,&icount,&iplex,&ires,&iwd,&iht);
pConPriv->pPsOut = PsOut_BeginFile(pConPriv->pJobFile,
- iorient, icount, iplex, ires,
- (int)iwd, (int)iht, (type == XPDocRaw));
+ title, iorient, icount, iplex, ires,
+ (int)iwd, (int)iht, (Bool)(type == XPDocRaw));
+
+ pConPriv->fontInfoRecords = NULL;
+ pConPriv->fontTypeInfoRecords = NULL;
return Success;
}
@@ -391,8 +415,11 @@ PsDocumentData(
PsContextPrivPtr cPriv;
PsOutPtr psOut;
- if (len_fmt != 12 || !strcmp(pFmt, "PostScript 2") || len_opt)
+ if (len_fmt != 12 ||
+ strncasecmp(pFmt, "PostScript 2", len_fmt) != 0 ||
+ len_opt)
return BadValue;
+
cPriv = pCon->devPrivates[PsContextPrivateIndex].ptr;
psOut = cPriv->pPsOut;
diff --git a/Xprint/ps/PsText.c b/Xprint/ps/PsText.c
index ae44b3f1c..8bb0b0fb2 100644
--- a/Xprint/ps/PsText.c
+++ b/Xprint/ps/PsText.c
@@ -73,49 +73,13 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsText.c,v 1.12tsi Exp $ */
#include "Ps.h"
#include "gcstruct.h"
#include "windowstr.h"
+#include "fntfil.h"
#include "fntfilst.h"
-#include <sys/stat.h>
-
-static int readFontName(char *fileName, char *file_name, char *dlfnam)
-{
- FILE *file;
- struct stat statb;
- char buf[256];
- char *front, *fn;
-
- file = fopen(fileName, "r");
- if(file)
- {
- if (fstat (fileno(file), &statb) == -1)
- return 0;
- while(fgets(buf, 255, file))
- {
- if((fn = strstr(buf, " -")))
- {
- strcpy(file_name, buf);
- file_name[fn - buf - 4] = '\0';
- fn++;
- if((front = strstr(fn, "normal-")))
- {
- fn[front - fn] = '\0';
- if(strstr(dlfnam, fn))
- {
- fclose(file);
- return 1;
- }
- }
- }
- }
- }
- file_name[0] = '\0';
- fclose(file);
- return 0;
-}
+#include <limits.h>
int
PsPolyText8(
@@ -147,70 +111,97 @@ PsPolyText8(
elm->c.text8.string = (char *)xalloc(count);
memcpy(elm->c.text8.string, string, count);
disp->nelms += 1;
+
+ return x;
}
else
{
- char *fnam, ffname[512], *dlfnam;
- FontDirectoryPtr dir;
- char file_name[MAXFONTNAMELEN];
-
- dir = pGC->font->fpe->private;
- sprintf(ffname, "%s%s", dir->directory, "fonts.dir");
-
- fnam = PsGetPSFontName(pGC->font);
- if(!fnam){
- if(!(dlfnam = PsGetFontName(pGC->font)))
- return x;
- /* If Type1 font, try to download to printer first */
- if(strstr(ffname, "Type1") && readFontName(ffname, file_name, dlfnam))
- {
- int siz;
- float mtx[4];
- PsOutPtr psOut;
- ColormapPtr cMap;
-
- if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE )
- return x;
- sprintf(ffname, "%s%s%s", dir->directory, file_name, ".pfa");
- PsOut_DownloadType1(psOut, file_name, ffname);
- PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
- PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
- siz = PsGetFontSize(pGC->font, mtx);
- if( !siz ) PsOut_TextAttrsMtx(psOut, file_name, mtx, 1);
- else PsOut_TextAttrs(psOut, file_name, siz, 1);
- PsOut_Text(psOut, x, y, string, count, -1);
- return x;
- }
- {
- unsigned long n, i;
- int w;
- CharInfoPtr charinfo[255];
-
- GetGlyphs(pGC->font, (unsigned long)count,
- (unsigned char *)string, Linear8Bit,&n, charinfo);
- w = 0;
- for (i=0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
- if (n != 0)
- PsPolyGlyphBlt(pDrawable, pGC, x, y, n,
- charinfo, FONTGLYPHS(pGC->font));
- x += w;
- }
- }else{
- int iso;
- int siz;
- float mtx[4];
- PsOutPtr psOut;
- ColormapPtr cMap;
-
- if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return x;
- PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
- PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
- siz = PsGetFontSize(pGC->font, mtx);
- iso = PsIsISOLatin1Encoding(pGC->font);
- if( !siz ) PsOut_TextAttrsMtx(psOut, fnam, mtx, iso);
- else PsOut_TextAttrs(psOut, fnam, siz, iso);
- PsOut_Text(psOut, x, y, string, count, -1);
+ PsFontInfoRec *firec;
+
+ /* We need a context for rendering... */
+ if (PsGetPsContextPriv(pDrawable) == NULL)
+ return x;
+
+ firec = PsGetFontInfoRec(pDrawable, pGC->font);
+ if (!firec)
+ return x;
+
+#ifdef XP_USE_FREETYPE
+ if (firec->ftir->downloadableFont &&
+ (firec->ftir->font_type == PSFTI_FONT_TYPE_FREETYPE))
+ {
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE )
+ return x;
+
+ if (firec->ftir->alreadyDownloaded[0] == False)
+ {
+ PsOut_DownloadFreeType(psOut,
+ firec->ftir->ft_download_font_type,
+ firec->ftir->download_ps_name, pGC->font, 0);
+ firec->ftir->alreadyDownloaded[0] = True;
+ }
+
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ if (!firec->size)
+ PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding);
+ else
+ PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding);
+ PsOut_FreeType_Text(pGC->font, psOut, x, y, string, count);
+
+ return x;
}
+ else
+#endif /* XP_USE_FREETYPE */
+ if (firec->ftir->downloadableFont &&
+ (firec->ftir->font_type != PSFTI_FONT_TYPE_FREETYPE))
+ {
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE )
+ return x;
+
+ if (firec->ftir->alreadyDownloaded[0] == False)
+ {
+ PsOut_DownloadType1(psOut, "PsPolyText8",
+ firec->ftir->download_ps_name, firec->ftir->filename);
+ firec->ftir->alreadyDownloaded[0] = True;
+ }
+
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ if (!firec->size)
+ PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding);
+ else
+ PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding);
+ PsOut_Text(psOut, x, y, string, count, -1);
+
+ return x;
+ }
+
+ /* Render glyphs as bitmaps */
+ {
+ unsigned long n, i;
+ int w;
+ CharInfoPtr charinfo[255];
+
+ GetGlyphs(pGC->font, (unsigned long)count,
+ (unsigned char *)string, Linear8Bit, &n, charinfo);
+ w = 0;
+ for (i=0; i < n; i++)
+ w += charinfo[i]->metrics.characterWidth;
+
+ if (n != 0)
+ PsPolyGlyphBlt(pDrawable, pGC, x, y, n,
+ charinfo, FONTGLYPHS(pGC->font));
+ x += w;
+
+ return x;
+ }
}
return x;
}
@@ -246,21 +237,136 @@ PsPolyText16(
(unsigned short *)xalloc(count*sizeof(unsigned short));
memcpy(elm->c.text16.string, string, count*sizeof(unsigned short));
disp->nelms += 1;
+
+ return x;
}
else
{
- unsigned long n, i;
- int w;
- CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */
-
- GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)string,
- (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
- &n, charinfo);
- w = 0;
- for (i=0; i < n; i++) w += charinfo[i]->metrics.characterWidth;
- if (n != 0)
- PsPolyGlyphBlt(pDrawable, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font));
- x += w;
+ PsFontInfoRec *firec;
+
+ /* We need a context for rendering... */
+ if (PsGetPsContextPriv(pDrawable) == NULL)
+ return x;
+
+ firec = PsGetFontInfoRec(pDrawable, pGC->font);
+ if (!firec)
+ return x;
+
+#ifdef XP_USE_FREETYPE
+ if (firec->ftir->downloadableFont &&
+ (firec->ftir->font_type == PSFTI_FONT_TYPE_FREETYPE))
+ {
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+ unsigned short c,
+ c_hiByte,
+ c_lowByte,
+ fontPage;
+ int i;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE )
+ return x;
+
+ /* Scan the string we want to render and download all neccesary parts
+ * of the font (one part(="font page") has 256 glyphs)
+ */
+ for( i = 0 ; i < count ; i++ )
+ {
+ c = string[i];
+#if IMAGE_BYTE_ORDER == LSBFirst
+ c_hiByte = c & 0x00FF;
+ c_lowByte = (c >> 8) & 0x00FF;
+#elif IMAGE_BYTE_ORDER == MSBFirst
+ c_hiByte = (c >> 8) & 0x00FF;
+ c_lowByte = c & 0x00FF;
+#else
+#error Unsupported byte order
+#endif
+ fontPage = c_hiByte;
+
+ if (firec->ftir->alreadyDownloaded[fontPage] == False)
+ {
+ char buffer[256];
+ const char *ps_name;
+
+ if (fontPage > 0)
+ {
+ sprintf(buffer, "%s_%x", firec->ftir->download_ps_name, (int)fontPage);
+ ps_name = buffer;
+ }
+ else
+ {
+ ps_name = firec->ftir->download_ps_name;
+ }
+
+ PsOut_DownloadFreeType(psOut,
+ firec->ftir->ft_download_font_type,
+ ps_name, pGC->font, (fontPage * 0x100)); /* same as (fontPage << 8) */
+
+ firec->ftir->alreadyDownloaded[fontPage] = True;
+ }
+ }
+
+
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ if (!firec->size)
+ PsOut_FreeType_TextAttrsMtx16(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding);
+ else
+ PsOut_FreeType_TextAttrs16(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding);
+ PsOut_FreeType_Text16(pGC->font, psOut, x, y, string, count);
+
+ return x;
+ }
+ else
+#endif /* XP_USE_FREETYPE */
+ if (firec->ftir->downloadableFont &&
+ (firec->ftir->font_type != PSFTI_FONT_TYPE_FREETYPE))
+ {
+ PsOutPtr psOut;
+ ColormapPtr cMap;
+ unsigned short c,
+ c_hiByte,
+ c_lowByte,
+ fontPage;
+ int i;
+
+ if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE )
+ return x;
+
+ PsOut_DownloadType1(psOut, "PsPolyText16",
+ firec->ftir->download_ps_name, firec->ftir->filename);
+ firec->ftir->alreadyDownloaded[fontPage] = True;
+
+ PsOut_Offset(psOut, pDrawable->x, pDrawable->y);
+ PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel));
+ if (!firec->size)
+ PsOut_TextAttrsMtx(psOut, firec->ftir->download_ps_name, firec->mtx, firec->ftir->is_iso_encoding);
+ else
+ PsOut_TextAttrs(psOut, firec->ftir->download_ps_name, firec->size, firec->ftir->is_iso_encoding);
+ PsOut_Text16(psOut, x, y, string, count, -1);
+
+ return x;
+ }
+
+ /* Render glyphs as bitmaps */
+ {
+ unsigned long n, i;
+ int w;
+ CharInfoPtr charinfo[255]; /* encoding only has 1 byte for count */
+
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)string,
+ (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
+ &n, charinfo);
+ w = 0;
+ for (i=0; i < n; i++)
+ w += charinfo[i]->metrics.characterWidth;
+ if (n != 0)
+ PsPolyGlyphBlt(pDrawable, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font));
+ x += w;
+
+ return x;
+ }
}
return x;
}
@@ -386,7 +492,7 @@ PsPolyGlyphBlt(
pointer pGlyphBase)
{
int width, height;
- PixmapPtr pPixmap = NullPixmap;
+ PixmapPtr pPixmap;
int nbyLine; /* bytes per line of padded pixmap */
FontPtr pfont;
GCPtr pGCtmp;
@@ -399,7 +505,7 @@ PsPolyGlyphBlt(
int gWidth, gHeight; /* width and height of glyph */
register int nbyGlyphWidth; /* bytes per scanline of glyph */
int nbyPadGlyph; /* server padded line of glyph */
- int w;
+ int w, tmpx;
XID gcvals[3];
pfont = pGC->font;
@@ -435,6 +541,7 @@ PsPolyGlyphBlt(
PsDestroyPixmap(pPixmap);
return;
}
+ tmpx = 0;
while(nGlyphs--)
{
pci = *pCharInfo++;
@@ -466,8 +573,9 @@ PsPolyGlyphBlt(
1, x + pci->metrics.leftSideBearing,
y - pci->metrics.ascent, gWidth, gHeight,
0, XYBitmap, (char *)pb);
- x += pci->metrics.characterWidth;
}
+
+ x += pci->metrics.characterWidth;
}
DEALLOCATE_LOCAL(pbits);
FreeScratchGC(pGCtmp);
diff --git a/Xprint/ps/PsWindow.c b/Xprint/ps/PsWindow.c
index 987d434ff..3a9a7ed2a 100644
--- a/Xprint/ps/PsWindow.c
+++ b/Xprint/ps/PsWindow.c
@@ -73,11 +73,9 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/PsWindow.c,v 1.12tsi Exp $ */
#include <stdio.h>
#include <string.h>
-#include <sys/types.h>
#include <sys/wait.h>
#include "mistruct.h"
@@ -87,7 +85,8 @@ in this Software without prior written authorization from The Open Group.
#include "Ps.h"
-#if 0
+extern WindowPtr *WindowTable;
+
/*
* The following list of strings defines the properties which will be
* placed on the screen's root window if the property was defined in
@@ -104,7 +103,7 @@ static char *propStrings[] = {
DT_PRINT_PAGE_COMMAND,
(char *)NULL
};
-#endif
+
/*
* PsCreateWindow - watch for the creation of the root window.
@@ -219,6 +218,8 @@ PsPaintWindow(
RegionPtr pRegion,
int what)
{
+ int status;
+ WindowPtr pRoot;
#define FUNCTION 0
#define FOREGROUND 1
@@ -298,6 +299,7 @@ PsPaintWindow(
gcmask |= GCFunction | GCClipMask;
i = pScreen->myNum;
+ pRoot = WindowTable[i];
pBgWin = pWin;
if (what == PW_BORDER)
@@ -375,14 +377,14 @@ PsPaintWindow(
}
break;
case GCClipMask:
- if( (pointer)(long)pGC->clientClipType!=(pointer)CT_NONE )
+ if( (pointer)pGC->clientClipType!=(pointer)CT_NONE )
{
gcmask |= index;
gcval[i++] = (pointer)CT_NONE;
}
break;
case GCSubwindowMode:
- if( (pointer)(long)pGC->subWindowMode!=newValues[SUBWINDOW] )
+ if( (pointer)pGC->subWindowMode!=newValues[SUBWINDOW] )
{
gcmask |= index;
gcval[i++] = newValues[SUBWINDOW];
@@ -396,7 +398,7 @@ PsPaintWindow(
}
break;
case GCFillStyle:
- if( (pointer)(long)pGC->fillStyle!=newValues[FILLSTYLE] )
+ if( (pointer)pGC->fillStyle!=newValues[FILLSTYLE] )
{
gcmask |= index;
gcval[i++] = newValues[FILLSTYLE];
diff --git a/Xprint/ps/psout.c b/Xprint/ps/psout.c
index 6b4c71a2b..d66374a4c 100644
--- a/Xprint/ps/psout.c
+++ b/Xprint/ps/psout.c
@@ -73,79 +73,21 @@ in this Software without prior written authorization from The Open Group.
** *********************************************************
**
********************************************************************/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/psout.c,v 1.11 2001/12/19 21:55:59 dawes Exp $ */
-
-/*
- * For XFree86 3.3.3:
- *
- * As a *quick* way of preventing some buffers overflowing onto the stack,
- * they have been made static. There are potential problems with
- * PsOutRec.Buf overflowing too which should be investigated as part of a
- * review of this code, but that is at least always allocated with malloc
- * and shouldn't pose an immediate stack trashing problem.
- *
- */
#include <stdlib.h>
+#include <stdio.h>
#include "os.h"
-#include "Ps.h"
+#define USE_PSOUT_PRIVATE 1
#include "psout.h"
+#ifdef XP_USE_FREETYPE
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#endif /* XP_USE_FREETYPE */
+/* For VENDOR_STRING and VENDOR_RELEASE */
+#include "site.h"
-typedef void *voidPtr;
-
-typedef struct PsPatRec_
-{
- PsFillEnum type;
- voidPtr tag;
-} PsPatRec;
-
-typedef PsPatRec *PsPatPtr;
-
-typedef struct PsOutRec_
-{
- FILE *Fp;
- char Buf[256];
- int CurColor;
- int LineWidth;
- PsCapEnum LineCap;
- PsJoinEnum LineJoin;
- int NDashes;
- int *Dashes;
- int DashOffset;
- int LineBClr;
- PsRuleEnum FillRule;
- char *FontName;
- int FontSize;
- float FontMtx[4];
- int ImageFormat;
- int RevImage;
- int NPatterns;
- int MxPatterns;
- PsPatPtr Patterns;
- int ClipType;
- PsClipRec Clip;
- int InFrame;
- int XOff;
- int YOff;
-
- PsFillEnum InTile;
- int ImgSkip;
- int ImgBClr;
- int ImgFClr;
- int ImgX;
- int ImgY;
- int ImgW;
- int ImgH;
- int SclW;
- int SclH;
-
- int NDownloads;
- int MxDownloads;
- char **Downloads;
- Bool isRaw;
-
- int start_image;
-} PsOutRec;
+extern PsElmPtr PsCloneFillElementList(int nElms, PsElmPtr elms);
+extern void PsDestroyFillElementList(int nElms, PsElmPtr elms);
/*
* Standard definitions
@@ -174,6 +116,7 @@ static char *S_StandardDefs = "\
/ie{ifelse}bd\
/len{length}bd\
/m{moveto}bd\
+/rm{rmoveto}bd\
/l{lineto}bd\
/rl{rlineto}bd\
/a{arc}bd\
@@ -236,7 +179,11 @@ static char *S_StandardDefs = "\
/mp{makepattern}bd\
/spt{setpattern}bd\
/spd{setpagedevice}bd\
-";
+"
+#ifdef XP_USE_FREETYPE
+"/trmoveto{currentfont /FontMatrix get transform rm}d"
+#endif /* XP_USE_FREETYPE */
+;
/*
* Composite definitions
@@ -341,7 +288,6 @@ static char *S_CompositeDefs = "\
/mtx{scl t [3 i 0 0 5 i 0 0]}bd \
";
-int pagenum = 0;
char *pg_orient[] = {"Portrait","Landscape","Reverse Portrait","Reverse Landscape"};
/*
* Setup definitions
@@ -360,7 +306,7 @@ static char *S_SetupDefs = "\
* PRIVATE FUNCTIONS *
*******************************************************************/
-static void
+void
S_Flush(PsOutPtr self)
{
if( self->Buf[0] )
@@ -388,7 +334,7 @@ S_OutDefs(PsOutPtr self, char *defs)
{
int i, k=0;
S_Flush(self);
- memset(self->Buf, 0, 256);
+ memset(self->Buf, 0, sizeof(self->Buf));
for( i=0 ; defs[i]!='\0' ;)
{
if( k>70 && (i==0 || (i && defs[i-1]!='/')) &&
@@ -396,7 +342,7 @@ S_OutDefs(PsOutPtr self, char *defs)
{
S_Flush(self);
k = 0;
- memset(self->Buf, 0, 256);
+ memset(self->Buf, 0, sizeof(self->Buf));
}
if( k && self->Buf[k-1]==' ' && defs[i]==' ' ) { i++; continue; }
self->Buf[k] = defs[i];
@@ -405,11 +351,11 @@ S_OutDefs(PsOutPtr self, char *defs)
S_Flush(self);
}
-static void
+void
S_OutNum(PsOutPtr self, float num)
{
int i;
- static char buf[64];
+ char buf[64];
sprintf(buf, "%.3f", num);
for( i=strlen(buf)-1 ; buf[i]=='0' ; i-- ); buf[i+1] = '\0';
if( buf[strlen(buf)-1]=='.' ) buf[strlen(buf)-1] = '\0';
@@ -422,7 +368,7 @@ static void
S_OutStr(PsOutPtr self, char *txt, int txtl)
{
int i, k;
- static char buf[512];
+ char buf[1024];
for( i=0,k=0 ; i<txtl ; i++ )
{
if( (txt[i]>=' ' && txt[i]<='~') &&
@@ -430,7 +376,9 @@ S_OutStr(PsOutPtr self, char *txt, int txtl)
{ buf[k] = txt[i]; k++; continue; }
buf[k] = '\\'; k++;
sprintf(&buf[k], "%03o", txt[i]&0xFF);
- k += 3;
+ /* Skip to the end of the buffer */
+ while( buf[k] != '\0' )
+ k++;
}
strcat(self->Buf, "(");
i = strlen(self->Buf);
@@ -440,7 +388,32 @@ S_OutStr(PsOutPtr self, char *txt, int txtl)
if( strlen(self->Buf)>70 ) S_Flush(self);
}
+/* Same as S_OutStr() but takes |short *| instead of |char *| */
static void
+S_OutStr16(PsOutPtr self, unsigned short *txt, int txtl)
+{
+ int i, k;
+ char buf[2048];
+ for( i=0,k=0 ; i<txtl ; i++ )
+ {
+ if( (txt[i]>=' ' && txt[i]<='~') &&
+ txt[i]!='(' && txt[i]!=')' && txt[i]!='\\' )
+ { buf[k] = txt[i]; k++; continue; }
+ buf[k] = '\\'; k++;
+ sprintf(&buf[k], "%03o", txt[i]&0xFFFF);
+ /* Skip to the end of the buffer */
+ while( buf[k] != '\0' )
+ k++;
+ }
+ strcat(self->Buf, "(");
+ i = strlen(self->Buf);
+ memcpy(&self->Buf[i], buf, k);
+ self->Buf[i+k] = '\0';
+ strcat(self->Buf, ")");
+ if( strlen(self->Buf)>70 ) S_Flush(self);
+}
+
+void
S_OutTok(PsOutPtr self, char *tok, int cr)
{
if( self->Buf[0] ) strcat(self->Buf, " ");
@@ -471,6 +444,27 @@ S_SetPageDevice(PsOutPtr self, int orient, int count, int plex, int res,
float fwd = ((float)wd/(float)res)*72.;
float fht = ((float)ht/(float)res)*72.;
+#define USE_WORKAROUND_COPY_COUNT_BUG 1
+
+#ifdef USE_WORKAROUND_COPY_COUNT_BUG
+ /* Workaround (see http://xprint.mozdev.org/bugs/show_bug.cgi?id=1861 -
+ * 'Need workaround for bug 1378 ...') to avoid that we print n^2 copies
+ * instead of n copies.
+ * The problem is that we use both /NumCopies here but pass the
+ * %copy-count% to the spooler, too.
+ * But we only have to use _one_ way...
+ *
+ * The final fix for bug 1378 (http://xprint.mozdev.org/bugs/show_bug.cgi?id=1378 -
+ * "PS DDX creates n^2 copies of a job instead of n copies") will back this
+ * workaround out and replace it with a better solution.
+ * (see mozilla.org bug 140030
+ * (http://bugzilla.mozilla.org/show_bug.cgi?id=140030 - "Setting number
+ * of copies causes too many copies to print") for the initial report for
+ * this issue...)
+ */
+ count = 1;
+#endif /* USE_WORKAROUND_COPY_COUNT_BUG */
+
S_OutTok(self, "/pWd", 0);
S_OutNum(self, fwd);
S_OutTok(self, "d /pHt", 0);
@@ -577,10 +571,11 @@ PsOut_ChangeFile(PsOutPtr self, FILE *fp)
}
PsOutPtr
-PsOut_BeginFile(FILE *fp, int orient, int count, int plex, int res,
+PsOut_BeginFile(FILE *fp, char *title, int orient, int count, int plex, int res,
int wd, int ht, Bool raw)
{
int i;
+ char buffer[256+32]; /* enougth space for a title with 256 chars... */
/*
* Get ready to output PostScript header
*/
@@ -589,15 +584,41 @@ PsOut_BeginFile(FILE *fp, int orient, int count, int plex, int res,
memset(psout, 0, sizeof(PsOutRec));
psout->Fp = fp;
psout->isRaw = raw;
- pagenum = 0;
+ psout->pagenum = 0;
if (!raw) {
/*
* Output PostScript header
*/
- S_Comment(psout, "%!PS-Adobe-3.0 EPSF-3.0");
- S_Comment(psout, "%%Creator: The Open Group PostScript Print Server");
- /*### BoundingBox ###*/
+ /* GhostScript will rant about the missing BoundingBox if we use
+ * "%!PS-Adobe-3.0 EPSF-3.0" here... */
+ S_Comment(psout, "%!PS-Adobe-3.0");
+#ifdef XP_USE_FREETYPE
+ {
+ FT_Int ftmajor = 0,
+ ftminor = 0,
+ ftpatch = 0;
+ extern FT_Library ftypeLibrary; /* defined in xc/lib/font/FreeType/ftfuncs.c */
+
+ FT_Library_Version(ftypeLibrary, &ftmajor, &ftminor, &ftpatch);
+ sprintf(buffer,
+ "%%%%Creator: The X Print Server's PostScript DDX "
+ "(%s, release %d, FreeType version %d.%d.%d)",
+ VENDOR_STRING, VENDOR_RELEASE,
+ (int)ftmajor, (int)ftminor, (int)ftpatch);
+ }
+#else
+ sprintf(buffer,
+ "%%%%Creator: The X Print Server's PostScript DDX (%s, release %d)",
+ VENDOR_STRING, VENDOR_RELEASE);
+#endif /* XP_USE_FREETYPE */
+ S_Comment(psout, buffer);
+
+ if (title)
+ {
+ sprintf(buffer, "%%%%Title: %.256s", title);
+ S_Comment(psout, buffer);
+ }
S_Comment(psout, "%%EndComments");
S_Comment(psout, "%%BeginProlog");
S_Comment(psout, "%%BeginProcSet: XServer_PS_Functions");
@@ -634,10 +655,13 @@ PsOut_EndFile(PsOutPtr self, int closeFile)
{
char coms[50];
int i;
+
+ if (!self)
+ return;
if (!self->isRaw) {
S_Comment(self,"%%Trailer");
- sprintf(coms,"%%%%Pages: %d",pagenum);
+ sprintf(coms,"%%%%Pages: %d", self->pagenum);
S_Comment(self, coms);
S_Comment(self, "%%EOF");
}
@@ -646,9 +670,6 @@ PsOut_EndFile(PsOutPtr self, int closeFile)
if( self->Patterns ) xfree(self->Patterns);
if( self->Clip.rects ) xfree(self->Clip.rects);
if( closeFile ) fclose(self->Fp);
- for( i=0 ; i<self->NDownloads ; i++ ) xfree(self->Downloads[i]);
- if( self->Downloads ) xfree(self->Downloads);
- pagenum = 0; /* reset page num back to 0 */
xfree(self);
}
@@ -661,8 +682,8 @@ PsOut_BeginPage(PsOutPtr self, int orient, int count, int plex, int res,
/*** comment for pagenumbers *****/
S_Comment(self,"%%PageHeader");
- pagenum++;
- sprintf(coms,"%%%%Page: %d %d",pagenum,pagenum);
+ self->pagenum++;
+ sprintf(coms,"%%%%Page: %d %d", self->pagenum, self->pagenum);
S_Comment(self, coms);
sprintf(coms,"%%%%PageOrientation: %s",pg_orient[orient]);
S_Comment(self, coms);
@@ -959,7 +980,7 @@ void
PsOut_TextAttrs(PsOutPtr self, char *fnam, int siz, int iso)
{
int i;
- static char buf[256];
+ char buf[256];
if( self->FontName && strcmp(fnam, self->FontName)==0 &&
siz==self->FontSize ) return;
if( self->FontName ) xfree(self->FontName);
@@ -979,7 +1000,7 @@ void
PsOut_TextAttrsMtx(PsOutPtr self, char *fnam, float *mtx, int iso)
{
int i;
- static char buf[256];
+ char buf[256];
if( self->FontName && strcmp(fnam, self->FontName)==0 &&
mtx[0]==self->FontMtx[0] && mtx[1]==self->FontMtx[1] &&
mtx[2]==self->FontMtx[2] && mtx[3]==self->FontMtx[3] ) return;
@@ -1171,6 +1192,30 @@ PsOut_Text(PsOutPtr self, int x, int y, char *text, int textl, int bclr)
}
}
+void
+PsOut_Text16(PsOutPtr self, int x, int y, unsigned short *text, int textl, int bclr)
+{
+ int xo = self->XOff;
+ int yo = self->YOff;
+
+ if( self->InFrame || self->InTile ) xo = yo = 0;
+ x += xo; y += yo;
+ S_OutStr16(self, text, textl);
+ S_OutNum(self, (float)x);
+ S_OutNum(self, (float)y);
+ if( bclr<0 ) S_OutTok(self, "T", 1);
+ else
+ {
+ int ir = bclr>>16;
+ int ig = (bclr>>8)&0xFF;
+ int ib = bclr&0xFF;
+ S_OutNum(self, (float)ir/255.);
+ S_OutNum(self, (float)ig/255.);
+ S_OutNum(self, (float)ib/255.);
+ S_OutTok(self, "Tb", 1);
+ }
+}
+
#ifdef BM_CACHE
void /* new */
PsOut_ImageCache(PsOutPtr self, int x, int y, long cache_id, int bclr, int fclr)
@@ -1181,7 +1226,7 @@ PsOut_ImageCache(PsOutPtr self, int x, int y, long cache_id, int bclr, int fclr)
if( self->InFrame || self->InTile ) xo = yo = 0;
x += xo; y += yo;
- sprintf(cacheID, "c%ldi", cache_id);
+ sprintf(cacheID, "c%di", cache_id);
S_OutNum(self, (float)x);
S_OutNum(self, (float)y);
@@ -1214,7 +1259,7 @@ PsOut_BeginImageCache(PsOutPtr self, long cache_id)
{
char cacheID[10];
- sprintf(cacheID, "/c%ldi {", cache_id);
+ sprintf(cacheID, "/c%di {", cache_id);
S_OutTok(self, cacheID, 0);
} /* new */
@@ -1225,7 +1270,7 @@ PsOut_EndImageCache(PsOutPtr self)
S_OutTok(self, "}bd", 1);
} /* new */
#endif
-
+
void
PsOut_BeginImage(PsOutPtr self, int bclr, int fclr, int x, int y,
int w, int h, int sw, int sh, int format)
@@ -1488,13 +1533,11 @@ PsOut_BeginPattern(PsOutPtr self, void *tag, int w, int h, PsFillEnum type,
}
self->Patterns[self->NPatterns].tag = tag;
self->Patterns[self->NPatterns].type = type;
- sprintf(key, "/ %ld", (long)tag);
+ sprintf(key, "/ %d", (int)tag);
switch(type) {
case PsTile: key[1] = 't'; break;
case PsStip: key[1] = 's'; break;
- case PsOpStip: key[1] = 'o'; break;
- default: break;
- }
+ case PsOpStip: key[1] = 'o'; break; }
S_OutTok(self, key, 0);
S_OutTok(self, "db/PatternType 1 d/PaintType 1 d", 0);
S_OutTok(self, "/TilingType 1 d/BBox[0 0", 0);
@@ -1535,13 +1578,11 @@ PsOut_SetPattern(PsOutPtr self, void *tag, PsFillEnum type)
for( i=0 ; i<self->NPatterns ; i++ )
{ if( tag==self->Patterns[i].tag && type==self->Patterns[i].type ) break; }
if( i>=self->NPatterns ) return;
- sprintf(key, " %ld", (long)tag);
+ sprintf(key, " %d", (int)tag);
switch(type) {
case PsTile: key[0] = 't'; break;
case PsStip: key[0] = 's'; break;
- case PsOpStip: key[0] = 'o'; break;
- default: break;
- }
+ case PsOpStip: key[0] = 'o'; break; }
S_OutTok(self, key, 0);
S_OutTok(self, "spt", 1);
self->CurColor = 0xFFFFFFFF;
@@ -1556,83 +1597,141 @@ PsOut_RawData(PsOutPtr self, char *data, int len)
}
}
-void
-PsOut_DownloadType1(PsOutPtr self, char *name, char *fname)
+typedef enum PsDownfontFontType_
+{
+ PsDFT_Type1PFA=0,
+ PsDFT_Type1PFB,
+ PsDFT_TrueType /* not implemented yet */
+} PsDownfontFontType;
+
+/* Download a PS Type1 font */
+int
+PsOut_DownloadType1(PsOutPtr self, const char *auditmsg, const char *name, const char *fname)
{
int i;
int stt;
- static char buf[256];
+ char buf[256];
FILE *fp;
+ PsDownfontFontType type;
+
+ fp = fopen(fname, "r");
+ if( !fp )
+ return 0;
+
+#ifdef DEBUG_gisburn
+ /* This should be log-able! */
+ fprintf(stderr, "PsOut_DownloadType1: %s: Downloading '%s' from '%s'\n", auditmsg, name, fname);
+#endif /* DEBUG_gisburn */
- for( i=0 ; i<self->NDownloads ; i++ )
- { if( strcmp(name, self->Downloads[i])==0 ) break; }
- if( i<self->NDownloads ) return;
+ fread(buf, 32, 1, fp);
+ fseek(fp, (long)0, 0);
- if( (self->NDownloads+1)>self->MxDownloads )
+ /* Is this a Adobe PostScript Type 1 binary font (PFB) ? */
+ if( (buf[0]&0xFF)==0x80 && (buf[1]&0xFF)==0x01 )
{
- if( self->NDownloads )
- {
- self->MxDownloads *= 2;
- self->Downloads = (char **)xrealloc(self->Downloads,
- self->MxDownloads*sizeof(char *));
- }
- else
- {
- self->MxDownloads = 32;
- self->Downloads = (char **)xalloc(self->MxDownloads*sizeof(char *));
- }
+ type = PsDFT_Type1PFB;
+ }
+ /* Is this a Adobe PostScript ASCII font (PFA) ? */
+ else if (!strncmp(buf, "%!PS-AdobeFont", 14))
+ {
+ type = PsDFT_Type1PFA;
}
-
- self->Downloads[self->NDownloads] = (char *)xalloc(strlen(name)+1);
- strcpy(self->Downloads[self->NDownloads], name);
- self->NDownloads += 1;
+ else
+ {
+ /* This should be log-able! */
+ fprintf(stderr, "PsOut_DownloadType1: Unknown font type for '%s'\n", fname);
+ return 0;
+ }
S_Flush(self);
sprintf(buf, "%%%%BeginFont: %s", name);
S_Comment(self, buf);
- fp = fopen(fname, "r");
- if( !fp ) return;
- fread(buf, 1, 1, fp);
- fseek(fp, (long)0, 0);
- if( (buf[0]&0xFF)==0x80 )
- {
- int len;
- for(;;)
+ if( type == PsDFT_Type1PFB )
+ {
+ char *buf,
+ *pt;
+ int len,
+ ch,
+ stype;
+
+ ch = fgetc(fp);
+ /* Strip out the binary headers and de-binary it */
+ while( (ch&0xFF) == 0x80 )
{
- stt = fread(buf, 1, 2, fp);
- if( stt!=2 || (buf[0]&0xFF)!=0x80 ) break;
- if( (int)buf[1]<1 || (int)buf[1]>2 ) break;
- stt = fread(buf, 1, 4, fp);
- if( stt!=4 ) break;
- len = ((buf[3]&0xFF)<<24)|((buf[2]&0xFF)<<16)|
- ((buf[1]&0xFF)<<8)|(buf[0]&0xFF);
- for(; len ;)
+ stype = fgetc(fp);
+ if( stype==3 ) /* eof mark */
+ break;
+ len = fgetc(fp);
+ len |= fgetc(fp)<<8;
+ len |= fgetc(fp)<<16;
+ len |= fgetc(fp)<<24;
+ buf = (char *)xalloc(len+1);
+ if( stype==1 )
+ {
+ /* Process ASCII section */
+ len = fread(buf, 1, len, fp);
+ /* convert any lone CRs (ie Mac eol) to LFs */
+ for( pt = buf ; (pt = memchr(pt, '\r', len-(pt-buf))) != NULL ; pt++ )
+ {
+ if ( pt[1]!='\n' )
+ *pt = '\n';
+ }
+ fwrite(buf, 1, len, self->Fp);
+ }
+ else if( stype==2 )
{
- i = len<256 ? len : 256;
- stt = fread(buf, 1, i, fp);
- if( stt<=0 ) break;
- if (!ferror(self->Fp)) {
- (void) fwrite(buf, 1, stt, self->Fp);
- }
- if( stt<i ) break;
- len -= i;
+ int i;
+
+ /* Process binary section */
+ len = fread(buf, 1, len, fp);
+ for( i=0 ; i<len ; i++ )
+ {
+ ch = buf[i];
+ if( ((ch>>4)&0xf) <= 9 )
+ fputc('0'+((ch>>4)&0xf), self->Fp);
+ else
+ fputc('A'-10+((ch>>4)&0xf), self->Fp);
+
+ if( (ch&0xf) <= 9 )
+ fputc('0'+(ch&0xf), self->Fp);
+ else
+ fputc('A'-10+(ch&0xf), self->Fp);
+
+ if( (i&0x1f)==0x1f )
+ fputc('\n', self->Fp);
+ }
}
+ xfree(buf);
+
+ /* Next block... */
+ ch = fgetc(fp);
}
}
- else
+ /* Is this a Adobe PostScript ASCII font (PFA) ? */
+ else if (type == PsDFT_Type1PFA)
{
for(;;)
{
stt = fread(buf, 1, 256, fp);
if( stt<=0 ) break;
if (!ferror(self->Fp)) {
- (void) fwrite(buf, 1, stt, self->Fp);
+ (void) fwrite(buf, 1, stt, self->Fp);
}
- if( stt<256 ) break;
+ if( stt<256 )
+ break;
}
}
fclose(fp);
S_Flush(self);
S_Comment(self, "%%EndFont");
+
+ /* Success... */
+ return 1;
}
+
+
+
+
+
+
diff --git a/Xprint/ps/psout.h b/Xprint/ps/psout.h
index 37b089ece..c592d7250 100644
--- a/Xprint/ps/psout.h
+++ b/Xprint/ps/psout.h
@@ -57,7 +57,6 @@ in this Software without prior written authorization from The Open Group.
* or other dealings in this Software without prior written authorization
* from said copyright holders.
*/
-/* $XFree86: xc/programs/Xserver/Xprint/ps/psout.h,v 1.4 2001/12/14 19:59:18 dawes Exp $ */
/*******************************************************************
**
@@ -147,10 +146,80 @@ typedef struct PsClipRec_
typedef PsClipRec *PsClipPtr;
+typedef enum PsFTDownloadFontType_
+{
+ PsFontBitmap=0,
+ PsFontType1,
+ PsFontType3
+} PsFTDownloadFontType;
+
+#ifdef USE_PSOUT_PRIVATE
+typedef void *voidPtr;
+
+typedef struct PsPatRec_
+{
+ PsFillEnum type;
+ voidPtr tag;
+} PsPatRec;
+
+typedef PsPatRec *PsPatPtr;
+
+typedef struct PsOutRec_
+{
+ FILE *Fp;
+ char Buf[16384];
+ int CurColor;
+ int LineWidth;
+ PsCapEnum LineCap;
+ PsJoinEnum LineJoin;
+ int NDashes;
+ int *Dashes;
+ int DashOffset;
+ int LineBClr;
+ PsRuleEnum FillRule;
+ char *FontName;
+ int FontSize;
+ float FontMtx[4];
+ int ImageFormat;
+ int RevImage;
+ int NPatterns;
+ int MxPatterns;
+ PsPatPtr Patterns;
+ int ClipType;
+ PsClipRec Clip;
+ int InFrame;
+ int XOff;
+ int YOff;
+
+ PsFillEnum InTile;
+ int ImgSkip;
+ int ImgBClr;
+ int ImgFClr;
+ int ImgX;
+ int ImgY;
+ int ImgW;
+ int ImgH;
+ int SclW;
+ int SclH;
+
+ Bool isRaw;
+
+ int pagenum;
+
+ int start_image;
+} PsOutRec;
+
typedef struct PsOutRec_ *PsOutPtr;
-extern PsOutPtr PsOut_BeginFile(FILE *fp, int orient, int count, int plex,
- int res, int wd, int ht, Bool raw);
+extern void S_Flush(PsOutPtr self);
+extern void S_OutNum(PsOutPtr self, float num);
+extern void S_OutTok(PsOutPtr self, char *tok, int cr);
+#else
+typedef struct PsOutRec_ *PsOutPtr;
+#endif /* USE_PSOUT_PRIVATE */
+
+extern PsOutPtr PsOut_BeginFile(FILE *fp, char *title, int orient, int count, int plex,
+ int res, int wd, int ht, Bool raw);
extern void PsOut_EndFile(PsOutPtr self, int closeFile);
extern void PsOut_BeginPage(PsOutPtr self, int orient, int count, int plex,
int res, int wd, int ht);
@@ -182,8 +251,9 @@ extern void PsOut_DrawArc(PsOutPtr self, int x, int y, int w, int h,
extern void PsOut_Text(PsOutPtr self, int x, int y, char *text, int textl,
int bclr);
+extern void PsOut_Text16(PsOutPtr self, int x, int y, unsigned short *text, int textl, int bclr);
-extern void PsOut_BeginImage(PsOutPtr self, int bclr, int fclr, int x, int y,
+extern void PsOut_BeginImage(PsOutPtr self, int bclr, int fclr, int x, int y,
int w, int h, int sw, int sh, int format);
extern void PsOut_BeginImageIM(PsOutPtr self, int bclr, int fclr, int x, int y,
int w, int h, int sw, int sh, int format);
@@ -200,16 +270,17 @@ extern void PsOut_EndPattern(PsOutPtr self);
extern void PsOut_SetPattern(PsOutPtr self, void *tag, PsFillEnum type);
extern void PsOut_RawData(PsOutPtr self, char *data, int len);
-extern void PsOut_DownloadType1(PsOutPtr self, char *name, char *fname);
-#ifdef BM_CACHE
-extern void PsOut_BeginImageCache(PsOutPtr self, long cache_id);
-extern void PsOut_EndImageCache(PsOutPtr self);
-extern void PsOut_ImageCache(PsOutPtr self, int x, int y, long cache_id,
- int bclr, int fclr);
-#endif
+extern int PsOut_DownloadType1(PsOutPtr self, const char *auditmsg, const char *name, const char *fname);
-extern FILE *PsOut_ChangeFile(PsOutPtr self, FILE *fp);
+extern int PsOut_DownloadFreeType1(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset);
+extern int PsOut_DownloadFreeType3(PsOutPtr self, const char *psfontname, FontPtr pFont, long block_offset);
+extern int PsOut_DownloadFreeType(PsOutPtr self, PsFTDownloadFontType downloadfonttype, const char *psfontname, FontPtr pFont, long block_offset);
+extern void PsOut_Get_FreeType_Glyph_Name( char *destbuf, FontPtr pFont, unsigned long x11fontindex);
+extern void PsOut_FreeType_Text(FontPtr pFont, PsOutPtr self, int x, int y, char *text, int textl);
+extern void PsOut_FreeType_Text16(FontPtr pFont, PsOutPtr self, int x, int y, unsigned short *text, int textl);
+extern void PsOut_FreeType_TextAttrs16(PsOutPtr self, char *fnam, int siz, int iso);
+extern void PsOut_FreeType_TextAttrsMtx16(PsOutPtr self, char *fnam, float *mtx, int iso);
#endif
diff --git a/Xprint/ps/ttf2pt1wrap.c b/Xprint/ps/ttf2pt1wrap.c
new file mode 100644
index 000000000..bd5ef526e
--- /dev/null
+++ b/Xprint/ps/ttf2pt1wrap.c
@@ -0,0 +1,10 @@
+/*
+ * Wrapper to add missing symbol to externally supplied code
+ */
+
+#ifdef Lynx
+extern int optind;
+extern char *optarg;
+#endif
+
+#include "ttf2pt1.c"