summaryrefslogtreecommitdiff
path: root/src/Type1
diff options
context:
space:
mode:
Diffstat (limited to 'src/Type1')
-rw-r--r--src/Type1/arith.c47
-rw-r--r--src/Type1/arith.h19
-rw-r--r--src/Type1/blues.h4
-rw-r--r--src/Type1/curves.c39
-rw-r--r--src/Type1/curves.h10
-rw-r--r--src/Type1/fontfcn.c462
-rw-r--r--src/Type1/fontfcn.h153
-rw-r--r--src/Type1/hints.c103
-rw-r--r--src/Type1/hints.h18
-rw-r--r--src/Type1/lines.c3
-rw-r--r--src/Type1/lines.h6
-rw-r--r--src/Type1/objects.c198
-rw-r--r--src/Type1/objects.h129
-rw-r--r--src/Type1/paths.c211
-rw-r--r--src/Type1/paths.h90
-rw-r--r--src/Type1/pictures.h6
-rw-r--r--src/Type1/regions.c261
-rw-r--r--src/Type1/regions.h69
-rw-r--r--src/Type1/scanfont.c1672
-rw-r--r--src/Type1/spaces.c239
-rw-r--r--src/Type1/spaces.h104
-rw-r--r--src/Type1/t1funcs.c1219
-rw-r--r--src/Type1/t1imager.h94
-rw-r--r--src/Type1/t1info.c703
-rw-r--r--src/Type1/t1intf.h109
-rw-r--r--src/Type1/t1io.c165
-rw-r--r--src/Type1/t1malloc.c134
-rw-r--r--src/Type1/t1snap.c17
-rw-r--r--src/Type1/t1stdio.h39
-rw-r--r--src/Type1/t1stub.c22
-rw-r--r--src/Type1/token.c143
-rw-r--r--src/Type1/token.h4
-rw-r--r--src/Type1/tokst.h68
-rw-r--r--src/Type1/trig.h6
-rw-r--r--src/Type1/type1.c364
-rw-r--r--src/Type1/util.c86
-rw-r--r--src/Type1/util.h48
37 files changed, 5308 insertions, 1756 deletions
diff --git a/src/Type1/arith.c b/src/Type1/arith.c
index 65162ea..693b970 100644
--- a/src/Type1/arith.c
+++ b/src/Type1/arith.c
@@ -26,6 +26,8 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/arith.c,v 1.6 2002/02/18 20:51:57 herrb Exp $ */
+
/* ARITH CWEB V0006 ******** */
/*
:h1.ARITH Module - Portable Module for Multiple Precision Fixed Point Arithmetic
@@ -48,9 +50,11 @@ assembly language, unlike C, will have 64-bit multiply products and
The included files are:
*/
+#include "os.h"
#include "objects.h"
#include "spaces.h"
#include "arith.h"
+
/*
:h3.
@@ -104,10 +108,8 @@ SIGNBITON tests the high order bit of a long 'w':
The two multiplicands must be positive.
*/
-void DLmult(product, u, v)
- register doublelong *product;
- register unsigned long u;
- register unsigned long v;
+void
+DLmult(doublelong *product, unsigned long u, unsigned long v)
{
#ifdef LONG64
/* printf("DLmult(? ?, %lx, %lx)\n", u, v); */
@@ -155,9 +157,9 @@ void DLmult(product, u, v)
Both the dividend and the divisor must be positive.
*/
-void DLdiv(quotient, divisor)
- doublelong *quotient; /* also where dividend is, originally */
- unsigned long divisor;
+void
+DLdiv(doublelong *quotient, /* also where dividend is, originally */
+ unsigned long divisor)
{
#ifdef LONG64
/* printf("DLdiv(%lx %lx)\n", quotient, divisor); */
@@ -213,7 +215,7 @@ void DLdiv(quotient, divisor)
divisor >>= 1;
if ((u1u2 >> (LONGSIZE - shift)) != 0 && shift != 0)
- abort("DLdiv: dividend too large");
+ Abort("DLdiv: dividend too large");
u1u2 = (u1u2 << shift) + ((shift == 0) ? 0 : u3u4 >> (LONGSIZE - shift));
u3u4 <<= shift;
@@ -276,7 +278,7 @@ void DLdiv(quotient, divisor)
*/
u1u2 = t;
if (HIGHDIGIT(u1u2) != 0)
- abort("divide algorithm error");
+ Abort("divide algorithm error");
u1u2 = ASSEMBLE(u1u2, LOWDIGIT(u3));
u3 = LOWDIGIT(u3u4);
q3q4 = ASSEMBLE(q3q4, qhat);
@@ -299,9 +301,9 @@ carry. Conversely, if there was a carry, the sum of the lows must be
less than the max of the lows. So, the test is "if and only if".
*/
-void DLadd(u, v)
- doublelong *u; /* u = u + v */
- doublelong *v;
+void
+DLadd(doublelong *u, /* u = u + v */
+ doublelong *v)
{
#ifdef LONG64
/* printf("DLadd(%lx %lx)\n", *u, *v); */
@@ -324,9 +326,9 @@ Testing for a borrow is even easier. If the v.low is greater than
u.low, there must be a borrow.
*/
-void DLsub(u, v)
- doublelong *u; /* u = u - v */
- doublelong *v;
+void
+DLsub(doublelong *u, /* u = u - v */
+ doublelong *v)
{
#ifdef LONG64
/* printf("DLsub(%lx %lx)\n", *u, *v); */
@@ -358,8 +360,8 @@ overflow will occur when the resulting value is passed back as
a fractpel.
*/
-fractpel FPmult(u, v)
- register fractpel u,v;
+fractpel
+FPmult(fractpel u, fractpel v)
{
doublelong w;
register int negative = FALSE; /* sign flag */
@@ -403,9 +405,8 @@ fractpel FPmult(u, v)
These values may be signed. The function returns the quotient.
*/
-fractpel FPdiv(dividend, divisor)
- register fractpel dividend;
- register fractpel divisor;
+fractpel
+FPdiv(fractpel dividend, fractpel divisor)
{
doublelong w; /* result will be built here */
int negative = FALSE; /* flag for sign bit */
@@ -451,8 +452,10 @@ an operator that first multiplies by one constant then divides by
another, keeping the intermediate result in extended precision.
*/
-fractpel FPstarslash(a, b, c)
- register fractpel a,b,c; /* result = a * b / c */
+fractpel
+FPstarslash(fractpel a, /* result = a * b / c */
+ fractpel b,
+ fractpel c)
{
doublelong w; /* result will be built here */
int negative = FALSE;
diff --git a/src/Type1/arith.h b/src/Type1/arith.h
index ab9412b..0eae659 100644
--- a/src/Type1/arith.h
+++ b/src/Type1/arith.h
@@ -26,21 +26,20 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/arith.h,v 1.5 2001/01/17 19:43:22 dawes Exp $ */
+
/*SHARED*/
#include <X11/Xmd.h> /* LONG64 */
-void DLmult(),DLdiv(),DLadd(),DLsub();
-
-fractpel FPmult();
-fractpel FPdiv();
-fractpel FPstarslash();
-
/*END SHARED*/
/*SHARED*/
+#undef SHORTSIZE
#define SHORTSIZE (sizeof(short)*8)
+#undef LONGSIZE
#define LONGSIZE (SHORTSIZE*2)
+#undef MAXSHORT
#define MAXSHORT ((1<<SHORTSIZE)-1)
/*END SHARED*/
@@ -67,4 +66,12 @@ typedef struct {
}
#endif
+extern void DLmult ( doublelong *product, unsigned long u, unsigned long v );
+extern void DLdiv ( doublelong *quotient, unsigned long divisor );
+extern void DLadd ( doublelong *u, doublelong *v );
+extern void DLsub ( doublelong *u, doublelong *v );
+extern fractpel FPmult ( fractpel u, fractpel v );
+extern fractpel FPdiv ( fractpel dividend, fractpel divisor );
+extern fractpel FPstarslash ( fractpel a, fractpel b, fractpel c );
+
/*END SHARED*/
diff --git a/src/Type1/blues.h b/src/Type1/blues.h
index 2480b14..c3943ec 100644
--- a/src/Type1/blues.h
+++ b/src/Type1/blues.h
@@ -28,8 +28,10 @@
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/blues.h,v 1.4 2001/01/17 19:43:22 dawes Exp $ */
+
-extern psobj *GetType1CharString();
+extern psobj *GetType1CharString ( psfont *fontP, unsigned char code );
#define TOPLEFT 1
#define BOTTOMRIGHT 2
diff --git a/src/Type1/curves.c b/src/Type1/curves.c
index d1033fe..206958a 100644
--- a/src/Type1/curves.c
+++ b/src/Type1/curves.c
@@ -29,6 +29,8 @@
/* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT */
/* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS */
/* SOFTWARE. */
+/* $XFree86: xc/lib/font/Type1/curves.c,v 1.8 2002/02/18 20:51:57 herrb Exp $ */
+
/*
:h1.CURVES Module - Stepping Beziers
@@ -42,6 +44,7 @@ through.
Include files needed:
*/
+#include "os.h"
#include "objects.h"
#include "spaces.h"
#include "paths.h"
@@ -88,8 +91,11 @@ struct bezierinfo {
to subdivide.
*/
-static int BezierTerminationTest(xa,ya,xb,yb,xc,yc,xd,yd)
-fractpel xa,ya,xb,yb,xc,yc,xd,yd;
+static int
+BezierTerminationTest(fractpel xa, fractpel ya,
+ fractpel xb, fractpel yb,
+ fractpel xc, fractpel yc,
+ fractpel xd, fractpel yd)
{
fractpel dmax;
dmax = ABS(xa - xb);
@@ -112,13 +118,12 @@ Bezier to define his curves as he did. If the input region 'R' is NULL,
the result is a path that is the 'flattened' curve; otherwise StepBezier
returns nothing special.
*/
-static struct segment *StepBezierRecurse(I,xA,yA,xB,yB,xC,yC,xD,yD)
- struct bezierinfo *I; /* Region under construction or NULL */
- fractpel xA,yA; /* A control point */
- fractpel xB,yB; /* B control point */
- fractpel xC,yC; /* C control point */
- fractpel xD,yD; /* D control point */
-
+static struct segment *
+StepBezierRecurse(struct bezierinfo *I, /* Region under construction or NULL */
+ fractpel xA, fractpel yA, /* A control point */
+ fractpel xB, fractpel yB, /* B control point */
+ fractpel xC, fractpel yC, /* C control point */
+ fractpel xD, fractpel yD) /* D control point */
{
if (BezierTerminationTest(xA,yA,xB,yB,xC,yC,xD,yD))
{
@@ -167,6 +172,7 @@ static struct segment *StepBezierRecurse(I,xA,yA,xB,yB,xC,yC,xD,yD)
StepBezierRecurse(I, xABCD, yABCD, xBCD, yBCD, xCD, yCD, xD, yD);
}
}
+ return NULL;
/*NOTREACHED*/
}
@@ -177,6 +183,7 @@ Intermediate values in the Bezier subdivision are 8 times bigger than
the starting values. If this overflows, a 'long', we are in trouble:
*/
+#undef BITS
#define BITS (sizeof(long)*8)
#define HIGHTEST(p) (((p)>>(BITS-4)) != 0) /* includes sign bit */
#define TOOBIG(xy) ((xy < 0) ? HIGHTEST(-xy) : HIGHTEST(xy))
@@ -187,12 +194,12 @@ the starting values. If this overflows, a 'long', we are in trouble:
This is the entry point called from outside the module.
*/
-struct segment *StepBezier(R, xA, yA, xB, yB, xC, yC, xD, yD)
- struct region *R; /* Region under construction or NULL */
- fractpel xA,yA; /* A control point */
- fractpel xB,yB; /* B control point */
- fractpel xC,yC; /* C control point */
- fractpel xD,yD; /* D control point */
+struct segment *
+StepBezier(struct region *R, /* Region under construction or NULL */
+ fractpel xA, fractpel yA, /* A control point */
+ fractpel xB, fractpel yB, /* B control point */
+ fractpel xC, fractpel yC, /* C control point */
+ fractpel xD, fractpel yD) /* D control point */
{
struct bezierinfo Info;
@@ -209,7 +216,7 @@ struct segment *StepBezier(R, xA, yA, xB, yB, xC, yC, xD, yD)
if ( TOOBIG(xB) || TOOBIG(yB) || TOOBIG(xC) || TOOBIG(yC)
|| TOOBIG(xD) || TOOBIG(yD) )
- abort("Beziers this big not yet supported");
+ Abort("Beziers this big not yet supported");
return(StepBezierRecurse(&Info,
(fractpel) 0, (fractpel) 0, xB, yB, xC, yC, xD, yD));
diff --git a/src/Type1/curves.h b/src/Type1/curves.h
index 4138a6f..ff2bf48 100644
--- a/src/Type1/curves.h
+++ b/src/Type1/curves.h
@@ -26,6 +26,8 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/curves.h,v 1.4 2001/01/17 19:43:22 dawes Exp $ */
+
/*SHARED*/
#define StepConic(R,xA,yA,xB,yB,xC,yC,r) t1_StepConic(R,xA,yA,xB,yB,xC,yC,r)
@@ -33,8 +35,10 @@
#define FlattenConic(xM,yM,xC,yC,r) t1_StepConic(NULL,(fractpel)0,(fractpel)0,xM,yM,xC,yC,r)
#define FlattenBezier(xB,yB,xC,yC,xD,yD) t1_StepBezier(NULL,(fractpel)0,(fractpel)0,xB,yB,xC,yC,xD,yD)
-
+
+#if 0
struct segment *t1_StepConic();
-struct segment *t1_StepBezier();
-
+#endif
+extern struct segment *t1_StepBezier ( struct region *R, fractpel xA, fractpel yA, fractpel xB, fractpel yB, fractpel xC, fractpel yC, fractpel xD, fractpel yD );
+
/*END SHARED*/
diff --git a/src/Type1/fontfcn.c b/src/Type1/fontfcn.c
index 5516468..471a4ee 100644
--- a/src/Type1/fontfcn.c
+++ b/src/Type1/fontfcn.c
@@ -1,4 +1,4 @@
-/* $Xorg: fontfcn.c,v 1.5 2000/12/01 16:26:25 steve Exp $ */
+/* $Xorg: fontfcn.c,v 1.4 2000/08/17 19:46:30 cpqbld Exp $ */
/* Copyright International Business Machines,Corp. 1991
* All Rights Reserved
*
@@ -28,15 +28,55 @@
* SOFTWARE.
*/
/* Author: Katherine A. Hitchcock IBM Almaden Research Laboratory */
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/fontfcn.c,v 1.11 2001/11/23 19:21:31 dawes Exp $ */
+#ifndef FONTMODULE
#include <stdio.h>
#include <string.h>
+#else
+#include "Xmd.h" /* For INT32 declaration */
+#include "Xdefs.h" /* For Bool */
+#include "xf86_ansic.h"
+#endif
#include "t1imager.h"
#include "util.h"
+#ifdef BUILDCID
+#include "range.h"
+#include "Xdefs.h"
+#endif
+#include "fntfilst.h"
#include "fontfcn.h"
-#include "fontmisc.h"
-
-extern xobject Type1Char();
+
+extern struct segment *Type1Char ( char *env, XYspace S,
+ psobj *charstrP, psobj *subrsP,
+ psobj *osubrsP,
+ struct blues_struct *bluesP, int *modeP );
+
+#ifdef BUILDCID
+extern struct xobject *CIDChar ( char *env, XYspace S,
+ psobj *charstrP, psobj *subrsP,
+ psobj *osubrsP,
+ struct blues_struct *bluesP, int *modeP );
+static boolean initCIDFont( int cnt );
+#endif
+
/***================================================================***/
/* GLOBALS */
/***================================================================***/
@@ -45,7 +85,16 @@ char *CurFontEnv;
char *vm_base = NULL;
psfont *FontP = NULL;
psfont TheCurrentFont;
-
+#ifdef BUILDCID
+char CurCIDFontName[CID_PATH_MAX];
+char CurCMapName[CID_PATH_MAX];
+cidfont *CIDFontP = NULL;
+cmapres *CMapP = NULL;
+cidfont TheCurrentCIDFont;
+cmapres TheCurrentCMap;
+psfont *FDArrayP = NULL;
+int FDArrayIndex = 0;
+#endif
/***================================================================***/
/* SearchDict - look for name */
@@ -53,9 +102,8 @@ psfont TheCurrentFont;
/* return 0 - not found. */
/* return n - nth element in dictionary. */
/***================================================================***/
-int SearchDictName(dictP,keyP)
- psdict *dictP;
- psobj *keyP;
+int
+SearchDictName(psdict *dictP, psobj *keyP)
{
int i,n;
@@ -73,15 +121,68 @@ int SearchDictName(dictP,keyP)
}
return(0);
}
+
+#ifdef BUILDCID
+static boolean
+initCIDFont(int cnt)
+{
+ if (!(vm_init(cnt))) return(FALSE);
+ vm_base = vm_next_byte();
+ strcpy(CurCIDFontName, ""); /* initialize to none */
+ strcpy(CurCMapName, ""); /* initialize to none */
+ /* cause a font data reset on the next Type 1 font */
+ strcpy(CurFontName, ""); /* initialize to none */
+ CIDFontP = &TheCurrentCIDFont;
+ CMapP = &TheCurrentCMap;
+ CIDFontP->vm_start = vm_next_byte();
+ CIDFontP->spacerangecnt = 0;
+ CIDFontP->notdefrangecnt = 0;
+ CIDFontP->cidrangecnt = 0;
+ CIDFontP->spacerangeP = NULL;
+ CIDFontP->notdefrangeP = NULL;
+ CIDFontP->cidrangeP = NULL;
+ CIDFontP->CIDFontFileName.len = 0;
+ CIDFontP->CIDFontFileName.data.valueP = CurCIDFontName;
+ CMapP->CMapFileName.len = 0;
+ CMapP->CMapFileName.data.valueP = CurCMapName;
+ CMapP->firstRow = 0xFFFF;
+ CMapP->firstCol = 0xFFFF;
+ CMapP->lastRow = 0;
+ CMapP->lastCol = 0;
+ return(TRUE);
+}
+
/***================================================================***/
-boolean initFont(cnt)
-int cnt;
+boolean
+initCIDType1Font(void)
+{
+ strcpy(CurFontName, ""); /* initialize to none */
+ FontP = &FDArrayP[FDArrayIndex];
+ FontP->vm_start = vm_next_byte();
+ FontP->FontFileName.len = 0;
+ FontP->FontFileName.data.valueP = CurFontName;
+ FontP->Subrs.len = 0;
+ FontP->Subrs.data.stringP = NULL;
+ FontP->CharStringsP = NULL;
+ FontP->Private = NULL;
+ FontP->fontInfoP = NULL;
+ FontP->BluesP = NULL;
+ return(TRUE);
+}
+#endif
+
+boolean
+initFont(int cnt)
{
if (!(vm_init(cnt))) return(FALSE);
vm_base = vm_next_byte();
if (!(Init_BuiltInEncoding())) return(FALSE);
strcpy(CurFontName, ""); /* iniitialize to none */
+#ifdef BUILDCID
+ /* cause a font data reset on the next CID-keyed font */
+ strcpy(CurCIDFontName, ""); /* initialize to none */
+#endif
FontP = &TheCurrentFont;
FontP->vm_start = vm_next_byte();
FontP->FontFileName.len = 0;
@@ -89,8 +190,53 @@ int cnt;
return(TRUE);
}
/***================================================================***/
-static void resetFont(env)
- char *env;
+#ifdef BUILDCID
+static void
+resetCIDFont(char *cidfontname, char *cmapfile)
+{
+
+ vm_next = CIDFontP->vm_start;
+ vm_free = vm_size - ( vm_next - vm_base);
+ CIDFontP->spacerangecnt = 0;
+ CIDFontP->notdefrangecnt = 0;
+ CIDFontP->cidrangecnt = 0;
+ CIDFontP->spacerangeP = NULL;
+ CIDFontP->notdefrangeP = NULL;
+ CIDFontP->cidrangeP = NULL;
+ CIDFontP->CIDfontInfoP = NULL;
+ /* This will load the font into the FontP */
+ strcpy(CurCIDFontName,cidfontname);
+ strcpy(CurCMapName,cmapfile);
+ CIDFontP->CIDFontFileName.len = strlen(CurCIDFontName);
+ CIDFontP->CIDFontFileName.data.valueP = CurCIDFontName;
+ CMapP->CMapFileName.len = strlen(CurCMapName);
+ CMapP->CMapFileName.data.valueP = CurCMapName;
+ CMapP->firstRow = 0xFFFF;
+ CMapP->firstCol = 0xFFFF;
+ CMapP->lastRow = 0;
+ CMapP->lastCol = 0;
+}
+
+static void
+resetCIDType1Font(void)
+{
+
+ vm_next = FontP->vm_start;
+ vm_free = vm_size - ( vm_next - vm_base);
+ FontP->Subrs.len = 0;
+ FontP->Subrs.data.stringP = NULL;
+ FontP->CharStringsP = NULL;
+ FontP->Private = NULL;
+ FontP->fontInfoP = NULL;
+ FontP->BluesP = NULL;
+ /* This will load the font into the FontP */
+ FontP->FontFileName.len = strlen(CurFontName);
+ FontP->FontFileName.data.valueP = CurFontName;
+}
+#endif
+
+static void
+resetFont(char *env)
{
vm_next = FontP->vm_start;
@@ -107,9 +253,55 @@ static void resetFont(env)
FontP->FontFileName.data.valueP = CurFontName;
}
+
+#ifdef BUILDCID
/***================================================================***/
-int readFont(env)
-char *env;
+int
+readCIDFont(char *cidfontname, char *cmapfile)
+{
+ int rcode;
+
+ /* restore the virtual memory and eliminate old font */
+ resetCIDFont(cidfontname, cmapfile);
+ /* This will load the font into the FontP */
+ rcode = scan_cidfont(CIDFontP, CMapP);
+ if (rcode == SCAN_OUT_OF_MEMORY) {
+ /* free the memory and start again */
+ if (!(initCIDFont(vm_size * 2))) {
+ /* we are really out of memory */
+ return(SCAN_OUT_OF_MEMORY);
+ }
+ resetCIDFont(cidfontname, cmapfile);
+ rcode = scan_cidfont(CIDFontP, CMapP);
+ /* only double the memory twice, then report error */
+ if (rcode == SCAN_OUT_OF_MEMORY) {
+ /* free the memory and start again */
+ if (!(initCIDFont(vm_size * 2))) {
+ /* we are really out of memory */
+ return(SCAN_OUT_OF_MEMORY);
+ }
+ resetCIDFont(cidfontname, cmapfile);
+ rcode = scan_cidfont(CIDFontP, CMapP);
+ }
+ }
+ return(rcode);
+}
+
+int
+readCIDType1Font(void)
+{
+ int rcode;
+
+ resetCIDType1Font();
+
+ /* This will load the font into the FontP */
+ rcode = scan_cidtype1font(FontP);
+ return(rcode);
+}
+#endif
+
+int
+readFont(char *env)
{
int rcode;
@@ -119,26 +311,39 @@ char *env;
rcode = scan_font(FontP);
if (rcode == SCAN_OUT_OF_MEMORY) {
/* free the memory and start again */
+#ifdef BUILDCID
+ /* xfree(vm_base); */
+#else
xfree(vm_base);
+#endif
if (!(initFont(vm_size * 2))) {
/* we are really out of memory */
return(SCAN_OUT_OF_MEMORY);
}
resetFont(env);
rcode = scan_font(FontP);
+#ifdef BUILDCID
+ /* only double the memory twice, then report error */
+ if (rcode == SCAN_OUT_OF_MEMORY) {
+ /* free the memory and start again */
+ /* xfree(vm_base) */
+ if (!(initFont(vm_size * 2))) {
+ /* we are really out of memory */
+ return(SCAN_OUT_OF_MEMORY);
+ }
+ resetFont(env);
+ rcode = scan_font(FontP);
+ }
+#else
/* only double the memory once, then report error */
+#endif
}
return(rcode);
}
/***================================================================***/
-xobject fontfcnB(S,code,lenP,mode)
-XYspace S;
-unsigned char *code;
-int *lenP;
-int *mode;
+struct xobject *
+fontfcnB(struct XYspace *S, unsigned char *code, int *lenP, int *mode)
{
- path updateWidth();
-
psobj *charnameP; /* points to psobj that is name of character*/
int N;
psdict *CharStringsDictP; /* dictionary with char strings */
@@ -146,7 +351,7 @@ int *mode;
psobj *SubrsArrayP;
psobj *theStringP;
- path charpath; /* the path for this character */
+ struct xobject *charpath; /* the path for this character */
charnameP = &CodeName;
charnameP->len = *lenP;
@@ -168,16 +373,87 @@ int *mode;
SubrsArrayP = &(FontP->Subrs);
/* scale the Adobe fonts to 1 unit high */
/* call the type 1 routine to rasterize the character */
- charpath = Type1Char(FontP,S,theStringP,SubrsArrayP,NULL,
+ charpath = (struct xobject *)Type1Char((char *)FontP,S,theStringP,
+ SubrsArrayP,NULL,
FontP->BluesP , mode);
/* if Type1Char reported an error, then return */
if ( *mode == FF_PARSE_ERROR) return(NULL);
/* fill with winding rule unless path was requested */
if (*mode != FF_PATH) {
- charpath = Interior(charpath,WINDINGRULE+CONTINUITY);
+ charpath = (struct xobject *)Interior((struct segment *)charpath,
+ WINDINGRULE+CONTINUITY);
}
return(charpath);
}
+
+#ifdef BUILDCID
+/***================================================================***/
+/* CIDfontfcnA(cidfontname, cmapfile, mode) */
+/* */
+/* 1) initialize the font - global indicates it has been done */
+/* 2) load the font */
+/***================================================================***/
+Bool
+CIDfontfcnA(char *cidfontname, char *cmapfile, int *mode)
+{
+ int rcode, cidinit;
+
+ cidinit = 0;
+ if (CIDFontP == NULL || strcmp(CurCIDFontName, "") == 0) {
+ InitImager();
+ if (!(initCIDFont(VM_SIZE))) {
+ /* we are really out of memory */
+ *mode = SCAN_OUT_OF_MEMORY;
+ return(FALSE);
+ }
+ cidinit = 1;
+ }
+
+ /* if the cidfontname is null, then use font already loaded */
+
+ /* if not the same font name */
+ if (cidinit || (cidfontname && strcmp(cidfontname,CurCIDFontName) != 0) ||
+ (cmapfile && strcmp(cmapfile,CurCMapName) != 0)) {
+ /* restore the virtual memory and eliminate old font, read new one */
+ rcode = readCIDFont(cidfontname, cmapfile);
+ if (rcode != 0 ) {
+ strcpy(CurCIDFontName, ""); /* no CIDFont loaded */
+ strcpy(CurCMapName, ""); /* no CMap loaded */
+ *mode = rcode;
+ return(FALSE);
+ }
+ }
+ return(TRUE);
+
+}
+
+/***================================================================***/
+/* CIDType1fontfcnA(mode) */
+/* */
+/* 1) initialize the font - global indicates it has been done */
+/* 2) load the font */
+/***================================================================***/
+Bool
+CIDType1fontfcnA(int *mode)
+{
+ int rcode;
+
+ if (!(initCIDType1Font())) {
+ /* we are really out of memory */
+ *mode = SCAN_OUT_OF_MEMORY;
+ return(FALSE);
+ }
+
+ if ((rcode = readCIDType1Font()) != 0) {
+ strcpy(CurFontName, ""); /* no font loaded */
+ *mode = rcode;
+ return(FALSE);
+ }
+ return(TRUE);
+
+}
+#endif
+
/***================================================================***/
/* fontfcnA(env, mode) */
/* */
@@ -186,15 +462,18 @@ int *mode;
/* 1) initialize the font - global indicates it has been done */
/* 2) load the font */
/***================================================================***/
-Bool fontfcnA(env,mode)
-char *env;
-int *mode;
+Bool
+fontfcnA(char *env, int *mode)
{
int rc;
/* Has the FontP initialized? If not, then */
/* Initialize */
+#ifdef BUILDCID
+ if (FontP == NULL || strcmp(CurFontName, "") == 0) {
+#else
if (FontP == NULL) {
+#endif
InitImager();
if (!(initFont(VM_SIZE))) {
/* we are really out of memory */
@@ -218,6 +497,101 @@ int *mode;
return(TRUE);
}
+
+#ifdef BUILDCID
+/***================================================================***/
+/* CIDQueryFontLib(cidfontname,cmapfile,infoName,infoValue,rcodeP) */
+/* */
+/* cidfontname is a pointer to a string that contains the fontname. */
+/* */
+/* 1) initialize the font - global indicates it has been done */
+/* 2) load the font */
+/* 3) use the font to call getInfo for that value. */
+/***================================================================***/
+
+void
+CIDQueryFontLib(char *cidfontname, char *cmapfile, char *infoName,
+ pointer infoValue, /* parameter returned here */
+ int *rcodeP)
+{
+ int rc,N,i,cidinit;
+ psdict *dictP;
+ psobj nameObj;
+ psobj *valueP;
+
+ /* Has the CIDFontP initialized? If not, then */
+ /* Initialize */
+ cidinit = 0;
+ if (CIDFontP == NULL || strcmp(CurCIDFontName, "") == 0) {
+ InitImager();
+ if (!(initCIDFont(VM_SIZE))) {
+ *rcodeP = 1;
+ return;
+ }
+ cidinit = 1;
+ }
+ /* if the file name is null, then use font already loaded */
+ /* if the not same font name, reset and load next font */
+ if (cidinit || (cidfontname && strcmp(cidfontname,CurCIDFontName) != 0) ||
+ (cmapfile && strcmp(cmapfile,CurCMapName) != 0)) {
+ /* restore the virtual memory and eliminate old font */
+ rc = readCIDFont(cidfontname, cmapfile);
+ if (rc != 0 ) {
+ strcpy(CurCIDFontName, ""); /* no font loaded */
+ strcpy(CurCMapName, ""); /* no font loaded */
+ *rcodeP = 1;
+ return;
+ }
+ }
+ dictP = CIDFontP->CIDfontInfoP;
+ objFormatName(&nameObj,strlen(infoName),infoName);
+ N = SearchDictName(dictP,&nameObj);
+ /* if found */
+ if ( N > 0 ) {
+ *rcodeP = 0;
+ switch (dictP[N].value.type) {
+ case OBJ_ARRAY:
+ valueP = dictP[N].value.data.arrayP;
+ /* Just double check valueP. H.J. */
+ if (valueP == NULL) break;
+ if (strcmp(infoName,"FontMatrix") == 0) {
+ /* 6 elments, return them as floats */
+ for (i=0;i<6;i++) {
+ if (valueP->type == OBJ_INTEGER )
+ ((float *)infoValue)[i] = valueP->data.integer;
+ else
+ ((float *)infoValue)[i] = valueP->data.real;
+ valueP++;
+ }
+ }
+ if (strcmp(infoName,"FontBBox") == 0) {
+ /* 4 elments for Bounding Box. all integers */
+ for (i=0;i<4;i++) {
+ ((int *)infoValue)[i] = valueP->data.integer;
+ valueP++;
+ }
+ break;
+ case OBJ_INTEGER:
+ case OBJ_BOOLEAN:
+ *((int *)infoValue) = dictP[N].value.data.integer;
+ break;
+ case OBJ_REAL:
+ *((float *)infoValue) = dictP[N].value.data.real;
+ break;
+ case OBJ_NAME:
+ case OBJ_STRING:
+ *((char **)infoValue) = dictP[N].value.data.valueP;
+ break;
+ default:
+ *rcodeP = 1;
+ break;
+ }
+ }
+ }
+ else *rcodeP = 1;
+}
+#endif
+
/***================================================================***/
/* QueryFontLib(env, infoName,infoValue,rcodeP) */
/* */
@@ -228,11 +602,10 @@ int *mode;
/* 3) use the font to call getInfo for that value. */
/***================================================================***/
-void QueryFontLib(env,infoName,infoValue,rcodeP)
-char *env;
-char *infoName;
-pointer infoValue; /* parameter returned here */
-int *rcodeP;
+void
+QueryFontLib(char *env, char *infoName,
+ pointer infoValue, /* parameter returned here */
+ int *rcodeP)
{
int rc,N,i;
psdict *dictP;
@@ -268,8 +641,8 @@ int *rcodeP;
switch (dictP[N].value.type) {
case OBJ_ARRAY:
valueP = dictP[N].value.data.arrayP;
- /* don't dereference a NULL pointer, in the case of a bad font file */
- if (valueP == NULL) break;
+ /* Just double check valueP. H.J. */
+ if (valueP == NULL) break;
if (strcmp(infoName,"FontMatrix") == 0) {
/* 6 elments, return them as floats */
for (i=0;i<6;i++) {
@@ -306,3 +679,24 @@ int *rcodeP;
}
else *rcodeP = 1;
}
+
+#ifdef BUILDCID
+struct xobject *
+CIDfontfcnC(struct XYspace *S, psobj *theStringP,
+ psobj *SubrsArrayP, struct blues_struct *BluesP,
+ int *lenP, int *mode)
+{
+ struct xobject *charpath; /* the path for this character */
+
+ charpath = (struct xobject *)CIDChar((char *)FontP,S,theStringP,
+ SubrsArrayP,NULL,BluesP,mode);
+ /* if Type1Char reported an error, then return */
+ if ( *mode == FF_PARSE_ERROR) return(NULL);
+ /* fill with winding rule unless path was requested */
+ if (*mode != FF_PATH) {
+ charpath = (struct xobject *)Interior((struct segment *)charpath,
+ WINDINGRULE+CONTINUITY);
+ }
+ return(charpath);
+}
+#endif
diff --git a/src/Type1/fontfcn.h b/src/Type1/fontfcn.h
index cbf23a1..9383e42 100644
--- a/src/Type1/fontfcn.h
+++ b/src/Type1/fontfcn.h
@@ -27,6 +27,53 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/fontfcn.h,v 1.5 2001/01/17 19:43:22 dawes Exp $ */
+
+
+#ifdef BUILDCID
+/* Definition of a PostScript CIDFont resource */
+typedef struct cid_font {
+ char *vm_start;
+ int spacerangecnt;
+ int notdefrangecnt;
+ int cidrangecnt;
+ spacerange *spacerangeP;
+ cidrange *notdefrangeP;
+ cidrange *cidrangeP;
+ int binarydata; /* 1=binary data, 0=hex data */
+ long bytecnt;
+ psobj CIDFontFileName;
+ psdict *CIDfontInfoP;
+} cidfont;
+
+/* Definition of a PostScript CMap resource */
+typedef struct cmap_res {
+ unsigned short firstCol;
+ unsigned short lastCol;
+ unsigned short firstRow;
+ unsigned short lastRow;
+ psobj CMapFileName;
+ psdict *CMapInfoP;
+} cmapres;
+#endif
+
/* Definition of a PostScript FONT */
typedef struct ps_font {
char *vm_start;
@@ -40,10 +87,13 @@ struct blues_struct *BluesP;
/***================================================================***/
/* Routines in scan_font */
/***================================================================***/
-
-extern boolean Init_StdEnc();
-extern int scan_font();
-extern int GetFontInfo();
+
+extern boolean Init_BuiltInEncoding ( void );
+#ifdef BUILDCID
+extern int scan_cidfont ( cidfont *CIDFontP, cmapres *CMapP );
+extern int scan_cidtype1font ( psfont *FontP );
+#endif
+extern int scan_font ( psfont *FontP );
/***================================================================***/
/* Return codes from scan_font */
/***================================================================***/
@@ -55,7 +105,43 @@ extern int GetFontInfo();
#define SCAN_TRUE -5
#define SCAN_FALSE -6
#define SCAN_END -7
-
+
+#ifdef BUILDCID
+/***================================================================***/
+/* Name of CID FontInfo fields */
+/***================================================================***/
+#define CIDCOUNT 1
+#define CIDFONTNAME 2
+#define CIDFONTTYPE 3
+#define CIDVERSION 4
+#define CIDREGISTRY 5
+#define CIDORDERING 6
+#define CIDSUPPLEMENT 7
+#define CIDMAPOFFSET 8
+#define CIDFDARRAY 9
+#define CIDFDBYTES 10
+#define CIDFONTBBOX 11
+#define CIDFULLNAME 12
+#define CIDFAMILYNAME 13
+#define CIDWEIGHT 14
+#define CIDNOTICE 15
+#define CIDGDBYTES 16
+#define CIDUIDBASE 17
+#define CIDXUID 18
+
+/***================================================================***/
+/* Name of CMapInfo fields */
+/***================================================================***/
+#define CMAPREGISTRY 1
+#define CMAPORDERING 2
+#define CMAPSUPPLEMENT 3
+#define CMAPNAME 4
+#define CMAPVERSION 5
+#define CMAPTYPE 6
+#define CMAPWMODE 7
+#define CMAPCIDCOUNT 8
+#endif
+
/***================================================================***/
/* Name of FontInfo fields */
/***================================================================***/
@@ -96,3 +182,60 @@ extern int GetFontInfo();
#define LENIV 14
#define RNDSTEMUP 15
#define EXPANSIONFACTOR 16
+
+#ifdef BUILDCID
+/***================================================================***/
+/* Name of CID Type 1 Private values */
+/***================================================================***/
+#define CIDT1MINFEATURE 1
+#define CIDT1LENIV 2
+#define CIDT1LANGGROUP 3
+#define CIDT1BLUEVALUES 4
+#define CIDT1OTHERBLUES 5
+#define CIDT1BLUESCALE 6
+#define CIDT1BLUEFUZZ 7
+#define CIDT1BLUESHIFT 8
+#define CIDT1FAMBLUES 9
+#define CIDT1FAMOTHERBLUES 10
+#define CIDT1STDHW 11
+#define CIDT1STDVW 12
+#define CIDT1STEMSNAPH 13
+#define CIDT1STEMSNAPV 14
+#define CIDT1SUBMAPOFF 15
+#define CIDT1SDBYTES 16
+#define CIDT1SUBRCNT 17
+#define CIDT1FORCEBOLD 18
+#define CIDT1RNDSTEMUP 19
+#define CIDT1EXPFACTOR 20
+
+#define CID_BITMAP_UNDEFINED 0
+extern int SearchDictName ( psdict *dictP, psobj *keyP );
+#ifdef BUILDCID
+extern boolean initCIDType1Font ( void );
+#endif
+extern boolean initFont ( int cnt );
+#ifdef BUILDCID
+extern int readCIDFont ( char *cidfontname, char *cmapfile );
+extern int readCIDType1Font ( void );
+#endif
+extern int readFont ( char *env );
+extern struct xobject *fontfcnB ( struct XYspace *S, unsigned char *code,
+ int *lenP, int *mode );
+#ifdef BUILDCID
+extern Bool CIDfontfcnA ( char *cidfontname, char *cmapfile, int *mode );
+extern Bool CIDType1fontfcnA ( int *mode );
+#endif
+extern Bool fontfcnA ( char *env, int *mode );
+#ifdef BUILDCID
+extern void CIDQueryFontLib ( char *cidfontname, char *cmapfile,
+ char *infoName, pointer infoValue, int *rcodeP );
+#endif
+extern void QueryFontLib ( char *env, char *infoName, pointer infoValue,
+ int *rcodeP );
+#ifdef BUILDCID
+extern struct xobject *CIDfontfcnC ( struct XYspace *S, psobj *theStringP,
+ psobj *SubrsArrayP,
+ struct blues_struct *BluesP, int *lenP,
+ int *mode );
+#endif
+#endif
diff --git a/src/Type1/hints.c b/src/Type1/hints.c
index c3db5a4..5150647 100644
--- a/src/Type1/hints.c
+++ b/src/Type1/hints.c
@@ -26,6 +26,8 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/hints.c,v 1.7 2002/02/18 20:51:57 herrb Exp $ */
+
/* HINTS CWEB V0006 ******** */
/*
:h1.HINTS Module - Processing Rasterization Hints
@@ -39,12 +41,13 @@ W. Pryor, Jr.
The included files are:
*/
+#include "os.h"
#include "objects.h"
#include "spaces.h"
#include "paths.h"
#include "regions.h"
#include "hints.h"
-
+
/*
:h3.Functions Provided to the TYPE1IMAGER User
@@ -81,7 +84,8 @@ static struct {
#define FPFLOOR(fp) TOFRACTPEL((fp) >> FRACTBITS)
#define FPROUND(fp) FPFLOOR((fp) + FPHALF)
-void InitHints()
+void
+InitHints(void)
{
int i;
@@ -96,8 +100,8 @@ void InitHints()
:h3.CloseHints(hintP) - Reverse hints that are still open
*/
-void CloseHints(hintP)
- struct fractpoint *hintP;
+void
+CloseHints(struct fractpoint *hintP)
{
int i;
@@ -120,10 +124,10 @@ void CloseHints(hintP)
:h3.ComputeHint(hP, currX, currY, hintP) - Compute the value of a hint
*/
-static void ComputeHint(hP, currX, currY, hintP)
- struct hintsegment *hP;
- fractpel currX, currY;
- struct fractpoint *hintP;
+static void
+ComputeHint(struct hintsegment *hP,
+ fractpel currX, fractpel currY,
+ struct fractpoint *hintP)
{
fractpel currRef, currWidth;
int idealWidth;
@@ -166,7 +170,7 @@ multiple of 90 degrees.
}
else /* error */
{
- abort("ComputeHint: invalid orientation");
+ Abort("ComputeHint: invalid orientation");
}
IfTrace4((HintDebug > 1),
@@ -200,7 +204,7 @@ multiple of 90 degrees.
}
else /* error */
{
- abort("ComputeHint: invalid hinttype");
+ Abort("ComputeHint: invalid hinttype");
}
IfTrace1((HintDebug > 1)," hintValue=%p", hintValue);
@@ -217,7 +221,7 @@ multiple of 90 degrees.
}
else /* error */
{
- abort("ComputeHint: invalid orientation");
+ Abort("ComputeHint: invalid orientation");
}
}
@@ -225,10 +229,10 @@ multiple of 90 degrees.
:h3.ProcessHint(hP, currX, currY, hintP) - Process a rasterization hint
*/
-void ProcessHint(hP, currX, currY, hintP)
- struct hintsegment *hP;
- fractpel currX, currY;
- struct fractpoint *hintP;
+void
+ProcessHint(struct hintsegment *hP,
+ fractpel currX, fractpel currY,
+ struct fractpoint *hintP)
{
struct fractpoint thisHint;
@@ -266,7 +270,7 @@ void ProcessHint(hP, currX, currY, hintP)
}
else /* error */
{
- abort("ProcessHint: invalid label");
+ Abort("ProcessHint: invalid label");
}
}
else if (hP->adjusttype == 'r') /* Reverse */
@@ -282,18 +286,18 @@ void ProcessHint(hP, currX, currY, hintP)
}
else /* error */
{
- abort("ProcessHint: label is not in use");
+ Abort("ProcessHint: label is not in use");
}
}
else /* error */
{
- abort("ProcessHint: invalid label");
+ Abort("ProcessHint: invalid label");
}
}
else /* error */
{
- abort("ProcessHint: invalid adjusttype");
+ Abort("ProcessHint: invalid adjusttype");
}
IfTrace3((HintDebug > 1)," label=%d, thisHint=(%p,%p)\n",
hP->label, thisHint.x, thisHint.y);
@@ -362,9 +366,9 @@ off of the edge's range; XofY() could be replace by FindXofY() to
call ourselves recursively if this were not true.
*/
-static pel SearchXofY(edge, y)
- register struct edgelist *edge; /* represents edge */
- register pel y; /* 'y' value to find edge for */
+static pel
+SearchXofY(register struct edgelist *edge, /* represents edge */
+ register pel y) /* 'y' value to find edge for */
{
register struct edgelist *e; /* loop variable */
@@ -385,7 +389,7 @@ static pel SearchXofY(edge, y)
else
return(XofY(edge, y));
- abort("bad subpath chain");
+ Abort("bad subpath chain");
/*NOTREACHED*/
}
/*
@@ -413,9 +417,10 @@ are at the top and the first edge is going up.
#define BLACKBELOW +1
#define NONE 0
-static int ImpliedHorizontalLine(e1, e2, y)
- register struct edgelist *e1,*e2; /* two edges to check */
- register int y; /* y where they might be connected */
+static int
+ImpliedHorizontalLine(struct edgelist *e1, /* two edges to check */
+ struct edgelist *e2,
+ int y) /* y where they might be connected */
{
register struct edgelist *e3,*e4;
@@ -466,7 +471,7 @@ Now we have everything to return the answer:
else if (ISBOTTOM(e1->flag) && y == e1->ymax)
return(!ISDOWN(e2->flag));
else
- abort("ImpliedHorizontalLine: why ask?");
+ Abort("ImpliedHorizontalLine: why ask?");
/*NOTREACHED*/
}
@@ -483,14 +488,14 @@ routine finds and fixes false breaks.
Also, this routine sets the ISTOP and ISBOTTOM flags in the edge lists.
*/
-static void FixSubPaths(R)
- register struct region *R; /* anchor of region */
+static void
+FixSubPaths(struct region *R) /* anchor of region */
{
register struct edgelist *e; /* fast loop variable */
register struct edgelist *edge; /* current edge in region */
register struct edgelist *next; /* next in subpath after 'edge' */
register struct edgelist *break1; /* first break after 'next' */
- register struct edgelist *break2; /* last break before 'edge' */
+ register struct edgelist *break2 = NULL; /* last break before 'edge' */
register struct edgelist *prev; /* previous edge for fixing links */
int left = TRUE;
@@ -505,7 +510,7 @@ static void FixSubPaths(R)
if (!ISBREAK(edge, next))
continue;
if (edge->ymax < next->ymin)
- abort("disjoint subpath?");
+ Abort("disjoint subpath?");
/*
'edge' now contains an edgelist at the bottom of an edge, and 'next'
contains the next subsequent edgelist in the subpath, which must be at
@@ -566,7 +571,7 @@ as 'next':
break1->subpath = break2->subpath;
if (ISBREAK(break1, break1->subpath))
- abort("unable to fix subpath break?");
+ Abort("unable to fix subpath break?");
break2->subpath = next;
@@ -626,10 +631,10 @@ get all the way to the outside without resolving ambiguity.
A debug tool.
*/
-static struct edgelist *before(); /* subroutine of DumpSubPaths */
+static struct edgelist *before(struct edgelist *e); /* subroutine of DumpSubPaths */
-static void DumpSubPaths(anchor)
- struct edgelist *anchor;
+static void
+DumpSubPaths(struct edgelist *anchor)
{
register struct edgelist *edge,*e,*e2;
@@ -672,8 +677,8 @@ static void DumpSubPaths(anchor)
}
}
-static struct edgelist *before(e)
- struct edgelist *e;
+static struct edgelist *
+before(struct edgelist *e)
{
struct edgelist *r;
for (r = e->subpath; r->subpath != e; r = r->subpath) { ; }
@@ -705,10 +710,10 @@ new x might exceed the region's bounds, updating those are the
responsibility of the caller.
*/
-static void writeXofY(e, y, x)
- struct edgelist *e; /* relevant edgelist */
- int y; /* y value */
- int x; /* new x value */
+static void
+writeXofY(struct edgelist *e,/* relevant edgelist */
+ int y, /* y value */
+ int x) /* new x value */
{
if (e->xmin > x) e->xmin = x;
if (e->xmax < x) e->xmax = x;
@@ -739,12 +744,12 @@ points (collapses) the white run as necessary if it is not. The
goal is to collapse the white run as little as possible.
*/
-static void CollapseWhiteRun(anchor, yblack, left, right, ywhite)
- struct edgelist *anchor; /* anchor of edge list */
- pel yblack; /* y of (hopefully) black run above or below */
- struct edgelist *left; /* edgelist at left of WHITE run */
- struct edgelist *right; /* edgelist at right of WHITE run */
- pel ywhite; /* y location of white run */
+static void
+CollapseWhiteRun(struct edgelist *anchor, /* anchor of edge list */
+ pel yblack, /* y of (hopefully) black run above or below */
+ struct edgelist *left, /* edgelist at left of WHITE run */
+ struct edgelist *right, /* edgelist at right of WHITE run */
+ pel ywhite) /* y location of white run */
{
struct edgelist *edge;
struct edgelist *swathstart = anchor;
@@ -810,8 +815,8 @@ This is the externally visible routine called from the REGIONS module
when the +CONTINUITY flag is on the Interior() fill rule.
*/
-void ApplyContinuity(R)
-struct region *R;
+void
+ApplyContinuity(struct region *R)
{
struct edgelist *left;
struct edgelist *right;
diff --git a/src/Type1/hints.h b/src/Type1/hints.h
index 79ef326..d5bb829 100644
--- a/src/Type1/hints.h
+++ b/src/Type1/hints.h
@@ -26,17 +26,23 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/hints.h,v 1.4 2001/01/17 19:43:22 dawes Exp $ */
+
/*SHARED*/
-#define InitHints() t1_InitHints()
-void t1_InitHints(); /* Initialize hint data structure */
+#define InitHints t1_InitHints
+extern void t1_InitHints ( void ); /* Initialize hint data structure */
#define CloseHints(hintP) t1_CloseHints(hintP)
-void t1_CloseHints(); /* Reverse hints that are still open */
+/* Reverse hints that are still open */
+extern void t1_CloseHints ( struct fractpoint *hintP );
#define ProcessHint(hP, currX, currY, hintP) t1_ProcessHint(hP, currX, currY, hintP)
-void t1_ProcessHint(); /* Process a rasterization hint */
-
+/* Process a rasterization hint */
+extern void t1_ProcessHint ( struct hintsegment *hP, fractpel currX, fractpel currY, struct fractpoint *hintP );
+
#define ApplyContinuity(R) t1_ApplyContinuity(R)
-void t1_ApplyContinuity(); /* fix false connection breaks in a region */
+/* fix false connection breaks in a region */
+extern void t1_ApplyContinuity ( struct region *R );
+
/*END SHARED*/
diff --git a/src/Type1/lines.c b/src/Type1/lines.c
index 3afcfc1..dec3f08 100644
--- a/src/Type1/lines.c
+++ b/src/Type1/lines.c
@@ -26,6 +26,8 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/lines.c,v 1.4 2001/01/17 19:43:22 dawes Exp $ */
+
/* LINES CWEB V0003 ******** */
/*
:h1.LINES Module - Rasterizing Lines
@@ -40,6 +42,7 @@ The included files are:
#include "objects.h"
#include "spaces.h"
+#include "paths.h"
#include "regions.h"
#include "lines.h"
diff --git a/src/Type1/lines.h b/src/Type1/lines.h
index 8e2cc74..c0d7392 100644
--- a/src/Type1/lines.h
+++ b/src/Type1/lines.h
@@ -26,12 +26,14 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/lines.h,v 1.4 2001/01/17 19:43:22 dawes Exp $ */
+
/*SHARED*/
#define StepLine(R,x1,y1,x2,y2) t1_StepLine(R,x1,y1,x2,y2)
#define Bresenham(e,x1,y1,x2,y2) t1_Bresenham(e,x1,y1,x2,y2)
-void t1_StepLine(); /* check for special conditions, call Bresenham */
-void t1_Bresenham(); /* produce run ends for lines */
+extern void t1_StepLine ( struct region *R, fractpel x1, fractpel y1, fractpel x2, fractpel y2 );
+extern void t1_Bresenham ( pel *edgeP, fractpel x1, fractpel y1, fractpel x2, fractpel y2 );
/*END SHARED*/
diff --git a/src/Type1/objects.c b/src/Type1/objects.c
index 438e859..57168b4 100644
--- a/src/Type1/objects.c
+++ b/src/Type1/objects.c
@@ -26,6 +26,7 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/objects.c,v 1.10 2002/02/18 20:51:57 herrb Exp $ */
/* OBJECTS CWEB V0025 ******** */
/*
:h1.OBJECTS Module - TYPE1IMAGER Objects Common Routines
@@ -53,8 +54,17 @@ system it is a pretty safe bet that these are external entry points and
you do do not need to include these header files.
*/
+#ifndef FONTMODULE
#include <string.h>
#include <ctype.h>
+#include <stdarg.h>
+#include "os.h"
+#else
+#include "Xdefs.h" /* Bool declaration */
+#include "Xmd.h" /* INT32 declaration */
+#include "os.h"
+#include "xf86_ansic.h"
+#endif
/*
override incorrect system functions; for example you might define
@@ -72,7 +82,9 @@ a macro for "strcpy" that diverts it to "my_strcpy".
#include "pictures.h"
#include "strokes.h"
#include "cluts.h"
-static char *TypeFmt();
+
+
+static char *TypeFmt(int type);
/*
:h3.The "pointer" Macro - Define a Generic Pointer
@@ -280,13 +292,12 @@ set to 1. So, a nun-NULL template must also have a "references" field.
PNM 3-26-91
*/
-struct xobject *t1_Allocate(size, template, extra) /* non-ANSI; type checking was too strict */
- register int size; /* number of bytes to allocate & initialize */
- register struct xobject *template; /* example structure to allocate */
- register int extra; /* any extra uninitialized bytes needed contiguously */
+struct xobject *
+t1_Allocate(int size, /* number of bytes to allocate & initialize */
+ pointer ptr, /* example structure to allocate */
+ int extra) /* any extra uninitialized bytes needed contiguously */
{
- extern char *xiMalloc(); /* standard C routine */
-
+ register struct xobject *template = (struct xobject *)ptr;
register struct xobject *r;
/*
@@ -295,14 +306,14 @@ struct xobject *t1_Allocate(size, template, extra) /* non-ANSI; type checking w
size = (size + sizeof(long) - 1) & -(int)sizeof(long);
extra = (extra + sizeof(long) - 1) & -(int)sizeof(long);
if (size + extra <= 0)
- abort("Non-positive allocate?");
+ Abort("Non-positive allocate?");
r = (struct xobject *) xiMalloc(size + extra);
while (r == NULL) {
if (!GimeSpace()) {
IfTrace1(TRUE, "malloc attempted %d bytes.\n",
size + extra);
- abort("We have REALLY run out of memory");
+ Abort("We have REALLY run out of memory");
}
r = (struct xobject *) xiMalloc(size + extra);
}
@@ -349,11 +360,13 @@ In either case, the object must not be the NULL pointer. This preserves
portability, as the C system xiFree() will not always accept NULL.
*/
-void Free(obj) /* non-ANSI to avoid overly strict type checking */
- register struct xobject *obj; /* structure to free */
+void
+Free(pointer objPtr)
{
+ struct xobject *obj = (struct xobject *)objPtr; /* structure to free */
+
if (obj->type == INVALIDTYPE)
- abort("Free of already freed object?");
+ Abort("Free of already freed object?");
obj->type = INVALIDTYPE;
if (MemoryDebug > 1) {
@@ -362,7 +375,7 @@ void Free(obj) /* non-ANSI to avoid overly strict type checking */
IfTrace4(TRUE,"Freeing at %x: %x %x %x\n", L, L[-1], L[0], L[1]);
}
- xiFree(obj);
+ xiFree((long *)obj);
}
/*
@@ -389,9 +402,11 @@ done is to change one of the old temporary handles to a permanent one.
3-26-91 PNM
*/
-struct xobject *t1_Permanent(obj) /* non-ANSI to avoid overly strict type checking */
- register struct xobject *obj; /* object to be made permanent */
+struct xobject *
+t1_Permanent(pointer objPtr)
{
+ struct xobject *obj = (struct xobject *)objPtr; /* object to be made permanent */
+
IfTrace1((MustTraceCalls),"Permanent(%z)\n", obj);
if ( (obj != NULL) && ( !(ISPERMANENT(obj->flag)) ) )
@@ -415,6 +430,7 @@ struct xobject *t1_Permanent(obj) /* non-ANSI to avoid overly strict type checki
return(obj);
}
+#ifdef notused
/*
:h3.Temporary() - Undoes the Effect of "Permanent()"
@@ -433,9 +449,11 @@ lost a permanent handle and gained a temporary one.
PNM 3-2-6-91
*/
-struct xobject *xiTemporary(obj) /* non-ANSI to avoid overly strict type checking */
- register struct xobject *obj; /* object to be made permanent */
+struct xobject *
+xiTemporary(pointer objPtr)
{
+ register struct xobject *obj
+ = (struct xobject *)objPtr; /* object to be made permanent */
IfTrace1((MustTraceCalls),"Temporary(%z)\n", obj);
if (obj != NULL) {
@@ -467,7 +485,8 @@ struct xobject *xiTemporary(obj) /* non-ANSI to avoid overly strict type checkin
}
return(obj);
}
-
+#endif /* notused */
+
/*
:h3.Dup() - Duplicate an Object
@@ -478,9 +497,11 @@ Note that Dup() retains the state of the permanent flag.
*/
-struct xobject *t1_Dup(obj) /* non-ANSI avoids overly strict type checking */
- register struct xobject *obj; /* object to be duplicated */
+struct xobject *
+t1_Dup(pointer objPtr)
{
+ register struct xobject *obj
+ = (struct xobject *)objPtr; /* object to be duplicated */
register char oldflag; /* copy of original object's flag byte */
IfTrace1((MustTraceCalls),"Dup(%z)\n", obj);
@@ -523,22 +544,28 @@ let each module provide us a routine (or macro) that duplicates the
objects it knows about.
*/
-struct xobject *t1_Copy(obj)
- register struct xobject *obj; /* object to be Copy'ed */
+struct xobject *
+t1_Copy(pointer objPtr)
{
+ register struct xobject *obj
+ = (struct xobject *)objPtr; /* object to be Copy'ed */
if (obj == NULL)
return(NULL);
if (ISPATHTYPE(obj->type))
- obj = (struct xobject *) CopyPath(obj);
+ obj = (struct xobject *) CopyPath((struct segment *)obj);
else
switch (obj->type) {
case SPACETYPE:
- obj = (struct xobject *) CopySpace(obj); break;
+ obj = (struct xobject *)
+ CopySpace((struct XYspace *)obj);
+ break;
case FONTTYPE:
obj = (struct xobject *) CopyFont(obj); break;
case REGIONTYPE:
- obj = (struct xobject *) CopyRegion(obj); break;
+ obj = (struct xobject *)
+ CopyRegion((struct region *)obj);
+ break;
case PICTURETYPE:
obj = (struct xobject *) CopyPicture(obj); break;
case LINESTYLETYPE:
@@ -560,9 +587,11 @@ struct xobject *t1_Copy(obj)
This can get complicated. Just like with Copy(), we let the experts
handle it.
*/
-struct xobject *Destroy(obj) /* non-ANSI avoids overly strict type checking */
- register struct xobject *obj; /* object to be destroyed */
+struct xobject *
+Destroy(pointer objPtr)
{
+ register struct xobject *obj
+ = (struct xobject *)objPtr; /* object to be destroyed */
IfTrace1((MustTraceCalls),"Destroy(%z)\n", obj);
if (obj == NULL)
@@ -572,11 +601,11 @@ struct xobject *Destroy(obj) /* non-ANSI avoids overly strict type checking */
return(NULL);
}
if (ISPATHTYPE(obj->type))
- KillPath(obj);
+ KillPath((struct segment *)obj);
else {
switch (obj->type) {
case REGIONTYPE:
- KillRegion(obj);
+ KillRegion((struct region *)obj);
break;
case SPACETYPE:
KillSpace(obj);
@@ -717,9 +746,11 @@ because permanent objects, by definition, are persistent. 3-2-6-91 PNM
:eol.
*/
-struct xobject *t1_Unique(obj)
- struct xobject *obj;
+struct xobject *
+t1_Unique(pointer objPtr)
{
+ struct xobject *obj = (struct xobject *)objPtr;
+
/* if the original object is not already unique, make a unique
copy...Note also that if the object was not permanent, we must
consume the old handle! 3-26-91 PNM
@@ -763,16 +794,16 @@ static char *ErrorMessage = NULL;
We provide a controlled way for the TYPE1IMAGER user to set and reset
our debugging and tracing:
*/
-void Pragmatics(username, value)
- char *username; /* name of the flag */
- int value; /* value to set it to */
+void
+Pragmatics(char *username, /* name of the flag */
+ int value) /* value to set it to */
{
register char *p; /* temporary loop variable */
#define NAMESIZE 40
char name[NAMESIZE]; /* buffer to store my copy of 'username' */
if (strlen(username) >= (unsigned)NAMESIZE)
- abort("Pragmatics name too large");
+ Abort("Pragmatics name too large");
strcpy(name, username);
for (p = name; *p != '\0'; p++)
*p = toupper(*p);
@@ -892,39 +923,19 @@ if it is already known that the object is temporary, it is faster to
just kill it rather than consume it, for example, KillSpace().
*/
-void Consume(n, obj1, obj2, obj3) /* non-ANSI avoids overly strict type checking */
- int n;
- struct xobject *obj1,*obj2,*obj3;
+void
+Consume(int n, ...)
{
- switch(n) {
-
- case 0:
- return;
-
- case 1:
- if (obj1 != NULL && !ISPERMANENT(obj1->flag))
- Destroy(obj1);
- return;
-
- case 2:
- if (obj1 != NULL && !ISPERMANENT(obj1->flag))
- Destroy(obj1);
- if (obj2 != NULL && !ISPERMANENT(obj2->flag))
- Destroy(obj2);
- return;
-
- case 3:
- if (obj1 != NULL && !ISPERMANENT(obj1->flag))
- Destroy(obj1);
- if (obj2 != NULL && !ISPERMANENT(obj2->flag))
- Destroy(obj2);
- if (obj3 != NULL && !ISPERMANENT(obj3->flag))
- Destroy(obj3);
- return;
-
- default:
- abort("Consume: too many objects");
- }
+ struct xobject *obj;
+ va_list ap;
+
+ va_start(ap, n);
+
+ while (n-- > 0) {
+ obj = va_arg(ap, struct xobject *);
+ if (obj != NULL && !ISPERMANENT(obj->flag))
+ Destroy(obj);
+ }
}
/*
:h4.ObjectPostMortem() - Prints as Much as We Can About a Bad Object
@@ -934,10 +945,8 @@ This is a subroutine of TypeErr() and ArgErr().
/*ARGSUSED*/
static void
-ObjectPostMortem(obj) /* non-ANSI avoids overly strict type checking */
- register struct xobject *obj;
+ObjectPostMortem(struct xobject *obj)
{
- extern struct XYspace *USER;
Pragmatics("Debug", 10);
IfTrace2(TRUE,"Bad object is of %s type %z\n", TypeFmt(obj->type), obj);
@@ -951,12 +960,14 @@ ObjectPostMortem(obj) /* non-ANSI avoids overly strict type checking */
:h3.TypeErr() - Handles "Invalid Object Type" Errors
*/
-struct xobject *TypeErr(name, obj, expect, ret) /* non-ANSI avoids overly strict type checking */
- char *name; /* Name of routine (for error message) */
- struct xobject *obj; /* Object in error */
- int expect; /* type expected */
- struct xobject *ret; /* object to return to caller */
+struct xobject *
+TypeErr(char *name, /* Name of routine (for error message) */
+ pointer objPtr, /* Object in error */
+ int expect, /* type expected */
+ pointer retPtr) /* object to return to caller */
{
+ struct xobject *obj = (struct xobject *)objPtr;
+ struct xobject *ret = (struct xobject *)retPtr;
/*
* This buffer must be large enough to hold 'name' plus
* two of the largest strings that can be returned by TypeFmt.
@@ -975,7 +986,7 @@ struct xobject *TypeErr(name, obj, expect, ret) /* non-ANSI avoids overly strict
ObjectPostMortem(obj);
if (MustCrash)
- abort("Terminating because of CrashOnUserError...");
+ Abort("Terminating because of CrashOnUserError...");
else
ErrorMessage = typemsg;
@@ -991,8 +1002,8 @@ struct xobject *TypeErr(name, obj, expect, ret) /* non-ANSI avoids overly strict
This is a subroutine of TypeErr().
*/
-static char *TypeFmt(type)
- int type; /* type field */
+static char *
+TypeFmt(int type) /* type field */
{
char *r;
@@ -1039,25 +1050,28 @@ is returned to the caller in case MustCrash is FALSE and ArgErr
returns to its caller.
*/
-struct xobject *ArgErr(string, obj, ret) /* non-ANSI avoids overly strict type checking */
- char *string; /* description of error */
- struct xobject *obj; /* object, if any, that was in error */
- struct xobject *ret; /* object returned to caller or NULL */
+struct xobject *
+ArgErr(char *string, /* description of error */
+ pointer objPtr, /* object, if any, that was in error */
+ pointer retPtr) /* object returned to caller or NULL */
{
+ struct xobject *obj = (struct xobject *)objPtr;
+ struct xobject *ret = (struct xobject *)retPtr;
+
if (MustCrash)
LineIOTrace = TRUE;
IfTrace1(TRUE,"ARGUMENT ERROR-- %s.\n", string);
if (obj != NULL)
ObjectPostMortem(obj);
if (MustCrash)
- abort("Terminating because of CrashOnUserError...");
+ Abort("Terminating because of CrashOnUserError...");
else
ErrorMessage = string;
return(ret);
}
/*
-:h3.abort() - Crash Due to Error
+:h3.Abort() - Crash Due to Error
Defined in objects.h to be FatalError(), the server's abort routine.
*/
@@ -1068,7 +1082,8 @@ Defined in objects.h to be FatalError(), the server's abort routine.
:h4.ErrorMsg() - Return the User an Error Message
*/
-char *ErrorMsg()
+char *
+ErrorMsg(void)
{
register char *r;
@@ -1087,7 +1102,8 @@ anyway.) Note that TYPE1IMAGER makes no assumptions about the size of an
:i1/portability assumptions/
*/
-void InitImager()
+void
+InitImager(void)
{
/* Check to see if we have been using our own malloc. If so,*/
@@ -1096,7 +1112,7 @@ void InitImager()
/* if (sizeof(short) != 2 || sizeof(INT32) != 4)
- abort("Fundamental TYPE1IMAGER assumptions invalid in this port");
+ Abort("Fundamental TYPE1IMAGER assumptions invalid in this port");
*/
InitSpaces();
InitFonts();
@@ -1112,14 +1128,18 @@ In some environments, constants and/or exception handling need to be
This only makes sense in a server environment; true TYPE1IMAGER needs do
nothing.
*/
-void TermImager()
+void
+TermImager(void)
{
return;
}
+#ifdef notused
/*
:h4.reportusage() - A Stub to Get a Clean Link with Portable PMP
*/
-void reportusage()
+void
+reportusage(void)
{
return;
}
+#endif
diff --git a/src/Type1/objects.h b/src/Type1/objects.h
index 30a9773..984ccbd 100644
--- a/src/Type1/objects.h
+++ b/src/Type1/objects.h
@@ -26,49 +26,119 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/objects.h,v 1.14 2002/12/24 17:42:59 tsi Exp $ */
/*SHARED*/
/*END SHARED*/
+#include <Xdefs.h>
+#include <Xfuncproto.h>
+#ifndef FONTMODULE
+#include <stdlib.h>
+#endif
/*SHARED*/
#define Permanent(obj) t1_Permanent(obj)
+#ifdef notused
#define Temporary(obj) t1_Temporary(obj)
+#endif
#define Destroy(obj) t1_Destroy(obj)
#define Dup(obj) t1_Dup(obj)
-#define InitImager() t1_InitImager()
-#define TermImager() t1_TermImager()
+#define InitImager t1_InitImager
+#define TermImager t1_TermImager
#define Pragmatics(f,v) t1_Pragmatics(f,v)
-#define ErrorMsg() t1_ErrorMsg()
+#define ErrorMsg t1_ErrorMsg
-struct xobject *t1_Permanent(); /* make an object permanent */
-struct xobject *t1_Temporary(); /* make an object temporary */
-struct xobject *t1_Destroy(); /* destroy an object */
-struct xobject *t1_Dup(); /* duplicate an object */
-void t1_InitImager(); /* initialize TYPE1IMAGER */
-void t1_TermImager(); /* terminate TYPE1IMAGER */
-void t1_Pragmatics(); /* set debug flags, etc. */
-char *t1_ErrorMsg(); /* return last TYPE1IMAGER error message */
+/* make an object permanent */
+extern struct xobject *t1_Permanent ( pointer obj );
+
+#ifdef notused
+/* make an object temporary */
+extern struct xobject *t1_Temporary( pointer obj );
+#endif
+
+/* destroy an object */
+extern struct xobject *t1_Destroy ( pointer obj );
+
+/* duplicate an object */
+extern struct xobject *t1_Dup ( pointer obj );
+
+
+extern void t1_InitImager ( void ); /* initialize TYPE1IMAGER */
+extern void t1_TermImager ( void ); /* terminate TYPE1IMAGER */
+/* set debug flags, etc. */
+extern void t1_Pragmatics ( char *username, int value );
+
+/* return last TYPE1IMAGER error message */
+extern char *t1_ErrorMsg ( void );
/*END SHARED*/
/*SHARED*/
-
-#define abort(line) FatalError(line)
+extern void xiFree ( long *addr );
+extern char *xiMalloc ( unsigned Size );
+extern void addmemory ( long *addr, long size );
+extern void delmemory ( void );
+
+#ifndef OS_H
+extern void FatalError(const char *f, ...)
+#if defined(__GNUC__) && \
+ ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ > 4)))
+__attribute((noreturn))
+#endif
+;
+
+extern void ErrorF(const char *f, ...);
+#endif
+
+#define Abort(line) FatalError(line)
#define Allocate(n,t,s) t1_Allocate(n,t,s)
#define Free(obj) t1_Free(obj)
-#define NonObjectFree(a) xiFree(a)
+#define NonObjectFree(a) xiFree((long *)(a))
#define Consume t1_Consume
#define ArgErr(s,o,r) t1_ArgErr(s,o,r)
#define TypeErr(n,o,e,r) t1_TypeErr(n,o,e,r)
#define Copy(obj) t1_Copy(obj)
#define Unique(obj) t1_Unique(obj)
-struct xobject *t1_Allocate(); /* allocate memory */
-void t1_Free(); /* free memory */
-struct xobject *t1_Unique(); /* make a unique temporary copy of an object */
-struct xobject *t1_ArgErr(); /* handle argument errors */
-struct xobject *t1_TypeErr(); /* handle 'bad type' argument errors */
-void t1_Consume(); /* consume a variable number of arguments */
-struct xobject *t1_Copy(); /* make a new copy, not reference bump PNM */
+/* allocate memory */
+extern struct xobject *t1_Allocate( int size, pointer template,
+ int extra );
+
+/* free memory */
+extern void t1_Free ( pointer obj );
+
+/* make a unique temporary copy of an object */
+extern struct xobject *t1_Unique ( pointer obj );
+
+/* handle argument errors */
+extern struct xobject *t1_ArgErr ( char *string, pointer obj, pointer ret );
+
+/* handle 'bad type' argument errors */
+extern struct xobject *t1_TypeErr ( char *name, pointer obj,
+ int expect, pointer ret );
+
+/* consume a variable number of arguments */
+extern void t1_Consume ( int n, ... );
+
+/* make a new copy, not reference bump PNM */
+extern struct xobject *t1_Copy ( pointer obj );
+
/*END SHARED*/
/*SHARED*/
@@ -82,7 +152,7 @@ struct xobject *t1_Copy(); /* make a new copy, not reference bump PNM */
#endif
#ifndef NULL
-#define NULL 0
+#include <stddef.h>
/*
The NULL pointer is system specific. (Most systems, however, use 0.)
TYPE1IMAGER could have its own NULL, independent of the rest of the system,
@@ -223,9 +293,10 @@ struct xobject {
#define IfTrace5(condition,model,arg0,arg1,arg2,arg3,arg4)
#define IfTrace6(condition,model,arg0,arg1,arg2,arg3,arg4,arg5)
-
+#if 0
void Trace0();
char *Trace1(),*Trace2(),*Trace3(),*Trace4(),*Trace5(),*Trace6();
+#endif
#ifdef GLOBALS
@@ -240,7 +311,11 @@ char *Trace1(),*Trace2(),*Trace3(),*Trace4(),*Trace5(),*Trace6();
extern char MustCheckArgs INITIALIZED(TRUE);
extern char MustTraceCalls INITIALIZED(FALSE);
+#ifdef BUILDCID
+extern char MustCrash INITIALIZED(FALSE);
+#else
extern char MustCrash INITIALIZED(TRUE);
+#endif
extern char InternalTrace INITIALIZED(TRUE);
extern char LineIOTrace INITIALIZED(TRUE);
@@ -281,11 +356,7 @@ We define other routines formatting parameters
#define DumpEdges(e) t1_DumpEdges(e)
#define FormatFP(s,p) t1_FormatFP(s,p)
-void t1_DumpArea(); /* dump a region structure */
-void t1_DumpText(); /* dump a textpath structure */
-void t1_DumpPath(); /* dump a path list */
-void t1_DumpSpace(); /* dump a coordinate space structure */
-void t1_DumpEdges(); /* dump a region's edge list */
-void t1_FormatFP(); /* dump a format a "fractpel" coordinate */
+/* dump a textpath structure */
+extern void t1_DumpText(void);
/*END SHARED*/
diff --git a/src/Type1/paths.c b/src/Type1/paths.c
index 35c3e41..6291d68 100644
--- a/src/Type1/paths.c
+++ b/src/Type1/paths.c
@@ -26,6 +26,8 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/paths.c,v 1.7 2002/02/18 20:51:57 herrb Exp $ */
+
/* PATHS CWEB V0021 ******** */
/*
:h1 id=paths.PATHS Module - Path Operator Handler
@@ -42,6 +44,7 @@ The included files are:
*/
/* after the system includes (dsr) */
+#include "os.h"
#include "objects.h"
#include "spaces.h"
#include "paths.h"
@@ -51,6 +54,7 @@ The included files are:
#include "strokes.h" /* understands how to coerce stroke paths */
#include "trig.h"
+
/*
:h3.Routines Available to the TYPE1IMAGER User
@@ -112,10 +116,10 @@ text, which has some auxilliary things involved. We don't feel
competent to duplicate text in this module, so we call someone who
knows how (in the FONTS module).
*/
-struct segment *CopyPath(p0)
- register struct segment *p0; /* path to duplicate */
+struct segment *
+CopyPath(struct segment *p0) /* path to duplicate */
{
- register struct segment *p,*n,*last,*anchor;
+ register struct segment *p,*n = NULL,*last = NULL,*anchor;
for (p = p0, anchor = NULL; p != NULL; p = p->link) {
@@ -150,8 +154,8 @@ At this point we have a chain of newly allocated segments hanging off
Destroying a path is simply a matter of freeing each segment in the
linked list. Again, we let the experts handle text.
*/
-void KillPath(p)
- register struct segment *p; /* path to destroy */
+void
+KillPath(struct segment *p) /* path to destroy */
{
register struct segment *linkp; /* temp register holding next segment*/
@@ -194,15 +198,15 @@ This template is used as a generic segment structure for Allocate:
/* added reference field 1 to temporary template below 3-26-91 PNM */
static struct segment movetemplate = { MOVETYPE, 0, 1, sizeof(struct segment), 0,
- NULL, NULL, 0, 0 };
+ NULL, NULL, {0, 0} };
/*
:h3.Loc() - Create an "Invisible Line" Between (0,0) and a Point
*/
-struct segment *t1_Loc(S, x, y)
- register struct XYspace *S; /* coordinate space to interpret X,Y */
- double x,y; /* destination point */
+struct segment *
+t1_Loc(struct XYspace *S, /* coordinate space to interpret X,Y */
+ double x, double y) /* destination point */
{
register struct segment *r;
@@ -222,9 +226,9 @@ struct segment *t1_Loc(S, x, y)
:h3.ILoc() - Loc() With Integer Arguments
*/
-struct segment *ILoc(S, x, y)
- register struct XYspace *S; /* coordinate space to interpret X,Y */
- register int x,y; /* destination point */
+struct segment *
+ILoc(struct XYspace *S, /* coordinate space to interpret X,Y */
+ int x, int y) /* destination point */
{
register struct segment *r;
@@ -250,9 +254,8 @@ The symmetrical function AddLoc() is totally redundent with Join(),
so it is not provided.
*/
-struct segment *SubLoc(p1, p2)
- register struct segment *p1;
- register struct segment *p2;
+struct segment *
+SubLoc(struct segment *p1, struct segment *p2)
{
IfTrace2((MustTraceCalls),"SubLoc(%z, %z)\n", p1, p2);
@@ -277,9 +280,9 @@ conversion is unnecessary. PathSegment() is an internal routine
provided to the rest of TYPE1IMAGER for handling these cases.
*/
-struct segment *t1_PathSegment(type, x, y)
- int type; /* LINETYPE or MOVETYPE */
- fractpel x,y; /* where to go to, if known */
+struct segment *
+t1_PathSegment(int type, /* LINETYPE or MOVETYPE */
+ fractpel x, fractpel y) /* where to go to, if known */
{
register struct segment *r; /* newly created segment */
@@ -295,8 +298,8 @@ struct segment *t1_PathSegment(type, x, y)
This involves just creating and filling out a segment structure:
*/
-struct segment *Line(P)
- register struct segment *P; /* relevant coordinate space */
+struct segment *
+Line(struct segment *P) /* relevant coordinate space */
{
IfTrace1((MustTraceCalls),"..Line(%z)\n", P);
@@ -330,10 +333,10 @@ inversely related to the length |CD|. Point A is always point (0,0).
This is just a simple matter of filling out a 'beziersegment' structure:
*/
-struct beziersegment *Bezier(B, C, D)
- register struct segment *B; /* second control point */
- register struct segment *C; /* third control point */
- register struct segment *D; /* fourth control point (ending point) */
+struct beziersegment *
+Bezier(struct segment *B, /* second control point */
+ struct segment *C, /* third control point */
+ struct segment *D) /* fourth control point (ending point) */
{
/* added reference field of 1 to temporary template below 3-26-91 PNM */
static struct beziersegment template =
@@ -371,15 +374,10 @@ This is temporary code while we experiment with hints.
*/
/*SHARED LINE(S) ORIGINATED HERE*/
-struct hintsegment *Hint(S, ref, width, orientation, hinttype, adjusttype, direction, label)
- struct XYspace *S;
- float ref;
- float width;
- char orientation;
- char hinttype;
- char adjusttype;
- char direction;
- int label;
+struct hintsegment *
+Hint(struct XYspace *S, float ref, float width,
+ char orientation, char hinttype, char adjusttype, char direction,
+ int label)
{
/* added reference field of 1 to hintsegment template below 3-26-91 PNM */
static struct hintsegment template = { HINTTYPE, 0, 1, sizeof(struct hintsegment), 0,
@@ -446,8 +444,8 @@ types other than paths, and also check for certain path consistency
rules.
*/
-struct segment *Join(p1, p2)
- register struct segment *p1,*p2;
+struct segment *
+Join(struct segment *p1, struct segment *p2)
{
IfTrace2((MustTraceCalls && PathDebug > 1),"..Join(%z, %z)\n", p1, p2);
IfTrace2((MustTraceCalls && PathDebug <=1),"..Join(%x, %x)\n", p1, p2);
@@ -570,11 +568,11 @@ This internal function is quicker than a full-fledged join because
it can do much less checking.
*/
-struct segment *t1_JoinSegment(before, type, x, y, after)
- register struct segment *before; /* path to join before new segment */
- int type; /* type of new segment (MOVETYPE or LINETYPE) */
- fractpel x,y; /* x,y of new segment */
- register struct segment *after; /* path to join after new segment */
+struct segment *
+t1_JoinSegment(struct segment *before, /* path to join before new segment */
+ int type, /* type of new segment (MOVETYPE or LINETYPE) */
+ fractpel x, fractpel y, /* x,y of new segment */
+ struct segment *after) /* path to join after new segment */
{
register struct segment *r; /* returned path built here */
@@ -596,14 +594,14 @@ struct segment *t1_JoinSegment(before, type, x, y, after)
*/
-struct segment *t1_ClosePath(p0,lastonly)
- register struct segment *p0; /* path to close */
- register int lastonly; /* flag deciding to close all subpaths or... */
+struct segment *
+t1_ClosePath(struct segment *p0, /* path to close */
+ int lastonly) /* flag deciding to close all subpaths or... */
{
- register struct segment *p,*last,*start; /* used in looping through path */
+ register struct segment *p,*last = NULL,*start; /* used in looping through path */
register fractpel x,y; /* current position in path */
- register fractpel firstx,firsty; /* start position of sub path */
- register struct segment *lastnonhint; /* last non-hint segment in path */
+ register fractpel firstx = 0,firsty = 0; /* start position of sub path */
+ register struct segment *lastnonhint = NULL; /* last non-hint segment in path */
IfTrace1((MustTraceCalls),"ClosePath(%z)\n", p0);
if (p0 != NULL && p0->type == TEXTTYPE)
@@ -689,18 +687,22 @@ etc.
We need three subroutines:
*/
-static struct segment *SplitPath(); /* break a path at any point */
-static struct segment *DropSubPath(); /* breaks a path after first sub-path */
-static struct segment *ReverseSubPath(); /* reverses a single sub-path */
-
+/* break a path at any point */
+static struct segment *SplitPath ( struct segment *anchor,
+ struct segment *before );
+/* breaks a path after first sub-path */
+static struct segment *DropSubPath ( struct segment *p0 );
+/* reverses a single sub-path */
+static struct segment *ReverseSubPath ( struct segment *p );
+
/*
:h3.Reverse() - User Operator to Reverse a Path
This operator reverses the entire path.
*/
-struct segment *Reverse(p)
- register struct segment *p; /* full path to reverse */
+struct segment *
+Reverse(struct segment *p) /* full path to reverse */
{
register struct segment *r; /* output path built here */
register struct segment *nextp; /* contains next sub-path */
@@ -733,8 +735,8 @@ struct segment *Reverse(p)
:h4.ReverseSubPath() - Subroutine to Reverse a Single Sub-Path
*/
-static struct segment *ReverseSubPath(p)
- register struct segment *p; /* input path */
+static struct segment *
+ReverseSubPath(struct segment *p) /* input path */
{
register struct segment *r; /* reversed path will be created here */
register struct segment *nextp; /* temporary variable used in loop */
@@ -790,7 +792,7 @@ So, we add "dest" instead of subtracting it:
break;
default:
- abort("Reverse: bad path segment");
+ Abort("Reverse: bad path segment");
}
/*
We need to reverse the order of segments too, so we break this segment
@@ -821,8 +823,8 @@ breaks the input path after the first sub-path so that a pointer to
the original path now contains the first sub-path only.
*/
-static struct segment *DropSubPath(p0)
- register struct segment *p0; /* original path */
+static struct segment *
+DropSubPath(struct segment *p0) /* original path */
{
register struct segment *p; /* returned remainder here */
@@ -834,9 +836,8 @@ static struct segment *DropSubPath(p0)
return(SplitPath(p0, p));
}
-static struct segment *SplitPath(anchor, before)
- register struct segment *anchor;
- register struct segment *before;
+static struct segment *
+SplitPath(struct segment *anchor, struct segment *before)
{
register struct segment *r;
@@ -852,15 +853,14 @@ static struct segment *SplitPath(anchor, before)
}
static void
-UnClose(p0)
- register struct segment *p0;
+UnClose(struct segment *p0)
{
register struct segment *p;
for (p=p0; p->link->link != NULL; p=p->link) { ; }
if (!LASTCLOSED(p->link->flag))
- abort("UnClose: no LASTCLOSED");
+ Abort("UnClose: no LASTCLOSED");
Free(SplitPath(p0, p));
p0->flag &= ~ISCLOSED(ON);
@@ -874,8 +874,8 @@ This user operator reverses the sub-paths in a path, but leaves the
already established.
*/
-struct segment *ReverseSubPaths(p)
- register struct segment *p; /* input path */
+struct segment *
+ReverseSubPaths(struct segment *p) /* input path */
{
register struct segment *r; /* reversed path will be created here */
register struct segment *nextp; /* temporary variable used in loop */
@@ -951,9 +951,9 @@ The transform is described as a "space", that way we can use our
old friend the "iconvert" function, which should be very efficient.
*/
-struct segment *PathTransform(p0, S)
- register struct segment *p0; /* path to transform */
- register struct XYspace *S; /* pseudo space to transform in */
+struct segment *
+PathTransform(struct segment *p0, /* path to transform */
+ struct XYspace *S) /* pseudo space to transform in */
{
register struct segment *p; /* to loop through path with */
register fractpel newx,newy; /* current transformed position in path */
@@ -1025,7 +1025,7 @@ struct segment *PathTransform(p0, S)
default:
IfTrace1(TRUE,"path = %z\n", p);
- abort("PathTransform: invalid segment");
+ Abort("PathTransform: invalid segment");
}
oldx += savex;
oldy += savey;
@@ -1039,9 +1039,9 @@ struct segment *PathTransform(p0, S)
:h3.PathDelta() - Return a Path's Ending Point
*/
-void PathDelta(p, pt)
- register struct segment *p; /* input path */
- register struct fractpoint *pt; /* pointer to x,y to set */
+void
+PathDelta(struct segment *p, /* input path */
+ struct fractpoint *pt) /* pointer to x,y to set */
{
struct fractpoint mypoint; /* I pass this to TextDelta */
register fractpel x,y; /* working variables for path current point */
@@ -1067,8 +1067,8 @@ This function is called by image code, when we know the size of the
image in pels, and need to get a bounding box path that surrounds it.
The starting/ending handle is in the lower right hand corner.
*/
-struct segment *BoundingBox(h, w)
- register pel h,w; /* size of box */
+struct segment *
+BoundingBox(pel h, pel w) /* size of box */
{
register struct segment *path;
@@ -1086,10 +1086,10 @@ struct segment *BoundingBox(h, w)
:h3.QueryLoc() - Return the X,Y of a Locition
*/
-void QueryLoc(P, S, xP, yP)
- register struct segment *P; /* location to query, not consumed */
- register struct XYspace *S; /* XY space to return coordinates in */
- register double *xP,*yP; /* coordinates returned here */
+void
+QueryLoc(struct segment *P, /* location to query, not consumed */
+ struct XYspace *S, /* XY space to return coordinates in */
+ double *xP, double *yP) /* coordinates returned here */
{
IfTrace4((MustTraceCalls),"QueryLoc(P=%z, S=%z, (%x, %x))\n",
P, S, xP, yP);
@@ -1114,13 +1114,13 @@ a move segment, for example, he only needs to pass pointers to return
one control point.
*/
-void QueryPath(path, typeP, Bp, Cp, Dp, fP)
- register struct segment *path; /* path to check */
- register int *typeP; /* return the type of path here */
- register struct segment **Bp; /* return location of first point */
- register struct segment **Cp; /* return location of second point */
- register struct segment **Dp; /* return location of third point */
- register double *fP; /* return Conic sharpness */
+void
+QueryPath(struct segment *path, /* path to check */
+ int *typeP, /* return the type of path here */
+ struct segment **Bp, /* return location of first point */
+ struct segment **Cp, /* return location of second point */
+ struct segment **Dp, /* return location of third point */
+ double *fP) /* return Conic sharpness */
{
register int coerced = FALSE; /* did I coerce a text path? */
@@ -1177,7 +1177,7 @@ void QueryPath(path, typeP, Bp, Cp, Dp, fP)
break;
default:
- abort("QueryPath: unknown segment");
+ Abort("QueryPath: unknown segment");
}
if (coerced)
KillPath(path);
@@ -1188,11 +1188,13 @@ void QueryPath(path, typeP, Bp, Cp, Dp, fP)
Returns the bounding box by setting the user's variables.
*/
-void QueryBounds(p0, S, xminP, yminP, xmaxP, ymaxP)
- register struct segment *p0; /* object to check for bound */
- struct XYspace *S; /* coordinate space of returned values */
- double *xminP,*yminP; /* lower left hand corner (set by routine) */
- double *xmaxP,*ymaxP; /* upper right hand corner (set by routine) */
+void
+QueryBounds(struct segment *p0, /* object to check for bound */
+ struct XYspace *S, /* coordinate space of returned values */
+ double *xminP, /* lower left hand corner (set by routine) */
+ double *yminP,
+ double *xmaxP, /* upper right hand corner (set by routine) */
+ double *ymaxP)
{
register struct segment *path; /* loop variable for path segments */
register fractpel lastx,lasty; /* loop variables: previous endingpoint */
@@ -1219,7 +1221,7 @@ void QueryBounds(p0, S, xminP, yminP, xmaxP, ymaxP)
p0 = (struct segment *) DoStroke(Dup(p0));
/* no break here, we have a region in p0 */
case REGIONTYPE:
- p0 = RegionBounds(p0);
+ p0 = RegionBounds((struct region *)p0);
break;
case PICTURETYPE:
@@ -1317,7 +1319,7 @@ void QueryBounds(p0, S, xminP, yminP, xmaxP, ymaxP)
case HINTTYPE:
break;
default:
- abort("QueryBounds: unknown type");
+ Abort("QueryBounds: unknown type");
}
if (x < min.x) min.x = x;
@@ -1356,9 +1358,8 @@ done:
/*
:h3.BoxPath()
*/
-struct segment *BoxPath(S, h, w)
- struct XYspace *S;
- int h,w;
+struct segment *
+BoxPath(struct XYspace *S, int h, int w)
{
struct segment *path;
@@ -1375,8 +1376,8 @@ shorter. It can be used in conjunction with QueryPath(), for example,
to ask about an entire path.
*/
-struct segment *DropSegment(path)
- register struct segment *path;
+struct segment *
+DropSegment(struct segment *path)
{
IfTrace1((MustTraceCalls),"DropSegment(%z)\n", path);
if (path != NULL && path->type == STROKEPATHTYPE)
@@ -1397,8 +1398,8 @@ This routine takes the path and returns a new path consists of the
first segment only.
*/
-struct segment *HeadSegment(path)
- register struct segment *path; /* input path */
+struct segment *
+HeadSegment(struct segment *path) /* input path */
{
IfTrace1((MustTraceCalls),"HeadSegment(%z)\n", path);
if (path == NULL)
@@ -1423,8 +1424,8 @@ struct segment *HeadSegment(path)
:h3.DumpPath() - Display a Path on the Trace File
*/
-void DumpPath(p)
- register struct segment *p;
+void
+DumpPath(struct segment *p)
{
register fractpel x,y;
register fractpel lastx,lasty;
@@ -1466,8 +1467,6 @@ void DumpPath(p)
case BEZIERTYPE:
{
- register struct beziersegment *bp = (struct beziersegment *) p;
-
IfTrace4(TRUE,". bezier to (%p,%p), B=(%p,%p)",
x + lastx, y + lasty,
bp->B.x + lastx, bp->B.y + lasty);
@@ -1478,8 +1477,6 @@ void DumpPath(p)
case HINTTYPE:
{
- register struct hintsegment *hp = (struct hintsegment *) p;
-
IfTrace4(TRUE,". hint ref=(%p,%p), width=(%p,%p)",
hp->ref.x + lastx, hp->ref.y + lasty,
hp->width.x, hp->width.y);
@@ -1491,7 +1488,9 @@ void DumpPath(p)
break;
case TEXTTYPE:
+#ifdef notyet
DumpText(p);
+#endif
break;
default:
diff --git a/src/Type1/paths.h b/src/Type1/paths.h
index e52a760..3f1b389 100644
--- a/src/Type1/paths.h
+++ b/src/Type1/paths.h
@@ -26,6 +26,8 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/paths.h,v 1.4 2001/01/17 19:43:22 dawes Exp $ */
+
/*SHARED*/
#define Loc(S,x,y) t1_Loc(S,(double)x,(double)y)
@@ -50,26 +52,53 @@
#define QueryPath(p,t,B,C,D,r) t1_QueryPath(p,t,B,C,D,r)
#define QueryBounds(p,S,x1,y1,x2,y2) t1_QueryBounds(p,S,x1,y1,x2,y2)
-
-struct segment *t1_Loc(); /* create a location object (or "move" segment) */
-struct segment *t1_ILoc(); /* integer argument version of same */
-struct segment *t1_Line(); /* straight line path segment */
-struct segment *t1_Join(); /* join two paths or regions together */
-struct segment *t1_ClosePath(); /* close a path or path set */
+
+/* create a location object (or "move" segment) */
+extern struct segment *t1_Loc ( struct XYspace *S, double x, double y );
+/* integer argument version of same */
+extern struct segment *t1_ILoc ( struct XYspace *S, int x, int y );
+/* straight line path segment */
+extern struct segment *t1_Line ( struct segment *P );
+/* join two paths or regions together */
+extern struct segment *t1_Join ( struct segment *p1, struct segment *p2 );
+/* close a path or path set */
+extern struct segment *t1_ClosePath ( struct segment *p0, int lastonly );
+#if 0
struct conicsegment *t1_Conic(); /* conic curve path segment */
+
struct conicsegment *t1_RoundConic(); /* ditto, specified another way */
struct conicsegment *t1_ArcP3(); /* circular path segment with three points */
struct conicsegment *t1_ArcCA(); /* ditto, with center point and angle */
-struct beziersegment *t1_Bezier(); /* Bezier third order curve path segment */
-struct hintsegment *t1_Hint(); /* produce a font 'hint' path segment */
-struct segment *t1_Reverse(); /* reverse the complete order of paths */
-struct segment *t1_ReverseSubPaths(); /* reverse only sub-paths; moves unchanged */
-struct segment *t1_SubLoc(); /* subtract two location objects */
-struct segment *t1_DropSegment(); /* Drop the first segment in a path */
-struct segment *t1_HeadSegment(); /* return the first segment in a path */
-void t1_QueryLoc(); /* Query location; return its (x,y) */
-void t1_QueryPath(); /* Query segment at head of a path */
-void t1_QueryBounds(); /* Query the bounding box of a path */
+#endif
+/* Bezier third order curve path segment */
+extern struct beziersegment *t1_Bezier ( struct segment *B, struct segment *C,
+ struct segment *D );
+/* produce a font 'hint' path segment */
+extern struct hintsegment *t1_Hint ( struct XYspace *S, float ref, float width,
+ char orientation, char hinttype,
+ char adjusttype, char direction,
+ int label );
+/* reverse the complete order of paths */
+extern struct segment *t1_Reverse ( struct segment *p );
+/* reverse only sub-paths; moves unchanged */
+extern struct segment *t1_ReverseSubPaths ( struct segment *p );
+/* subtract two location objects */
+extern struct segment *t1_SubLoc ( struct segment *p1, struct segment *p2 );
+/* Drop the first segment in a path */
+extern struct segment *t1_DropSegment ( struct segment *path );
+/* return the first segment in a path */
+extern struct segment *t1_HeadSegment ( struct segment *path );
+/* Query location; return its (x,y) */
+extern void t1_QueryLoc ( struct segment *P, struct XYspace *S, double *xP,
+ double *yP );
+/* Query segment at head of a path */
+extern void t1_QueryPath ( struct segment *path, int *typeP,
+ struct segment **Bp, struct segment **Cp,
+ struct segment **Dp, double *fP );
+/* Query the bounding box of a path */
+extern void t1_QueryBounds ( struct segment *p0, struct XYspace *S,
+ double *xminP, double *yminP,
+ double *xmaxP, double *ymaxP );
/*END SHARED*/
/*SHARED*/
@@ -83,15 +112,26 @@ void t1_QueryBounds(); /* Query the bounding box of a path */
#define JoinSegment(b,t,x,y,a) t1_JoinSegment(b,t,(fractpel)x,(fractpel)y,a)
#define Hypoteneuse(dx,dy) t1_Hypoteneuse(dx,dy)
#define BoxPath(S,h,w) t1_BoxPath(S,h,w)
-
-struct segment *t1_CopyPath(); /* duplicate a path */
-void t1_KillPath(); /* destroy a path */
-struct segment *t1_PathXform(); /* transform a path arbitrarily */
-void t1_PathDelta(); /* calculate the ending point of a path */
-struct segment *t1_PathSegment(); /* produce a MOVE or LINE segment */
-struct segment *t1_JoinSegment(); /* join a MOVE or LINE segment to a path */
+
+/* duplicate a path */
+extern struct segment *t1_CopyPath ( struct segment *p0 );
+/* destroy a path */
+extern void t1_KillPath ( struct segment *p );
+/* transform a path arbitrarily */
+extern struct segment *t1_PathXform ( struct segment *p0, struct XYspace *S );
+/* calculate the ending point of a path */
+extern void t1_PathDelta ( struct segment *p, struct fractpoint *pt );
+/* */
+extern struct segment *t1_BoundingBox ( pel h, pel w );
+/* produce a MOVE or LINE segment */
+extern struct segment *t1_PathSegment ( int type, fractpel x, fractpel y );
+/* join a MOVE or LINE segment to a path */
+extern struct segment *t1_JoinSegment ( struct segment *before, int type, fractpel x, fractpel y, struct segment *after );
+#if 0
double t1_Hypoteneuse(); /* returns the length of a line */
-struct segment *t1_BoxPath(); /* returns a rectangular path */
+#endif
+/* returns a rectangular path */
+extern struct segment *t1_BoxPath ( struct XYspace *S, int h, int w );
/*END SHARED*/
/*SHARED*/
@@ -195,3 +235,5 @@ is also used by the STROKES module.)
p2->last = NULL; } /* only first segment has non-NULL "last" */
/*END SHARED*/
+/* dump a path list */
+extern void t1_DumpPath ( struct segment *p );
diff --git a/src/Type1/pictures.h b/src/Type1/pictures.h
index 6a14292..aa02ce5 100644
--- a/src/Type1/pictures.h
+++ b/src/Type1/pictures.h
@@ -27,6 +27,8 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/pictures.h,v 1.4 2001/01/17 19:43:23 dawes Exp $ */
+
/* STUB */
#define CopyPicture(p) p
@@ -44,5 +46,5 @@ struct picture {
#define Phantom(o) t1_Phantom(o)
#define Snap(o) t1_Snap(o)
-struct segment *t1_Phantom();
-struct segment *t1_Snap();
+extern struct segment *t1_Phantom ( struct segment *p );
+extern struct segment *t1_Snap ( struct segment *p );
diff --git a/src/Type1/regions.c b/src/Type1/regions.c
index 2824887..724d3f5 100644
--- a/src/Type1/regions.c
+++ b/src/Type1/regions.c
@@ -26,6 +26,7 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/regions.c,v 3.8 2002/02/18 20:51:57 herrb Exp $ */
/* REGIONS CWEB V0023 LOTS */
/*
:h1 id=regions.REGIONS Module - Regions Operator Handler
@@ -40,26 +41,31 @@ This module is responsible for creating and manipulating regions.
The included files are:
*/
+#include "os.h"
#include "objects.h"
#include "spaces.h"
-#include "regions.h"
#include "paths.h"
+#include "regions.h"
#include "curves.h"
#include "lines.h"
#include "pictures.h"
#include "fonts.h"
#include "hints.h"
#include "strokes.h" /* to pick up 'DoStroke' */
-static void newfilledge();
-static struct edgelist *splitedge();
-static void vertjoin();
-static int touches();
-static int crosses();
-static void edgemin();
-static void edgemax();
-static struct edgelist *NewEdge();
-static struct edgelist *swathxsort(); /* 'SortSwath' function */
-
+
+
+static void newfilledge ( struct region *R, fractpel xmin, fractpel xmax,
+ fractpel ymin, fractpel ymax, int isdown );
+static struct edgelist *splitedge ( struct edgelist *list, pel y );
+static void vertjoin ( struct edgelist *top, struct edgelist *bottom );
+static int touches ( int h, pel *left, pel *right );
+static int crosses ( int h, pel *left, pel *right );
+static void edgemin ( int h, pel *e1, pel *e2 );
+static void edgemax ( int h, pel *e1, pel *e2 );
+static struct edgelist *NewEdge ( pel xmin, pel xmax, pel ymin, pel ymax,
+ pel *xvalues, int isdown );
+static struct edgelist *swathxsort ( struct edgelist *before0,
+ struct edgelist *edge );
/*
:h3.Functions Provided to the TYPE1IMAGER User
@@ -128,19 +134,19 @@ set. The flag is used to optimize some paths.
/*SHARED LINE(S) ORIGINATED HERE*/
/*
-:h4."INFINITY" - A Constant Region Structure of Infinite Extent
+:h4."TT_INFINITY" - A Constant Region Structure of Infinite Extent
Infinity is the complement of a null area:
Note - removed the refcount = 1 init, replaced with references = 2 3-26-91 PNM
*/
-static struct region infinity = { REGIONTYPE,
+static struct region _infinity = { REGIONTYPE,
ISCOMPLEMENT(ON)+ISINFINITE(ON)+ISPERMANENT(ON)+ISIMMORTAL(ON), 2,
- 0, 0, 0, 0,
+ {0, 0}, {0, 0},
0, 0, 0, 0,
NULL, NULL,
0, 0, 0, 0, 0, NULL, NULL,
NULL, 0, NULL, NULL };
-struct region *INFINITY = &infinity;
+struct region *TT_INFINITY = &_infinity;
/*
:h4."EmptyRegion" - A Region Structure with Zero Area
@@ -153,7 +159,7 @@ Note - replaced refcount = 1 init with references = 2 3-26-91 PNM
/*SHARED LINE(S) ORIGINATED HERE*/
struct region EmptyRegion = { REGIONTYPE,
ISPERMANENT(ON)+ISIMMORTAL(ON), 2,
- 0, 0, 0, 0,
+ {0, 0}, {0, 0},
MAXPEL, MAXPEL, MINPEL, MINPEL,
NULL, NULL,
0, 0, 0, 0, 0, NULL, NULL,
@@ -221,14 +227,14 @@ associated (thresholded) picture.
Note - added conditional return based on references 3-26-91 PNM
*/
-void KillRegion(area)
- register struct region *area; /* area to free */
+void
+KillRegion(struct region *area) /* area to free */
{
register struct edgelist *p; /* loop variable */
register struct edgelist *next; /* loop variable */
if (area->references < 0)
- abort("KillRegion: negative reference count");
+ Abort("KillRegion: negative reference count");
if ( (--(area->references) > 1) ||
( (area->references == 1) && !ISPERMANENT(area->flag) ) )
return;
@@ -244,11 +250,11 @@ void KillRegion(area)
/*
:h3.CopyRegion() - Makes a Copy of a Region
*/
-struct region *CopyRegion(area)
- register struct region *area; /* region to duplicate */
+struct region *
+CopyRegion(struct region *area) /* region to duplicate */
{
register struct region *r; /* output region built here */
- register struct edgelist *last; /* loop variable */
+ register struct edgelist *last = NULL; /* loop variable */
register struct edgelist *p,*newp; /* loop variables */
r = (struct region *)Allocate(sizeof(struct region), area, 0);
@@ -278,11 +284,11 @@ edgelist structure to free all memory associated with it. Damn
clever, huh?
*/
-static struct edgelist *NewEdge(xmin, xmax, ymin, ymax, xvalues, isdown)
- pel xmin,xmax; /* X extent of edge */
- pel ymin,ymax; /* Y extent of edge */
- pel *xvalues; /* list of X values for entire edge */
- int isdown; /* flag: TRUE means edge progresses downward */
+static struct edgelist *
+NewEdge(pel xmin, pel xmax, /* X extent of edge */
+ pel ymin, pel ymax, /* Y extent of edge */
+ pel *xvalues, /* list of X values for entire edge */
+ int isdown) /* flag: TRUE means edge progresses downward */
{
static struct edgelist template = {
EDGETYPE, 0, 1, NULL, NULL,
@@ -294,7 +300,7 @@ static struct edgelist *NewEdge(xmin, xmax, ymin, ymax, xvalues, isdown)
IfTrace2((RegionDebug),"....new edge: ymin=%d, ymax=%d ",
(long)ymin, (long) ymax);
if (ymin >= ymax)
- abort("newedge: height not positive");
+ Abort("newedge: height not positive");
/*
We are going to copy the xvalues into a newly allocated area. It
helps performance if the values are all "long" aligned. We can test
@@ -302,7 +308,7 @@ if the xvalues are long aligned by ANDing the address with the
(sizeof(long) - 1)--if non zero, the xvalues are not aligned well. We
set 'iy' to the ymin value that would give us good alignment:
*/
- iy = ymin - (((int) xvalues) & (sizeof(long) - 1)) / sizeof(pel);
+ iy = ymin - (((unsigned long)xvalues) & (sizeof(long)-1)) / sizeof(pel);
r = (struct edgelist *)Allocate(sizeof(struct edgelist), &template,
(ymax - iy) * sizeof(pel));
@@ -347,9 +353,8 @@ of the list and set ymin=ymax.
*/
static void
-discard(left, right)
- register struct edgelist *left,*right; /* all edges between here exclusive */
- /* should be discarded */
+discard(struct edgelist *left, /* all edges between here exclusive */
+ struct edgelist *right) /* should be discarded */
{
register struct edgelist *beg,*end,*p;
@@ -361,7 +366,7 @@ discard(left, right)
for (p = beg; p != right; p = p->link) {
if (p->link == NULL && right != NULL)
- abort("discard(): ran off end");
+ Abort("discard(): ran off end");
IfTrace1((RegionDebug > 0),"discarding %x\n", p);
p->ymin = p->ymax = 32767;
end = p;
@@ -389,10 +394,9 @@ discard the second one. Everything should balance; we should discard
an even number of edges; of course, we abort if we don't.
*/
static void
-Unwind(area)
- register struct edgelist *area; /* input area modified in place */
+Unwind(struct edgelist *area) /* input area modified in place */
{
- register struct edgelist *last,*next; /* struct before and after current one */
+ register struct edgelist *last = NULL,*next; /* struct before and after current one */
register int y; /* ymin of current swath */
register int count,newcount; /* winding count registers */
@@ -422,7 +426,7 @@ Unwind(area)
} while (area != NULL && area->ymin == y);
if (count != 0)
- abort("Unwind: uneven edges");
+ Abort("Unwind: uneven edges");
}
}
/*
@@ -453,9 +457,9 @@ region, we allow the same ChangeDirection logic to be used by stroking.
/*SHARED LINE(S) ORIGINATED HERE*/
-struct region *Interior(p, fillrule)
- register struct segment *p; /* take interior of this path */
- register int fillrule; /* rule to follow if path crosses itself */
+struct region *
+Interior(struct segment *p, /* take interior of this path */
+ int fillrule) /* rule to follow if path crosses itself */
{
register fractpel x,y; /* keeps ending point of path segment */
fractpel lastx,lasty; /* previous x,y from path segment before */
@@ -488,11 +492,12 @@ user asked, >1: do it regardless).
/* if (fillrule != EVENODDRULE)
else */
return((struct region *)UniquePath(p));
- if (p->type == STROKEPATHTYPE)
+ if (p->type == STROKEPATHTYPE) {
if (fillrule == WINDINGRULE)
return((struct region *)DoStroke(p));
else
p = CoercePath(p);
+ }
R = (struct region *)Allocate(sizeof(struct region), &EmptyRegion, 0);
@@ -575,7 +580,8 @@ segment (or NULL), and each hint segment will be freed if necessary.
while ((nextP != NULL) && (nextP->type == HINTTYPE)) {
if (ProcessHints)
- ProcessHint(nextP, x + hint.x, y + hint.y, &hint);
+ ProcessHint((struct hintsegment *)nextP,
+ x + hint.x, y + hint.y, &hint);
{
register struct segment *saveP = nextP;
@@ -645,7 +651,7 @@ MOVETYPE at the end of the path, if it isn't closed:
break;
default:
- abort("Interior: path type error");
+ Abort("Interior: path type error");
}
/*
We're done with this segment. Advance to the next path segment in
@@ -693,11 +699,11 @@ emerging edgelist at 'anchor' by calling whatever "newedgefcn"
is appropriate.
*/
-void ChangeDirection(type, R, x, y, dy)
- int type; /* CD_FIRST, CD_CONTINUE, or CD_LAST */
- register struct region *R; /* region in which we are changing direction */
- fractpel x,y; /* current beginning x,y */
- fractpel dy; /* direction and magnitude of change in y */
+void
+ChangeDirection(int type, /* CD_FIRST, CD_CONTINUE, or CD_LAST */
+ struct region *R, /* region in which we are changing direction */
+ fractpel x, fractpel y, /* current beginning x,y */
+ fractpel dy) /* direction and magnitude of change in y */
{
register fractpel ymin,ymax; /* minimum and maximum Y since last call */
register fractpel x_at_ymin,x_at_ymax; /* their respective X's */
@@ -724,11 +730,11 @@ void ChangeDirection(type, R, x, y, dy)
}
if (ymax < ymin)
- abort("negative sized edge?");
+ Abort("negative sized edge?");
(*R->newedgefcn)(R, R->edgexmin, R->edgexmax, ymin, ymax,
- R->lastdy > 0, x_at_ymin, x_at_ymax);
+ R->lastdy > 0);
}
@@ -779,11 +785,11 @@ This function also has to keep the bounding box of the region
up to date.
*/
-static void newfilledge(R, xmin, xmax, ymin, ymax, isdown)
- register struct region *R; /* region being built */
- fractpel xmin,xmax; /* X range of this edge */
- fractpel ymin,ymax; /* Y range of this edge */
- int isdown; /* flag: TRUE means edge goes down, else up */
+static void
+newfilledge(struct region *R, /* region being built */
+ fractpel xmin, fractpel xmax, /* X range of this edge */
+ fractpel ymin, fractpel ymax, /* Y range of this edge */
+ int isdown) /* flag: TRUE means edge goes down, else up */
{
register pel pelxmin,pelymin,pelxmax,pelymax; /* pel versions of bounds */
@@ -836,10 +842,10 @@ exactly where the bottom part belongs.
#define TOP(e) ((e)->ymin) /* the top of an edge (for readability */
#define BOTTOM(e) ((e)->ymax) /* the bottom of an edge (for readability */
-struct edgelist *SortSwath(anchor, edge, swathfcn)
- struct edgelist *anchor; /* list being built */
- register struct edgelist *edge; /* incoming edge or pair of edges */
- struct edgelist *(*swathfcn)(); /* horizontal sorter */
+struct edgelist *
+SortSwath(struct edgelist *anchor, /* list being built */
+ struct edgelist *edge, /* incoming edge or pair of edges */
+ SwathFunc swathfcn) /* horizontal sorter */
{
register struct edgelist *before,*after;
struct edgelist base;
@@ -951,12 +957,12 @@ is guaranteed not to change the address of the old swath while splitting
it.
*/
-static struct edgelist *splitedge(list, y)
- struct edgelist *list; /* area to split */
- register pel y; /* Y value to split list at */
+static struct edgelist *
+splitedge(struct edgelist *list, /* area to split */
+ pel y) /* Y value to split list at */
{
register struct edgelist *new; /* anchor for newly built list */
- register struct edgelist *last; /* end of newly built list */
+ register struct edgelist *last = NULL; /* end of newly built list */
register struct edgelist *r; /* temp pointer to new structure */
register struct edgelist *lastlist; /* temp pointer to last 'list' value */
@@ -968,9 +974,9 @@ static struct edgelist *splitedge(list, y)
if (y < list->ymin)
break;
if (y >= list->ymax)
- abort("splitedge: above top of list");
+ Abort("splitedge: above top of list");
if (y == list->ymin)
- abort("splitedge: would be null");
+ Abort("splitedge: would be null");
r = (struct edgelist *)Allocate(sizeof(struct edgelist), list, 0);
/*
@@ -1010,7 +1016,7 @@ list at 'lastlist', and add the broken off part to the end of 'new'.
Then, we return the caller a pointer to 'new':
*/
if (new == NULL)
- abort("null splitedge");
+ Abort("null splitedge");
lastlist->link = NULL;
last->link = list;
IfTrace1((RegionDebug > 1),"yields %x\n", new);
@@ -1027,7 +1033,7 @@ static void vertjoin(top, bottom)
register struct edgelist *bottom; /* bottommost region */
{
if (BOTTOM(top) > TOP(bottom))
- abort("vertjoin not disjoint");
+ Abort("vertjoin not disjoint");
for (; top->link != NULL; top=top->link) { ; }
@@ -1045,13 +1051,13 @@ all swath functions, this function returns a pointer to the edge
BEFORE the given edge in the sort.
*/
-static struct edgelist *swathxsort(before0, edge)
- register struct edgelist *before0; /* edge before this swath */
- register struct edgelist *edge; /* input edge */
+static struct edgelist *
+swathxsort(struct edgelist *before0, /* edge before this swath */
+ struct edgelist *edge) /* input edge */
{
register struct edgelist *before;
register struct edgelist *after;
- register pel y;
+ register pel y = 0;
before = before0;
after = before->link;
@@ -1121,9 +1127,9 @@ fun comes in they overlap the existing edges. Then some edges
will disappear.
*/
-struct edgelist *SwathUnion(before0, edge)
- register struct edgelist *before0; /* edge before the swath */
- register struct edgelist *edge; /* list of two edges to be unioned */
+struct edgelist *
+SwathUnion(struct edgelist *before0, /* edge before the swath */
+ struct edgelist *edge) /* list of two edges to be unioned */
{
register int h; /* saves height of edge */
register struct edgelist *rightedge; /* saves right edge of 'edge' */
@@ -1135,7 +1141,7 @@ struct edgelist *SwathUnion(before0, edge)
h0 = h = edge->ymax - edge->ymin;
if (h <= 0)
- abort("SwathUnion: 0 height swath?");
+ Abort("SwathUnion: 0 height swath?");
before = before0;
after = before->link;
@@ -1271,6 +1277,7 @@ were overlapped and have been combined with the new incoming 'edge':
}
return(before);
}
+#ifdef notused
/*
:h3.swathrightmost() - Simply Sorts New Edge to Rightmost of Swath
@@ -1278,9 +1285,9 @@ Like all swath functions, this function returns a pointer to the edge
BEFORE the given edge in the sort.
*/
-static struct edgelist *swathrightmost(before, edge)
- register struct edgelist *before; /* edge before this swath */
- register struct edgelist *edge; /* input edge */
+static struct edgelist *
+swathrightmost(struct edgelist *before, /* edge before this swath */
+ struct edgelist *edge) /* input edge */
{
register struct edgelist *after;
@@ -1294,6 +1301,7 @@ static struct edgelist *swathrightmost(before, edge)
return(before);
}
+#endif
/*
:h3.touches() - Returns the Remaining Height When Two Edges Touch
@@ -1301,9 +1309,8 @@ So, it will return 0 if they never touch. Allows incredibly(?) mnemonic
if (touches(...)) construct.
*/
-static int touches(h, left, right)
- register int h;
- register pel *left,*right;
+static int
+touches(int h, pel *left, pel *right)
{
for (; h > 0; h--)
if (*left++ >= *right++)
@@ -1316,9 +1323,8 @@ static int touches(h, left, right)
So, it will return 0 if they never cross.
*/
-static int crosses(h, left, right)
- register int h;
- register pel *left,*right;
+static int
+crosses(int h, pel *left, pel *right)
{
for (; h > 0; h--)
if (*left++ > *right++)
@@ -1329,10 +1335,8 @@ static int crosses(h, left, right)
:h3.cedgemin() - Stores the Mininum of an Edge and an X Value
*/
-static void cedgemin(h, e1, x)
- register int h;
- register pel *e1;
- register pel x;
+static void
+cedgemin(int h, pel *e1, pel x)
{
for (; --h >= 0; e1++)
if (*e1 > x)
@@ -1342,10 +1346,8 @@ static void cedgemin(h, e1, x)
:h3.cedgemax() - Stores the Maximum of an Edge and an X Value
*/
-static void cedgemax(h, e1, x)
- register int h;
- register pel *e1;
- register pel x;
+static void
+cedgemax(int h, pel *e1, pel x)
{
for (; --h >= 0; e1++)
if (*e1 < x)
@@ -1355,9 +1357,8 @@ static void cedgemax(h, e1, x)
:h3.edgemin() - Stores the Mininum of Two Edges in First Edge
*/
-static void edgemin(h, e1, e2)
- register int h;
- register pel *e1,*e2;
+static void
+edgemin(int h, pel *e1, pel *e2)
{
for (; --h >= 0; e1++,e2++)
if (*e1 > *e2)
@@ -1367,9 +1368,8 @@ static void edgemin(h, e1, e2)
:h3.edgemax() - Stores the Maximum of Two Edges in First Edge
*/
-static void edgemax(h, e1, e2)
- register int h;
- register pel *e1,*e2;
+static void
+edgemax(int h, pel *e1, pel *e2)
{
for (; --h >= 0; e1++,e2++)
if (*e1 < *e2)
@@ -1387,9 +1387,8 @@ region.
*/
void
-MoveEdges(R, dx, dy)
- register struct region *R; /* region to modify */
- register fractpel dx,dy; /* delta X and Y to move edge list by */
+MoveEdges(struct region *R, /* region to modify */
+ fractpel dx, fractpel dy) /* delta X and Y to move edge list by */
{
register struct edgelist *edge; /* for looping through edges */
@@ -1436,8 +1435,8 @@ From now on we will deal with dx and dy as integer pel values:
It is an open question whether it pays in general to do this.
*/
-void UnJumble(region)
- struct region *region; /* region to sort */
+void
+UnJumble(struct region *region) /* region to sort */
{
register struct edgelist *anchor; /* new lists built here */
register struct edgelist *edge; /* edge pointer for loop */
@@ -1447,7 +1446,7 @@ void UnJumble(region)
for (edge=region->anchor; VALIDEDGE(edge); edge=next) {
if (edge->link == NULL)
- abort("UnJumble: unpaired edge?");
+ Abort("UnJumble: unpaired edge?");
next = edge->link->link;
edge->link->link = NULL;
anchor = SortSwath(anchor, edge, t1_SwathUnion);
@@ -1462,10 +1461,9 @@ void UnJumble(region)
/*
*/
-
+#ifdef notused
static void
-OptimizeRegion(R)
- struct region *R; /* region to optimize */
+OptimizeRegion(struct region *R) /* region to optimize */
{
register pel *xP; /* pel pointer for inner loop */
register int x; /* holds X value */
@@ -1486,15 +1484,16 @@ OptimizeRegion(R)
if (xmin != xmax || (xmin != R->xmin && xmax != R->xmax))
R->flag &= ~ISRECTANGULAR(ON);
if (xmin < e->xmin || xmax > e->xmax)
- abort("Tighten: existing edge bound was bad");
+ Abort("Tighten: existing edge bound was bad");
if (xmin < R->xmin || xmax > R->xmax)
- abort("Tighten: existing region bound was bad");
+ Abort("Tighten: existing region bound was bad");
e->xmin = xmin;
e->xmax = xmax;
}
R->flag |= ISOPTIMIZED(ON);
}
-
+#endif
+
/*
:h2.Miscelaneous Routines
@@ -1506,10 +1505,10 @@ it gets a shorter 'dy'.
*/
/*ARGSUSED*/
-void MoreWorkArea(R, x1, y1, x2, y2)
- struct region *R; /* region we are generating */
- fractpel x1,y1; /* starting point of line */
- fractpel x2,y2; /* ending point of line */
+void
+MoreWorkArea(struct region *R, /* region we are generating */
+ fractpel x1, fractpel y1, /* starting point of line */
+ fractpel x2, fractpel y2) /* ending point of line */
{
register int idy; /* integer dy of line */
@@ -1538,10 +1537,10 @@ clipping box is specified in REGION coordinates, that is, in
coordinates relative to the region (0,0) point
*/
-struct region *BoxClip(R, xmin, ymin, xmax, ymax)
- register struct region *R; /* region to clip */
- register pel xmin,ymin; /* upper left hand corner of rectangle */
- register pel xmax,ymax; /* lower right hand corner */
+struct region *
+BoxClip(struct region *R, /* region to clip */
+ pel xmin, pel ymin, /* upper left hand corner of rectangle */
+ pel xmax, pel ymax) /* lower right hand corner */
{
struct edgelist anchor; /* pretend edgelist to facilitate discards */
register struct edgelist *e,*laste;
@@ -1618,8 +1617,8 @@ couldn't have it be consumed) and this would probably require
unnecessary CopyRegions in most cases.
*/
-struct region *CoerceRegion(tp)
- register struct textpath *tp; /* input TEXTTYPE */
+struct region *
+CoerceRegion(struct textpath *tp) /* input TEXTTYPE */
{
struct segment *path; /* temporary character path */
struct region *R; /* returned region */
@@ -1634,11 +1633,9 @@ struct region *CoerceRegion(tp)
:h3.RegionBounds() - Returns Bounding Box of a Region
*/
-struct segment *RegionBounds(R)
- register struct region *R;
+struct segment *
+RegionBounds(struct region *R)
{
- extern struct XYspace *IDENTITY;
-
register struct segment *path; /* returned path */
path = BoxPath(IDENTITY, R->ymax - R->ymin, R->xmax - R->xmin);
@@ -1653,8 +1650,8 @@ struct segment *RegionBounds(R)
:h3.DumpArea() - Display a Region
*/
-void DumpArea(area)
- register struct region *area;
+void
+DumpArea(struct region *area)
{
IfTrace1(TRUE,"Dumping area %x,", area);
IfTrace4(TRUE," X %d:%d Y %d:%d;", (long) area->xmin,
@@ -1675,25 +1672,23 @@ void DumpArea(area)
/*ARGSUSED*/
static void
-edgecheck(edge, oldmin, oldmax)
- struct edgelist *edge;
- int oldmin,oldmax;
+edgecheck(struct edgelist *edge, int oldmin, int oldmax)
{
if (edge->type != EDGETYPE)
- abort("EDGE ERROR: non EDGETYPE in list");
+ Abort("EDGE ERROR: non EDGETYPE in list");
/*
The following check is not valid if the region is jumbled so I took it
out:
*/
/* if (edge->ymin < oldmax && edge->ymin != oldmin)
- abort("EDGE ERROR: overlapping swaths"); */
+ Abort("EDGE ERROR: overlapping swaths"); */
}
static pel RegionDebugYMin = MINPEL;
static pel RegionDebugYMax = MAXPEL;
-void DumpEdges(edges)
- register struct edgelist *edges;
+void
+DumpEdges(struct edgelist *edges)
{
register struct edgelist *p,*p2;
register pel ymin = MINPEL;
diff --git a/src/Type1/regions.h b/src/Type1/regions.h
index 3870cf4..9d27e76 100644
--- a/src/Type1/regions.h
+++ b/src/Type1/regions.h
@@ -26,6 +26,7 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/regions.h,v 1.8 2001/06/15 08:09:20 alanh Exp $ */
/*SHARED*/
#define Interior(p,rule) t1_Interior(p,rule)
@@ -33,21 +34,27 @@
#define Intersect(a1,a2) t1_Intersect(a1,a2)
#define Complement(area) t1_Complement(area)
#define Overlap(a1,a2) t1_OverLap(a1,a2)
-
-struct region *t1_Interior(); /* returns the interior of a closed path */
+
+
+/* returns the interior of a closed path */
+extern struct region *t1_Interior ( struct segment *p, int fillrule );
+#if 0
struct region *t1_Union(); /* set union of paths or regions */
struct region *t1_Intersect(); /* set intersection of regions */
struct region *t1_Complement(); /* complement of a region */
int t1_Overlap(); /* returns a Boolean; TRUE if regions overlap */
-
-#define INFINITY t1_Infinity
+#endif
+
+#define TT_INFINITY t1_Infinity
/*END SHARED*/
/*SHARED*/
#define ChangeDirection(type,R,x,y,dy) t1_ChangeDirection(type,R,x,y,dy)
-void t1_ChangeDirection(); /* called when we change direction in Y */
+/* called when we change direction in Y */
+extern void t1_ChangeDirection ( int type, struct region *R, fractpel x,
+ fractpel y, fractpel dy );
#define CD_FIRST -1 /* enumeration of ChangeDirection type */
#define CD_CONTINUE 0 /* enumeration of ChangeDirection type */
#define CD_LAST 1 /* enumeration of ChangeDirection type */
@@ -63,17 +70,37 @@ void t1_ChangeDirection(); /* called when we change direction in Y */
#define MoveEdges(R,dx,dy) t1_MoveEdges(R,dx,dy)
#define UnJumble(R) t1_UnJumble(R)
-void t1_MoreWorkArea(); /* get longer edge list for stepping */
-struct region *t1_CopyRegion(); /* duplicate a region */
-void t1_KillRegion(); /* destroy a region */
-struct region *t1_BoxClip(); /* clip a region to a rectangle */
-struct edgelist *t1_SortSwath(); /* sort edges onto growing edge list */
-struct edgelist *t1_SwathUnion(); /* 'union' two edges into a swath */
-struct segment *t1_RegionBounds(); /* returns bounding box of a region */
-struct region *t1_CoerceRegion(); /* force text to become a true region */
-void t1_MoveEdges(); /* moves the edge values in a region */
-void t1_UnJumble(); /* sort the edges and reset the jumbled flag */
+typedef struct edgelist *(*SwathFunc)(struct edgelist *, struct edgelist *);
+
+/* get longer edge list for stepping */
+extern void t1_MoreWorkArea ( struct region *R, fractpel x1, fractpel y1,
+ fractpel x2, fractpel y2 );
+/* duplicate a region */
+extern struct region *t1_CopyRegion ( struct region *area );
+/* destroy a region */
+extern void t1_KillRegion ( struct region *area );
+/* clip a region to a rectangle */
+extern struct region *t1_BoxClip ( struct region *R, pel xmin, pel ymin,
+ pel xmax, pel ymax );
+/* sort edges onto growing edge list */
+extern struct edgelist *t1_SortSwath ( struct edgelist *anchor,
+ struct edgelist *edge,
+ SwathFunc swathfcn );
+/* 'union' two edges into a swath */
+extern struct edgelist *t1_SwathUnion ( struct edgelist *before0,
+ struct edgelist *edge );
+/* returns bounding box of a region */
+extern struct segment *t1_RegionBounds ( struct region *R );
+#ifdef notdef
+/* force text to become a true region */
+struct region *t1_CoerceRegion(struct textpath *tp);
+#endif
+/* moves the edge values in a region */
+extern void t1_MoveEdges ( struct region *R, fractpel dx, fractpel dy );
+/* sort the edges and reset the jumbled flag */
+extern void t1_UnJumble ( struct region *region );
+
/*END SHARED*/
/*SHARED*/
@@ -95,9 +122,11 @@ void t1_UnJumble(); /* sort the edges and reset the jumbled flag */
else if (x2 > R->edgexmax) R->edgexmax = x2; \
}
+#ifndef FONTMODULE
#ifndef __sxg__
#include <limits.h>
#endif
+#endif
#ifdef SHRT_MIN
#define MINPEL SHRT_MIN
#else
@@ -122,6 +151,9 @@ to be made unique for that reason (i.e., references > 1).
/*END SHARED*/
/*SHARED*/
+typedef void (*NewEdgeFunc)(struct region *,
+ fractpel, fractpel, fractpel, fractpel, int);
+
struct region {
XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
/* type = REGIONTYPE */
@@ -144,7 +176,7 @@ scratchpad areas used while the region is being built:
struct edgelist *lastedge,*firstedge; /* last and first edges in subpath */
pel *edge; /* pointer to array of X values for edge */
fractpel edgeYstop; /* Y value where 'edges' array ends */
- void (*newedgefcn)(); /* function to use when building a new edge */
+ NewEdgeFunc newedgefcn; /* function to use when building a new edge */
struct strokeinfo *strokeinfo; /* scratchpad info during stroking only */
} ;
/*
@@ -211,3 +243,8 @@ Interior() rule enumerations:
#define CONTINUITY 0x80 /* can be added to above rules; e.g. WINDINGRULE+CONTINUITY */
/*END SHARED*/
+
+/* dump a region structure */
+extern void t1_DumpArea ( struct region *area );
+/* dump a region's edge list */
+extern void t1_DumpEdges ( struct edgelist *edges );
diff --git a/src/Type1/scanfont.c b/src/Type1/scanfont.c
index 71dd687..b8aff94 100644
--- a/src/Type1/scanfont.c
+++ b/src/Type1/scanfont.c
@@ -1,4 +1,4 @@
-/* $Xorg: scanfont.c,v 1.4 2000/12/01 16:26:25 steve Exp $ */
+/* $Xorg: scanfont.c,v 1.3 2000/08/17 19:46:32 cpqbld Exp $ */
/* Copyright International Business Machines,Corp. 1991
* All Rights Reserved
*
@@ -28,15 +28,55 @@
* SOFTWARE.
*/
/* Author: Katherine A. Hitchcock IBM Almaden Research Laboratory */
-
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/scanfont.c,v 1.15 2001/07/25 15:04:55 dawes Exp $ */
+
+#ifndef FONTMODULE
#include <string.h>
+#else
+#include "Xdefs.h" /* Bool declaration */
+#include "Xmd.h" /* INT32 declaration */
+#include "xf86_ansic.h"
+#endif
#include "t1stdio.h"
#include "util.h"
#include "token.h"
+#ifdef BUILDCID
+#include "range.h"
+#endif
+#include "objects.h"
+#include "spaces.h"
#include "fontfcn.h"
#include "blues.h"
-
+#ifdef BUILDCID
+#define CID_BUFSIZE 80
+
+extern psfont *FDArrayP;
+static spacerange *spacerangeP;
+static cidrange *notdefrangeP;
+static cidrange *cidrangeP;
+extern int FDArrayIndex;
+static boolean CIDWantFontInfo;
+static boolean InFDArray;
+static psobj inputFile1;
+#endif
static int rc;
static boolean InPrivateDict;
@@ -60,357 +100,358 @@ typedef struct /* Builtin Standard Encoding */
} EncodingTable;
static EncodingTable StdEnc[] = {
- 040 , "space",
- 041 , "exclam",
- 042 , "quotedbl",
- 043 , "numbersign",
- 044 , "dollar",
- 045 , "percent",
- 046 , "ampersand",
- 047 , "quoteright",
- 050 , "parenleft",
- 051 , "parenright",
- 052 , "asterisk",
- 053 , "plus",
- 054 , "comma",
- 055 , "hyphen",
- 056 , "period",
- 057 , "slash",
- 060 , "zero",
- 061 , "one",
- 062 , "two",
- 063 , "three",
- 064 , "four",
- 065 , "five",
- 066 , "six",
- 067 , "seven",
- 070 , "eight",
- 071 , "nine",
- 072 , "colon",
- 073 , "semicolon",
- 074 , "less",
- 075 , "equal",
- 076 , "greater",
- 077 , "question",
- 0100 , "at",
- 0101 , "A",
- 0102 , "B",
- 0103 , "C",
- 0104 , "D",
- 0105 , "E",
- 0106 , "F",
- 0107 , "G",
- 0110 , "H",
- 0111 , "I",
- 0112 , "J",
- 0113 , "K",
- 0114 , "L",
- 0115 , "M",
- 0116 , "N",
- 0117 , "O",
- 0120 , "P",
- 0121 , "Q",
- 0122 , "R",
- 0123 , "S",
- 0124 , "T",
- 0125 , "U",
- 0126 , "V",
- 0127 , "W",
- 0130 , "X",
- 0131 , "Y",
- 0132 , "Z",
- 0133 , "bracketleft",
- 0134 , "backslash",
- 0135 , "bracketright",
- 0136 , "asciicircum",
- 0137 , "underscore",
- 0140 , "quoteleft",
- 0141 , "a",
- 0142 , "b",
- 0143 , "c",
- 0144 , "d",
- 0145 , "e",
- 0146 , "f",
- 0147 , "g",
- 0150 , "h",
- 0151 , "i",
- 0152 , "j",
- 0153 , "k",
- 0154 , "l",
- 0155 , "m",
- 0156 , "n",
- 0157 , "o",
- 0160 , "p",
- 0161 , "q",
- 0162 , "r",
- 0163 , "s",
- 0164 , "t",
- 0165 , "u",
- 0166 , "v",
- 0167 , "w",
- 0170 , "x",
- 0171 , "y",
- 0172 , "z",
- 0173 , "braceleft",
- 0174 , "bar",
- 0175 , "braceright",
- 0176 , "asciitilde",
- 0241 , "exclamdown",
- 0242 , "cent",
- 0243 , "sterling",
- 0244 , "fraction",
- 0245 , "yen",
- 0246 , "florin",
- 0247 , "section",
- 0250 , "currency",
- 0251 , "quotesingle",
- 0252 , "quotedblleft",
- 0253 , "guillemotleft",
- 0254 , "guilsinglleft",
- 0255 , "guilsinglright",
- 0256 , "fi",
- 0257 , "fl",
- 0261 , "endash",
- 0262 , "dagger",
- 0263 , "daggerdbl",
- 0264 , "periodcentered",
- 0266 , "paragraph",
- 0267 , "bullet",
- 0270 , "quotesinglbase",
- 0271 , "quotedblbase",
- 0272 , "quotedblright",
- 0273 , "guillemotright",
- 0274 , "ellipsis",
- 0275 , "perthousand",
- 0277 , "questiondown",
- 0301 , "grave",
- 0302 , "acute",
- 0303 , "circumflex",
- 0304 , "tilde",
- 0305 , "macron",
- 0306 , "breve",
- 0307 , "dotaccent",
- 0310 , "dieresis",
- 0312 , "ring",
- 0313 , "cedilla",
- 0315 , "hungarumlaut",
- 0316 , "ogonek",
- 0317 , "caron",
- 0320 , "emdash",
- 0341 , "AE",
- 0343 , "ordfeminine",
- 0350 , "Lslash",
- 0351 , "Oslash",
- 0352 , "OE",
- 0353 , "ordmasculine",
- 0361 , "ae",
- 0365 , "dotlessi",
- 0370 , "lslash",
- 0371 , "oslash",
- 0372 , "oe",
- 0373 , "germandbls",
- 0, 0
+ { 040 , "space" },
+ { 041 , "exclam" },
+ { 042 , "quotedbl" },
+ { 043 , "numbersign" },
+ { 044 , "dollar" },
+ { 045 , "percent" },
+ { 046 , "ampersand" },
+ { 047 , "quoteright" },
+ { 050 , "parenleft" },
+ { 051 , "parenright" },
+ { 052 , "asterisk" },
+ { 053 , "plus" },
+ { 054 , "comma" },
+ { 055 , "hyphen" },
+ { 056 , "period" },
+ { 057 , "slash" },
+ { 060 , "zero" },
+ { 061 , "one" },
+ { 062 , "two" },
+ { 063 , "three" },
+ { 064 , "four" },
+ { 065 , "five" },
+ { 066 , "six" },
+ { 067 , "seven" },
+ { 070 , "eight" },
+ { 071 , "nine" },
+ { 072 , "colon" },
+ { 073 , "semicolon" },
+ { 074 , "less" },
+ { 075 , "equal" },
+ { 076 , "greater" },
+ { 077 , "question" },
+ { 0100 , "at" },
+ { 0101 , "A" },
+ { 0102 , "B" },
+ { 0103 , "C" },
+ { 0104 , "D" },
+ { 0105 , "E" },
+ { 0106 , "F" },
+ { 0107 , "G" },
+ { 0110 , "H" },
+ { 0111 , "I" },
+ { 0112 , "J" },
+ { 0113 , "K" },
+ { 0114 , "L" },
+ { 0115 , "M" },
+ { 0116 , "N" },
+ { 0117 , "O" },
+ { 0120 , "P" },
+ { 0121 , "Q" },
+ { 0122 , "R" },
+ { 0123 , "S" },
+ { 0124 , "T" },
+ { 0125 , "U" },
+ { 0126 , "V" },
+ { 0127 , "W" },
+ { 0130 , "X" },
+ { 0131 , "Y" },
+ { 0132 , "Z" },
+ { 0133 , "bracketleft" },
+ { 0134 , "backslash" },
+ { 0135 , "bracketright" },
+ { 0136 , "asciicircum" },
+ { 0137 , "underscore" },
+ { 0140 , "quoteleft" },
+ { 0141 , "a" },
+ { 0142 , "b" },
+ { 0143 , "c" },
+ { 0144 , "d" },
+ { 0145 , "e" },
+ { 0146 , "f" },
+ { 0147 , "g" },
+ { 0150 , "h" },
+ { 0151 , "i" },
+ { 0152 , "j" },
+ { 0153 , "k" },
+ { 0154 , "l" },
+ { 0155 , "m" },
+ { 0156 , "n" },
+ { 0157 , "o" },
+ { 0160 , "p" },
+ { 0161 , "q" },
+ { 0162 , "r" },
+ { 0163 , "s" },
+ { 0164 , "t" },
+ { 0165 , "u" },
+ { 0166 , "v" },
+ { 0167 , "w" },
+ { 0170 , "x" },
+ { 0171 , "y" },
+ { 0172 , "z" },
+ { 0173 , "braceleft" },
+ { 0174 , "bar" },
+ { 0175 , "braceright" },
+ { 0176 , "asciitilde" },
+ { 0241 , "exclamdown" },
+ { 0242 , "cent" },
+ { 0243 , "sterling" },
+ { 0244 , "fraction" },
+ { 0245 , "yen" },
+ { 0246 , "florin" },
+ { 0247 , "section" },
+ { 0250 , "currency" },
+ { 0251 , "quotesingle" },
+ { 0252 , "quotedblleft" },
+ { 0253 , "guillemotleft" },
+ { 0254 , "guilsinglleft" },
+ { 0255 , "guilsinglright" },
+ { 0256 , "fi" },
+ { 0257 , "fl" },
+ { 0261 , "endash" },
+ { 0262 , "dagger" },
+ { 0263 , "daggerdbl" },
+ { 0264 , "periodcentered" },
+ { 0266 , "paragraph" },
+ { 0267 , "bullet" },
+ { 0270 , "quotesinglbase" },
+ { 0271 , "quotedblbase" },
+ { 0272 , "quotedblright" },
+ { 0273 , "guillemotright" },
+ { 0274 , "ellipsis" },
+ { 0275 , "perthousand" },
+ { 0277 , "questiondown" },
+ { 0301 , "grave" },
+ { 0302 , "acute" },
+ { 0303 , "circumflex" },
+ { 0304 , "tilde" },
+ { 0305 , "macron" },
+ { 0306 , "breve" },
+ { 0307 , "dotaccent" },
+ { 0310 , "dieresis" },
+ { 0312 , "ring" },
+ { 0313 , "cedilla" },
+ { 0315 , "hungarumlaut" },
+ { 0316 , "ogonek" },
+ { 0317 , "caron" },
+ { 0320 , "emdash" },
+ { 0341 , "AE" },
+ { 0343 , "ordfeminine" },
+ { 0350 , "Lslash" },
+ { 0351 , "Oslash" },
+ { 0352 , "OE" },
+ { 0353 , "ordmasculine" },
+ { 0361 , "ae" },
+ { 0365 , "dotlessi" },
+ { 0370 , "lslash" },
+ { 0371 , "oslash" },
+ { 0372 , "oe" },
+ { 0373 , "germandbls" },
+ { 0, 0 }
};
static EncodingTable ISO8859Enc[] = {
- 32, "space",
- 33, "exclam",
- 34, "quotedbl",
- 35, "numbersign",
- 36, "dollar",
- 37, "percent",
- 38, "ampersand",
- 39, "quoteright",
- 40, "parenleft",
- 41, "parenright",
- 42, "asterisk",
- 43, "plus",
- 44, "comma",
- 45, "minus",
- 46, "period",
- 47, "slash",
- 48, "zero",
- 49, "one",
- 50, "two",
- 51, "three",
- 52, "four",
- 53, "five",
- 54, "six",
- 55, "seven",
- 56, "eight",
- 57, "nine",
- 58, "colon",
- 59, "semicolon",
- 60, "less",
- 61, "equal",
- 62, "greater",
- 63, "question",
- 64, "at",
- 65, "A",
- 66, "B",
- 67, "C",
- 68, "D",
- 69, "E",
- 70, "F",
- 71, "G",
- 72, "H",
- 73, "I",
- 74, "J",
- 75, "K",
- 76, "L",
- 77, "M",
- 78, "N",
- 79, "O",
- 80, "P",
- 81, "Q",
- 82, "R",
- 83, "S",
- 84, "T",
- 85, "U",
- 86, "V",
- 87, "W",
- 88, "X",
- 89, "Y",
- 90, "Z",
- 91, "bracketleft",
- 92, "backslash",
- 93, "bracketright",
- 94, "asciicircum",
- 95, "underscore",
- 96, "quoteleft",
- 97, "a",
- 98, "b",
- 99, "c",
- 100, "d",
- 101, "e",
- 102, "f",
- 103, "g",
- 104, "h",
- 105, "i",
- 106, "j",
- 107, "k",
- 108, "l",
- 109, "m",
- 110, "n",
- 111, "o",
- 112, "p",
- 113, "q",
- 114, "r",
- 115, "s",
- 116, "t",
- 117, "u",
- 118, "v",
- 119, "w",
- 120, "x",
- 121, "y",
- 122, "z",
- 123, "braceleft",
- 124, "bar",
- 125, "braceright",
- 126, "asciitilde",
- 161, "exclamdown",
- 162, "cent",
- 163, "sterling",
- 164, "currency",
- 165, "yen",
- 166, "brokenbar",
- 167, "section",
- 168, "dieresis",
- 169, "copyright",
- 170, "ordfeminine",
- 171, "guillemotleft",
- 172, "logicalnot",
- 173, "hyphen",
- 174, "registered",
- 175, "macron",
- 176, "degree",
- 177, "plusminus",
- 178, "twosuperior",
- 179, "threesuperior",
- 180, "acute",
- 181, "mu",
- 182, "paragraph",
- 183, "periodcentered",
- 184, "cedilla",
- 185, "onesuperior",
- 186, "ordmasculine",
- 187, "guillemotright",
- 188, "onequarter",
- 189, "onehalf",
- 190, "threequarters",
- 191, "questiondown",
- 192, "Agrave",
- 193, "Aacute",
- 194, "Acircumflex",
- 195, "Atilde",
- 196, "Adieresis",
- 197, "Aring",
- 198, "AE",
- 199, "Ccedilla",
- 200, "Egrave",
- 201, "Eacute",
- 202, "Ecircumflex",
- 203, "Edieresis",
- 204, "Igrave",
- 205, "Iacute",
- 206, "Icircumflex",
- 207, "Idieresis",
- 208, "Eth",
- 209, "Ntilde",
- 210, "Ograve",
- 211, "Oacute",
- 212, "Ocircumflex",
- 213, "Otilde",
- 214, "Odieresis",
- 215, "multiply",
- 216, "Oslash",
- 217, "Ugrave",
- 218, "Uacute",
- 219, "Ucircumflex",
- 220, "Udieresis",
- 221, "Yacute",
- 222, "Thorn",
- 223, "germandbls",
- 224, "agrave",
- 225, "aacute",
- 226, "acircumflex",
- 227, "atilde",
- 228, "adieresis",
- 229, "aring",
- 230, "ae",
- 231, "ccedilla",
- 232, "egrave",
- 233, "eacute",
- 234, "ecircumflex",
- 235, "edieresis",
- 236, "igrave",
- 237, "iacute",
- 238, "icircumflex",
- 239, "idieresis",
- 240, "eth",
- 241, "ntilde",
- 242, "ograve",
- 243, "oacute",
- 244, "ocircumflex",
- 245, "otilde",
- 246, "odieresis",
- 247, "divide",
- 248, "oslash",
- 249, "ugrave",
- 250, "uacute",
- 251, "ucircumflex",
- 252, "udieresis",
- 253, "yacute",
- 254, "thorn",
- 255, "ydieresis",
- 0, 0
+ { 32, "space" },
+ { 33, "exclam" },
+ { 34, "quotedbl" },
+ { 35, "numbersign" },
+ { 36, "dollar" },
+ { 37, "percent" },
+ { 38, "ampersand" },
+ { 39, "quoteright" },
+ { 40, "parenleft" },
+ { 41, "parenright" },
+ { 42, "asterisk" },
+ { 43, "plus" },
+ { 44, "comma" },
+ { 45, "minus" },
+ { 46, "period" },
+ { 47, "slash" },
+ { 48, "zero" },
+ { 49, "one" },
+ { 50, "two" },
+ { 51, "three" },
+ { 52, "four" },
+ { 53, "five" },
+ { 54, "six" },
+ { 55, "seven" },
+ { 56, "eight" },
+ { 57, "nine" },
+ { 58, "colon" },
+ { 59, "semicolon" },
+ { 60, "less" },
+ { 61, "equal" },
+ { 62, "greater" },
+ { 63, "question" },
+ { 64, "at" },
+ { 65, "A" },
+ { 66, "B" },
+ { 67, "C" },
+ { 68, "D" },
+ { 69, "E" },
+ { 70, "F" },
+ { 71, "G" },
+ { 72, "H" },
+ { 73, "I" },
+ { 74, "J" },
+ { 75, "K" },
+ { 76, "L" },
+ { 77, "M" },
+ { 78, "N" },
+ { 79, "O" },
+ { 80, "P" },
+ { 81, "Q" },
+ { 82, "R" },
+ { 83, "S" },
+ { 84, "T" },
+ { 85, "U" },
+ { 86, "V" },
+ { 87, "W" },
+ { 88, "X" },
+ { 89, "Y" },
+ { 90, "Z" },
+ { 91, "bracketleft" },
+ { 92, "backslash" },
+ { 93, "bracketright" },
+ { 94, "asciicircum" },
+ { 95, "underscore" },
+ { 96, "quoteleft" },
+ { 97, "a" },
+ { 98, "b" },
+ { 99, "c" },
+ { 100, "d" },
+ { 101, "e" },
+ { 102, "f" },
+ { 103, "g" },
+ { 104, "h" },
+ { 105, "i" },
+ { 106, "j" },
+ { 107, "k" },
+ { 108, "l" },
+ { 109, "m" },
+ { 110, "n" },
+ { 111, "o" },
+ { 112, "p" },
+ { 113, "q" },
+ { 114, "r" },
+ { 115, "s" },
+ { 116, "t" },
+ { 117, "u" },
+ { 118, "v" },
+ { 119, "w" },
+ { 120, "x" },
+ { 121, "y" },
+ { 122, "z" },
+ { 123, "braceleft" },
+ { 124, "bar" },
+ { 125, "braceright" },
+ { 126, "asciitilde" },
+ { 160, "space" },
+ { 161, "exclamdown" },
+ { 162, "cent" },
+ { 163, "sterling" },
+ { 164, "currency" },
+ { 165, "yen" },
+ { 166, "brokenbar" },
+ { 167, "section" },
+ { 168, "dieresis" },
+ { 169, "copyright" },
+ { 170, "ordfeminine" },
+ { 171, "guillemotleft" },
+ { 172, "logicalnot" },
+ { 173, "hyphen" },
+ { 174, "registered" },
+ { 175, "macron" },
+ { 176, "degree" },
+ { 177, "plusminus" },
+ { 178, "twosuperior" },
+ { 179, "threesuperior" },
+ { 180, "acute" },
+ { 181, "mu" },
+ { 182, "paragraph" },
+ { 183, "periodcentered" },
+ { 184, "cedilla" },
+ { 185, "onesuperior" },
+ { 186, "ordmasculine" },
+ { 187, "guillemotright" },
+ { 188, "onequarter" },
+ { 189, "onehalf" },
+ { 190, "threequarters" },
+ { 191, "questiondown" },
+ { 192, "Agrave" },
+ { 193, "Aacute" },
+ { 194, "Acircumflex" },
+ { 195, "Atilde" },
+ { 196, "Adieresis" },
+ { 197, "Aring" },
+ { 198, "AE" },
+ { 199, "Ccedilla" },
+ { 200, "Egrave" },
+ { 201, "Eacute" },
+ { 202, "Ecircumflex" },
+ { 203, "Edieresis" },
+ { 204, "Igrave" },
+ { 205, "Iacute" },
+ { 206, "Icircumflex" },
+ { 207, "Idieresis" },
+ { 208, "Eth" },
+ { 209, "Ntilde" },
+ { 210, "Ograve" },
+ { 211, "Oacute" },
+ { 212, "Ocircumflex" },
+ { 213, "Otilde" },
+ { 214, "Odieresis" },
+ { 215, "multiply" },
+ { 216, "Oslash" },
+ { 217, "Ugrave" },
+ { 218, "Uacute" },
+ { 219, "Ucircumflex" },
+ { 220, "Udieresis" },
+ { 221, "Yacute" },
+ { 222, "Thorn" },
+ { 223, "germandbls" },
+ { 224, "agrave" },
+ { 225, "aacute" },
+ { 226, "acircumflex" },
+ { 227, "atilde" },
+ { 228, "adieresis" },
+ { 229, "aring" },
+ { 230, "ae" },
+ { 231, "ccedilla" },
+ { 232, "egrave" },
+ { 233, "eacute" },
+ { 234, "ecircumflex" },
+ { 235, "edieresis" },
+ { 236, "igrave" },
+ { 237, "iacute" },
+ { 238, "icircumflex" },
+ { 239, "idieresis" },
+ { 240, "eth" },
+ { 241, "ntilde" },
+ { 242, "ograve" },
+ { 243, "oacute" },
+ { 244, "ocircumflex" },
+ { 245, "otilde" },
+ { 246, "odieresis" },
+ { 247, "divide" },
+ { 248, "oslash" },
+ { 249, "ugrave" },
+ { 250, "uacute" },
+ { 251, "ucircumflex" },
+ { 252, "udieresis" },
+ { 253, "yacute" },
+ { 254, "thorn" },
+ { 255, "ydieresis" },
+ { 0, 0 }
};
static psobj *StdEncArrayP = NULL;
psobj *ISOLatin1EncArrayP = NULL;
-static psobj *MakeEncodingArrayP(encodingTable)
- EncodingTable *encodingTable;
+static psobj *
+MakeEncodingArrayP(EncodingTable *encodingTable)
{
int i;
psobj *encodingArrayP;
@@ -433,7 +474,8 @@ static psobj *MakeEncodingArrayP(encodingTable)
return(encodingArrayP);
}
-boolean Init_BuiltInEncoding()
+boolean
+Init_BuiltInEncoding(void)
{
StdEncArrayP = MakeEncodingArrayP(StdEnc);
ISOLatin1EncArrayP = MakeEncodingArrayP(ISO8859Enc);
@@ -442,8 +484,8 @@ boolean Init_BuiltInEncoding()
/********************************************************************/
/***================================================================***/
-static int getNextValue(valueType)
- int valueType;
+static int
+getNextValue(int valueType)
{
scan_token(inputP);
if (tokenType != valueType) {
@@ -455,7 +497,8 @@ static int getNextValue(valueType)
/***================================================================***/
/* This routine will set the global rc if there is an error */
/***================================================================***/
-static int getInt()
+static int
+getInt(void)
{
scan_token(inputP);
if (tokenType != TOKEN_INTEGER) {
@@ -472,23 +515,16 @@ static int getInt()
* See Sec 10.3 of ``Adobe Type 1 Font Format'' v1.1,
* for parsing Encoding.
*/
-static int getEncoding(arrayP)
- psobj *arrayP;
+static int
+getEncoding(psobj *arrayP)
{
-
scan_token(inputP);
- if ((tokenType == TOKEN_NAME)
- &&
- (((tokenLength==16) && (!strncmp(tokenStartP,"StandardEncoding",16))) ||
- (((tokenLength==17) && (!strncmp(tokenStartP,"ISOLatin1Encoding",17))))))
+ if ((tokenType == TOKEN_NAME && (tokenLength==16 || tokenLength==17)))
{
- /* Adobe Standard Encoding */
-
- if (tokenLength == 16)
- arrayP->data.valueP = (char *) StdEncArrayP;
- else
- arrayP->data.valueP = (char *) ISOLatin1EncArrayP;
-
+ if((tokenLength==16) && (!strncmp(tokenStartP,"StandardEncoding",16)))
+ arrayP->data.valueP = (char *) StdEncArrayP;
+ else
+ arrayP->data.valueP = (char *) ISOLatin1EncArrayP;
arrayP->len = 256;
return(SCAN_OK);
}
@@ -586,45 +622,92 @@ static int getEncoding(arrayP)
return (SCAN_ERROR);
}
/***================================================================***/
-static int getArray(arrayP)
- psobj *arrayP;
+#ifdef BUILDCID
+static int
+getFDArray(psobj *arrayP)
+{
+ int rc;
+
+ /* get the number of items in the FDArray */
+ scan_token(inputP);
+ if (tokenType == TOKEN_INTEGER) {
+ /* an FD array must contain at least one element */
+ if (tokenValue.integer <= 0)
+ return(SCAN_ERROR);
+ arrayP->len = tokenValue.integer;
+ } else
+ return(SCAN_ERROR);
+
+ /* get the token "array" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || strncmp(tokenStartP, "array", 5) != 0)
+ return(SCAN_ERROR);
+
+ /* format the array in memory, save pointer to the beginning */
+ arrayP->data.valueP = tokenStartP;
+
+ /* allocate FDArray */
+ FDArrayP = (psfont *)vm_alloc(arrayP->len*(sizeof(psfont)));
+ if (!(FDArrayP)) return(SCAN_OUT_OF_MEMORY);
+
+ /* get a specified number of font dictionaries */
+ for (FDArrayIndex = 0; FDArrayIndex < arrayP->len; FDArrayIndex++) {
+ /* get "dup" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || strncmp(tokenStartP, "dup", 3) != 0)
+ return(SCAN_ERROR);
+ /* get an integer digit */
+ scan_token(inputP);
+ if (tokenType != TOKEN_INTEGER)
+ return(SCAN_ERROR);
+
+ /* read a CID version of a Type 1 font */
+ if (!CIDType1fontfcnA(&rc))
+ return(rc);
+
+ /* get "put" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || strncmp(tokenStartP, "put", 3) != 0)
+ return(SCAN_ERROR);
+ }
+ return(SCAN_OK);
+}
+#endif
+
+static int
+getArray(psobj *arrayP)
{
int N; /* count the items in the array */
psobj *objP;
- int scanning;
- char *tmp; /* If some font file has /foo/foo,
- * e.g. ftp://ftp.cdrom.com/pub/os2/fonts/future.zip
- * we will treat it as /foo.
- */
- if (!(tmp = strdup(tokenStartP)))
- return(SCAN_OUT_OF_MEMORY);
-
- scanning = 1;
- while (scanning == 1) {
+ /* That is totally a kludge. If some stupid font file has
+ * /foo/foo # ftp://ftp.cdrom.com/pub/os2/fonts/future.zip
+ * we will treat it as /foo.
+ * H.J. */
+ char tmp [1024];
+
+ strncpy (tmp, tokenStartP, sizeof (tmp));
+ tmp [sizeof (tmp) - 1] = '\0';
+
+restart:
scan_token(inputP);
switch (tokenType)
{
- case TOKEN_LEFT_BRACE:
- case TOKEN_LEFT_BRACKET:
- scanning = 0;
- break;
-
- case TOKEN_LITERAL_NAME:
- tokenStartP[tokenLength] = '\0';
- if (strcmp (tokenStartP, tmp) == 0) {
- /* Ok, if we see /foo/foo, let's go back to the top of the loop,
- * otherwise drop out of the loop. */
- continue;
- }
+ case TOKEN_LEFT_BRACE:
+ case TOKEN_LEFT_BRACKET:
+ break;
- default:
- free(tmp);
- return(SCAN_ERROR);
- }
- }
- free(tmp);
+ case TOKEN_LITERAL_NAME:
+ tokenStartP[tokenLength] = '\0';
+ if (strcmp (tokenStartP, tmp) == 0)
+ {
+ /* Ok, We see /foo/foo. Let's restart. */
+ goto restart;
+ }
+ default:
+ return(SCAN_ERROR);
+ }
/* format the array in memory, save pointer to the beginning */
arrayP->data.valueP = tokenStartP;
/* loop, picking up next object, until right BRACE or BRACKET */
@@ -655,8 +738,8 @@ static int getArray(arrayP)
/* NOTREACHED*/
}
/***================================================================***/
-static int getName(nameP)
- char *nameP;
+static int
+getName(char *nameP)
{
do {
scan_token(inputP);
@@ -670,8 +753,8 @@ static int getName(nameP)
return(SCAN_OK);
}
/***================================================================***/
-static int getNbytes(N)
- int N;
+static int
+getNbytes(int N)
{
int I;
@@ -693,8 +776,8 @@ static int getNbytes(N)
/* It means that the CharStrings does not have as many characters */
/* as the dictionary said it would and that is ok. */
/***================================================================***/
-static int getLiteralName(nameObjP)
- psobj *nameObjP;
+static int
+getLiteralName(psobj *nameObjP)
{
do {
scan_token(inputP);
@@ -722,8 +805,8 @@ static int getLiteralName(nameObjP)
*/
/***================================================================***/
-static int BuildSubrs(FontP)
- psfont *FontP;
+static int
+BuildSubrs(psfont *FontP)
{
int N; /* number of values in Subrs */
int I; /* index into Subrs */
@@ -797,8 +880,8 @@ static int BuildSubrs(FontP)
*/
/***================================================================***/
-static int BuildCharStrings(FontP)
- psfont *FontP;
+static int
+BuildCharStrings(psfont *FontP)
{
int N; /* number of values in CharStrings */
int i; /* loop thru Subrs */
@@ -852,13 +935,104 @@ static int BuildCharStrings(FontP)
}
/***================================================================***/
+#ifdef BUILDCID
+/***================================================================***/
+/*
+ * BuildCIDFontInfo Dictionary
+ */
+/***================================================================***/
+static int
+BuildCIDFontInfo(cidfont *CIDfontP)
+{
+ psdict *dictP;
+
+ /* allocate the private dictionary (max number of entries + 1) */
+ dictP = (psdict *)vm_alloc(20*sizeof(psdict));
+ if (!(dictP)) return(SCAN_OUT_OF_MEMORY);
+
+ CIDfontP->CIDfontInfoP = dictP;
+ CIDfontP->CIDfontInfoP[0].key.len = 18; /* number of actual entries */
+ objFormatName(&(dictP[CIDCOUNT].key),8,"CIDCount");
+ objFormatInteger(&(dictP[CIDCOUNT].value),-1);
+ objFormatName(&(dictP[CIDFONTNAME].key),11,"CIDFontName");
+ objFormatName(&(dictP[CIDFONTNAME].value),0,NULL);
+ objFormatName(&(dictP[CIDFONTTYPE].key),11,"CIDFontType");
+ objFormatInteger(&(dictP[CIDFONTTYPE].value),-1);
+ objFormatName(&(dictP[CIDVERSION].key),14,"CIDFontVersion");
+ objFormatInteger(&(dictP[CIDVERSION].value),-1);
+ objFormatName(&(dictP[CIDREGISTRY].key),8,"Registry");
+ objFormatString(&(dictP[CIDREGISTRY].value),0,NULL);
+ objFormatName(&(dictP[CIDORDERING].key),8,"Ordering");
+ objFormatString(&(dictP[CIDORDERING].value),0,NULL);
+ objFormatName(&(dictP[CIDSUPPLEMENT].key),10,"Supplement");
+ objFormatInteger(&(dictP[CIDSUPPLEMENT].value),-1);
+ objFormatName(&(dictP[CIDMAPOFFSET].key),12,"CIDMapOffset");
+ objFormatInteger(&(dictP[CIDMAPOFFSET].value),-1);
+ objFormatName(&(dictP[CIDFDARRAY].key),7,"FDArray");
+ objFormatArray(&(dictP[CIDFDARRAY].value),0,NULL);
+ objFormatName(&(dictP[CIDFDBYTES].key),7,"FDBytes");
+ objFormatInteger(&(dictP[CIDFDBYTES].value),-1);
+ objFormatName(&(dictP[CIDFONTBBOX].key),8,"FontBBox");
+ objFormatArray(&(dictP[CIDFONTBBOX].value),0,NULL);
+ objFormatName(&(dictP[CIDFULLNAME].key),8,"FullName");
+ objFormatString(&(dictP[CIDFULLNAME].value),0,NULL);
+ objFormatName(&(dictP[CIDFAMILYNAME].key),10,"FamilyName");
+ objFormatString(&(dictP[CIDFAMILYNAME].value),0,NULL);
+ objFormatName(&(dictP[CIDWEIGHT].key),6,"Weight");
+ objFormatString(&(dictP[CIDWEIGHT].value),0,NULL);
+ objFormatName(&(dictP[CIDNOTICE].key),6,"Notice");
+ objFormatString(&(dictP[CIDNOTICE].value),0,NULL);
+ objFormatName(&(dictP[CIDGDBYTES].key),7,"GDBytes");
+ objFormatInteger(&(dictP[CIDGDBYTES].value),-1);
+ objFormatName(&(dictP[CIDUIDBASE].key),7,"UIDBase");
+ objFormatInteger(&(dictP[CIDUIDBASE].value),0);
+ objFormatName(&(dictP[CIDXUID].key),4,"XUID");
+ objFormatInteger(&(dictP[CIDXUID].value),0);
+ return(SCAN_OK);
+}
+/***================================================================***/
+/*
+ * BuildCMapInfo Dictionary
+ */
+/***================================================================***/
+static int
+BuildCMapInfo(cmapres *CMapP)
+{
+ psdict *dictP;
+
+ /* allocate the private dictionary (max number of entries + 1) */
+ dictP = (psdict *)vm_alloc(20*sizeof(psdict));
+ if (!(dictP)) return(SCAN_OUT_OF_MEMORY);
+
+ CMapP->CMapInfoP = dictP;
+ CMapP->CMapInfoP[0].key.len = 8; /* number of actual entries */
+ objFormatName(&(dictP[CMAPREGISTRY].key),8,"Registry");
+ objFormatString(&(dictP[CMAPREGISTRY].value),0,NULL);
+ objFormatName(&(dictP[CMAPORDERING].key),8,"Ordering");
+ objFormatString(&(dictP[CMAPORDERING].value),0,NULL);
+ objFormatName(&(dictP[CMAPSUPPLEMENT].key),10,"Supplement");
+ objFormatInteger(&(dictP[CMAPSUPPLEMENT].value),-1);
+ objFormatName(&(dictP[CMAPNAME].key),8,"CMapName");
+ objFormatString(&(dictP[CMAPNAME].value),0,NULL);
+ objFormatName(&(dictP[CMAPVERSION].key),11,"CMapVersion");
+ objFormatInteger(&(dictP[CMAPVERSION].value),-1);
+ objFormatName(&(dictP[CMAPTYPE].key),8,"CMapType");
+ objFormatInteger(&(dictP[CMAPTYPE].value),-1);
+ objFormatName(&(dictP[CMAPWMODE].key),5,"WMode");
+ objFormatInteger(&(dictP[CMAPWMODE].value),-1);
+ objFormatName(&(dictP[CMAPCIDCOUNT].key),8,"CIDCount");
+ objFormatInteger(&(dictP[CMAPCIDCOUNT].value),-1);
+ return(SCAN_OK);
+}
+#endif
+
/***================================================================***/
/*
* BuildFontInfo Dictionary
*/
/***================================================================***/
-static int BuildFontInfo(fontP)
- psfont *fontP;
+static int
+BuildFontInfo(psfont *fontP)
{
psdict *dictP;
@@ -904,13 +1078,77 @@ static int BuildFontInfo(fontP)
objFormatReal(&(dictP[UNDERLINETHICKNESS].value),0.0);
return(SCAN_OK);
}
+#ifdef BUILDCID
+/***================================================================***/
+/*
+ * BuildCIDType1Private Dictionary
+ */
+/***================================================================***/
+static int
+BuildCIDType1Private(psfont *fontP)
+{
+ psdict *Private;
+
+ /* allocate the private dictionary */
+ Private = (psdict *)vm_alloc(21*sizeof(psdict));
+
+ if (!(Private)) return(SCAN_OUT_OF_MEMORY);
+
+ fontP->Private = Private;
+ fontP->Private[0].key.len = 20; /* number of actual entries */
+
+ objFormatName(&(Private[CIDT1MINFEATURE].key),10,"MinFeature");
+ objFormatArray(&(Private[CIDT1MINFEATURE].value),0,NULL);
+ objFormatName(&(Private[CIDT1LENIV].key),5,"lenIV");
+ objFormatInteger(&(Private[CIDT1LENIV].value),DEFAULTLENIV);
+ objFormatName(&(Private[CIDT1LANGGROUP].key),13,"LanguageGroup");
+ objFormatInteger(&(Private[CIDT1LANGGROUP].value),DEFAULTLANGUAGEGROUP);
+ objFormatName(&(Private[CIDT1BLUEVALUES].key),10,"BlueValues");
+ objFormatArray(&(Private[CIDT1BLUEVALUES].value),0,NULL);
+ objFormatName(&(Private[CIDT1OTHERBLUES].key),10,"OtherBlues");
+ objFormatArray(&(Private[CIDT1OTHERBLUES].value),0,NULL);
+ objFormatName(&(Private[CIDT1BLUESCALE].key),9,"BlueScale");
+ objFormatReal(&(Private[CIDT1BLUESCALE].value),DEFAULTBLUESCALE);
+ objFormatName(&(Private[CIDT1BLUEFUZZ].key),8,"BlueFuzz");
+ objFormatInteger(&(Private[CIDT1BLUEFUZZ].value),DEFAULTBLUEFUZZ);
+ objFormatName(&(Private[CIDT1BLUESHIFT].key),9,"BlueShift");
+ objFormatInteger(&(Private[CIDT1BLUESHIFT].value),DEFAULTBLUESHIFT);
+ objFormatName(&(Private[CIDT1FAMBLUES].key),11,"FamilyBlues");
+ objFormatArray(&(Private[CIDT1FAMBLUES].value),0,NULL);
+ objFormatName(&(Private[CIDT1FAMOTHERBLUES].key),16,"FamilyOtherBlues");
+ objFormatArray(&(Private[CIDT1FAMOTHERBLUES].value),0,NULL);
+ objFormatName(&(Private[CIDT1STDHW].key),5,"StdHW");
+ objFormatArray(&(Private[CIDT1STDHW].value),0,NULL);
+ objFormatName(&(Private[CIDT1STDVW].key),5,"StdVW");
+ objFormatArray(&(Private[CIDT1STDVW].value),0,NULL);
+ objFormatName(&(Private[CIDT1STEMSNAPH].key),9,"StemSnapH");
+ objFormatArray(&(Private[CIDT1STEMSNAPH].value),0,NULL);
+ objFormatName(&(Private[CIDT1STEMSNAPV].key),9,"StemSnapV");
+ objFormatArray(&(Private[CIDT1STEMSNAPV].value),0,NULL);
+ /* skip password */
+ objFormatName(&(Private[CIDT1SUBMAPOFF].key),13,"SubrMapOffset");
+ objFormatInteger(&(Private[CIDT1SUBMAPOFF].value),0);
+ objFormatName(&(Private[CIDT1SDBYTES].key),7,"SDBytes");
+ objFormatInteger(&(Private[CIDT1SDBYTES].value),0);
+ objFormatName(&(Private[CIDT1SUBRCNT].key),9,"SubrCount");
+ objFormatInteger(&(Private[CIDT1SUBRCNT].value),0);
+ objFormatName(&(Private[CIDT1FORCEBOLD].key),9,"ForceBold");
+ objFormatBoolean(&(Private[CIDT1FORCEBOLD].value),DEFAULTFORCEBOLD);
+ objFormatName(&(Private[CIDT1RNDSTEMUP].key),9,"RndStemUp");
+ objFormatBoolean(&(Private[CIDT1RNDSTEMUP].value),DEFAULTRNDSTEMUP);
+ objFormatName(&(Private[CIDT1EXPFACTOR].key),15,"ExpansionFactor");
+ objFormatReal(&(Private[CIDT1EXPFACTOR].value),
+ DEFAULTEXPANSIONFACTOR);
+ return(SCAN_OK);
+}
+#endif
/***================================================================***/
/*
* BuildPrivate Dictionary
*/
/***================================================================***/
-static int BuildPrivate(fontP)
- psfont *fontP;
+static int
+BuildPrivate(psfont *fontP)
{
psdict *Private;
@@ -968,8 +1206,8 @@ static int BuildPrivate(fontP)
/* */
/* */
/**********************************************************************/
-static int GetType1Blues(fontP)
- psfont *fontP;
+static int
+GetType1Blues(psfont *fontP)
{
psdict *PrivateDictP; /* the Private dict relating to hints */
struct blues_struct *blues; /* ptr for the blues struct we will allocate */
@@ -1238,9 +1476,8 @@ static int GetType1Blues(fontP)
/* */
/* Returns a psobj (string) */
/**********************************************************************/
-psobj *GetType1CharString(fontP, code)
-psfont *fontP;
-unsigned char code;
+psobj *
+GetType1CharString(psfont *fontP, unsigned char code)
{
int N; /* the 'Nth' entry in the CharStrings */
psobj *charnameP; /* points to psobj that is name of character*/
@@ -1282,8 +1519,8 @@ unsigned char code;
*/
/***================================================================***/
-static int FindDictValue(dictP)
- psdict *dictP;
+static int
+FindDictValue(psdict *dictP)
{
psobj LitName;
int N;
@@ -1303,7 +1540,14 @@ static int FindDictValue(dictP)
if ( V != SCAN_OK ) return(V);
break;
case OBJ_ARRAY:
+#ifdef BUILDCID
+ if (0 == strncmp(tokenStartP,"FDArray",7))
+ V = getFDArray(&(dictP[N].value));
+ else
+ V = getArray(&(dictP[N].value));
+#else
V = getArray(&(dictP[N].value));
+#endif
if ( V != SCAN_OK ) return(V);
break;
case OBJ_INTEGER:
@@ -1359,15 +1603,605 @@ static int FindDictValue(dictP)
}
/***================================================================***/
-
+
+#ifdef BUILDCID
+/*
+ * -------------------------------------------------------------------
+ * Scan the next token and convert it into an object
+ * Result is placed on the Operand Stack as next object
+ * -------------------------------------------------------------------
+ */
+int
+scan_cidfont(cidfont *CIDFontP, cmapres *CMapP)
+{
+ char filename[CID_PATH_MAX];
+ char cmapfile[CID_PATH_MAX];
+ char buf[CID_BUFSIZE];
+ char filetype[3];
+ FILE *fileP;
+ FILE *fileP1;
+ char *nameP;
+ char *p;
+ int namelen;
+ int i, j;
+ int cread, rangecnt;
+ unsigned int char_row, char_col;
+
+ InFDArray = FALSE;
+
+ filetype[0] = 'r';
+ filetype[1] = 'b';
+ filetype[2] = '\0';
+
+ /* copy the filename and remove leading or trailing blanks */
+ /* point to name and search for leading blanks */
+ nameP= CIDFontP->CIDFontFileName.data.nameP;
+ namelen = CIDFontP->CIDFontFileName.len;
+ while (nameP[0] == ' ') {
+ nameP++;
+ namelen--;
+ }
+ /* now remove any trailing blanks */
+ while ((namelen>0) && ( nameP[namelen-1] == ' ')) {
+ namelen--;
+ }
+ strncpy(filename,nameP,namelen);
+ filename[namelen] = '\0';
+ /* file name is now constructed */
+ inputFile.data.fileP = NULL;
+ filterFile.data.fileP = NULL;
+
+ /* check whether a CIDFont file */
+ if ((fileP = fopen(filename,filetype))) {
+ cread = fread(buf, 1, CID_BUFSIZE, fileP);
+ fclose(fileP);
+ if (cread > 17) {
+ if (strncmp(buf, "%!", 2) ||
+ (p = strstr(buf, "Resource-CIDFont")) == NULL)
+ return(SCAN_FILE_OPEN_ERROR);
+ } else
+ return(SCAN_FILE_OPEN_ERROR);
+ } else
+ return(SCAN_FILE_OPEN_ERROR);
+
+ /* copy the CMap file name and remove leading or trailing blanks */
+ /* point to name and search for leading blanks */
+ nameP = CMapP->CMapFileName.data.nameP;
+ namelen = CMapP->CMapFileName.len;
+ while (nameP[0] == ' ') {
+ nameP++;
+ namelen--;
+ }
+ /* now remove any trailing blanks */
+ while ((namelen>0) && ( nameP[namelen-1] == ' ')) {
+ namelen--;
+ }
+ strncpy(cmapfile,nameP,namelen);
+ cmapfile[namelen] = '\0';
+ /* CMap file name is now constructed */
+ inputFile1.data.fileP = NULL;
+
+ /* check whether a CMap file */
+ if ((fileP1 = fopen(cmapfile,filetype))) {
+ cread = fread(buf, 1, CID_BUFSIZE, fileP1);
+ fclose(fileP1);
+ if (cread > 17) {
+ if (strncmp(buf, "%!", 2) ||
+ (p = strstr(buf, "Resource-CMap")) == NULL)
+ return(SCAN_FILE_OPEN_ERROR);
+ } else
+ return(SCAN_FILE_OPEN_ERROR);
+ } else
+ return(SCAN_FILE_OPEN_ERROR);
+
+ /* read the specified CMap file */
+ inputP = &inputFile1;
+
+ if (!(fileP1 = fopen(cmapfile,filetype)))
+ return(SCAN_FILE_OPEN_ERROR);
+
+ objFormatFile(inputP,fileP1);
+
+ if ((rc = BuildCMapInfo(CMapP)) != 0)
+ return(rc);
+
+ /* Assume everything will be OK */
+ rc = 0;
+ rangecnt = 0;
+
+ do {
+ /* Scan the next token */
+ scan_token(inputP);
+ if (tokenType == TOKEN_INTEGER)
+ rangecnt = tokenValue.integer;
+
+ /* ==> tokenLength, tokenTooLong, tokenType, and */
+ /* tokenValue are now set */
+
+ switch (tokenType) {
+ case TOKEN_EOF:
+ case TOKEN_NONE:
+ case TOKEN_INVALID:
+ /* in this case we are done */
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ rc = SCAN_ERROR;
+ break;
+ case TOKEN_LITERAL_NAME:
+ /* Look up the name */
+ tokenStartP[tokenLength] = '\0';
+
+ rc = FindDictValue(CMapP->CMapInfoP);
+ /* we are not going to report errors */
+ rc = SCAN_OK;
+ break;
+ case TOKEN_NAME:
+ if (0 == strncmp(tokenStartP,"begincodespacerange",19)) {
+ CIDFontP->spacerangecnt++;
+ spacerangeP = (spacerange *)vm_alloc(sizeof(spacerange));
+ if (!spacerangeP) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ spacerangeP->next = NULL;
+ spacerangeP->rangecnt = rangecnt;
+ spacerangeP->spacecode =
+ (spacerangecode *)vm_alloc(rangecnt*sizeof(spacerangecode));
+ if (!spacerangeP->spacecode) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ for (i = 0; i < rangecnt; i++) {
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ spacerangeP->spacecode[i].srcCodeLo = 0;
+ for (j = 0; j < tokenLength; j++)
+ spacerangeP->spacecode[i].srcCodeLo +=
+ (unsigned char)tokenStartP[j] << (8 * (tokenLength - 1 - j));
+
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ spacerangeP->spacecode[i].srcCodeHi = 0;
+ for (j = 0; j < tokenLength; j++)
+ spacerangeP->spacecode[i].srcCodeHi +=
+ (unsigned char)tokenStartP[j] << (8 * (tokenLength - 1 - j));
+ }
+
+ if (CIDFontP->spacerangeP) {
+ if (CIDFontP->spacerangeP->next == NULL)
+ CIDFontP->spacerangeP->next = spacerangeP;
+ else {
+ spacerangeP->next = CIDFontP->spacerangeP->next;
+ CIDFontP->spacerangeP->next = spacerangeP;
+ }
+ } else
+ CIDFontP->spacerangeP = spacerangeP;
+
+ /* read "endcodespacerange" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || (tokenType == TOKEN_NAME &&
+ (strncmp(tokenStartP,"endcodespacerange",17) != 0))) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ }
+ if (0 == strncmp(tokenStartP,"begincidrange",13)) {
+ CIDFontP->cidrangecnt++;
+ cidrangeP = (cidrange *)vm_alloc(sizeof(cidrange));
+ if (!cidrangeP) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ cidrangeP->next = NULL;
+ cidrangeP->rangecnt = rangecnt;
+ cidrangeP->range =
+ (cidrangecode *)vm_alloc(rangecnt*sizeof(cidrangecode));
+ if (!cidrangeP->range) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ for (i = 0; i < rangecnt; i++) {
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ cidrangeP->range[i].srcCodeLo = 0;
+ for (j = 0; j < tokenLength; j++)
+ cidrangeP->range[i].srcCodeLo +=
+ (unsigned char)tokenStartP[j] << (8 * (tokenLength - 1 - j));
+ char_row = (cidrangeP->range[i].srcCodeLo >> 8) & 0xff;
+ char_col = cidrangeP->range[i].srcCodeLo & 0xff;
+ if (char_row < CMapP->firstRow)
+ CMapP->firstRow = char_row;
+ if (char_row > CMapP->lastRow)
+ CMapP->lastRow = char_row;
+ if (char_col < CMapP->firstCol)
+ CMapP->firstCol = char_col;
+ if (char_col > CMapP->lastCol)
+ CMapP->lastCol = char_col;
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ cidrangeP->range[i].srcCodeHi = 0;
+ for (j = 0; j < tokenLength; j++)
+ cidrangeP->range[i].srcCodeHi +=
+ (unsigned char)tokenStartP[j] << (8 * (tokenLength - 1 - j));
+ char_row = (cidrangeP->range[i].srcCodeHi >> 8) & 0xff;
+ char_col = cidrangeP->range[i].srcCodeHi & 0xff;
+ if (char_row < CMapP->firstRow)
+ CMapP->firstRow = char_row;
+ if (char_row > CMapP->lastRow)
+ CMapP->lastRow = char_row;
+ if (char_col < CMapP->firstCol)
+ CMapP->firstCol = char_col;
+ if (char_col > CMapP->lastCol)
+ CMapP->lastCol = char_col;
+ scan_token(inputP);
+ if (tokenType != TOKEN_INTEGER) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ cidrangeP->range[i].dstCIDLo = tokenValue.integer;
+ }
+
+ if (CIDFontP->cidrangeP) {
+ if (CIDFontP->cidrangeP->next == NULL)
+ CIDFontP->cidrangeP->next = cidrangeP;
+ else {
+ cidrangeP->next = CIDFontP->cidrangeP->next;
+ CIDFontP->cidrangeP->next = cidrangeP;
+ }
+ } else
+ CIDFontP->cidrangeP = cidrangeP;
+
+ /* read "endcidrange" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || (tokenType == TOKEN_NAME &&
+ (strncmp(tokenStartP,"endcidrange",11) != 0))) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ }
+
+ if (0 == strncmp(tokenStartP,"beginnotdefrange",16)) {
+ CIDFontP->notdefrangecnt++;
+ notdefrangeP = (cidrange *)vm_alloc(sizeof(cidrange));
+ if (!notdefrangeP) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ notdefrangeP->next = 0;
+ notdefrangeP->rangecnt = rangecnt;
+ notdefrangeP->range =
+ (cidrangecode *)vm_alloc(rangecnt*sizeof(cidrangecode));
+ if (!notdefrangeP->range) {
+ rc = SCAN_OUT_OF_MEMORY;
+ break;
+ }
+ for (i = 0; i < rangecnt; i++) {
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ notdefrangeP->range[i].srcCodeLo = 0;
+ for (j = 0; j < tokenLength; j++)
+ notdefrangeP->range[i].srcCodeLo = (int)(tokenStartP[j] <<
+ (8 * (tokenLength - 1 - j)));
+ scan_token(inputP);
+ if (tokenType != TOKEN_HEX_STRING) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ notdefrangeP->range[i].srcCodeHi = 0;
+ for (j = 0; j < tokenLength; j++)
+ notdefrangeP->range[i].srcCodeHi = (int)(tokenStartP[j] <<
+ (8 * (tokenLength - 1 - j)));
+ scan_token(inputP);
+ if (tokenType != TOKEN_INTEGER) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ notdefrangeP->range[i].dstCIDLo = tokenValue.integer;
+ }
+ if (CIDFontP->notdefrangeP) {
+ if (CIDFontP->notdefrangeP->next == NULL)
+ CIDFontP->notdefrangeP->next = notdefrangeP;
+ else {
+ notdefrangeP->next = CIDFontP->notdefrangeP->next;
+ CIDFontP->notdefrangeP->next = notdefrangeP;
+ }
+ } else
+ CIDFontP->notdefrangeP = notdefrangeP;
+
+ /* read "endnotdefrange" */
+ scan_token(inputP);
+ if (tokenType != TOKEN_NAME || (tokenType == TOKEN_NAME &&
+ (strncmp(tokenStartP,"endnotdefrange",14) != 0))) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ }
+
+ if (0 == strncmp(tokenStartP,"endcmap",7)) {
+ if (CMapP->CMapInfoP[CMAPREGISTRY].value.data.valueP == NULL ||
+ CMapP->CMapInfoP[CMAPORDERING].value.data.valueP == NULL ||
+ CMapP->CMapInfoP[CMAPSUPPLEMENT].value.data.integer == -1) {
+ rc = SCAN_ERROR;
+ break;
+ } else {
+ rc = SCAN_FILE_EOF;
+ break;
+ }
+ }
+ break;
+ }
+ }
+ while (rc == 0);
+ fclose(inputP->data.fileP);
+ if (tokenTooLong)
+ rc = SCAN_OUT_OF_MEMORY;
+ if (rc == SCAN_OUT_OF_MEMORY) return(rc);
+
+ /* open the specified CIDFont file */
+ if (!(fileP = fopen(filename,filetype)))
+ return(SCAN_FILE_OPEN_ERROR);
+
+ inputP = &inputFile;
+ objFormatFile(inputP,fileP);
+ CIDWantFontInfo = TRUE;
+ TwoSubrs = FALSE;
+ rc = BuildCIDFontInfo(CIDFontP);
+ if (rc != 0) return(rc);
+
+ /* Assume everything will be OK */
+ rc = 0;
+
+ /* Loop until complete font is read */
+ do {
+ /* Scan the next token */
+ scan_token(inputP);
+
+ /* ==> tokenLength, tokenTooLong, tokenType, and tokenValue are */
+ /* now set */
+
+ switch (tokenType) {
+ case TOKEN_EOF:
+ case TOKEN_NONE:
+ case TOKEN_INVALID:
+ /* in this case we are done */
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ rc = SCAN_ERROR;
+ break;
+ case TOKEN_LITERAL_NAME:
+ /* Look up the name */
+ tokenStartP[tokenLength] = '\0';
+ if (0 == strncmp(tokenStartP,"FDArray",7))
+ InFDArray = TRUE;
+
+ if (CIDWantFontInfo) {
+ rc = FindDictValue(CIDFontP->CIDfontInfoP);
+ /* we are not going to report errors */
+ rc = SCAN_OK;
+ break;
+ }
+ break;
+ case TOKEN_STRING:
+ tokenStartP[tokenLength] = '\0';
+ if (0 == strncmp(tokenStartP,"Binary",6)) {
+ CIDFontP->binarydata = 1;
+ scan_token(inputP);
+ if (tokenType == TOKEN_INTEGER)
+ CIDFontP->bytecnt = tokenValue.integer;
+ else {
+ rc = SCAN_ERROR;
+ break;
+ }
+ } else if (0 == strncmp(tokenStartP,"Hex",3)) {
+ /* not yet supported */
+ rc = SCAN_ERROR;
+ break;
+#if 0
+ /* uncomment when the hex format is supported */
+ CIDFontP->binarydata = 0;
+ scan_token(inputP);
+ if (tokenType == TOKEN_INTEGER)
+ CIDFontP->bytecnt = tokenValue.integer;
+ else {
+ rc = SCAN_ERROR;
+ break;
+ }
+#endif
+ }
+ break;
+ case TOKEN_NAME:
+ /* end of PostScript and beginning of data */
+ if (0 == strncmp(tokenStartP,"StartData",9)) {
+ /* every CIDFont must have an FDArray */
+ /* check whether other required dictionary entries were found */
+ if (CIDFontP->CIDfontInfoP[CIDFDARRAY].value.data.arrayP == NULL ||
+ CIDFontP->CIDfontInfoP[CIDFONTNAME].value.data.nameP == NULL ||
+ CIDFontP->CIDfontInfoP[CIDFONTTYPE].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDVERSION].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDREGISTRY].value.data.valueP == NULL ||
+ CIDFontP->CIDfontInfoP[CIDORDERING].value.data.valueP == NULL ||
+ CIDFontP->CIDfontInfoP[CIDSUPPLEMENT].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP == NULL ||
+ CIDFontP->CIDfontInfoP[CIDMAPOFFSET].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDFDBYTES].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDGDBYTES].value.data.integer == -1 ||
+ CIDFontP->CIDfontInfoP[CIDCOUNT].value.data.integer == -1) {
+ rc = SCAN_ERROR;
+ break;
+ } else {
+ /* do Registry and Ordering entries match? */
+ if (strcmp(CIDFontP->CIDfontInfoP[CIDREGISTRY].value.data.valueP,
+ CMapP->CMapInfoP[CMAPREGISTRY].value.data.valueP) != 0 ||
+ strcmp(CIDFontP->CIDfontInfoP[CIDORDERING].value.data.valueP,
+ CMapP->CMapInfoP[CMAPORDERING].value.data.valueP) != 0) {
+ rc = SCAN_ERROR;
+ break;
+ } else {
+ fclose(inputP->data.fileP);
+ return(SCAN_OK);
+ }
+ }
+ }
+ break;
+ }
+
+ }
+ while (rc ==0);
+ fclose(inputP->data.fileP);
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ return(rc);
+}
+
+/*
+ * -------------------------------------------------------------------
+ * Scan the next token and convert it into an object
+ * Result is placed on the Operand Stack as next object
+ * -------------------------------------------------------------------
+ */
+int
+scan_cidtype1font(psfont *FontP)
+{
+ int i;
+ int begincnt = 0; /* counter for the number of unpaired begin operators */
+ int currentfilefound = 0;
+
+ WantFontInfo = TRUE;
+ InPrivateDict = FALSE;
+ TwoSubrs = FALSE;
+ rc = BuildFontInfo(FontP);
+ if (rc != 0) return(rc);
+
+ /* Assume everything will be OK */
+ rc = 0;
+ filterFile.data.fileP = NULL;
+
+ /* Loop until complete font is read */
+ do {
+ /* Scan the next token */
+ scan_token(inputP);
+
+ /* ==> tokenLength, tokenTooLong, tokenType, and tokenValue are */
+ /* now set */
+
+ switch (tokenType) {
+ case TOKEN_EOF:
+ case TOKEN_NONE:
+ case TOKEN_INVALID:
+ /* in this case we are done */
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ rc = SCAN_ERROR;
+ break;
+ case TOKEN_LITERAL_NAME:
+ /* Look up the name */
+ tokenStartP[tokenLength] = '\0';
+ if (InPrivateDict ) {
+ rc = FindDictValue(FontP->Private);
+ /* we are not going to report errors */
+ /* Sometimes the font file may test a value such as */
+ /* testing to see if the font is alreadly loaded with */
+ /* same UniqueID. We would faile on /UniqueID get */
+ /* because we are expecting a int to follow UniqueID*/
+ /* If the correct object type does not follow a Name*/
+ /* then we will skip over it without reporting error*/
+ rc = SCAN_OK;
+ break;
+ } /* end of reading Private dictionary */
+ else
+ if (0 == strncmp(tokenStartP,"Private",7) ) {
+ InPrivateDict = TRUE;
+ rc = BuildCIDType1Private(FontP);
+ break;
+ }
+ else
+ if (WantFontInfo) {
+ rc = FindDictValue(FontP->fontInfoP);
+ /* we are not going to report errors */
+ rc = SCAN_OK;
+ break;
+ }
+ break;
+ case TOKEN_NAME:
+ if (0 == strncmp(tokenStartP,"currentfile",11)) {
+ currentfilefound = 1;
+ break;
+ } else if (0 == strncmp(tokenStartP,"eexec",5)) {
+ if (currentfilefound == 1) {
+ currentfilefound = 0;
+ filterFile.data.fileP = CIDeexec(inputP->data.fileP);
+ if (filterFile.data.fileP == NULL) {
+ fclose(inputFile.data.fileP);
+ return(SCAN_FILE_OPEN_ERROR);
+ }
+ inputP = &filterFile;
+ } else {
+ rc = SCAN_ERROR;
+ break;
+ }
+ } else if (0 == strncmp(tokenStartP,"begin",5)) {
+ begincnt++;
+ currentfilefound = 0;
+ } else if (0 == strncmp(tokenStartP,"end",3)) {
+ currentfilefound = 0;
+ begincnt--;
+ if (begincnt == 0) {
+ if (filterFile.data.fileP != NULL) {
+ scan_token(inputP); /* get 'currentfile' */
+ scan_token(inputP); /* get 'closefile' */
+ inputP = &inputFile;
+ resetDecrypt();
+ inputP->data.fileP->b_cnt =
+ F_BUFSIZ - (inputP->data.fileP->b_ptr -
+ inputP->data.fileP->b_base);
+ if (inputP->data.fileP->b_cnt > 0) {
+ for (i = 0; i < inputP->data.fileP->b_cnt; i++)
+ if (*(inputP->data.fileP->b_ptr + i) == '%')
+ break;
+ if (i < inputP->data.fileP->b_cnt) {
+ inputP->data.fileP->b_cnt -= i;
+ inputP->data.fileP->b_ptr += i;
+ } else
+ inputP->data.fileP->b_cnt = 0;
+ }
+ }
+ rc = SCAN_OK;
+ return(rc);
+ }
+ if (begincnt < 0) {
+ rc = SCAN_ERROR;
+ break;
+ }
+ }
+ break;
+ }
+
+ }
+ while (rc == 0);
+ if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
+ return(rc);
+}
+#endif
+
/*
* -------------------------------------------------------------------
* Scan the next token and convert it into an object
* Result is placed on the Operand Stack as next object
* -------------------------------------------------------------------
*/
-int scan_font(FontP)
- psfont *FontP;
+int
+scan_font(psfont *FontP)
{
@@ -1403,7 +2237,7 @@ int scan_font(FontP)
filterFile.data.fileP = NULL;
inputP = &inputFile;
- if (fileP = T1Open(filename,filetype)) {
+ if ((fileP = T1Open(filename,filetype))) {
/* get the first byte of file */
V = _XT1getc(fileP);
/* if file starts with x'80' then skip next 5 bytes */
diff --git a/src/Type1/spaces.c b/src/Type1/spaces.c
index 8b28d37..8eb4b52 100644
--- a/src/Type1/spaces.c
+++ b/src/Type1/spaces.c
@@ -26,6 +26,7 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/spaces.c,v 3.10 2002/02/18 20:51:57 herrb Exp $ */
/* SPACES CWEB V0021 ******** */
/*
:h1 id=spaces.SPACES Module - Handles Coordinate Spaces
@@ -37,6 +38,16 @@ This module is responsible for handling the TYPE1IMAGER "XYspace" object.
:h3.Include Files
*/
+
+#ifdef FONTMODULE
+#include "Xdefs.h" /* Bool declaration ??? */
+#include "Xmd.h" /* INT32 declaration ??? */
+#include "os.h"
+#include "xf86_ansic.h"
+#else
+#include "X11/Xos.h"
+#include "os.h"
+#endif
#include "objects.h"
#include "spaces.h"
#include "paths.h"
@@ -45,8 +56,12 @@ This module is responsible for handling the TYPE1IMAGER "XYspace" object.
#include "arith.h"
#include "trig.h"
-static void FindFfcn();
-static void FindIfcn();
+static void FindFfcn ( double cx, double cy,
+ convertFunc *fcnP );
+static void FindIfcn ( double cx, double cy,
+ fractpel *icxP, fractpel *icyP,
+ iconvertFunc *fcnP );
+
/*
:h3.Entry Points Provided to the TYPE1IMAGER User
*/
@@ -121,8 +136,8 @@ The XYspace structure represents the XYspace object.
static unsigned int SpaceID = 1;
-struct XYspace *CopySpace(S)
- register struct XYspace *S;
+struct XYspace *
+CopySpace(struct XYspace *S)
{
S = (struct XYspace *)Allocate(sizeof(struct XYspace), S, 0);
S->ID = NEXTID;
@@ -166,9 +181,9 @@ static struct XYspace identity = { SPACETYPE, ISPERMANENT(ON) + ISIMMORTAL(ON)
NULL, NULL,
NULL, NULL, NULL, NULL,
INVALIDID + 1, 0,
- FRACTFLOAT, 0.0, 0.0, FRACTFLOAT,
- 1.0/FRACTFLOAT, 0.0, 0.0, 1.0/FRACTFLOAT,
- 0, 0, 0, 0 };
+ {{{FRACTFLOAT, 0.0}, {0.0, FRACTFLOAT}},
+ {{1.0/FRACTFLOAT, 0.0}, {0.0, 1.0/FRACTFLOAT}}},
+ {{0, 0}, {0, 0}}};
struct XYspace *IDENTITY = &identity;
/*
@@ -182,12 +197,6 @@ static struct doublematrix contexts[MAXCONTEXTS];
static int nextcontext = 1;
/*SHARED LINE(S) ORIGINATED HERE*/
-
-#ifdef __STDC__
-#define pointer void *
-#else
-#define pointer char *
-#endif
/*
:h3.FindDeviceContext() - Find the Context Given a Device
@@ -197,8 +206,8 @@ transformation matrix in the context array. If it cannot find it,
it will allocate a new array entry and fill it out.
*/
-static int FindDeviceContext(device)
- pointer device; /* device token */
+static int
+FindDeviceContext(pointer device) /* device token */
{
double M[2][2]; /* temporary matrix */
float Xres,Yres; /* device resolution */
@@ -206,7 +215,7 @@ static int FindDeviceContext(device)
int rc = -1; /* return code for QueryDeviceState */
if (rc != 0) /* we only bother with this check once */
- abort("Context: QueryDeviceState didn't work");
+ Abort("Context: QueryDeviceState didn't work");
M[0][0] = M[1][0] = M[0][1] = M[1][1] = 0.0;
@@ -224,7 +233,7 @@ static int FindDeviceContext(device)
M[1][0] = -Yres; M[0][1] = -Xres;
break;
default:
- abort("QueryDeviceState returned invalid orientation");
+ Abort("QueryDeviceState returned invalid orientation");
}
return(FindContext(M));
}
@@ -237,8 +246,8 @@ the context array. If it cannot find it, it will allocate a new array
entry and fill it out.
*/
-int FindContext(M)
- double M[2][2]; /* array to search for */
+int
+FindContext(double M[2][2]) /* array to search for */
{
register int i; /* loop variable for search */
for (i=0; i < nextcontext; i++)
@@ -248,7 +257,7 @@ int FindContext(M)
if (i >= nextcontext) {
if (i >= MAXCONTEXTS)
- abort("Context: out of them");
+ Abort("Context: out of them");
LONGCOPY(contexts[i].normal, M, sizeof(contexts[i].normal));
MatrixInvert(M, contexts[i].inverse);
nextcontext++;
@@ -265,9 +274,9 @@ array index, then transforming IDENTITY space to create an appropriate
cooridnate space.
*/
-struct XYspace *Context(device, units)
- pointer device; /* device token */
- double units; /* multiples of one inch */
+struct XYspace *
+Context(pointer device, /* device token */
+ double units) /* multiples of one inch */
{
double M[2][2]; /* device transformation matrix */
register int n; /* will hold device context number */
@@ -308,11 +317,11 @@ So this subroutine, given an :f/M/and an object, finds the :f/D/ for that
object and modifies :f/M/ so it is :f/D sup <-1> times M times D/.
*/
-static void ConsiderContext(obj, M)
- register struct xobject *obj; /* object to be transformed */
- register double M[2][2]; /* matrix (may be changed) */
+static void
+ConsiderContext(struct xobject *obj, /* object to be transformed */
+ double M[2][2]) /* matrix (may be changed) */
{
- register int context; /* index in contexts array */
+ register int context = 0; /* index in contexts array */
if (obj == NULL) return;
@@ -360,19 +369,19 @@ These secondary routines come in many flavors to handle different
special cases as quickly as possible.
*/
-static void FXYConvert(pt, S, x, y)
- register struct fractpoint *pt; /* point to set */
- register struct XYspace *S; /* relevant coordinate space */
- register double x,y; /* user's coordinates of point */
+static void
+FXYConvert(struct fractpoint *pt, /* point to set */
+ struct XYspace *S, /* relevant coordinate space */
+ double x, double y) /* user's coordinates of point */
{
pt->x = (*S->xconvert)(S->tofract.normal[0][0], S->tofract.normal[1][0], x, y);
pt->y = (*S->yconvert)(S->tofract.normal[0][1], S->tofract.normal[1][1], x, y);
}
-static void IXYConvert(pt, S, x, y)
- register struct fractpoint *pt; /* point to set */
- register struct XYspace *S; /* relevant coordinate space */
- register long x,y; /* user's coordinates of point */
+static void
+IXYConvert(struct fractpoint *pt, /* point to set */
+ struct XYspace *S, /* relevant coordinate space */
+ long x, long y) /* user's coordinates of point */
{
pt->x = (*S->ixconvert)(S->itofract[0][0], S->itofract[1][0], x, y);
pt->y = (*S->iyconvert)(S->itofract[0][1], S->itofract[1][1], x, y);
@@ -385,10 +394,10 @@ precision in the answer with fixed point arithmetic. So, we force the
integers to floats, and do the arithmetic all with floats:
*/
-static void ForceFloat(pt, S, x, y)
- register struct fractpoint *pt; /* point to set */
- register struct XYspace *S; /* relevant coordinate space */
- register long x,y; /* user's coordinates of point */
+static void
+ForceFloat(struct fractpoint *pt, /* point to set */
+ struct XYspace *S, /* relevant coordinate space */
+ long x, long y) /* user's coordinates of point */
{
(*S->convert)(pt, S, (double) x, (double) y);
}
@@ -402,9 +411,9 @@ FXonly() and FYonly() are special cases when one of the coefficients
is 0.0.
*/
-static fractpel FXYboth(cx, cy, x, y)
- register double cx,cy; /* x and y coefficients */
- register double x,y; /* user x,y */
+static fractpel
+FXYboth(double cx, double cy, /* x and y coefficients */
+ double x, double y) /* user x,y */
{
register double r; /* temporary float */
@@ -413,9 +422,9 @@ static fractpel FXYboth(cx, cy, x, y)
}
/*ARGSUSED*/
-static fractpel FXonly(cx, cy, x, y)
- register double cx,cy; /* x and y coefficients */
- register double x,y; /* user x,y */
+static fractpel
+FXonly(double cx, double cy, /* x and y coefficients */
+ double x, double y) /* user x,y */
{
register double r; /* temporary float */
@@ -424,9 +433,9 @@ static fractpel FXonly(cx, cy, x, y)
}
/*ARGSUSED*/
-static fractpel FYonly(cx, cy, x, y)
- register double cx,cy; /* x and y coefficients */
- register double x,y; /* user x,y */
+static fractpel
+FYonly(double cx, double cy, /* x and y coefficients */
+ double x, double y) /* user x,y */
{
register double r; /* temporary float */
@@ -444,25 +453,25 @@ IXYboth() is the general purpose routine; IXonly() and IYonly() are
special cases when one of the coefficients is 0.
*/
-static fractpel IXYboth(cx, cy, x, y)
- register fractpel cx,cy; /* x and y coefficients */
- register long x,y; /* user x,y */
+static fractpel
+IXYboth(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
{
return(x * cx + y * cy);
}
/*ARGSUSED*/
-static fractpel IXonly(cx, cy, x, y)
- register fractpel cx,cy; /* x and y coefficients */
- register long x,y; /* user x,y */
+static fractpel
+IXonly(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
{
return(x * cx);
}
/*ARGSUSED*/
-static fractpel IYonly(cx, cy, x, y)
- register fractpel cx,cy; /* x and y coefficients */
- register long x,y; /* user x,y */
+static fractpel
+IYonly(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
{
return(y * cy);
}
@@ -485,25 +494,25 @@ Note that it is perfectly possible for us to calculate X with the
on how the functions in the XYspace structure are filled out.
*/
-static fractpel FPXYboth(cx, cy, x, y)
- register fractpel cx,cy; /* x and y coefficients */
- register long x,y; /* user x,y */
+static fractpel
+FPXYboth(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
{
return( FPmult(x, cx) + FPmult(y, cy) );
}
/*ARGSUSED*/
-static fractpel FPXonly(cx, cy, x, y)
- register fractpel cx,cy; /* x and y coefficients */
- register long x,y; /* user x,y */
+static fractpel
+FPXonly(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
{
return( FPmult(x, cx) );
}
/*ARGSUSED*/
-static fractpel FPYonly(cx, cy, x, y)
- register fractpel cx,cy; /* x and y coefficients */
- register long x,y; /* user x,y */
+static fractpel
+FPYonly(fractpel cx, fractpel cy, /* x and y coefficients */
+ long x, long y) /* user x,y */
{
return( FPmult(y, cy) );
}
@@ -518,8 +527,8 @@ in an XYspace structure, and also fills the "helper"
functions that actually do the work.
*/
-static void FillOutFcns(S)
- register struct XYspace *S; /* functions will be set in this structure */
+static void
+FillOutFcns(struct XYspace *S) /* functions will be set in this structure */
{
S->convert = FXYConvert;
S->iconvert = IXYConvert;
@@ -542,9 +551,9 @@ This function tests for the special case of one of the coefficients
being zero:
*/
-static void FindFfcn(cx, cy, fcnP)
- register double cx,cy; /* x and y coefficients */
- register fractpel (**fcnP)(); /* pointer to function to set */
+static void
+FindFfcn(double cx, double cy, /* x and y coefficients */
+ convertFunc *fcnP) /* pointer to function to set */
{
if (cx == 0.0)
*fcnP = FYonly;
@@ -565,10 +574,10 @@ we store a NULL indicating that this we should do the conversion in
floating point.
*/
-static void FindIfcn(cx, cy, icxP, icyP, fcnP)
- register double cx,cy; /* x and y coefficients */
- register fractpel *icxP,*icyP; /* fixed point coefficients to set */
- register fractpel (**fcnP)(); /* pointer to function to set */
+static void
+FindIfcn(double cx, double cy, /* x and y coefficients */
+ fractpel *icxP, fractpel *icyP, /* fixed point coefficients to set */
+ iconvertFunc *fcnP) /* pointer to function to set */
{
register fractpel imax; /* maximum of cx and cy */
@@ -635,10 +644,10 @@ zero determinants, so by convention, we mark the matrix is invalid by
marking both X terms zero.
*/
-void UnConvert(S, pt, xp, yp)
- register struct XYspace *S; /* relevant coordinate space */
- register struct fractpoint *pt; /* device coordinates */
- double *xp,*yp; /* where to store resulting x,y */
+void
+UnConvert(struct XYspace *S, /* relevant coordinate space */
+ struct fractpoint *pt, /* device coordinates */
+ double *xp, double *yp) /* where to store resulting x,y */
{
double x,y;
@@ -668,9 +677,9 @@ get the same result if we did S, then R, then T on the space and mapping
an unmodified font through that space.
*/
-struct xobject *t1_Xform(obj, M)
- register struct xobject *obj; /* object to transform */
- register double M[2][2]; /* transformation matrix */
+struct xobject *
+t1_Xform(struct xobject *obj, /* object to transform */
+ double M[2][2]) /* transformation matrix */
{
if (obj == NULL)
return(NULL);
@@ -703,7 +712,8 @@ transformation matrix and keep the handles up to date.
if (ISPATHTYPE(obj->type)) {
struct XYspace pseudo; /* local temporary space */
PseudoSpace(&pseudo, M);
- return((struct xobject *) PathTransform(obj, &pseudo));
+ return((struct xobject *) PathTransform((struct segment *)obj,
+ &pseudo));
}
@@ -734,9 +744,10 @@ transformation matrix and keep the handles up to date.
This is the external user's entry point.
*/
-struct xobject *t1_Transform(obj, cxx, cyx, cxy, cyy)
- struct xobject *obj;
- double cxx,cyx,cxy,cyy; /* 2x2 transform matrix elements in row order */
+struct xobject *
+t1_Transform(struct xobject *obj,
+ double cxx, double cyx, /* 2x2 transform matrix elements */
+ double cxy, double cyy) /* in row order */
{
double M[2][2];
@@ -756,9 +767,9 @@ struct xobject *t1_Transform(obj, cxx, cyx, cxy, cyy)
This is a user operator.
*/
-struct xobject *t1_Scale(obj, sx, sy)
- struct xobject *obj; /* object to scale */
- double sx,sy; /* scale factors in x and y */
+struct xobject *
+t1_Scale(struct xobject *obj, /* object to scale */
+ double sx, double sy) /* scale factors in x and y */
{
double M[2][2];
IfTrace3((MustTraceCalls),"Scale(%z, %f, %f)\n", obj, &sx, &sy);
@@ -777,9 +788,9 @@ and accuracy within the DegreeSin() and DegreeCos() routines themselves.
*/
#ifdef notdef
-struct xobject *xiRotate(obj, degrees)
- struct xobject *obj; /* object to be transformed */
- double degrees; /* degrees of COUNTER-clockwise rotation */
+struct xobject *
+xiRotate(struct xobject *obj, /* object to be transformed */
+ double degrees) /* degrees of COUNTER-clockwise rotation */
{
double M[2][2];
@@ -804,9 +815,9 @@ subroutine takes the arbitrary matrix and builds a coordinate
space, with all its nifty function pointers.
*/
-void PseudoSpace(S, M)
- struct XYspace *S; /* coordinate space structure to fill out */
- double M[2][2]; /* matrix that will become 'tofract.normal' */
+void
+PseudoSpace(struct XYspace *S, /* coordinate space structure to fill out */
+ double M[2][2]) /* matrix that will become 'tofract.normal' */
{
S->type = SPACETYPE;
S->flag = ISPERMANENT(ON) + ISIMMORTAL(ON);
@@ -849,9 +860,9 @@ To remind myself, matrix multiplication goes rows of A times columns
of B.
The output matrix may be the same as one of the input matrices.
*/
-void MatrixMultiply(A, B, C)
- register double A[2][2],B[2][2]; /* input matrices */
- register double C[2][2]; /* output matrix */
+void
+MatrixMultiply(double A[2][2], double B[2][2], /* input matrices */
+ double C[2][2]) /* output matrix */
{
register double txx,txy,tyx,tyy;
@@ -871,9 +882,9 @@ void MatrixMultiply(A, B, C)
My reference for matrix inversion was :hp1/Elementary Linear Algebra/
by Paul C. Shields, Worth Publishers, Inc., 1968.
*/
-void MatrixInvert(M, Mprime)
- double M[2][2]; /* input matrix */
- double Mprime[2][2]; /* output inverted matrix */
+void
+MatrixInvert(double M[2][2], /* input matrix */
+ double Mprime[2][2]) /* output inverted matrix */
{
register double D; /* determinant of matrix M */
register double txx,txy,tyx,tyy;
@@ -885,7 +896,7 @@ void MatrixInvert(M, Mprime)
D = M[1][1] * M[0][0] - M[1][0] * M[0][1];
if (D == 0.0)
- abort("MatrixInvert: can't");
+ Abort("MatrixInvert: can't");
Mprime[0][0] = tyy / D;
Mprime[1][0] = -txy / D;
@@ -904,7 +915,8 @@ maps 72nds of an inch to pels on the default device.
struct XYspace *USER = &identity;
-void InitSpaces()
+void
+InitSpaces(void)
{
IDENTITY->type = SPACETYPE;
FillOutFcns(IDENTITY);
@@ -930,9 +942,10 @@ must be taken out before we return the matrix to the user. Fortunately,
this is simple: just multiply by the inverse of IDENTITY!
*/
-void QuerySpace(S, cxxP, cyxP, cxyP, cyyP)
- register struct XYspace *S; /* space asked about */
- register double *cxxP,*cyxP,*cxyP,*cyyP; /* where to put answer */
+void
+QuerySpace(struct XYspace *S, /* space asked about */
+ double *cxxP, double *cyxP, /* where to put answer */
+ double *cxyP, double *cyyP)
{
double M[2][2]; /* temp matrix to build user's answer */
@@ -959,9 +972,9 @@ We make sure we have N (FRACTBITS/4) digits past the decimal point.
*/
#define FRACTMASK ((1<<FRACTBITS)-1) /* mask for fractional part */
-void FormatFP(string, fpel)
- register char *string; /* output string */
- register fractpel fpel; /* fractional pel input */
+void
+FormatFP(char *string, /* output string */
+ fractpel fpel) /* fractional pel input */
{
char temp[8];
register char *s;
@@ -974,18 +987,18 @@ void FormatFP(string, fpel)
else
sign = "";
- sprintf(temp, "000%x", fpel & FRACTMASK);
+ sprintf(temp, "000%lx", fpel & FRACTMASK);
s = temp + strlen(temp) - (FRACTBITS/4);
- sprintf(string, "%s%d.%sx", sign, fpel >> FRACTBITS, s);
+ sprintf(string, "%s%d.%sx", sign, (int)(fpel >> FRACTBITS), s);
}
/*
:h3.DumpSpace() - Display a Coordinate Space
*/
/*ARGSUSED*/
-void DumpSpace(S)
- register struct XYspace *S;
+void
+DumpSpace(struct XYspace *S)
{
IfTrace4(TRUE,"--Coordinate space at %x,ID=%d,convert=%x,iconvert=%x\n",
S, S->ID, S->convert, S->iconvert);
diff --git a/src/Type1/spaces.h b/src/Type1/spaces.h
index 21eee17..efbcecb 100644
--- a/src/Type1/spaces.h
+++ b/src/Type1/spaces.h
@@ -26,6 +26,8 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/spaces.h,v 3.4 2001/01/17 19:43:23 dawes Exp $ */
+
/*SHARED*/
#define USER t1_User
@@ -37,35 +39,26 @@
#define Scale(o,sx,sy) t1_Scale(o,sx,sy)
#define QuerySpace(S,f1,f2,f3,f4) t1_QuerySpace(S,f1,f2,f3,f4)
#define Warp(s1,o,s2) t1_Warp(s1,o,s2)
-
-struct XYspace *t1_Context(); /* creates a coordinate space for a device */
-struct xobject *t1_Transform(); /* transform an object */
+
+/* IDENTITY space */
+extern struct XYspace *IDENTITY;
+
+/* creates a coordinate space for a device */
+extern struct XYspace *Context(pointer device, double units);
+/* transform an object */
+extern struct xobject *t1_Transform ( struct xobject *obj, double cxx,
+ double cyx, double cxy, double cyy );
+#if 0
struct xobject *t1_Rotate(); /* rotate an object */
-struct xobject *t1_Scale(); /* scale an object */
+#endif
+/* scale an object */
+extern struct xobject *t1_Scale ( struct xobject *obj, double sx, double sy );
+#if 0
struct xobject *t1_Warp(); /* transform like delta of two spaces */
-void t1_QuerySpace(); /* returns coordinate space matrix */
-
-/*END SHARED*/
-/*SHARED*/
-
-#define DeviceResolution t1_DeviceResolution
-#define InitSpaces() t1_InitSpaces()
-#define CopySpace(s) t1_CopySpace(s)
-#define Xform(o,M) t1_Xform(o,M)
-#define UnConvert(S,pt,xp,yp) t1_UnConvert(S,pt,xp,yp)
-#define MatrixMultiply(A,B,C) t1_MMultiply(A,B,C)
-#define MatrixInvert(A,B) t1_MInvert(A,B)
-#define PseudoSpace(S,M) t1_PseudoSpace(S,M)
-#define FindContext(M) t1_FindContext(M)
-
-void t1_InitSpaces(); /* initialize pre-defined coordinate spaces */
-struct XYspace *t1_CopySpace(); /* duplicate a coordinate space */
-struct xobject *t1_Xform(); /* transform object by matrix */
-void t1_UnConvert(); /* return user coordinates from device coordinates */
-void t1_MMultiply(); /* multiply two matrices */
-void t1_MInvert(); /* invert a matrix */
-void t1_PseudoSpace(); /* force a coordinate space from a matrix */
-int t1_FindContext(); /* return the "context" represented by a matrix */
+#endif
+/* returns coordinate space matrix */
+extern void t1_QuerySpace ( struct XYspace *S, double *cxxP, double *cyxP,
+ double *cxyP, double *cyyP );
/*END SHARED*/
/*SHARED*/
@@ -108,15 +101,24 @@ struct doublematrix {
/*END SHARED*/
/*SHARED*/
+struct fractpoint {
+ fractpel x,y;
+} ;
+
+/*SHARED*/
+
+typedef fractpel (*convertFunc)(double, double, double, double);
+typedef fractpel (*iconvertFunc)(fractpel, fractpel, long, long);
+
struct XYspace {
XOBJ_COMMON /* xobject common data define 3-26-91 PNM */
/* type = SPACETYPE */
- void (*convert)(); /* calculate "fractpoint" X,Y from float X,Y */
- void (*iconvert)(); /* calculate "fractpoint" X,Y from int X,Y */
- fractpel (*xconvert)(); /* subroutine of convert */
- fractpel (*yconvert)(); /* subroutine of convert */
- fractpel (*ixconvert)(); /* subroutine of iconvert */
- fractpel (*iyconvert)(); /* subroutine of iconvert */
+ void (*convert)(struct fractpoint *, struct XYspace *, double, double); /* calculate "fractpoint" X,Y from float X,Y */
+ void (*iconvert)(struct fractpoint *, struct XYspace *, long, long); /* calculate "fractpoint" X,Y from int X,Y */
+ convertFunc xconvert; /* subroutine of convert */
+ convertFunc yconvert; /* subroutine of convert */
+ iconvertFunc ixconvert; /* subroutine of iconvert */
+ iconvertFunc iyconvert; /* subroutine of iconvert */
int ID; /* unique identifier (used in font caching) */
unsigned char context; /* device context of coordinate space */
struct doublematrix tofract; /* xform to get to fractional pels */
@@ -126,15 +128,45 @@ struct XYspace {
#define INVALIDID 0 /* no valid space will have this ID */
/*END SHARED*/
+/*END SHARED*/
/*SHARED*/
-struct fractpoint {
- fractpel x,y;
-} ;
+#define DeviceResolution t1_DeviceResolution
+#define InitSpaces t1_InitSpaces
+#define CopySpace(s) t1_CopySpace(s)
+#define Xform(o,M) t1_Xform(o,M)
+#define UnConvert(S,pt,xp,yp) t1_UnConvert(S,pt,xp,yp)
+#define MatrixMultiply(A,B,C) t1_MMultiply(A,B,C)
+#define MatrixInvert(A,B) t1_MInvert(A,B)
+#define PseudoSpace(S,M) t1_PseudoSpace(S,M)
+#define FindContext(M) t1_FindContext(M)
+/* initialize pre-defined coordinate spaces */
+extern void t1_InitSpaces ( void );
+/* duplicate a coordinate space */
+extern struct XYspace *t1_CopySpace ( struct XYspace *S );
+/* transform object by matrix */
+extern struct xobject *t1_Xform ( struct xobject *obj, double M[2][2] );
+/* return user coordinates from device coordinates */
+extern void t1_UnConvert ( struct XYspace *S, struct fractpoint *pt,
+ double *xp, double *yp );
+/* multiply two matrices */
+extern void t1_MMultiply ( double A[2][2], double B[2][2], double C[2][2] );
+/* invert a matrix */
+extern void t1_MInvert ( double M[2][2], double Mprime[2][2] );
+/* force a coordinate space from a matrix */
+extern void t1_PseudoSpace ( struct XYspace *S, double M[2][2] );
+/* return the "context" represented by a matrix */
+int t1_FindContext(double M[2][2]);
+
/*END SHARED*/
/*SHARED*/
#define NULLCONTEXT 0
/*END SHARED*/
+
+/* dump a coordinate space structure */
+extern void t1_DumpSpace ( struct XYspace *S );
+/* dump a format a "fractpel" coordinate */
+extern void t1_FormatFP ( char *string, fractpel fpel );
diff --git a/src/Type1/t1funcs.c b/src/Type1/t1funcs.c
index ef113db..20b7b66 100644
--- a/src/Type1/t1funcs.c
+++ b/src/Type1/t1funcs.c
@@ -54,6 +54,24 @@
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/t1funcs.c,v 3.30 2002/12/09 17:29:59 dawes Exp $ */
/*
@@ -82,8 +100,14 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-
+
+#ifndef FONTMODULE
#include <string.h>
+#ifdef BUILDCID
+#include <stdlib.h>
+#include <sys/types.h>
+#include <dirent.h>
+#endif
#ifdef _XOPEN_SOURCE
#include <math.h>
#else
@@ -92,54 +116,386 @@ from The Open Group.
#undef _XOPEN_SOURCE
#endif
#include "X11/Xfuncs.h"
+#ifdef USE_MMAP
+#include <sys/types.h>
+#include <sys/mman.h>
+#endif
+#else
+#include "Xmd.h"
+#include "Xdefs.h"
+#include "xf86_ansic.h"
+#endif
+
+#include "os.h"
#include "fntfilst.h"
+#include "fontutil.h"
#include "FSproto.h"
-#include "t1intf.h"
+#include "fontenc.h"
+#include "t1unicode.h"
+#ifdef BUILDCID
+#include "range.h"
+#endif
+
#include "objects.h"
#include "spaces.h"
+#include "paths.h"
#include "regions.h"
#include "t1stdio.h"
#include "util.h"
#include "fontfcn.h"
-
-int Type1OpenScalable ();
-static int Type1GetGlyphs();
-void Type1CloseFont();
-extern int Type1GetInfoScalable ();
-
-static int Type1GetMetrics ();
+#include "t1intf.h"
+
+
+static int Type1GetGlyphs ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, CharInfoPtr *glyphs );
+
+#ifdef BUILDCID
+#define CMapDir "/CMap/"
+#define CFMDir "/CFM/"
+#define CIDFontDir "/CIDFont/"
+#endif
+
+static int Type1GetMetrics ( FontPtr pFont, unsigned long count,
+ unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount,
+ xCharInfo **glyphs );
+
#define minchar(p) ((p).min_char_low + ((p).min_char_high << 8))
#define maxchar(p) ((p).max_char_low + ((p).max_char_high << 8))
-static void fillrun();
-
+static void fillrun ( char *p, pel x0, pel x1, int bit );
extern psfont *FontP;
extern psobj *ISOLatin1EncArrayP;
-extern unsigned long *Xalloc();
-static void fill();
+#ifdef BUILDCID
+extern char CurCIDFontName[];
+extern char CurCMapName[];
+
+static CharInfoPtr CIDGetGlyph ( FontPtr pFont, unsigned int charcode,
+ CharInfoPtr pci );
+
+extern cidfont *CIDFontP;
+extern cmapres *CMapP;
+#endif
+
+static void fill ( char *dest, int h, int w, struct region *area, int byte,
+ int bit, int wordsize );
+
+#ifdef BUILDCID
+int
+CIDOpenScalable (FontPathElementPtr fpe,
+ FontPtr *ppFont,
+ int flags,
+ FontEntryPtr entry,
+ char *fileName,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font) /* We don't do licensing */
+{
+ FontPtr pFont;
+ int bit,
+ byte,
+ glyph,
+ scan,
+ image;
+ int pad,wordsize; /* scan & image in bits */
+ long *pool; /* memory pool for ximager objects */
+ int size; /* for memory size calculations */
+ struct XYspace *S; /* coordinate space for character */
+ register int i;
+ int nchars, len, rc;
+ cidglyphs *cid;
+ char *p;
+ double t1 = .001, t2 = 0.0, t3 = 0.0, t4 = .001;
+ double sxmult;
+ char CIDFontName[CID_NAME_MAX];
+ char CMapName[CID_NAME_MAX];
+ char cidfontname[CID_PATH_MAX];
+ char cmapname[CID_PATH_MAX];
+ char *path;
+ char cidfontpath[CID_PATH_MAX];
+ char cmappath[CID_PATH_MAX];
+#if defined(HAVE_CFM) || defined(CID_ALL_CHARS)
+ char cfmdir[CID_PATH_MAX];
+ char cfmfilename[CID_NAME_MAX];
+#endif
+#if defined(CID_ALL_CHARS)
+ char *cf;
+#endif
+ long sAscent, sDescent;
+
+ /* check the font name */
+ len = strlen(fileName);
+ if (len <= 0 || len > CID_NAME_MAX - 1)
+ return BadFontName;
+
+#if defined(HAVE_CFM) || defined(CID_ALL_CHARS)
+ strcpy(cfmdir, fileName);
+ p = strrchr(cfmdir, '/');
+ if (p) *p = '\0';
+#endif
+
+ path = fileName;
+ if (!(fileName = strrchr(fileName, '/')))
+ return BadFontName;
+
+ len = fileName - path;
+ strncpy(cidfontpath, path, len);
+ cidfontpath[len] = '\0';
+ strcpy(cmappath, cidfontpath);
+ strcat(cmappath, CMapDir);
+#ifdef HAVE_CFM
+ strcpy(cfmdir, cidfontpath);
+ strcat(cfmdir, CFMDir);
+#endif
+ strcat(cidfontpath, CIDFontDir);
+
+ fileName++;
+
+ /* extract the CIDFontName and CMapName from the font name */
+ /* check for <CIDFontName>--<CMapName> */
+ if ((p = strstr(fileName, "--"))) {
+ if (p == fileName)
+ return BadFontName;
+ else {
+ strcpy(CIDFontName, fileName);
+ CIDFontName[p - fileName] = '\0';
+ p += 2;
+ i = 0;
+ while (*p && *p != '.')
+ CMapName[i++] = *p++;
+ CMapName[i] = '\0';
+ if ((len = strlen(CMapName)) <= 0)
+ return BadFontName;
+ }
+ } else
+ return BadFontName;
+
+ /* The CMap files whose names end with -V are not yet supported */
+ len = strlen(CMapName);
+ if ((len >= 2 && CMapName[len - 2] == '-' && CMapName[len - 1] == 'V') ||
+ (len == 1 && CMapName[len - 1] == 'V'))
+ return BadFontName;
+
+ /* Reject ridiculously small font sizes that will blow up the math */
+ if (hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]) < 1.0 ||
+ hypot(vals->pixel_matrix[2], vals->pixel_matrix[3]) < 1.0)
+ return BadFontName;
+
+#ifdef CID_ALL_CHARS
+ if ((cf = getenv("CFMDIR")) == NULL)
+ strcat(cfmdir, CFMDir);
+ else {
+ strcpy(cfmdir, cf);
+ strcat(cfmdir, "/");
+ }
+#endif
+
+#if defined(HAVE_CFM) || defined(CID_ALL_CHARS)
+ strcpy(cfmfilename, cfmdir);
+ strcat(cfmfilename, CIDFontName);
+ strcat(cfmfilename, "--");
+ strcat(cfmfilename, CMapName);
+ strcat(cfmfilename, ".cfm");
+#endif
+
+ /* create a full-path name for a CIDFont file */
+ if (strlen(cidfontpath) + strlen(CIDFontName) + 2 >
+ CID_PATH_MAX)
+ return BadFontName;
+ strcpy(cidfontname, cidfontpath);
+ strcat(cidfontname, CIDFontName);
+
+ /* create a full-path name for a CMap file */
+ if (strlen(cmappath) + strlen(CMapName) + 2 > CID_PATH_MAX)
+ return BadFontName;
+ strcpy(cmapname, cmappath);
+ strcat(cmapname, CMapName);
+
+ /* set up default values */
+ FontDefaultFormat(&bit, &byte, &glyph, &scan);
+ /* get any changes made from above */
+ rc = CheckFSFormat(format, fmask, &bit, &byte, &scan, &glyph, &image);
+ if (rc != Successful)
+ return rc;
+
+ pad = glyph * 8;
+ wordsize = scan * 8;
+
+#define PAD(bits, pad) (((bits)+(pad)-1)&-(pad))
+
+ if (!(pFont = CreateFontRec()))
+ return AllocError;
+
+ cid = (cidglyphs *)xalloc(sizeof(cidglyphs));
+ if (cid == NULL) {
+ DestroyFontRec(pFont);
+ return AllocError;
+ }
+ bzero(cid, sizeof(cidglyphs));
+
+ /* heuristic for "maximum" size of pool we'll need: */
+ size = 200000 + 600 *
+ (int)hypot(vals->pixel_matrix[2], vals->pixel_matrix[3])
+ * sizeof(short);
+ if (size < 0 || NULL == (pool = (long *) xalloc(size))) {
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return AllocError;
+ }
+
+ addmemory(pool, size);
+
+ /* load font if not already loaded */
+ if (!CIDfontfcnA(cidfontname, cmapname, &rc)) {
+ FontP = NULL;
+ delmemory();
+ xfree(pool);
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return Type1ReturnCodeToXReturnCode(rc);
+ }
+
+ FontP = NULL;
+
+ S = (struct XYspace *) t1_Transform((struct xobject *)IDENTITY,
+ t1, t2, t3, t4);
+
+ S = (struct XYspace *) Permanent(t1_Transform((struct xobject *)S,
+ vals->pixel_matrix[0],
+ -vals->pixel_matrix[1],
+ vals->pixel_matrix[2],
+ -vals->pixel_matrix[3]));
+
+ /* multiplier for computation of raw values */
+ sxmult = hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]);
+ if (sxmult > EPS) sxmult = 1000.0 / sxmult;
+
+ pFont->info.firstRow = CMapP->firstRow;
+ pFont->info.firstCol = CMapP->firstCol;
+ pFont->info.lastRow = CMapP->lastRow;
+ pFont->info.lastCol = CMapP->lastCol;
+
+ nchars = (pFont->info.lastRow - pFont->info.firstRow + 1) *
+ (pFont->info.lastCol - pFont->info.firstCol + 1);
+
+ delmemory();
+ xfree(pool);
+
+ if (pFont->info.firstCol > pFont->info.lastCol)
+ {
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return BadFontName;
+ }
+
+ cid->glyphs = (CharInfoRec **)xalloc(nchars*sizeof(CharInfoRec *));
+ if (cid->glyphs == NULL) {
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return AllocError;
+ }
+ bzero(cid->glyphs, nchars*sizeof(CharInfoRec *));
+
+ pFont->info.defaultCh = 0;
+ pFont->format = format;
+
+ pFont->bit = bit;
+ pFont->byte = byte;
+ pFont->glyph = glyph;
+ pFont->scan = scan;
+
+ pFont->get_metrics = CIDGetMetrics;
+ pFont->get_glyphs = CIDGetGlyphs;
+ pFont->unload_font = CIDCloseFont;
+ pFont->unload_glyphs = NULL;
+ pFont->refcnt = 0;
+
+ len = strlen(cidfontname);
+ cid->CIDFontName = (char *)xalloc(len + 1);
+ if (cid->CIDFontName == NULL) {
+ xfree(cid->glyphs);
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return AllocError;
+ }
+ strcpy(cid->CIDFontName, cidfontname);
+
+ len = strlen(cmapname);
+ cid->CMapName = (char *)xalloc(len + 1);
+ if (cid->CMapName == NULL) {
+ xfree(cid->CIDFontName);
+ xfree(cid->glyphs);
+ xfree(cid);
+ DestroyFontRec(pFont);
+ return AllocError;
+ }
+ strcpy(cid->CMapName, cmapname);
+
+ cid->pixel_matrix[0] = vals->pixel_matrix[0];
+ cid->pixel_matrix[1] = vals->pixel_matrix[1];
+ cid->pixel_matrix[2] = vals->pixel_matrix[2];
+ cid->pixel_matrix[3] = vals->pixel_matrix[3];
+
+ pFont->fontPrivate = (unsigned char *)cid;
+
+ pFont->info.fontAscent =
+ (CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[3].data.integer *
+ vals->pixel_matrix[3] +
+ (CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[3].data.integer >
+ 0 ? 500 : -500)) / 1000;
+
+ pFont->info.fontDescent =
+ -(int)((double)CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[1].data.integer
+ * vals->pixel_matrix[3] +
+ (CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[1].data.integer >
+ 0 ? 500 : -500)) / 1000;
+
+ /* Adobe does not put isFixedPitch entries in CID-keyed fonts. */
+ /* CID-keyed are not constant-width fonts. */
+ pFont->info.constantWidth = 0;
+
+ sAscent = CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[3].data.integer;
+ sDescent = -CIDFontP->CIDfontInfoP[CIDFONTBBOX].value.data.arrayP[1].data.integer;
+
+ if (strncmp(entry->name.name, "-bogus", 6)) {
+#ifdef CID_ALL_CHARS
+ ComputeBoundsAllChars(pFont, cfmfilename, sxmult);
+#else
+#ifdef HAVE_CFM
+ CIDFillFontInfo(pFont, vals, cidfontname, entry->name.name, cmapname,
+ cfmfilename, sAscent, sDescent, sxmult);
+#else
+ CIDFillFontInfo(pFont, vals, cidfontname, entry->name.name, cmapname,
+ sAscent, sDescent, sxmult);
+#endif /* HAVE_CFM */
+#endif /* CID_ALL_CHARS */
+ }
+
+ *ppFont = pFont;
+
+ return Successful;
+}
+#endif
/*ARGSUSED*/
-int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
- fmask, non_cachable_font)
- FontPathElementPtr fpe;
- FontPtr *ppFont;
- int flags;
- FontEntryPtr entry;
- char *fileName;
- FontScalablePtr vals;
- fsBitmapFormat format;
- fsBitmapFormatMask fmask;
- FontPtr non_cachable_font; /* We don't do licensing */
+int
+Type1OpenScalable (FontPathElementPtr fpe,
+ FontPtr *ppFont,
+ int flags,
+ FontEntryPtr entry,
+ char *fileName,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font) /* We don't do licensing */
{
- extern struct XYspace *IDENTITY;
- extern Bool fontfcnA();
- extern struct region *fontfcnB();
-
-
FontPtr pFont;
int bit,
byte,
@@ -147,7 +503,7 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
scan,
image;
int pad,wordsize; /* scan & image in bits */
- unsigned long *pool; /* memory pool for ximager objects */
+ long *pool; /* memory pool for ximager objects */
int size; /* for memory size calculations */
struct XYspace *S; /* coordinate space for character */
struct region *area;
@@ -156,7 +512,8 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
int len, rc, count = 0;
struct type1font *type1;
char *p;
- psobj *fontencoding = NULL;
+ FontMapPtr mapping = NULL;
+ int no_mapping;
psobj *fontmatrix;
long x0, total_width = 0, total_raw_width = 0;
double x1, y1, t1 = .001, t2 = 0.0, t3 = 0.0, t4 = .001;
@@ -179,24 +536,28 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
#define PAD(bits, pad) (((bits)+(pad)-1)&-(pad))
- pFont = (FontPtr) xalloc(sizeof(FontRec));
+ pFont = CreateFontRec();
if (pFont == NULL)
return AllocError;
-
+
type1 = (struct type1font *)xalloc(sizeof(struct type1font));
if (type1 == NULL) {
- xfree(pFont);
+ DestroyFontRec(pFont);
return AllocError;
}
bzero(type1, sizeof(struct type1font));
/* heuristic for "maximum" size of pool we'll need: */
- size = 200000 + 120 *
+#ifdef BUILDCID
+ size = 400000 + 600 *
+#else
+ size = 200000 + 600 *
+#endif
(int)hypot(vals->pixel_matrix[2], vals->pixel_matrix[3])
* sizeof(short);
- if (size < 0 || NULL == (pool = (unsigned long *) xalloc(size))) {
+ if (size < 0 || NULL == (pool = (long *) xalloc(size))) {
xfree(type1);
- xfree(pFont);
+ DestroyFontRec(pFont);
return AllocError;
}
@@ -209,7 +570,7 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
if (!fontfcnA(fileName, &rc)) {
delmemory();
xfree(type1);
- xfree(pFont);
+ DestroyFontRec(pFont);
xfree(pool);
return Type1ReturnCodeToXReturnCode(rc);
}
@@ -229,61 +590,103 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
assign(3, t4, .001);
}
- S = (struct XYspace *) t1_Transform(IDENTITY, t1, t2, t3, t4);
+ S = (struct XYspace *) t1_Transform((struct xobject *)IDENTITY,
+ t1, t2, t3, t4);
- S = (struct XYspace *) Permanent(t1_Transform(S, vals->pixel_matrix[0],
- -vals->pixel_matrix[1],
- vals->pixel_matrix[2],
- -vals->pixel_matrix[3]));
+ S = (struct XYspace *) Permanent(t1_Transform((struct xobject *)S,
+ vals->pixel_matrix[0],
+ -vals->pixel_matrix[1],
+ vals->pixel_matrix[2],
+ -vals->pixel_matrix[3]));
/* multiplier for computation of raw values */
sxmult = hypot(vals->pixel_matrix[0], vals->pixel_matrix[1]);
if (sxmult > EPS) sxmult = 1000.0 / sxmult;
- p = entry->name.name + entry->name.length - 19;
- if (entry->name.ndashes == 14 &&
- p >= entry->name.name &&
- !strcmp (p, "-adobe-fontspecific"))
- {
- fontencoding = FontP->fontInfoP[ENCODING].value.data.arrayP;
+ no_mapping=0;
+ p = FontEncFromXLFD(entry->name.name, entry->name.length);
+
+ if(p==0) { /* XLFD does not specify an encoding */
+ mapping=0;
+ no_mapping=2; /* ISO 8859-1 */
}
- if (!fontencoding)
- fontencoding = ISOLatin1EncArrayP;
+ if(!strcmp(p, "adobe-fontspecific")) {
+ mapping=0;
+ no_mapping=1; /* font's native encoding vector */
+ }
+
+ if(!no_mapping) {
+ mapping = FontEncMapFind(p,
+ FONT_ENCODING_POSTSCRIPT, -1, -1,
+ fileName);
+ if(!mapping)
+ mapping = FontEncMapFind(p,
+ FONT_ENCODING_UNICODE, -1, -1,
+ fileName);
+ if(!mapping)
+ no_mapping=2;
+ else
+ no_mapping=0;
+ }
pFont->info.firstCol = 255;
- pFont->info.lastCol = FIRSTCOL;
+ pFont->info.lastCol = 0;
- for (i=0; i < 256-FIRSTCOL; i++) {
+ for (i=0; i < 256; i++) {
long h,w;
long paddedW;
int j;
char *codename;
- codename = fontencoding[i + FIRSTCOL].data.valueP;
- len = fontencoding[i + FIRSTCOL].len;
- if (len == 7 && strcmp(codename,".notdef")==0)
- continue;
-
+ if(no_mapping == 1) {
+ codename = FontP->fontInfoP[ENCODING].
+ value.data.arrayP[i].data.valueP;
+ len = FontP->fontInfoP[ENCODING].
+ value.data.arrayP[i].len;
+ } else if(no_mapping) {
+ codename = unicodetoPSname(i);
+ len = codename ? strlen(codename) : 0;
+ } else {
+ if(mapping->type == FONT_ENCODING_UNICODE) {
+ codename = unicodetoPSname(FontEncRecode(i, mapping));
+ } else
+ codename = FontEncName(i, mapping);
+ len=codename?strlen(codename):0;
+ }
+
+ /* Avoid multiply rasterising the undefined glyph */
+ if(len==7 && !strncmp(codename, ".notdef", 7)) {
+ len=0;
+ codename=0;
+ }
+
+ /* But do rasterise it at least once */
+ if(len==0) {
+ if(i==0) {
+ codename=".notdef";
+ len=7;
+ } else
+ continue;
+ }
+
/* See if this character is in the list of ranges specified
in the XLFD name */
- for (j = 0; j < vals->nranges; j++)
- if (i + FIRSTCOL >= minchar(vals->ranges[j]) &&
- i + FIRSTCOL <= maxchar(vals->ranges[j]))
- break;
+ if(i!=0) {
+ for (j = 0; j < vals->nranges; j++)
+ if (i >= minchar(vals->ranges[j]) &&
+ i <= maxchar(vals->ranges[j]))
+ break;
- /* If not, don't realize it. */
- if (vals->nranges && j == vals->nranges)
- continue;
-
- if (pFont->info.firstCol > i + FIRSTCOL)
- pFont->info.firstCol = i + FIRSTCOL;
- if (pFont->info.lastCol < i + FIRSTCOL)
- pFont->info.lastCol = i + FIRSTCOL;
+ /* If not, don't realize it. */
+ if (vals->nranges && j == vals->nranges)
+ continue;
+ }
rc = 0;
- area = fontfcnB(S, codename, &len, &rc);
+ area = (struct region *)fontfcnB(S, (unsigned char *)codename,
+ &len, &rc);
if (rc < 0) {
rc = Type1ReturnCodeToXReturnCode(rc);
break;
@@ -294,6 +697,11 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
if (area == NULL)
continue;
+ if (pFont->info.firstCol > i)
+ pFont->info.firstCol = i;
+ if (pFont->info.lastCol < i)
+ pFont->info.lastCol = i;
+
h = area->ymax - area->ymin;
w = area->xmax - area->xmin;
paddedW = PAD(w, pad);
@@ -356,16 +764,16 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
if (pFont->info.firstCol > pFont->info.lastCol)
{
xfree(type1);
- xfree(pFont);
+ DestroyFontRec(pFont);
return BadFontName;
}
- if (i != 256 - FIRSTCOL) {
+ if (i != 256) {
for (i--; i >= 0; i--)
if (glyphs[i].bits != NULL)
xfree(glyphs[i].bits);
xfree(type1);
- xfree(pFont);
+ DestroyFontRec(pFont);
return rc;
}
type1->pDefault = NULL;
@@ -385,8 +793,6 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
pFont->unload_font = Type1CloseFont;
pFont->unload_glyphs = NULL;
pFont->refcnt = 0;
- pFont->maxPrivate = -1;
- pFont->devPrivates = 0;
pFont->fontPrivate = (unsigned char *) type1;
@@ -408,15 +814,283 @@ int Type1OpenScalable (fpe, ppFont, flags, entry, fileName, vals, format,
*ppFont = pFont;
return Successful;
}
+
+#ifdef BUILDCID
+unsigned int
+getCID(FontPtr pFont, unsigned int charcode)
+{
+ unsigned int cidcode = 0;
+ Bool charvalid = FALSE;
+ cidglyphs *cid;
+ int i, j;
+ unsigned int char_row, char_col, rangelo_row, rangelo_col, k;
+ unsigned int rangehi_row, rangehi_col;
+ spacerange *spacerangeP;
+ cidrange *notdefrangeP, *cidrangeP;
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+ if (cid == NULL)
+ return cidcode;
+
+ char_row = (charcode >> 8) & 0xff;
+ char_col = charcode & 0xff;
+
+ spacerangeP = CIDFontP->spacerangeP;
+ for (i = 0; i < CIDFontP->spacerangecnt; i++) {
+ for (j = 0; j < spacerangeP->rangecnt; j++) {
+ rangelo_row =
+ (spacerangeP->spacecode[j].srcCodeLo >> 8) & 0xff;
+ rangelo_col = spacerangeP->spacecode[j].srcCodeLo & 0xff;
+ rangehi_row =
+ (spacerangeP->spacecode[j].srcCodeHi >> 8) & 0xff;
+ rangehi_col = spacerangeP->spacecode[j].srcCodeHi & 0xff;
+ if (char_row >= rangelo_row && char_row <= rangehi_row &&
+ char_col >= rangelo_col && char_col <= rangehi_col) {
+ charvalid = TRUE;
+ break;
+ }
+ }
+ if (charvalid) break;
+ spacerangeP = spacerangeP->next;
+ }
+
+ if (charvalid) {
+ charvalid = FALSE;
+ cidrangeP = CIDFontP->cidrangeP;
+ for (i = 0; i < CIDFontP->cidrangecnt; i++) {
+ for (j = 0; j < cidrangeP->rangecnt; j++) {
+ rangelo_row =
+ (cidrangeP->range[j].srcCodeLo >> 8) & 0xff;
+ rangelo_col = cidrangeP->range[j].srcCodeLo & 0xff;
+ rangehi_row =
+ (cidrangeP->range[j].srcCodeHi >> 8) & 0xff;
+ rangehi_col = cidrangeP->range[j].srcCodeHi & 0xff;
+ if (char_row >= rangelo_row && char_row <= rangehi_row &&
+ char_col >= rangelo_col && char_col <= rangehi_col) {
+ charvalid = TRUE;
+ for (k = cidrangeP->range[j].srcCodeLo;
+ k <= cidrangeP->range[j].srcCodeHi; k++) {
+ if (k == charcode)
+ cidcode = cidrangeP->range[j].dstCIDLo + k -
+ cidrangeP->range[j].srcCodeLo;
+ }
+ break;
+ }
+ }
+ if (charvalid) break;
+ cidrangeP = cidrangeP->next;
+ }
+ }
+
+ if (charvalid) {
+ charvalid = FALSE;
+ notdefrangeP = CIDFontP->notdefrangeP;
+ for (i = 0; i < CIDFontP->notdefrangecnt; i++) {
+ for (j = 0; j < notdefrangeP->rangecnt; j++) {
+ rangelo_row =
+ (notdefrangeP->range[j].srcCodeLo >> 8) & 0xff;
+ rangelo_col = notdefrangeP->range[j].srcCodeLo & 0xff;
+ rangehi_row =
+ (notdefrangeP->range[j].srcCodeHi >> 8) & 0xff;
+ rangehi_col = notdefrangeP->range[j].srcCodeHi & 0xff;
+ if (char_row >= rangelo_row && char_row <= rangehi_row &&
+ char_col >= rangelo_col && char_col <= rangehi_col) {
+ charvalid = TRUE;
+ for (k = notdefrangeP->range[j].srcCodeLo;
+ k <= notdefrangeP->range[j].srcCodeHi; k++) {
+ if (k == charcode)
+ /* the whole range is mapped to a single CID code */
+ cidcode = notdefrangeP->range[j].dstCIDLo;
+ }
+ break;
+ }
+ }
+ if (charvalid) break;
+ notdefrangeP = notdefrangeP->next;
+ }
+ }
+
+ /* If you specify a CMap that has more CIDs than a specified CIDFont, */
+ /* the program could go beyond the number of entries in CIDMap. Make */
+ /* sure that that does not happen. */
+ if (cidcode < CIDFontP->CIDfontInfoP[CIDCOUNT].value.data.integer)
+ return cidcode;
+ else
+ return 0;
+}
+
+static CharInfoPtr
+CIDGetGlyph(FontPtr pFont, unsigned int charcode, CharInfoPtr pci)
+{
+ int rc;
+ CharInfoPtr cp = NULL;
+ unsigned int cidcode;
+
+ /* character code -> CID */
+ cidcode = getCID(pFont, charcode);
+
+ cp = CIDGetGlyphInfo(pFont, cidcode, pci, &rc);
+
+ if (rc != Successful && cidcode) {
+ cidcode = 0;
+ cp = CIDGetGlyphInfo(pFont, cidcode, pci, &rc);
+ }
+
+ return cp;
+}
+
+int
+CIDGetGlyphs(FontPtr pFont,
+ unsigned long count,
+ unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ CharInfoPtr *glyphs) /* RETURN */
+{
+ unsigned int firstRow, numRows, code, char_row, char_col;
+ CharInfoPtr *glyphsBase;
+ register unsigned int c;
+ CharInfoPtr pci;
+ CharInfoPtr pDefault;
+ cidglyphs *cid;
+ register int firstCol;
+ int rc = 0;
+ int cid_valid = 0;
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+ FontP = NULL;
+
+ firstCol = pFont->info.firstCol;
+ pDefault = cid->pDefault;
+ glyphsBase = glyphs;
+
+ switch (charEncoding) {
+
+#define EXIST(pci) \
+ ((pci)->metrics.attributes || \
+ (pci)->metrics.ascent != -(pci)->metrics.descent || \
+ (pci)->metrics.leftSideBearing != (pci)->metrics.rightSideBearing)
+
+ case Linear8Bit:
+ case TwoD8Bit:
+ if (pFont->info.firstRow > 0)
+ break;
+ while (count--) {
+ c = (*chars++);
+ if (c >= firstCol && c <= pFont->info.lastCol) {
+ code = c - firstCol;
+ if (!(pci = (CharInfoRec *)cid->glyphs[code]) ||
+ ((long)pci->bits == CID_BITMAP_UNDEFINED)) {
+ /* load font if not already loaded */
+ if(!cid_valid) {
+ if(!CIDfontfcnA(cid->CIDFontName, cid->CMapName, &rc)) { FontP = NULL;
+ return Type1ReturnCodeToXReturnCode(rc);
+ }
+ cid_valid = 1;
+ }
+ pci = CIDGetGlyph(pFont, c, pci);
+ }
+ if (pci && EXIST(pci)) {
+ *glyphs++ = pci;
+ cid->glyphs[code] = pci;
+ } else if (pDefault) {
+ *glyphs++ = pDefault;
+ cid->glyphs[code] = pDefault;
+ }
+ } else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+ case Linear16Bit:
+ while (count--) {
+ char_row = *chars++;
+ char_col = *chars++;
+ c = char_row << 8;
+ c = (c | char_col);
+ if (pFont->info.firstRow <= char_row && char_row <=
+ pFont->info.lastRow && pFont->info.firstCol <= char_col &&
+ char_col <= pFont->info.lastCol) {
+ code = pFont->info.lastCol - pFont->info.firstCol + 1;
+ char_row = char_row - pFont->info.firstRow;
+ char_col = char_col - pFont->info.firstCol;
+ code = char_row * code + char_col;
+ if (!(pci = (CharInfoRec *)cid->glyphs[code]) ||
+ ((long)pci->bits == CID_BITMAP_UNDEFINED)) {
+ /* load font if not already loaded */
+ if(!cid_valid) {
+ if(!CIDfontfcnA(cid->CIDFontName, cid->CMapName, &rc)) { FontP = NULL;
+ return Type1ReturnCodeToXReturnCode(rc);
+ }
+ cid_valid = 1;
+ }
+ pci = CIDGetGlyph(pFont, c, pci);
+ }
+ if (pci && EXIST(pci)) {
+ *glyphs++ = pci;
+ cid->glyphs[code] = pci;
+ } else if (pDefault) {
+ *glyphs++ = pDefault;
+ cid->glyphs[code] = pDefault;
+ }
+ } else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+
+ case TwoD16Bit:
+ firstRow = pFont->info.firstRow;
+ numRows = pFont->info.lastRow - firstRow + 1;
+ while (count--) {
+ char_row = (*chars++);
+ char_col = (*chars++);
+ c = char_row << 8;
+ c = (c | char_col);
+ if (pFont->info.firstRow <= char_row && char_row <=
+ pFont->info.lastRow && pFont->info.firstCol <= char_col &&
+ char_col <= pFont->info.lastCol) {
+ code = pFont->info.lastCol - pFont->info.firstCol + 1;
+ char_row = char_row - pFont->info.firstRow;
+ char_col = char_col - pFont->info.firstCol;
+ code = char_row * code + char_col;
+ if (!(pci = (CharInfoRec *)cid->glyphs[code]) ||
+ ((long)pci->bits == CID_BITMAP_UNDEFINED)) {
+ /* load font if not already loaded */
+ if(!cid_valid) {
+ if(!CIDfontfcnA(cid->CIDFontName, cid->CMapName, &rc)) { FontP = NULL;
+ return Type1ReturnCodeToXReturnCode(rc);
+ }
+ cid_valid = 1;
+ }
+ pci = CIDGetGlyph(pFont, c, pci);
+ }
+ if (pci && EXIST(pci)) {
+ *glyphs++ = pci;
+ cid->glyphs[code] = pci;
+ } else if (pDefault) {
+ *glyphs++ = pDefault;
+ cid->glyphs[code] = pDefault;
+ }
+ } else if (pDefault)
+ *glyphs++ = pDefault;
+ }
+ break;
+ }
+ *glyphCount = glyphs - glyphsBase;
+ return Successful;
+
+#undef EXIST
+}
+#endif
static int
-Type1GetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
- FontPtr pFont;
- unsigned long count;
- register unsigned char *chars;
- FontEncoding charEncoding;
- unsigned long *glyphCount; /* RETURN */
- CharInfoPtr *glyphs; /* RETURN */
+Type1GetGlyphs(FontPtr pFont,
+ unsigned long count,
+ unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ CharInfoPtr *glyphs) /* RETURN */
{
unsigned int firstRow;
unsigned int numRows;
@@ -447,7 +1121,7 @@ Type1GetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
while (count--) {
c = (*chars++);
if (c >= firstCol &&
- (pci = &type1Font->glyphs[c-FIRSTCOL]) &&
+ (pci = &type1Font->glyphs[c]) &&
EXIST(pci))
*glyphs++ = pci;
else if (pDefault)
@@ -459,7 +1133,7 @@ Type1GetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
c = *chars++ << 8;
c = (c | *chars++);
if (c < 256 && c >= firstCol &&
- (pci = &type1Font->glyphs[c-FIRSTCOL]) &&
+ (pci = &type1Font->glyphs[c]) &&
EXIST(pci))
*glyphs++ = pci;
else if (pDefault)
@@ -474,7 +1148,7 @@ Type1GetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
r = (*chars++) - firstRow;
c = (*chars++);
if (r < numRows && c < 256 && c >= firstCol &&
- (pci = &type1Font->glyphs[(r << 8) + c - FIRSTCOL]) &&
+ (pci = &type1Font->glyphs[(r << 8) + c]) &&
EXIST(pci))
*glyphs++ = pci;
else if (pDefault)
@@ -487,15 +1161,67 @@ Type1GetGlyphs(pFont, count, chars, charEncoding, glyphCount, glyphs)
#undef EXIST
}
-
+
+#ifdef BUILDCID
+static CharInfoRec nonExistantChar;
+
+int
+CIDGetMetrics(FontPtr pFont,
+ unsigned long count,
+ unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ xCharInfo **glyphs) /* RETURN */
+{
+ int ret;
+ cidglyphs *cid;
+ CharInfoPtr oldDefault;
+ char cidafmname[CID_PATH_MAX];
+ char CIDFontName[CID_NAME_MAX];
+ char *ptr;
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+ strcpy(cidafmname, cid->CIDFontName);
+ if (!(ptr = strrchr(cidafmname, '/')))
+ return BadFontName;
+
+ *ptr = '\0';
+
+ strcpy(CIDFontName, ptr + 1);
+
+ if (!(ptr = strrchr(cidafmname, '/')))
+ return BadFontName;
+
+ *ptr = '\0';
+
+ strcat(cidafmname, "/AFM/");
+ strcat(cidafmname, CIDFontName);
+
+ strcat(cidafmname, ".afm");
+
+ oldDefault = cid->pDefault;
+ cid->pDefault = &nonExistantChar;
+
+ ret = CIDGetAFM(pFont, count, chars, charEncoding, glyphCount, (CharInfoPtr
+*)glyphs, cidafmname);
+ if (ret != Successful)
+ ret = CIDGetGlyphs(pFont, count, chars, charEncoding, glyphCount,
+ (CharInfoPtr *)glyphs);
+
+ *ptr = 0;
+ cid->pDefault = oldDefault;
+ return ret;
+}
+#endif
+
static int
-Type1GetMetrics(pFont, count, chars, charEncoding, glyphCount, glyphs)
- FontPtr pFont;
- unsigned long count;
- register unsigned char *chars;
- FontEncoding charEncoding;
- unsigned long *glyphCount; /* RETURN */
- xCharInfo **glyphs; /* RETURN */
+Type1GetMetrics(FontPtr pFont,
+ unsigned long count,
+ unsigned char *chars,
+ FontEncoding charEncoding,
+ unsigned long *glyphCount, /* RETURN */
+ xCharInfo **glyphs) /* RETURN */
{
static CharInfoRec nonExistantChar;
@@ -510,15 +1236,75 @@ Type1GetMetrics(pFont, count, chars, charEncoding, glyphCount, glyphs)
type1Font->pDefault = oldDefault;
return ret;
}
-
-void Type1CloseFont(pFont)
- FontPtr pFont;
+
+#ifdef BUILDCID
+void
+CIDCloseFont(FontPtr pFont)
+{
+ register int i;
+ cidglyphs *cid;
+ int nchars;
+
+ if (pFont) {
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+ if (cid) {
+
+ if (cid->CIDFontName && !strcmp(cid->CIDFontName, CurCIDFontName)
+ && cid->CMapName && !strcmp(cid->CMapName, CurCMapName)){
+ strcpy(CurCIDFontName, ""); /* initialize to none */
+ strcpy(CurCMapName, ""); /* initialize to none */
+ }
+
+ if (cid->CIDFontName)
+ xfree(cid->CIDFontName);
+
+ if (cid->CMapName)
+ xfree(cid->CMapName);
+
+ nchars = (pFont->info.lastRow - pFont->info.firstRow + 1) *
+ (pFont->info.lastCol - pFont->info.firstCol + 1);
+
+ for (i = 0; i < nchars; i++) {
+ if (cid->glyphs[i] && (cid->glyphs[i] != &nonExistantChar)) {
+ if (cid->glyphs[i]->bits)
+ xfree(cid->glyphs[i]->bits);
+ xfree(cid->glyphs[i]);
+ }
+ }
+
+ if (cid->glyphs)
+ xfree(cid->glyphs);
+
+ if (cid->AFMinfo)
+ xfree(cid->AFMinfo);
+#ifdef USE_MMAP
+ if (cid->CIDdata)
+ munmap(cid->CIDdata, cid->CIDsize);
+#endif
+ xfree(cid);
+ }
+
+ if (pFont->info.props)
+ xfree(pFont->info.props);
+
+ if (pFont->info.isStringProp)
+ xfree(pFont->info.isStringProp);
+
+ DestroyFontRec(pFont);
+ }
+}
+#endif
+
+void
+Type1CloseFont(FontPtr pFont)
{
register int i;
struct type1font *type1;
type1 = (struct type1font *) pFont->fontPrivate;
- for (i=0; i < 256 - FIRSTCOL; i++)
+ for (i=0; i < 256; i++)
if (type1->glyphs[i].bits != NULL)
xfree(type1->glyphs[i].bits);
xfree(type1);
@@ -529,20 +1315,15 @@ void Type1CloseFont(pFont)
if (pFont->info.isStringProp)
xfree(pFont->info.isStringProp);
- if (pFont->devPrivates)
- xfree(pFont->devPrivates);
-
- xfree(pFont);
+ DestroyFontRec(pFont);
}
-
-
-
-static void fill(dest, h, w, area, byte, bit, wordsize)
- register char *dest; /* destination bitmap */
- int h,w; /* dimensions of 'dest', w padded */
- register struct region *area; /* region to write to 'dest' */
- int byte,bit; /* flags; LSBFirst or MSBFirst */
- int wordsize; /* number of bits per word for LSB/MSB purposes */
+
+static void
+fill(char *dest, /* destination bitmap */
+ int h, int w, /* dimensions of 'dest', w padded */
+ struct region *area, /* region to write to 'dest' */
+ int byte, int bit, /* flags; LSBFirst or MSBFirst */
+ int wordsize) /* number of bits per word for LSB/MSB purposes */
{
register struct edgelist *edge; /* for looping through edges */
register char *p; /* current scan line in 'dest' */
@@ -609,7 +1390,7 @@ it:
break;
}
default:
- abort("xiFill: unknown format");
+ Abort("xiFill: unknown format");
}
}
@@ -617,10 +1398,10 @@ it:
#define ALLONES 0xFF
-static void fillrun(p, x0, x1, bit)
- register char *p; /* address of this scan line */
- pel x0,x1; /* left and right X */
- int bit; /* format: LSBFirst or MSBFirst */
+static void
+fillrun(char *p, /* address of this scan line */
+ pel x0, pel x1, /* left and right X */
+ int bit) /* format: LSBFirst or MSBFirst */
{
register int startmask,endmask; /* bits to set in first and last char*/
register int middle; /* number of chars between start and end + 1 */
@@ -643,33 +1424,61 @@ static void fillrun(p, x0, x1, bit)
else {
*p++ |= startmask;
while (--middle > 0)
- *p++ = ALLONES;
+ *p++ = (char)ALLONES;
*p |= endmask;
}
}
#define CAPABILITIES (CAP_MATRIX | CAP_CHARSUBSETTING)
+
+#ifdef BUILDCID
+FontRendererRec CIDRendererInfo[] = {
+ { ".cid", 4, NULL, CIDOpenScalable,
+ NULL, CIDGetInfoScalable, 0, CAPABILITIES }
+};
+#endif
+#ifdef BUILDCID
+FontRendererRec Type1RendererInfo[] = {
+#else
static FontRendererRec renderers[] = {
- { ".pfa", 4, (int (*)()) 0, Type1OpenScalable,
- (int (*)()) 0, Type1GetInfoScalable, 0, CAPABILITIES },
- { ".pfb", 4, (int (*)()) 0, Type1OpenScalable,
- (int (*)()) 0, Type1GetInfoScalable, 0, CAPABILITIES }
+#endif
+ { ".pfa", 4, NULL, Type1OpenScalable,
+ NULL, Type1GetInfoScalable, 0, CAPABILITIES },
+ { ".pfb", 4, NULL, Type1OpenScalable,
+ NULL, Type1GetInfoScalable, 0, CAPABILITIES }
};
-
+#ifdef BUILDCID
+void
+CIDRegisterFontFileFunctions(void)
+{
+ int i;
+
+ Type1InitStdProps();
+ for (i=0; i < sizeof(CIDRendererInfo) / sizeof(FontRendererRec); i++)
+ FontFileRegisterRenderer(&CIDRendererInfo[i]);
+}
+#endif
+
void
-Type1RegisterFontFileFunctions()
+Type1RegisterFontFileFunctions(void)
{
int i;
+#ifdef BUILDCID
+ Type1InitStdProps();
+ for (i=0; i < sizeof(Type1RendererInfo) / sizeof(FontRendererRec); i++)
+ FontFilePriorityRegisterRenderer(&Type1RendererInfo[i], -10);
+#else
T1InitStdProps();
for (i=0; i < sizeof(renderers) / sizeof(FontRendererRec); i++)
- FontFileRegisterRenderer(&renderers[i]);
+ FontFilePriorityRegisterRenderer(&renderers[i], -10);
+#endif
}
-int Type1ReturnCodeToXReturnCode(rc)
- int rc;
+int
+Type1ReturnCodeToXReturnCode(int rc)
{
switch(rc) {
case SCAN_OK:
@@ -688,7 +1497,165 @@ int Type1ReturnCodeToXReturnCode(rc)
/* fall through */
default:
/* this should not happen */
+#ifdef BUILDCID
+ ErrorF("Font return code cannot be converted to X return code: %d\n", rc);
+#else
ErrorF("Type1 return code not convertable to X return code: %d\n", rc);
+#endif
return rc;
}
}
+
+#ifdef BUILDCID
+CharInfoPtr
+CIDRenderGlyph(FontPtr pFont, psobj *charstringP, psobj *subarrayP,
+ struct blues_struct *bluesP, CharInfoPtr pci, int *mode)
+{
+ int bit,
+ byte,
+ glyph,
+ scan,
+ image;
+ int pad,wordsize; /* scan & image in bits */
+ long *pool; /* memory pool for ximager objects */
+ int size; /* for memory size calculations */
+ struct XYspace *S; /* coordinate space for character */
+ struct region *area;
+ CharInfoRec *glyphs;
+ int len, rc;
+ long x0;
+ double x1, y1, t1 = .001, t2 = 0.0, t3 = 0.0, t4 = .001;
+ double sxmult;
+ long h,w;
+ long paddedW;
+ cidglyphs *cid;
+ fsBitmapFormat format = 0;
+ fsBitmapFormatMask fmask = 0;
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+ /* set up default values */
+ FontDefaultFormat(&bit, &byte, &glyph, &scan);
+ /* get any changes made from above */
+ rc = CheckFSFormat(format, fmask, &bit, &byte, &scan, &glyph, &image);
+ if (rc != Successful) {
+ *mode = rc;
+ return(NULL);
+ }
+
+ pad = glyph * 8;
+ wordsize = scan * 8;
+
+#define PAD(bits, pad) (((bits)+(pad)-1)&-(pad))
+
+ /* heuristic for "maximum" size of pool we'll need: */
+ size = 200000 + 600 *
+ (int)hypot(cid->pixel_matrix[2], cid->pixel_matrix[3])
+ * sizeof(short);
+ if (size < 0 || NULL == (pool = (long *) xalloc(size))) {
+ *mode = AllocError;
+ return(NULL);
+ }
+
+ addmemory(pool, size);
+
+ if (pci && (long)pci->bits == CID_BITMAP_UNDEFINED)
+ glyphs = pci;
+ else {
+ if (!(glyphs = (CharInfoRec *)xalloc(sizeof(CharInfoRec)))) {
+ delmemory();
+ xfree(pool);
+ *mode = AllocError;
+ return(NULL);
+ }
+ bzero(glyphs, sizeof(CharInfoRec));
+ }
+
+ S = (struct XYspace *) t1_Transform((struct xobject *)IDENTITY,
+ t1, t2, t3, t4);
+
+ S = (struct XYspace *) Permanent(t1_Transform((struct xobject *)S,
+ cid->pixel_matrix[0],
+ -cid->pixel_matrix[1],
+ cid->pixel_matrix[2],
+ -cid->pixel_matrix[3]));
+
+ /* multiplier for computation of raw values */
+ sxmult = hypot(cid->pixel_matrix[0], cid->pixel_matrix[1]);
+ if (sxmult > EPS) sxmult = 1000.0 / sxmult;
+
+ rc = 0;
+ area = (struct region *)CIDfontfcnC(S, charstringP, subarrayP, bluesP,
+ &len, &rc);
+ if (rc < 0 || area == NULL) {
+ delmemory();
+ xfree(pool);
+ if (pci != glyphs) xfree(glyphs);
+ *mode = Type1ReturnCodeToXReturnCode(rc);
+ return(NULL);
+ }
+
+ h = area->ymax - area->ymin;
+ w = area->xmax - area->xmin;
+ paddedW = PAD(w, pad);
+
+ if (h > 0 && w > 0) {
+ size = h * paddedW / 8;
+ glyphs[0].bits = (char *)xalloc(size);
+ if (glyphs[0].bits == NULL) {
+ Destroy(area);
+ delmemory();
+ xfree(pool);
+ if (pci != glyphs) xfree(glyphs);
+ *mode = AllocError;
+ return(NULL);
+ }
+ bzero(glyphs[0].bits, size);
+ }
+ else {
+ size = 0;
+ h = w = 0;
+ area->xmin = area->xmax = 0;
+ area->ymax = area->ymax = 0;
+ glyphs[0].bits = NULL;
+ }
+
+ glyphs[0].metrics.leftSideBearing = area->xmin;
+ x1 = (double)(x0 = area->ending.x - area->origin.x);
+ y1 = (double)(area->ending.y - area->origin.y);
+ glyphs[0].metrics.characterWidth =
+ (x0 + (x0 > 0 ? FPHALF : -FPHALF)) / (1 << FRACTBITS);
+ if (!glyphs[0].metrics.characterWidth && size == 0)
+ {
+ /* Zero size and zero extents: presumably caused by
+ the choice of transformation. Let's create a
+ small bitmap so we're not mistaken for an undefined
+ character. */
+ h = w = 1;
+ size = paddedW = PAD(w, pad);
+ glyphs[0].bits = (char *)xalloc(size);
+ if (glyphs[0].bits == NULL) {
+ Destroy(area);
+ delmemory();
+ xfree(pool);
+ if (pci != glyphs) xfree(glyphs);
+ *mode = AllocError;
+ return(NULL);
+ }
+ bzero(glyphs[0].bits, size);
+ }
+ glyphs[0].metrics.attributes =
+ NEARESTPEL((long)(hypot(x1, y1) * sxmult));
+ glyphs[0].metrics.rightSideBearing = w + area->xmin;
+ glyphs[0].metrics.descent = area->ymax - NEARESTPEL(area->origin.y);
+ glyphs[0].metrics.ascent = h - glyphs[0].metrics.descent;
+
+ if (h > 0 && w > 0)
+ fill(glyphs[0].bits, h, paddedW, area, byte, bit, wordsize);
+ Destroy(area);
+ delmemory();
+ xfree(pool);
+ *mode = Successful;
+ return(glyphs);
+}
+#endif
diff --git a/src/Type1/t1imager.h b/src/Type1/t1imager.h
index 472b36f..7d72495 100644
--- a/src/Type1/t1imager.h
+++ b/src/Type1/t1imager.h
@@ -27,41 +27,22 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/t1imager.h,v 1.5 2001/07/25 15:04:55 dawes Exp $ */
-#include "fontmisc.h"
-
-typedef pointer xobject;
-typedef pointer location;
-typedef pointer path;
-typedef pointer region;
-typedef pointer XYspace;
-
-#ifndef NOEXTERNS
-/*
-The following are the user entry locations to TYPE1IMAGER
-*/
-extern path t1_Bezier();
-extern path t1_ClosePath();
-extern xobject t1_Destroy();
-extern xobject t1_Dup();
-extern char *t1_ErrorMsg();
-extern void t1_InitImager();
-extern region t1_Interior();
-extern location t1_ILoc();
-extern xobject t1_Join();
-extern path t1_Line();
-extern xobject t1_Permanent();
-extern path t1_Phantom();
-extern location t1_Loc();
-extern xobject t1_Scale();
-extern xobject t1_Snap();
-extern location t1_SubLoc();
-extern xobject t1_Temporary();
-
-#endif
+
+#include "objects.h"
+#include "spaces.h"
+#include "paths.h"
+#include "regions.h"
+
+typedef struct xobject *xobject;
+typedef struct segment *path;
+typedef struct region *region;
+typedef struct XYspace *XYspace;
+
#ifndef NULL
-#define NULL 0
+#include <stddef.h>
#endif
#ifndef TRUE
@@ -71,57 +52,13 @@ extern xobject t1_Temporary();
#ifndef FALSE
#define FALSE 0
#endif
-
-/*
-Here are some TYPE1IMAGER functions that are defined in terms of others:
-*/
-
-#define t1_AddLoc(p1,p2) t1_Join(p1,p2)
-
-#ifndef NONAMES
-/*
-Define the simple form of all the subroutine names:
-*/
-#define AddLoc(p1,p2) t1_AddLoc(p1,p2)
-#define Bezier(B,C,D) t1_Bezier(B,C,D)
-#define ClosePath(p) t1_ClosePath(p,0)
-#define Complement(area) t1_Complement(area)
-#define Destroy(o) t1_Destroy(o)
-#define Dup(o) t1_Dup(o)
-#define ErrorMsg() t1_ErrorMsg()
-#define HeadSegment(p) t1_HeadSegment(p)
-#define InitImager() t1_InitImager()
-#define Interior(p,rule) t1_Interior(p,rule)
-#define ILoc(S,x,y) t1_ILoc(S,x,y)
-#define Join(p1,p2) t1_Join(p1,p2)
-#define Line(P) t1_Line(P)
-#define Permanent(o) t1_Permanent(o)
-#define Phantom(o) t1_Phantom(o)
-#define Loc(S,x,y) t1_Loc(S,(double)x,(double)y)
-#define Scale(o,sx,sy) t1_Scale(o,(double)sx,(double)sy)
-#define Snap(o) t1_Snap(o)
-#define SubLoc(a,b) t1_SubLoc(a,b)
-#define Temporary(o) t1_Temporary(o)
-#define TermImager() t1_TermImager()
-#define Transform(o,cxx,cyx,cxy,cyy) t1_Transform(o,(double)cxx,(double)cyx,\
- (double)cxy,(double)cyy)
-
-#endif
-
+
+
#define WINDINGRULE -2
#define EVENODDRULE -3
#define CONTINUITY 0x80 /* can be added to above rules; e.g. WINDINGRULE+CONTINUITY */
-/*
-Stroke() line style constants:
-*/
-
-/*
-Coordinate space constants:
-*/
-#define IDENTITY t1_Identity
-extern XYspace *IDENTITY;
/*
Generic null object definition:
@@ -145,4 +82,3 @@ extern region *INFINITY;
#define FF_PARSE_ERROR 5
#define FF_PATH 1
-extern pointer xiStub();
diff --git a/src/Type1/t1info.c b/src/Type1/t1info.c
index dff6257..0ee137f 100644
--- a/src/Type1/t1info.c
+++ b/src/Type1/t1info.c
@@ -82,13 +82,66 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/t1info.c,v 1.18 2002/09/10 16:14:33 tsi Exp $ */
-#include <stdio.h>
#include "fntfilst.h"
+#include "fontutil.h"
+#ifndef FONTMODULE
+#include <stdio.h>
+#ifndef BUILDCID
+#include <math.h>
+#endif
+#else
+#include "xf86_ansic.h"
+#endif
#include "FSproto.h"
-#include "t1intf.h"
+
+#ifdef BUILDCID
+#ifndef FONTMODULE
+#ifdef _XOPEN_SOURCE
#include <math.h>
-
+#else
+#define _XOPEN_SOURCE
+#include <math.h>
+#undef _XOPEN_SOURCE
+#endif
+#endif
+#include "objects.h"
+#include "spaces.h"
+#include "range.h"
+#endif
+
+#ifdef BUILDCID
+#include "util.h"
+#include "fontfcn.h"
+
+#if defined(HAVE_CFM) || defined(CID_ALL_CHARS)
+#ifndef DEFAULT_CFM_DIR
+#define DEFAULT_CFM_DIR "./"
+#endif
+char cfmDefaultDir[] = DEFAULT_CFM_DIR;
+#define CFMMAGIC 0x91239123
+#endif
+#endif
+#include "t1intf.h"
+
#define DECIPOINTSPERINCH 722.7
#define DEFAULTRES 75
#define DEFAULTPOINTSIZE 120
@@ -97,7 +150,22 @@ enum scaleType {
atom, truncate_atom, pixel_size, point_size, resolution_x,
resolution_y, average_width
};
-
+
+#ifdef BUILDCID
+extern cidfont *CIDFontP;
+static int stdpropsinit = 0;
+
+typedef struct cfm_rec {
+ xCharInfo maxbounds;
+ xCharInfo minbounds;
+ xCharInfo ink_maxbounds;
+ xCharInfo ink_minbounds;
+ INT32 totalrw;
+ INT16 maxo;
+ INT16 alle;
+} cfmrec;
+#endif
+
typedef struct _fontProp {
char *name;
long atom;
@@ -131,7 +199,9 @@ static fontProp extraProps[] = {
{ "RAW_ASCENT", 0, },
{ "RAW_DESCENT", 0, },
{ "RAW_AVERAGE_WIDTH", 0, },
- { "FACE_NAME", 0, }
+ { "FACE_NAME", 0, },
+ { "FONT_TYPE", 0, },
+ { "RASTERIZER_NAME", 0, }
};
/* this is a bit kludgy */
@@ -143,6 +213,8 @@ static fontProp extraProps[] = {
#define RAWDESCENTPROP 5
#define RAWWIDTHPROP 6
#define FACE_NAMEPROP 7
+#define FONT_TYPEPROP 8
+#define RASTERIZER_NAMEPROP 9
#define NNAMEPROPS (sizeof(fontNamePropTable) / sizeof(fontProp))
#define NEXTRAPROPS (sizeof(extraProps) / sizeof(fontProp))
@@ -151,9 +223,7 @@ static fontProp extraProps[] = {
/*ARGSUSED*/
static void
-FillHeader(pInfo, Vals)
- FontInfoPtr pInfo;
- FontScalablePtr Vals;
+FillHeader(FontInfoPtr pInfo, FontScalablePtr Vals)
{
/* OpenScalable in T1FUNCS sets the following:
pInfo->firstCol,
@@ -175,10 +245,7 @@ FillHeader(pInfo, Vals)
}
static void
-adjust_min_max(minc, maxc, tmp)
- xCharInfo *minc,
- *maxc,
- *tmp;
+adjust_min_max(xCharInfo *minc, xCharInfo *maxc, xCharInfo *tmp)
{
#define MINMAX(field,ci) \
if (minc->field > (ci)->field) \
@@ -203,10 +270,7 @@ adjust_min_max(minc, maxc, tmp)
}
static void
-ComputeBounds(pInfo, pChars, Vals)
- FontInfoPtr pInfo;
- CharInfoPtr pChars;
- FontScalablePtr Vals;
+ComputeBounds(FontInfoPtr pInfo, CharInfoPtr pChars, FontScalablePtr Vals)
{
int i;
xCharInfo minchar, maxchar;
@@ -224,7 +288,7 @@ ComputeBounds(pInfo, pChars, Vals)
maxlap = -32767;
totchars = pInfo->lastCol - pInfo->firstCol + 1;
- pChars += pInfo->firstCol - FIRSTCOL;
+ pChars += pInfo->firstCol;
pInfo->allExist = 1;
for (i = 0; i < totchars; i++,pChars++) {
xCharInfo *pmetrics = &pChars->metrics;
@@ -262,14 +326,252 @@ ComputeBounds(pInfo, pChars, Vals)
*/
FontComputeInfoAccelerators (pInfo);
}
-
+
+#ifdef BUILDCID
+#ifdef CID_ALL_CHARS
+void
+ComputeBoundsAllChars(FontPtr pFont, char *cfmfilename, double sxmult)
+{
+ FILE *cfm;
+ CARD32 magic;
+ int count = 0;
+ int maxlap, overlap, i, j, k, ret;
+ xCharInfo minchar, maxchar;
+ cidrange *cidrangeP;
+ unsigned char ccode[2];
+ unsigned long ccount;
+ xCharInfo *pmetrics;
+ long total_raw_width = 0, total_width = 0;
+ char cfmd[CID_PATH_MAX];
+ cfmrec *cfmp;
+ char *p;
+
+ if (!(cfm = fopen(cfmfilename, "w"))) {
+ fprintf(stderr,
+ "Unable to open the file %s. You are probably not logged in as root.\n",
+ cfmfilename);
+ p = strrchr(cfmfilename, '/');
+ if (p == NULL) exit(1);
+ strcpy(cfmd, cfmDefaultDir);
+ strcat(cfmd, p + 1);
+ if (!(cfm = fopen(cfmd, "w"))) {
+ fprintf(stderr,
+ "Switching to current directory. Unable to open the file %s.\n",
+ cfmd);
+ exit(1);
+ }
+ }
+
+ if ((cfmp = (cfmrec *)xalloc(sizeof(cfmrec))) == NULL) {
+ fprintf(stderr, "Unable to allocate memory.");
+ exit(1);
+ }
+ bzero(cfmp, sizeof(cfmrec));
+
+ minchar.ascent = minchar.descent =
+ minchar.leftSideBearing = minchar.rightSideBearing =
+ minchar.characterWidth = minchar.attributes = 32767;
+ maxchar.ascent = maxchar.descent =
+ maxchar.leftSideBearing = maxchar.rightSideBearing =
+ maxchar.characterWidth = maxchar.attributes = -32767;
+
+ maxlap = -32767;
+ cfmp->alle = 1;
+ cidrangeP = CIDFontP->cidrangeP;
+
+ /* go through all character codes specified in a given CMap */
+ for (i = 0; i < CIDFontP->cidrangecnt; i++) {
+ for (j = 0; j < cidrangeP->rangecnt; j++) {
+ for (k = cidrangeP->range[j].srcCodeLo;
+ k <= cidrangeP->range[j].srcCodeHi; k++) {
+ ccode[0] = (k >> 8) & 0xff;
+ ccode[1] = k & 0xff;
+ ret = CIDGetMetrics(pFont, 1, ccode, 2, &ccount, &pmetrics);
+ if (ret != Successful || (ret == Successful && pmetrics == NULL))
+ continue;
+ total_width += pmetrics->attributes;
+ total_raw_width += abs((int)(INT16)pmetrics->attributes);
+ if (pmetrics->attributes ||
+ pmetrics->ascent != -pmetrics->descent ||
+ pmetrics->leftSideBearing != pmetrics->rightSideBearing) {
+ count++;
+ adjust_min_max(&minchar, &maxchar, pmetrics);
+ overlap = pmetrics->rightSideBearing - pmetrics->characterWidth;
+ if (overlap > maxlap) maxlap = overlap;
+ }
+ else cfmp->alle = 0;
+ }
+ }
+ }
+
+ if (count)
+ {
+ total_raw_width = (total_raw_width * 10 + count / 2) / count;
+ if (total_width < 0)
+ {
+ /* Predominant direction is R->L */
+ total_raw_width = -total_raw_width;
+ }
+ }
+
+ cfmp->totalrw = (INT32)total_raw_width;
+
+ cfmp->maxbounds.leftSideBearing =
+ floor((double)maxchar.leftSideBearing * sxmult + 0.5);
+ cfmp->maxbounds.rightSideBearing =
+ floor((double)maxchar.rightSideBearing * sxmult + 0.5);
+ cfmp->maxbounds.characterWidth =
+ floor((double)maxchar.characterWidth * sxmult + 0.5);
+ cfmp->maxbounds.ascent =
+ floor((double)maxchar.ascent * sxmult + 0.5);
+ cfmp->maxbounds.descent =
+ floor((double)maxchar.descent * sxmult);
+ cfmp->maxbounds.attributes = maxchar.attributes;
+
+ cfmp->minbounds.leftSideBearing =
+ floor((double)minchar.leftSideBearing * sxmult + 0.5);
+ cfmp->minbounds.rightSideBearing =
+ floor((double)minchar.rightSideBearing * sxmult + 0.5);
+ cfmp->minbounds.characterWidth =
+ floor((double)minchar.characterWidth * sxmult + 0.5);
+ cfmp->minbounds.ascent =
+ floor((double)minchar.ascent * sxmult + 0.5);
+ cfmp->minbounds.descent =
+ floor((double)minchar.descent * sxmult + 0.5);
+ cfmp->minbounds.attributes = minchar.attributes;
+
+ cfmp->ink_maxbounds.leftSideBearing =
+ floor((double)maxchar.leftSideBearing * sxmult + 0.5);
+ cfmp->ink_maxbounds.rightSideBearing =
+ floor((double)maxchar.rightSideBearing * sxmult + 0.5);
+ cfmp->ink_maxbounds.characterWidth =
+ floor((double)maxchar.characterWidth * sxmult + 0.5);
+ cfmp->ink_maxbounds.ascent =
+ floor((double)maxchar.ascent * sxmult + 0.5);
+ cfmp->ink_maxbounds.descent =
+ floor((double)maxchar.descent * sxmult + 0.5);
+ cfmp->ink_maxbounds.attributes = maxchar.attributes;
+
+ cfmp->ink_minbounds.leftSideBearing =
+ floor((double)minchar.leftSideBearing * sxmult + 0.5);
+ cfmp->ink_minbounds.rightSideBearing =
+ floor((double)minchar.rightSideBearing * sxmult + 0.5);
+ cfmp->ink_minbounds.characterWidth =
+ floor((double)minchar.characterWidth * sxmult + 0.5);
+ cfmp->ink_minbounds.ascent =
+ floor((double)minchar.ascent * sxmult + 0.5);
+ cfmp->ink_minbounds.descent =
+ floor((double)minchar.descent * sxmult + 0.5);
+ cfmp->ink_minbounds.attributes = minchar.attributes;
+
+ cfmp->maxo = (INT32)(maxlap + -(minchar.leftSideBearing));
+
+ magic = CFMMAGIC;
+ fwrite(&magic, sizeof(CARD32), 1, cfm);
+ fwrite(cfmp, sizeof(cfmrec), 1, cfm);
+ xfree(cfmp);
+ fclose(cfm);
+}
+#else
+static long
+ComputeBoundsAll(FontPtr pFont)
+{
+ int count = 0;
+ int maxlap, overlap, i, j, k, ret;
+ xCharInfo minchar, maxchar;
+ cidrange *cidrangeP;
+ unsigned char ccode[2];
+ unsigned long ccount;
+ xCharInfo *pmetrics;
+ CharInfoRec *cinfo[1];
+ long total_raw_width = 0, total_width = 0;
+ FontInfoPtr pInfo = &(pFont->info);
+
+ minchar.ascent = minchar.descent =
+ minchar.leftSideBearing = minchar.rightSideBearing =
+ minchar.characterWidth = minchar.attributes = 32767;
+ maxchar.ascent = maxchar.descent =
+ maxchar.leftSideBearing = maxchar.rightSideBearing =
+ maxchar.characterWidth = maxchar.attributes = -32767;
+
+ maxlap = -32767;
+ pInfo->allExist = 1;
+ cidrangeP = CIDFontP->cidrangeP;
+
+ /* go through all character codes specified in a given CMap */
+ for (i = 0; i < CIDFontP->cidrangecnt; i++) {
+ for (j = 0; j < cidrangeP->rangecnt; j++) {
+ for (k = cidrangeP->range[j].srcCodeLo;
+ k <= cidrangeP->range[j].srcCodeHi; k++) {
+ ccode[0] = (k >> 8) & 0xff;
+ ccode[1] = k & 0xff;
+ ret = CIDGetMetrics(pFont, 1, ccode, 2, &ccount, (xCharInfo **)cinfo);
+ if (ret != Successful || cinfo == NULL)
+ continue;
+ pmetrics = &cinfo[0]->metrics;
+ total_width += pmetrics->attributes;
+ total_raw_width += abs((int)(INT16)pmetrics->attributes);
+ if (pmetrics->attributes ||
+ pmetrics->ascent != -pmetrics->descent ||
+ pmetrics->leftSideBearing != pmetrics->rightSideBearing) {
+ count++;
+ adjust_min_max(&minchar, &maxchar, pmetrics);
+ overlap = pmetrics->rightSideBearing - pmetrics->characterWidth;
+ if (overlap > maxlap) maxlap = overlap;
+ }
+ else pInfo->allExist = 0;
+ }
+ }
+ }
+
+ if (count)
+ {
+ total_raw_width = (total_raw_width * 10 + count / 2) / count;
+ if (total_width < 0)
+ {
+ /* Predominant direction is R->L */
+ total_raw_width = -total_raw_width;
+ }
+ }
+
+ pInfo->maxbounds.leftSideBearing = maxchar.leftSideBearing;
+ pInfo->maxbounds.rightSideBearing = maxchar.rightSideBearing;
+ pInfo->maxbounds.characterWidth = maxchar.characterWidth;
+ pInfo->maxbounds.ascent = maxchar.ascent;
+ pInfo->maxbounds.descent = maxchar.descent;
+ pInfo->maxbounds.attributes = maxchar.attributes;
+
+ pInfo->minbounds.leftSideBearing = minchar.leftSideBearing;
+ pInfo->minbounds.rightSideBearing = minchar.rightSideBearing;
+ pInfo->minbounds.characterWidth = minchar.characterWidth;
+ pInfo->minbounds.ascent = minchar.ascent;
+ pInfo->minbounds.descent = minchar.descent;
+ pInfo->minbounds.attributes = minchar.attributes;
+
+ pInfo->ink_maxbounds.leftSideBearing = maxchar.leftSideBearing;
+ pInfo->ink_maxbounds.rightSideBearing = maxchar.rightSideBearing;
+ pInfo->ink_maxbounds.characterWidth = maxchar.characterWidth;
+ pInfo->ink_maxbounds.ascent = maxchar.ascent;
+ pInfo->ink_maxbounds.descent = maxchar.descent;
+ pInfo->ink_maxbounds.attributes = maxchar.attributes;
+
+ pInfo->ink_minbounds.leftSideBearing = minchar.leftSideBearing;
+ pInfo->ink_minbounds.rightSideBearing = minchar.rightSideBearing;
+ pInfo->ink_minbounds.characterWidth = minchar.characterWidth;
+ pInfo->ink_minbounds.ascent = minchar.ascent;
+ pInfo->ink_minbounds.descent = minchar.descent;
+ pInfo->ink_minbounds.attributes = minchar.attributes;
+
+ pInfo->maxOverlap = maxlap + -(minchar.leftSideBearing);
+
+ return total_raw_width;
+}
+#endif
+#endif
+
static void
-ComputeProps(pInfo, Vals, Filename, sAscent, sDescent)
- FontInfoPtr pInfo;
- FontScalablePtr Vals;
- char *Filename;
- long *sAscent;
- long *sDescent;
+ComputeProps(FontInfoPtr pInfo, FontScalablePtr Vals, char *Filename,
+ long *sAscent, long *sDescent)
{
int infoint;
int infoBBox[4];
@@ -291,27 +593,163 @@ ComputeProps(pInfo, Vals, Filename, sAscent, sDescent)
*sDescent = -infoBBox[1];
}
}
+
+#ifdef BUILDCID
+#ifndef CID_ALL_CHARS
+static void
+CIDComputeStdProps(FontInfoPtr pInfo, FontScalablePtr Vals,
+ char *Filename, char *Cmapname, char *Fontname,
+ long sAscent, long sDescent, long sWidth)
+{
+ FontPropPtr pp;
+ int i,
+ nprops;
+ fontProp *fpt;
+ char *is_str;
+ char *ptr1 = NULL,
+ *ptr2;
+ char *ptr3;
+ char *infostrP;
+ int rc;
+ char scaledName[CID_PATH_MAX];
+
+ strcpy (scaledName, Fontname);
+ /* Fill in our copy of the fontname from the Vals structure */
+ FontParseXLFDName (scaledName, Vals, FONT_XLFD_REPLACE_VALUE);
+
+ /* This form of the properties is used by the X-client; the X-server
+ doesn't care what they are. */
+ nprops = pInfo->nprops = NPROPS;
+ pInfo->isStringProp = (char *) xalloc(sizeof(char) * nprops);
+ pInfo->props = (FontPropPtr) xalloc(sizeof(FontPropRec) * nprops);
+ if (!pInfo->isStringProp || !pInfo->props) {
+ xfree(pInfo->isStringProp);
+ pInfo->isStringProp = (char *) 0;
+ xfree(pInfo->props);
+ pInfo->props = (FontPropPtr) 0;
+ pInfo->nprops = 0;
+ return;
+ }
+ bzero(pInfo->isStringProp, (sizeof(char) * nprops));
+
+ ptr2 = scaledName;
+ for (i = NNAMEPROPS, pp = pInfo->props, fpt = fontNamePropTable, is_str = pInfo->isStringProp;
+ i;
+ i--, pp++, fpt++, is_str++) {
+
+ if (*ptr2)
+ {
+ ptr1 = ptr2 + 1;
+ if (!(ptr2 = strchr(ptr1, '-'))) ptr2 = strchr(ptr1, '\0');
+ }
+
+ pp->name = fpt->atom;
+ switch (fpt->type) {
+ case atom: /* Just copy info from scaledName */
+ *is_str = TRUE;
+ pp->value = MakeAtom(ptr1, ptr2 - ptr1, TRUE);
+ break;
+ case truncate_atom:
+ *is_str = TRUE;
+ for (ptr3 = ptr1; *ptr3; ptr3++)
+ if (*ptr3 == '[')
+ break;
+ pp->value = MakeAtom(ptr1, ptr3 - ptr1, TRUE);
+ break;
+ case pixel_size:
+ pp->value = (int)(fabs(Vals->pixel_matrix[3]) + .5);
+ break;
+ case point_size:
+ pp->value = (int)(fabs(Vals->point_matrix[3]) * 10.0 + .5);
+ break;
+ case resolution_x:
+ pp->value = Vals->x;
+ break;
+ case resolution_y:
+ pp->value = Vals->y;
+ break;
+ case average_width:
+ pp->value = Vals->width;
+ break;
+ }
+ }
+
+ for (i = 0, fpt = extraProps;
+ i < NEXTRAPROPS;
+ i++, is_str++, pp++, fpt++) {
+ pp->name = fpt->atom;
+ switch (i) {
+ case FONTPROP:
+ *is_str = TRUE;
+ pp->value = MakeAtom(scaledName, strlen(scaledName), TRUE);
+ break;
+ case COPYRIGHTPROP:
+ *is_str = TRUE;
+ CIDQueryFontLib(Filename, Cmapname, "Notice", &infostrP, &rc);
+ if (rc || !infostrP) {
+ infostrP = "Copyright Notice not available";
+ }
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case FACE_NAMEPROP:
+ *is_str = TRUE;
+ CIDQueryFontLib(Filename, Cmapname, "CIDFontName", &infostrP, &rc);
+ if (rc || !infostrP) {
+ infostrP = "(unknown)";
+ }
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case FONT_TYPEPROP:
+ *is_str = TRUE;
+ infostrP = "CIDFont";
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case RASTERIZER_NAMEPROP:
+ *is_str = TRUE;
+ infostrP = "X Consortium Type 1 Rasterizer";
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case RAWPIXELPROP:
+ *is_str = FALSE;
+ pp->value = 1000;
+ break;
+ case RAWPOINTPROP:
+ *is_str = FALSE;
+ pp->value = (long)(72270.0 / (double)Vals->y + .5);
+ break;
+ case RAWASCENTPROP:
+ *is_str = FALSE;
+ pp->value = sAscent;
+ break;
+ case RAWDESCENTPROP:
+ *is_str = FALSE;
+ pp->value = sDescent;
+ break;
+ case RAWWIDTHPROP:
+ *is_str = FALSE;
+ pp->value = sWidth;
+ break;
+ }
+ }
+}
+#endif
+#endif
static void
-ComputeStdProps(pInfo, Vals, Filename, Fontname, sAscent, sDescent, sWidth)
- FontInfoPtr pInfo;
- FontScalablePtr Vals;
- char *Filename;
- char *Fontname;
- long sAscent;
- long sDescent;
- long sWidth;
+ComputeStdProps(FontInfoPtr pInfo, FontScalablePtr Vals,
+ char *Filename, char *Fontname,
+ long sAscent, long sDescent, long sWidth)
{
FontPropPtr pp;
int i,
nprops;
fontProp *fpt;
char *is_str;
- char *ptr1,
+ char *ptr1 = NULL,
*ptr2;
char *ptr3;
char *infostrP;
- long rc;
+ int rc;
char scaledName[MAXFONTNAMELEN];
strcpy (scaledName, Fontname);
@@ -399,6 +837,16 @@ ComputeStdProps(pInfo, Vals, Filename, Fontname, sAscent, sDescent, sWidth)
}
pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
break;
+ case FONT_TYPEPROP:
+ *is_str = TRUE;
+ infostrP = "Type 1";
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
+ case RASTERIZER_NAMEPROP:
+ *is_str = TRUE;
+ infostrP = "X Consortium Type 1 Rasterizer";
+ pp->value = MakeAtom(infostrP, strlen(infostrP), TRUE);
+ break;
case RAWPIXELPROP:
*is_str = FALSE;
pp->value = 1000;
@@ -422,16 +870,46 @@ ComputeStdProps(pInfo, Vals, Filename, Fontname, sAscent, sDescent, sWidth)
}
}
}
-
+
+#ifdef BUILDCID
/*ARGSUSED*/
int
-Type1GetInfoScalable(fpe, pInfo, entry, fontName, fileName, Vals)
- FontPathElementPtr fpe;
- FontInfoPtr pInfo;
- FontEntryPtr entry;
- FontNamePtr fontName;
- char *fileName;
- FontScalablePtr Vals;
+CIDGetInfoScalable(FontPathElementPtr fpe,
+ FontInfoPtr pInfo,
+ FontEntryPtr entry,
+ FontNamePtr fontName,
+ char *fileName,
+ FontScalablePtr Vals)
+{
+ FontPtr pfont;
+ int flags = 0;
+ long format = 0; /* It doesn't matter what format for just info */
+ long fmask = 0;
+ int ret;
+
+ ret = CIDOpenScalable(fpe, &pfont, flags, entry, fileName, Vals,
+ format, fmask, NULL);
+ if (ret != Successful)
+ return ret;
+ *pInfo = pfont->info;
+
+ /* XXX - Set pointers in pfont->info to NULL so they are not freed. */
+ pfont->info.props = NULL;
+ pfont->info.isStringProp = NULL;
+
+ CIDCloseFont(pfont);
+ return Successful;
+}
+#endif
+
+/*ARGSUSED*/
+int
+Type1GetInfoScalable(FontPathElementPtr fpe,
+ FontInfoPtr pInfo,
+ FontEntryPtr entry,
+ FontNamePtr fontName,
+ char *fileName,
+ FontScalablePtr Vals)
{
FontPtr pfont;
int flags = 0;
@@ -439,7 +917,8 @@ Type1GetInfoScalable(fpe, pInfo, entry, fontName, fileName, Vals)
long fmask = 0;
int ret;
- ret = Type1OpenScalable(fpe, &pfont, flags, entry, fileName, Vals, format, fmask);
+ ret = Type1OpenScalable(fpe, &pfont, flags, entry, fileName, Vals,
+ format, fmask , NULL);
if (ret != Successful)
return ret;
*pInfo = pfont->info;
@@ -451,14 +930,120 @@ Type1GetInfoScalable(fpe, pInfo, entry, fontName, fileName, Vals)
Type1CloseFont(pfont);
return Successful;
}
-
+
+#ifdef BUILDCID
+#ifndef CID_ALL_CHARS
+void
+CIDFillFontInfo(FontPtr pFont, FontScalablePtr Vals,
+ char *Filename, char *Fontname, char *Cmapname,
+#ifdef HAVE_CFM
+ char *cfmfilename,
+#endif
+ long sAscent, long sDescent, double sxmult)
+{
+#ifdef HAVE_CFM
+ FILE *cfm;
+ cfmrec *cfmp;
+ int gotcfm = 0;
+ CARD32 magic;
+#endif
+ long sWidth = 0;
+ FontInfoPtr pInfo = &pFont->info;
+
+ FillHeader(pInfo, Vals);
+
+#ifdef HAVE_CFM
+ if ((cfm = fopen(cfmfilename,"r"))) {
+ fread(&magic,sizeof(CARD32),1,cfm);
+ if(magic == CFMMAGIC) {
+ if ((cfmp = (cfmrec *)xalloc(sizeof(cfmrec))) != NULL) {
+ fread(cfmp,sizeof(cfmrec),1,cfm);
+ sWidth = (long)cfmp->totalrw;
+ pInfo->allExist = cfmp->alle;
+ if (sxmult != 0) {
+ pInfo->maxbounds.leftSideBearing =
+ floor((double)cfmp->maxbounds.leftSideBearing /
+ sxmult + 0.5);
+ pInfo->maxbounds.rightSideBearing =
+ floor((double)cfmp->maxbounds.rightSideBearing /
+ sxmult + 0.5);
+ pInfo->maxbounds.characterWidth =
+ floor((double)cfmp->maxbounds.characterWidth /
+ sxmult + 0.5);
+ pInfo->maxbounds.ascent =
+ floor((double)cfmp->maxbounds.ascent /
+ sxmult + 0.5);
+ pInfo->maxbounds.descent =
+ floor((double)cfmp->maxbounds.descent /
+ sxmult + 0.5);
+ pInfo->maxbounds.attributes =
+ cfmp->maxbounds.attributes;
+
+ pInfo->minbounds.leftSideBearing =
+ cfmp->minbounds.leftSideBearing / sxmult;
+ pInfo->minbounds.rightSideBearing =
+ cfmp->minbounds.rightSideBearing / sxmult;
+ pInfo->minbounds.characterWidth =
+ cfmp->minbounds.characterWidth / sxmult;
+ pInfo->minbounds.ascent =
+ cfmp->minbounds.ascent / sxmult;
+ pInfo->minbounds.descent =
+ cfmp->minbounds.descent / sxmult;
+ pInfo->minbounds.attributes = cfmp->minbounds.attributes;
+
+ pInfo->ink_maxbounds.leftSideBearing =
+ cfmp->ink_maxbounds.leftSideBearing / sxmult;
+ pInfo->ink_maxbounds.rightSideBearing =
+ cfmp->ink_maxbounds.rightSideBearing / sxmult;
+ pInfo->ink_maxbounds.characterWidth =
+ cfmp->ink_maxbounds.characterWidth / sxmult;
+ pInfo->ink_maxbounds.ascent =
+ cfmp->ink_maxbounds.ascent / sxmult;
+ pInfo->ink_maxbounds.descent =
+ cfmp->ink_maxbounds.descent / sxmult;
+ pInfo->ink_maxbounds.attributes =
+ cfmp->ink_maxbounds.attributes;
+
+ pInfo->ink_minbounds.leftSideBearing =
+ cfmp->ink_minbounds.leftSideBearing / sxmult;
+ pInfo->ink_minbounds.rightSideBearing =
+ cfmp->ink_minbounds.rightSideBearing / sxmult;
+ pInfo->ink_minbounds.characterWidth =
+ cfmp->ink_minbounds.characterWidth / sxmult;
+ pInfo->ink_minbounds.ascent =
+ cfmp->ink_minbounds.ascent / sxmult;
+ pInfo->ink_minbounds.descent =
+ cfmp->ink_minbounds.descent / sxmult;
+ pInfo->ink_minbounds.attributes =
+ cfmp->ink_minbounds.attributes;
+ pInfo->ink_minbounds.attributes =
+ cfmp->ink_minbounds.attributes;
+
+ pInfo->maxOverlap = (short)cfmp->maxo;
+
+ gotcfm = 1;
+ }
+ xfree(cfmp);
+ }
+ }
+ fclose(cfm);
+ }
+
+ if (!gotcfm)
+#endif
+ sWidth = ComputeBoundsAll(pFont);
+
+ FontComputeInfoAccelerators(pInfo);
+
+ CIDComputeStdProps(pInfo, Vals, Filename, Cmapname, Fontname, sAscent,
+ sDescent, sWidth);
+}
+#endif /* CID_ALL_CHARS */
+#endif /* BUILDCID */
+
void
-T1FillFontInfo(pFont, Vals, Filename, Fontname, sWidth)
- FontPtr pFont;
- FontScalablePtr Vals;
- char *Filename;
- char *Fontname;
- long sWidth;
+T1FillFontInfo(FontPtr pFont, FontScalablePtr Vals,
+ char *Filename, char *Fontname, long sWidth)
{
FontInfoPtr pInfo = &pFont->info;
struct type1font *p = (struct type1font *)pFont->fontPrivate;
@@ -474,15 +1059,31 @@ T1FillFontInfo(pFont, Vals, Filename, Fontname, sWidth)
/* Called once, at renderer registration time */
void
-T1InitStdProps()
+#ifdef BUILDCID
+Type1InitStdProps(void)
+#else
+T1InitStdProps(void)
+#endif
{
int i;
fontProp *t;
+#ifdef BUILDCID
+ if (!stdpropsinit) {
+ stdpropsinit = 1;
+ i = sizeof(fontNamePropTable) / sizeof(fontProp);
+ for (t = fontNamePropTable; i; i--, t++)
+ t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
+ i = sizeof(extraProps) / sizeof(fontProp);
+ for (t = extraProps; i; i--, t++)
+ t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
+ }
+#else
i = sizeof(fontNamePropTable) / sizeof(fontProp);
for (t = fontNamePropTable; i; i--, t++)
t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
i = sizeof(extraProps) / sizeof(fontProp);
for (t = extraProps; i; i--, t++)
t->atom = MakeAtom(t->name, (unsigned) strlen(t->name), TRUE);
+#endif
}
diff --git a/src/Type1/t1intf.h b/src/Type1/t1intf.h
index 52cedb7..c1e0e44 100644
--- a/src/Type1/t1intf.h
+++ b/src/Type1/t1intf.h
@@ -27,10 +27,113 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
-
-#define FIRSTCOL 32
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/t1intf.h,v 1.7 2001/07/25 15:04:55 dawes Exp $ */
+
+#ifdef BUILDCID
+#include "AFM.h"
+#endif
struct type1font {
CharInfoPtr pDefault;
- CharInfoRec glyphs[256-FIRSTCOL];
+ CharInfoRec glyphs[256];
};
+
+#ifdef BUILDCID
+typedef struct cid_glyphs {
+ char *CIDFontName;
+ char *CMapName;
+ long dataoffset;
+ double pixel_matrix[4];
+ CharInfoPtr pDefault;
+ CharInfoRec **glyphs;
+ FontInfo *AFMinfo;
+#ifdef USE_MMAP
+ unsigned char *CIDdata;
+ long CIDsize;
+#endif
+} cidglyphs;
+#endif
+
+/*
+ * Function prototypes
+ */
+/* t1funcs.c */
+#ifdef BUILDCID
+extern int CIDOpenScalable ( FontPathElementPtr fpe, FontPtr *ppFont,
+ int flags, FontEntryPtr entry, char *fileName,
+ FontScalablePtr vals, fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font );
+#endif
+extern int Type1OpenScalable ( FontPathElementPtr fpe, FontPtr *ppFont,
+ int flags, FontEntryPtr entry, char *fileName,
+ FontScalablePtr vals, fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font );
+#ifdef BUILDCID
+extern unsigned int getCID ( FontPtr pFont, unsigned int charcode );
+extern int CIDGetGlyphs ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, CharInfoPtr *glyphs );
+extern int CIDGetMetrics ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, xCharInfo **glyphs );
+extern void CIDCloseFont ( FontPtr pFont );
+#endif
+extern void Type1CloseFont ( FontPtr pFont );
+extern int Type1ReturnCodeToXReturnCode ( int rc );
+#ifdef BUILDCID
+extern CharInfoPtr CIDRenderGlyph ( FontPtr pFont, psobj *charstringP,
+ psobj *subarrayP,
+ struct blues_struct *bluesP,
+ CharInfoPtr pci, int *mode );
+#endif
+
+/* t1info.c */
+#ifdef CID_ALL_CHARS
+extern void ComputeBoundsAllChars ( FontPtr pFont, char *cfmfilename, double sxmult );
+#endif
+#ifdef BUILDCID
+extern int CIDGetInfoScalable ( FontPathElementPtr fpe, FontInfoPtr pInfo,
+ FontEntryPtr entry, FontNamePtr fontName,
+ char *fileName, FontScalablePtr Vals );
+#endif
+extern int Type1GetInfoScalable ( FontPathElementPtr fpe, FontInfoPtr pInfo,
+ FontEntryPtr entry, FontNamePtr fontName,
+ char *fileName, FontScalablePtr Vals );
+#ifdef BUILDCID
+extern void CIDFillFontInfo ( FontPtr pFont, FontScalablePtr Vals,
+ char *Filename, char *Fontname, char *Cmapname,
+#ifdef HAVE_CFM
+ char *cfmfilename,
+#endif
+ long sAscent, long sDescent, double sxmult );
+#endif
+extern void T1FillFontInfo ( FontPtr pFont, FontScalablePtr Vals,
+ char *Filename, char *Fontname, long sWidth );
+extern void Type1InitStdProps ( void );
+
+/* cidchar.c */
+extern CharInfoPtr CIDGetGlyphInfo ( FontPtr pFont, unsigned int cidcode,
+ CharInfoPtr pci, int *rc );
+extern int CIDGetAFM ( FontPtr pFont, unsigned long count,
+ unsigned char *chars, FontEncoding charEncoding,
+ unsigned long *glyphCount, CharInfoPtr *glyphs,
+ char *cidafmfile );
diff --git a/src/Type1/t1io.c b/src/Type1/t1io.c
index cd5b77a..d5ce774 100644
--- a/src/Type1/t1io.c
+++ b/src/Type1/t1io.c
@@ -28,21 +28,47 @@
* SOFTWARE.
* Author: Carol H. Thompson IBM Almaden Research Center
*/
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/t1io.c,v 3.9 2001/08/27 19:49:54 dawes Exp $ */
/*******************************************************************
* I/O package for Type 1 font reading
********************************************************************/
-
+
#ifndef STATIC
#define STATIC static
#endif
+#ifndef FONTMODULE
#include <fcntl.h>
+#include <unistd.h>
+#else
+#include "Xdefs.h" /* Bool declaration */
+#include "Xmd.h" /* INT32 declaration */
+#include "xf86_ansic.h"
+#endif
#include "t1stdio.h"
#include "t1hdigit.h"
#ifdef WIN32
#include <X11/Xw32defs.h>
#endif
-
+#include "Xdefs.h"
+
/* Constants and variables used in the decryption */
#define c1 ((unsigned short)52845)
#define c2 ((unsigned short)22719)
@@ -56,16 +82,22 @@ STATIC F_FILE TheFile;
STATIC unsigned char TheBuffer[F_BUFSIZ];
/* Our routines */
-F_FILE *T1Open(), *T1Eexec();
-int T1Close();
-int T1Read(), T1Getc(), T1Ungetc();
-STATIC int T1Decrypt(), T1Fill();
+static int T1Decrypt ( unsigned char *p, int len );
+static int T1Fill ( F_FILE *f );
+
+#ifdef BUILDCID
+void
+resetDecrypt(void)
+{
+ Decrypt = 0;
+}
+#endif
/* -------------------------------------------------------------- */
/*ARGSUSED*/
-F_FILE *T1Open(fn, mode)
- char *fn; /* Pointer to filename */
- char *mode; /* Pointer to open mode string */
+F_FILE *
+T1Open(char *fn, /* Pointer to filename */
+ char *mode) /* Pointer to open mode string */
{
F_FILE *of = &TheFile;
int oflags = O_RDONLY; /* We know we are only reading */
@@ -75,7 +107,7 @@ F_FILE *T1Open(fn, mode)
#ifdef O_BINARY /* VMS or DOS */
oflags |= O_BINARY;
#endif
- of->fd = open(fn, oflags);
+ of->fd = open(fn, oflags, 0);
if (of->fd < 0)
return NULL;
@@ -91,8 +123,8 @@ F_FILE *T1Open(fn, mode)
} /* end Open */
/* -------------------------------------------------------------- */
-int T1Getc(f) /* Read one character */
- F_FILE *f; /* Stream descriptor */
+int /* Read one character */
+T1Getc(F_FILE *f) /* Stream descriptor */
{
if (f->b_base == NULL) return EOF; /* already closed */
@@ -111,9 +143,9 @@ int T1Getc(f) /* Read one character */
} /* end Getc */
/* -------------------------------------------------------------- */
-int T1Ungetc(c, f) /* Put back one character */
- int c;
- F_FILE *f; /* Stream descriptor */
+int /* Put back one character */
+T1Ungetc(int c,
+ F_FILE *f) /* Stream descriptor */
{
if (c != EOF) {
f->ungotc = c;
@@ -124,11 +156,11 @@ int T1Ungetc(c, f) /* Put back one character */
} /* end Ungetc */
/* -------------------------------------------------------------- */
-int T1Read(buffP, size, n, f) /* Read n items into caller's buffer */
- char *buffP; /* Buffer to be filled */
- int size; /* Size of each item */
- int n; /* Number of items to read */
- F_FILE *f; /* Stream descriptor */
+int /* Read n items into caller's buffer */
+T1Read(char *buffP, /* Buffer to be filled */
+ int size, /* Size of each item */
+ int n, /* Number of items to read */
+ F_FILE *f) /* Stream descriptor */
{
int bytelen, cnt, i;
F_char *p = (F_char *)buffP;
@@ -162,23 +194,66 @@ int T1Read(buffP, size, n, f) /* Read n items into caller's buffer */
} /* end Read */
/* -------------------------------------------------------------- */
-int T1Close(f) /* Close the file */
- F_FILE *f; /* Stream descriptor */
+int /* Close the file */
+T1Close(F_FILE *f) /* Stream descriptor */
{
if (f->b_base == NULL) return 0; /* already closed */
f->b_base = NULL; /* no valid stream */
return close(f->fd);
} /* end Close */
-#ifdef __STDC__
-#define pointer void *
-#else
-#define pointer char *
-#endif
/* -------------------------------------------------------------- */
-F_FILE *T1eexec(f) /* Initialization */
- F_FILE *f; /* Stream descriptor */
+F_FILE * /* Initialization */
+T1eexec(F_FILE *f) /* Stream descriptor */
+{
+ int i, c;
+ int H;
+ unsigned char *p;
+ unsigned char randomP[8];
+
+ r = 55665; /* initial key */
+ asc = 1; /* indicate ASCII form */
+
+ /* Consume the 4 random bytes, determining if we are also to
+ ASCIIDecodeHex as we process our input. (See pages 63-64
+ of the Adobe Type 1 Font Format book.) */
+
+ /* Skip over any initial white space chars */
+ while (HighHexP[c=_XT1getc(f)] == HWHITE_SPACE) ;
+
+ /* If ASCII, the next 7 chars are guaranteed consecutive */
+ randomP[0] = c; /* store first non white space char */
+ T1Read((pointer)(randomP+1), 1, 3, f); /* read 3 more, for a total of 4 */
+ /* store first four chars */
+ for (i=0,p=randomP; i<4; i++) { /* Check 4 valid ASCIIEncode chars */
+ if (HighHexP[*p++] > LAST_HDIGIT) { /* non-ASCII byte */
+ asc = 0;
+ break;
+ }
+ }
+ if (asc) { /* ASCII form, convert first eight bytes to binary */
+ T1Read((pointer)(randomP+4), 1, 4, f); /* Need four more */
+ for (i=0,p=randomP; i<4; i++) { /* Convert */
+ H = HighHexP[*p++];
+ randomP[i] = H | LowHexP[*p++];
+ }
+ }
+
+ /* Adjust our key */
+ for (i=0,p=randomP; i<4; i++) {
+ r = (*p++ + r) * c1 + c2;
+ }
+
+ /* Decrypt the remaining buffered bytes */
+ f->b_cnt = T1Decrypt(f->b_ptr, f->b_cnt);
+ Decrypt = 1;
+ return (T1Feof(f))?NULL:f;
+} /* end eexec */
+
+#ifdef BUILDCID
+F_FILE * /* Initialization */
+CIDeexec(F_FILE *f) /* Stream descriptor */
{
int i, c;
int H;
@@ -218,19 +293,31 @@ F_FILE *T1eexec(f) /* Initialization */
r = (*p++ + r) * c1 + c2;
}
- /* Decrypt the remaining buffered bytes */
- f->b_cnt = T1Decrypt(f->b_ptr, f->b_cnt);
+ /* Decrypt up to, but not including, the first '%' sign */
+ if (f->b_cnt > 0) {
+ for (i = 0; i < f->b_cnt; i++)
+ if (*(f->b_ptr + i) == '%')
+ break;
+
+ if (i < f->b_cnt) {
+ if (i == 0)
+ f->b_cnt = 0;
+ else
+ f->b_cnt = T1Decrypt(f->b_ptr, i);
+ } else
+ f->b_cnt = T1Decrypt(f->b_ptr, f->b_cnt);
+ }
Decrypt = 1;
return (T1Feof(f))?NULL:f;
} /* end eexec */
-
+#endif
+
/* -------------------------------------------------------------- */
-STATIC int T1Decrypt(p, len)
- unsigned char *p;
- int len;
+STATIC int
+T1Decrypt(unsigned char *p, int len)
{
int n;
- int H, L;
+ int H = 0, L;
unsigned char *inp = p;
unsigned char *tblP;
@@ -272,11 +359,11 @@ STATIC int T1Decrypt(p, len)
} /* end Decrypt */
/* -------------------------------------------------------------- */
-STATIC int T1Fill(f) /* Refill stream buffer */
- F_FILE *f; /* Stream descriptor */
+STATIC int /* Refill stream buffer */
+T1Fill(F_FILE *f) /* Stream descriptor */
{
int rc;
-
+
rc = read(f->fd, f->b_base, F_BUFSIZ);
/* propagate any error or eof to current file */
if (rc <= 0) {
diff --git a/src/Type1/t1malloc.c b/src/Type1/t1malloc.c
index 5028c8c..08a3a8b 100644
--- a/src/Type1/t1malloc.c
+++ b/src/Type1/t1malloc.c
@@ -26,6 +26,7 @@
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/t1malloc.c,v 1.11 2002/02/18 20:51:57 herrb Exp $ */
/* MALLOC CWEB V0004 LOTS */
/*
:h1.MALLOC - Fast Memory Allocation
@@ -37,12 +38,16 @@ routines (malloc/free).
*/
-#include "objects.h" /* get #define for abort() */
+#ifdef FONTMODULE
+#include "Xdefs.h" /* Bool declaration */
+#include "Xmd.h" /* INT32 declaration */
+#include "os.h"
+#include "xf86_ansic.h"
+#else
+#include "os.h"
+#endif
+#include "objects.h" /* get #define for Abort() */
-static void combine();
-static void freeuncombinable();
-static void unhook();
-static void dumpchain();
/*
:h3.Define NULL
@@ -54,7 +59,7 @@ popular (in terms of reducing compiler complaints), however, if your
compiler is unhappy about it, you can redefine it on the command line:
*/
#ifndef NULL
-#define NULL 0
+#include <stddef.h>
#endif
/*
Of course, NULL is important because xiMalloc() is defined to return
@@ -165,6 +170,18 @@ asked for.
long AvailableWords = 0; /* number of words available in memory */
char mallocdebug = 0; /* a flag that enables some chatty printf's */
+
+/*
+:h3.Prototypes of static functions
+*/
+
+static void combine ( void );
+static void freeuncombinable ( long *addr, long size );
+static void unhook ( struct freeblock *p );
+static void dumpchain ( void );
+#ifdef notused
+static void reportarea ( long *area );
+#endif
/*
:h3.whocalledme() - Debug for Memory Leaks
@@ -178,9 +195,9 @@ We use it to see who is malloc-ing memory without free-ing it.
#if DEBUGWORDS
-static whocalledme(addr, stack)
- long *addr; /* address of memory block */
- long *stack; /* address of malloc's parameter on stack */
+static void
+whocalledme(long *addr, /* address of memory block */
+ long *stack) /* address of malloc's parameter on stack */
{
register long size; /* size of memory block */
register int i; /* loop index */
@@ -206,8 +223,8 @@ The actual beginning of the block is one 'long' before the address we
gave to the user. The block begins and ends with '-size' in words.
*/
-void xiFree(addr)
- register long *addr; /* user's memory to be returned */
+void
+xiFree(long *addr) /* user's memory to be returned */
{
register long size; /* amount of memory in this block */
register struct freeblock *p; /* identical to 'addr' */
@@ -223,9 +240,9 @@ Make sure this address looks OK; 'size' must be less than zero (meaning
the block is allocated) and should be repeated at the end of the block.
*/
if (size >= 0)
- abort("free: bad size");
+ Abort("free: bad size");
if (addr[-1 - size] != size)
- abort("free: mismatched size");
+ Abort("free: mismatched size");
/*
Now make this a 'freeblock' structure and tack it on the FRONT of the
free list (where uncombined blocks go):
@@ -264,7 +281,7 @@ In any event, that block will be moved to the end of the list (after
*/
static void
-combine()
+combine(void)
{
register struct freeblock *p; /* block we will try to combine */
register long *addr; /* identical to 'p' for 'long' access */
@@ -273,12 +290,12 @@ combine()
p = firstcombined->back;
if (p == &firstfree)
- abort("why are we combining?");
+ Abort("why are we combining?");
addr = (long *) p;
size = - p->size;
if (--uncombined < 0)
- abort("too many combine()s");
+ Abort("too many combine()s");
if (addr[-1] < 0 && addr[size] < 0) {
/*
@@ -302,8 +319,8 @@ First we attempt to combine this with the block immediately above:
*addr = COMBINED; /* might help debug */
addr -= size2;
if (addr[0] != size2)
- abort("bad block above");
- unhook(addr);
+ Abort("bad block above");
+ unhook((struct freeblock *)addr);
size += size2;
}
/*
@@ -317,7 +334,7 @@ below:
if (size2 > 0) { /* i.e., block below is free */
p->size = COMBINED;
if (size2 != ((long *) p)[size2 - 1])
- abort("bad block below");
+ Abort("bad block below");
unhook(p);
size += size2;
}
@@ -337,9 +354,8 @@ no neighbors.
*/
static void
-freeuncombinable(addr, size)
- register long *addr; /* address of the block to be freed */
- register long size; /* size of block in words */
+freeuncombinable(long *addr, /* address of the block to be freed */
+ long size) /* size of block in words */
{
register struct freeblock *p; /* a convenient synonym for 'addr' */
@@ -372,8 +388,7 @@ have to worry about the end cases.)
*/
static void
-unhook(p)
- register struct freeblock *p; /* block to unhook */
+unhook(struct freeblock *p) /* block to unhook */
{
p->back->fore = p->fore;
p->fore->back = p->back;
@@ -394,10 +409,10 @@ cache.
#ifdef TYPE1IMAGER
-static char *malloc_local();
+static char *malloc_local(unsigned size);
-char *xiMalloc(size)
- register unsigned size;
+char *
+xiMalloc(unsigned size)
{
char *memaddr;
@@ -418,11 +433,12 @@ memory, and it is also compatible with the definition of a "size_t"
in most systems.
*/
#ifdef TYPE1IMAGER
-static char *malloc_local(Size)
+static char *
+malloc_local(unsigned Size) /* number of bytes the user requested */
#else
-char *xiMalloc(Size)
+char *
+xiMalloc(unsigned Size)
#endif
- unsigned Size; /* number of bytes the user requested */
{
register long size = (long)Size; /* a working register for size */
register struct freeblock *p; /* tentative block to be returned */
@@ -454,7 +470,7 @@ only to be "unhook"ed:
unhook(p);
uncombined--;
if (mallocdebug) {
- printf("fast xiMalloc(%d) = %p, ", size, p);
+ printf("fast xiMalloc(%ld) = %p, ", size, p);
dumpchain();
}
AvailableWords += size; /* decreases AvailableWords */
@@ -511,7 +527,7 @@ flag that this block is allocated:
area[size - 1] = area[0] = - size;
if (mallocdebug) {
- printf("slow xiMalloc(%d) @ %08x, ", size, area);
+ printf("slow xiMalloc(%ld) @ %p, ", size, area);
dumpchain();
}
whocalledme(area, &Size);
@@ -548,9 +564,9 @@ boundary.
static long *freearea[MAXAREAS] = { NULL }; /* so we can report later */
-void addmemory(addr, size)
- register long *addr; /* beginning of free area */
- register long size; /* number of bytes of free area */
+void
+addmemory(long *addr, /* beginning of free area */
+ long size) /* number of bytes of free area */
{
register int i; /* loop index variable */
register long *aaddr; /* aligned beginning of free area */
@@ -571,7 +587,7 @@ We'll record where the area was that was given to us for later reports:
for (i=0; i < MAXAREAS; i++)
if (freearea[i] == NULL) break;
if (i >= MAXAREAS)
- abort("too many addmemory()s");
+ Abort("too many addmemory()s");
aaddr = (long *) ( ((long) addr + sizeof(double) - 1) & - (long)sizeof(double) );
size -= (char *) aaddr - (char *) addr;
freearea[i] = aaddr;
@@ -595,7 +611,8 @@ free list:
/*
:h3.delmemory() - Delete Memory Pool
*/
-void delmemory()
+void
+delmemory(void)
{
register int i;
@@ -615,7 +632,7 @@ void delmemory()
*/
static void
-dumpchain()
+dumpchain(void)
{
register struct freeblock *p; /* current free block */
register long size; /* size of block */
@@ -627,36 +644,36 @@ dumpchain()
for (p = firstfree.fore, i=uncombined; p != firstcombined;
p = p->fore) {
if (--i < 0)
- abort("too many uncombined areas");
+ Abort("too many uncombined areas");
size = p->size;
printf(". . . area @ %p, size = %ld\n", p, -size);
if (size >= 0 || size != ((int *) p)[-1 - size])
- abort("dumpchain: bad size");
+ Abort("dumpchain: bad size");
if (p->back != back)
- abort("dumpchain: bad back");
+ Abort("dumpchain: bad back");
back = p;
}
printf("DUMPING COMBINED FREE LIST:\n");
for (; p != &lastfree; p = p->fore) {
size = p->size;
- printf(". . . area @ %p, size = %d\n", p, size);
+ printf(". . . area @ %p, size = %ld\n", p, size);
if (size <= 0 || size != ((int *) p)[size - 1])
- abort("dumpchain: bad size");
+ Abort("dumpchain: bad size");
if (p->back != back)
- abort("dumpchain: bad back");
+ Abort("dumpchain: bad back");
back = p;
}
if (back != lastfree.back)
- abort("dumpchain: bad lastfree");
+ Abort("dumpchain: bad lastfree");
}
+#ifdef notused
/*
:h3.reportarea() - Display a Contiguous Set of Memory Blocks
*/
static void
-reportarea(area)
- register long *area; /* start of blocks (from addmemory) */
+reportarea(long *area) /* start of blocks (from addmemory) */
{
register long size; /* size of current block */
register long wholesize; /* size of original area */
@@ -673,7 +690,7 @@ reportarea(area)
register int i,j;
size = -size;
- printf("Allocated %5d bytes at %08x, first words=%08x %08x\n",
+ printf("Allocated %5ld bytes at %p, first words=%08lx %08lx\n",
size * sizeof(long), area + 1, area[1], area[2]);
#if DEBUGWORDS
printf(" ...Last operator: %s\n",
@@ -682,29 +699,29 @@ reportarea(area)
for (i = size - DEBUGWORDS; i < size - 2; i += 8) {
printf(" ...");
for (j=0; j<8; j++)
- printf(" %08x", area[i+j]);
+ printf(" %08lx", area[i+j]);
printf("\n");
}
}
else {
- printf("Free %d bytes at %x\n", size * sizeof(long),
+ printf("Free %ld bytes at %p\n", size * sizeof(long),
area);
if (size == 0)
- abort("zero sized memory block");
+ Abort("zero sized memory block");
for (p = firstfree.fore; p != NULL; p = p->fore)
if ((long *) p == area) break;
if ((long *) p != area)
- abort("not found on forward chain");
+ Abort("not found on forward chain");
for (p = lastfree.back; p != NULL; p = p->back)
if ((long *) p == area) break;
if ((long *) p != area)
- abort("not found on backward chain");
+ Abort("not found on backward chain");
}
if (area[0] != area[size - 1])
- abort("unmatched check sizes");
+ Abort("unmatched check sizes");
area += size;
wholesize -= size;
}
@@ -714,7 +731,8 @@ reportarea(area)
:h3.MemReport() - Display All of Memory
*/
-void MemReport()
+void
+MemReport(void)
{
register int i;
@@ -728,8 +746,10 @@ void MemReport()
:h3.MemBytesAvail - Display Number of Bytes Now Available
*/
-void MemBytesAvail()
+void
+MemBytesAvail(void)
{
- printf("There are now %d bytes available\n", AvailableWords *
+ printf("There are now %ld bytes available\n", AvailableWords *
sizeof(long) );
}
+#endif
diff --git a/src/Type1/t1snap.c b/src/Type1/t1snap.c
index fd26e36..90c396b 100644
--- a/src/Type1/t1snap.c
+++ b/src/Type1/t1snap.c
@@ -27,10 +27,13 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/t1snap.c,v 1.4 2001/01/17 19:43:24 dawes Exp $ */
+
#include "objects.h"
#include "spaces.h"
#include "paths.h"
+#include "pictures.h"
/*
:h2.Handle Functions
@@ -40,15 +43,15 @@
This is a user operator. Its new name is QueryHandle.
*/
-struct segment *t1_Phantom(obj)
- register struct xobject *obj; /* object to take the Phantom of */
+struct segment *
+t1_Phantom(struct segment *p) /* object to take the Phantom of */
{
struct fractpoint pt; /* handle size will built here */
- if (obj == NULL)
+ if (p == NULL)
pt.x = pt.y = 0;
else
- PathDelta(obj, &pt);
+ PathDelta(p, &pt);
return(PathSegment(MOVETYPE, pt.x, pt.y));
}
@@ -59,8 +62,8 @@ struct segment *t1_Phantom(obj)
This is a user operator.
*/
-struct xobject *t1_Snap(p)
- register struct segment *p; /* path to snap */
+struct segment *
+t1_Snap(struct segment *p) /* path to snap */
{
struct fractpoint pt; /* for finding length of path */
@@ -75,5 +78,5 @@ struct xobject *t1_Snap(p)
}
else
p = JoinSegment(p, MOVETYPE, -pt.x, -pt.y, NULL);
- return((struct xobject *)p);
+ return(p);
}
diff --git a/src/Type1/t1stdio.h b/src/Type1/t1stdio.h
index b18ac5c..d4e71e8 100644
--- a/src/Type1/t1stdio.h
+++ b/src/Type1/t1stdio.h
@@ -27,7 +27,11 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/t1stdio.h,v 1.10 2001/07/25 15:04:55 dawes Exp $ */
/* T1IO FILE structure and related stuff */
+#ifdef XFree86LOADER
+#undef FILE
+#endif
#define FILE F_FILE
typedef unsigned char F_char;
@@ -49,11 +53,12 @@ typedef struct F_FILE {
#define FIOERROR (0x40)
#ifndef NULL
-#define NULL 0 /* null pointer */
+#include <stddef.h>
#endif
+
#define EOF (-1) /* end of file */
#define F_BUFSIZ (512)
-
+
#define _XT1getc(f) \
( \
( ((f)->b_cnt > 0) && ((f)->flags == 0) ) ? \
@@ -63,6 +68,30 @@ typedef struct F_FILE {
#define T1Feof(f) (((f)->flags & FIOEOF) && ((f)->b_cnt==0))
-extern FILE *T1Open(), *T1eexec();
-extern int T1Close(), T1Ungetc(), T1Read();
-
+#ifdef BUILDCID
+extern F_FILE *CIDeexec ( FILE *f );
+#endif
+
+extern FILE *T1Open ( char *fn, char *mode );
+extern int T1Getc ( FILE *f );
+extern int T1Ungetc ( int c, FILE *f );
+extern int T1Read ( char *buffP, int size, int n, FILE *f );
+extern int T1Close ( FILE *f );
+extern FILE *T1eexec ( FILE *f );
+extern void resetDecrypt ( void );
+
+#undef fclose
+#undef fopen
+#undef ungetc
+#undef fgetc
+#undef fread
+#undef feof
+#undef ferror
+#define fclose(f) T1Close(f)
+#define fopen(name,mode) T1Open(name,mode)
+#define ungetc(c,f) T1Ungetc(c,f)
+#define fgetc(f) T1Getc(f)
+
+#define fread(bufP,size,n,f) T1Read(bufP,size,n,f)
+#define feof(f) (((f)->flags & FIOEOF) && ((f)->b_cnt==0))
+#define ferror(f) (((f)->flags & FIOERROR)?(f)->error:0)
diff --git a/src/Type1/t1stub.c b/src/Type1/t1stub.c
index 82be9b3..cfe6ea9 100644
--- a/src/Type1/t1stub.c
+++ b/src/Type1/t1stub.c
@@ -27,16 +27,28 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/t1stub.c,v 1.9 2002/02/18 20:51:57 herrb Exp $ */
-#include "objects.h" /* get #define for abort() */
-
-xiStub()
+#ifdef FONTMODULE
+#include "Xdefs.h" /* Bool declaration */
+#include "Xmd.h" /* INT32 declaration */
+#include "os.h"
+#include "xf86_ansic.h"
+#else
+#include <stdio.h>
+#include "os.h"
+#endif
+#include "objects.h" /* get #define for Abort() */
+
+static void
+xiStub(void)
{
printf("xiStub called\n");
- abort("xiStub called");
+ Abort("xiStub called");
}
-void t1_DumpText()
+void
+t1_DumpText(void)
{
xiStub();
}
diff --git a/src/Type1/token.c b/src/Type1/token.c
index 054e1ea..ef28990 100644
--- a/src/Type1/token.c
+++ b/src/Type1/token.c
@@ -27,6 +27,7 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/token.c,v 1.5 2001/01/17 19:43:24 dawes Exp $ */
/* Authors: Sig Nin & Carol Thompson IBM Almaden Research Laboratory */
#include "t1stdio.h"
#include "util.h"
@@ -97,8 +98,8 @@ static double Exp10T[128] = {
1e56, 1e57, 1e58, 1e59, 1e60, 1e61, 1e62, 1e63
};
-static double P10(exponent)
- long exponent;
+static double
+P10(long exponent)
{
double value, power;
@@ -201,15 +202,15 @@ isWHITE_SPACE(ch)\
#define DONE (256)
/* Get the next input character */
-static int next_char(ch)
- int ch;
+static int
+next_char(int ch)
{
return(next_ch());
}
/* Add character to token */
-static int add_char(ch)
- int ch;
+static int
+add_char(int ch)
{
save_ch(ch);
return(next_ch());
@@ -221,8 +222,8 @@ static int add_char(ch)
*/
/* Skip white space */
-static int skip_space(ch)
- int ch;
+static int
+skip_space(int ch)
{
do {
ch = next_ch();
@@ -231,8 +232,8 @@ static int skip_space(ch)
}
/* Skip comments */
-static int skip_comment(ch)
- int ch;
+static int
+skip_comment(int ch)
{
do {
ch = next_ch();
@@ -259,23 +260,23 @@ static long r_base;
static long r_value;
static long r_scale;
-static int add_sign(ch)
- int ch;
+static int
+add_sign(int ch)
{
m_sign = ch;
save_unsafe_ch(ch);
return(next_ch());
}
-static int add_1st_digits(ch)
- int ch;
+static int
+add_1st_digits(int ch)
{
m_sign = '+';
return(add_digits(ch));
}
-static int add_digits(ch)
- int ch;
+static int
+add_digits(int ch)
{
long value, p_value, scale;
int digit;
@@ -366,15 +367,15 @@ static int add_digits(ch)
return(ch);
}
-static int add_1st_decpt(ch)
- int ch;
+static int
+add_1st_decpt(int ch)
{
m_sign = '+';
return(add_decpt(ch));
}
-static int add_decpt(ch)
- int ch;
+static int
+add_decpt(int ch)
{
/* On entry, expect m_sign to be set to '+' or '-' */
m_value = 0;
@@ -383,8 +384,8 @@ static int add_decpt(ch)
return(next_ch());
}
-static int add_fraction(ch)
- int ch;
+static int
+add_fraction(int ch)
{
long value, scale;
int digit;
@@ -480,16 +481,16 @@ static int add_fraction(ch)
return(ch);
}
-static int add_e_sign(ch)
- int ch;
+static int
+add_e_sign(int ch)
{
e_sign = ch;
save_ch(ch);
return(next_ch());
}
-static int add_exponent(ch)
- int ch;
+static int
+add_exponent(int ch)
{
long value, p_value;
long scale = 0;
@@ -558,8 +559,8 @@ static int add_exponent(ch)
return(ch);
}
-static int add_radix(ch)
- int ch;
+static int
+add_radix(int ch)
{
if (2 <= m_value && m_value <= 36 && m_scale == 0) {
r_base = m_value;
@@ -572,8 +573,8 @@ static int add_radix(ch)
}
}
-static int add_r_digits(ch)
- int ch;
+static int
+add_r_digits(int ch)
{
unsigned long value;
long radix, scale;
@@ -654,8 +655,8 @@ static int add_r_digits(ch)
*/
/* Done: Radix Number */
-static int RADIX_NUMBER(ch)
- int ch;
+static int
+RADIX_NUMBER(int ch)
{
back_ch_not_white(ch);
if (r_scale == 0) {
@@ -669,8 +670,8 @@ static int RADIX_NUMBER(ch)
}
/* Done: Integer */
-static int INTEGER(ch)
- int ch;
+static int
+INTEGER(int ch)
{
back_ch_not_white(ch);
if (m_scale == 0) {
@@ -685,8 +686,8 @@ static int INTEGER(ch)
}
/* Done: Real */
-static int REAL(ch)
- int ch;
+static int
+REAL(int ch)
{
double temp;
@@ -722,8 +723,8 @@ static int REAL(ch)
*/
/* Done: Hex String */
-static int HEX_STRING(ch)
- int ch;
+static int
+HEX_STRING(int ch)
{
int value;
@@ -795,8 +796,8 @@ static int HEX_STRING(ch)
* "\\", "\(", and "\)", simply store the second
* character.
*/
-static void save_digraph(ch)
- int ch;
+static void
+save_digraph(int ch)
{
int value;
@@ -858,8 +859,8 @@ static void save_digraph(ch)
}
/* Done: String */
-static int STRING(ch)
- int ch;
+static int
+STRING(int ch)
{
int nest_level = 1;
@@ -925,8 +926,8 @@ static int STRING(ch)
* start out looking like something else).
*/
-static int AAH_NAME(ch)
- int ch;
+static int
+AAH_NAME(int ch)
{
do {
save_ch(ch);
@@ -939,8 +940,8 @@ static int AAH_NAME(ch)
}
/* Done: Name */
-static int NAME(ch)
- int ch;
+static int
+NAME(int ch)
{
save_unsafe_ch(ch);
ch = next_ch();
@@ -979,8 +980,8 @@ static int NAME(ch)
}
/* Done: Literal Name */
-static int LITERAL_NAME(ch)
- int ch;
+static int
+LITERAL_NAME(int ch)
{
if (isNAME(ch)) {
save_unsafe_ch(ch);
@@ -1017,8 +1018,8 @@ static int LITERAL_NAME(ch)
}
/* Done: immediate Name */
-static int IMMED_NAME(ch)
- int ch;
+static int
+IMMED_NAME(int ch)
{
ch = next_ch();
if (isNAME(ch)) {
@@ -1056,8 +1057,8 @@ static int IMMED_NAME(ch)
}
/* Done: Name found while looking for something else */
-static int OOPS_NAME(ch)
- int ch;
+static int
+OOPS_NAME(int ch)
{
back_ch_not_white(ch);
tokenType = TOKEN_NAME;
@@ -1070,40 +1071,40 @@ static int OOPS_NAME(ch)
*/
/* Done: Unmatched Right Angle-Bracket */
-static int RIGHT_ANGLE(ch)
- int ch;
+static int
+RIGHT_ANGLE(int ch)
{
tokenType = TOKEN_RIGHT_ANGLE;
return(DONE);
}
/* Done: Unmatched Right Parenthesis */
-static int RIGHT_PAREN(ch)
- int ch;
+static int
+RIGHT_PAREN(int ch)
{
tokenType = TOKEN_RIGHT_PAREN;
return(DONE);
}
/* Done: Left Brace */
-static int LEFT_BRACE(ch)
- int ch;
+static int
+LEFT_BRACE(int ch)
{
tokenType = TOKEN_LEFT_BRACE;
return(DONE);
}
/* Done: Right Brace */
-static int RIGHT_BRACE(ch)
- int ch;
+static int
+RIGHT_BRACE(int ch)
{
tokenType = TOKEN_RIGHT_BRACE;
return(DONE);
}
/* Done: Left Bracket */
-static int LEFT_BRACKET(ch)
- int ch;
+static int
+LEFT_BRACKET(int ch)
{
save_unsafe_ch(ch);
tokenType = TOKEN_LEFT_BRACKET;
@@ -1111,8 +1112,8 @@ static int LEFT_BRACKET(ch)
}
/* Done: Right Bracket */
-static int RIGHT_BRACKET(ch)
- int ch;
+static int
+RIGHT_BRACKET(int ch)
{
save_unsafe_ch(ch);
tokenType = TOKEN_RIGHT_BRACKET;
@@ -1120,16 +1121,16 @@ static int RIGHT_BRACKET(ch)
}
/* Done: Break */
-static int BREAK_SIGNAL(ch)
- int ch;
+static int
+BREAK_SIGNAL(int ch)
{
tokenType = TOKEN_BREAK;
return(DONE);
}
/* Done: No Token Found */
-static int NO_TOKEN(ch)
- int ch;
+static int
+NO_TOKEN(int ch)
{
tokenType = TOKEN_EOF;
return(DONE);
@@ -1159,13 +1160,13 @@ static int NO_TOKEN(ch)
*
* -------------------------------------------------------------------
*/
-void scan_token(inputP)
- psobj *inputP;
+void
+scan_token(psobj *inputP)
{
int ch;
unsigned char *stateP = s0;
unsigned char entry;
- int (*actionP)();
+ int (*actionP)(int);
/* Define input source */
inputFileP = inputP->data.fileP;
diff --git a/src/Type1/token.h b/src/Type1/token.h
index 2dfe3fa..caa2ca2 100644
--- a/src/Type1/token.h
+++ b/src/Type1/token.h
@@ -27,6 +27,8 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/token.h,v 1.4 2001/01/17 19:43:24 dawes Exp $ */
+
#ifndef TOKEN_H
#define TOKEN_H
@@ -56,7 +58,7 @@
#define TOKEN_IMMED_NAME (16)
/* Token routines */
-extern void scan_token();
+extern void scan_token( psobj *inputP );
/*
* -------------------------------------------------------------------------
diff --git a/src/Type1/tokst.h b/src/Type1/tokst.h
index de3f0ec..61f1ff9 100644
--- a/src/Type1/tokst.h
+++ b/src/Type1/tokst.h
@@ -27,6 +27,8 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* $XFree86: xc/lib/font/Type1/tokst.h,v 1.4 2001/01/17 19:43:24 dawes Exp $ */
+
/* -------------------------------------- */
/* --- MACHINE GENERATED, DO NOT EDIT --- */
/* -------------------------------------- */
@@ -291,41 +293,41 @@ static unsigned char si11[258] = { 0x53,0x54,
* state. There are several entries for each state.
*
*/
-static int AAH_NAME();
-static int BREAK_SIGNAL();
-static int HEX_STRING();
-static int IMMED_NAME();
-static int INTEGER();
-static int LEFT_BRACE();
-static int LEFT_BRACKET();
-static int LITERAL_NAME();
-static int NAME();
-static int NO_TOKEN();
-static int OOPS_NAME();
-static int RADIX_NUMBER();
-static int REAL();
-static int RIGHT_ANGLE();
-static int RIGHT_BRACE();
-static int RIGHT_BRACKET();
-static int RIGHT_PAREN();
-static int STRING();
-static int add_1st_decpt();
-static int add_1st_digits();
-static int add_char();
-static int add_decpt();
-static int add_digits();
-static int add_e_sign();
-static int add_exponent();
-static int add_fraction();
-static int add_r_digits();
-static int add_radix();
-static int add_sign();
-static int next_char();
-static int skip_comment();
-static int skip_space();
+static int AAH_NAME ( int ch );
+static int BREAK_SIGNAL ( int ch );
+static int HEX_STRING ( int ch );
+static int IMMED_NAME ( int ch );
+static int INTEGER ( int ch );
+static int LEFT_BRACE ( int ch );
+static int LEFT_BRACKET ( int ch );
+static int LITERAL_NAME ( int ch );
+static int NAME ( int ch );
+static int NO_TOKEN ( int ch );
+static int OOPS_NAME ( int ch );
+static int RADIX_NUMBER ( int ch );
+static int REAL ( int ch );
+static int RIGHT_ANGLE ( int ch );
+static int RIGHT_BRACE ( int ch );
+static int RIGHT_BRACKET ( int ch );
+static int RIGHT_PAREN ( int ch );
+static int STRING ( int ch );
+static int add_1st_decpt ( int ch );
+static int add_1st_digits ( int ch );
+static int add_char ( int ch );
+static int add_decpt ( int ch );
+static int add_digits ( int ch );
+static int add_exponent ( int ch );
+static int add_e_sign ( int ch );
+static int add_fraction ( int ch );
+static int add_radix ( int ch );
+static int add_r_digits ( int ch );
+static int add_sign ( int ch );
+static int next_char ( int ch );
+static int skip_comment ( int ch );
+static int skip_space ( int ch );
static struct cat {
- int (*actionRoutineP)();
+ int (*actionRoutineP)(int);
unsigned char *nextStateP;
} classActionTable[] = {
diff --git a/src/Type1/trig.h b/src/Type1/trig.h
index c742f96..f442a61 100644
--- a/src/Type1/trig.h
+++ b/src/Type1/trig.h
@@ -28,6 +28,12 @@
* SOFTWARE.
*/
/*SHARED*/
+
+/* $XFree86: xc/lib/font/Type1/trig.h,v 1.3 2001/01/17 19:43:24 dawes Exp $ */
+
+#undef DegreeCos
+#undef DegreeSin
+#undef sqrt
#define DegreeCos(d) xiStub()
#define DegreeSin(d) xiStub()
diff --git a/src/Type1/type1.c b/src/Type1/type1.c
index f1b11c0..5b83dd0 100644
--- a/src/Type1/type1.c
+++ b/src/Type1/type1.c
@@ -28,6 +28,24 @@
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/type1.c,v 1.9 2001/01/17 19:43:24 dawes Exp $ */
/*********************************************************************/
/* */
@@ -46,16 +64,24 @@
/******************/
/* Include Files: */
/******************/
+#ifndef FONTMODULE
#include <stdio.h> /* a system-dependent include, usually */
-
+#include <math.h>
+#else
+#include "Xdefs.h"
+#include "Xmd.h"
+#include "xf86_ansic.h"
+#endif
#include "objects.h"
#include "spaces.h"
#include "paths.h"
#include "fonts.h" /* understands about TEXTTYPEs */
#include "pictures.h" /* understands about handles */
+#include "range.h"
typedef struct xobject xobject;
#include "util.h" /* PostScript objects */
+#include "fontfcn.h"
#include "blues.h" /* Blues structure for font-level hints */
/**********************************/
@@ -66,7 +92,11 @@ typedef struct xobject xobject;
#define MAXPSFAKESTACK 32 /* Max depth of fake PostScript stack (local) */
#define MAXSTRLEN 512 /* Max length of a Type 1 string (local) */
#define MAXLABEL 256 /* Maximum number of new hints */
+#ifdef BUILDCID
+#define MAXSTEMS 500 /* Maximum number of VSTEM and HSTEM hints */
+#else
#define MAXSTEMS 128 /* Maximum number of VSTEM and HSTEM hints */
+#endif
#define EPS 0.001 /* Small number for comparisons */
/************************************/
@@ -106,14 +136,12 @@ typedef struct xobject xobject;
/*****************/
/* Useful macros */
/*****************/
-static double tmpx; /* Store macro argument in tmpx to avoid re-evaluation */
-static long tmpi; /* Store converted value in tmpi to avoid re-evaluation */
-#define FABS(x) (((tmpx = (x)) < 0.0) ? -tmpx : tmpx)
+#define FABS(x) fabs(x)
-#define CEIL(x) (((tmpi = (long) (tmpx = (x))) < (x)) ? ++tmpi : tmpi)
+#define CEIL(x) ceil(x)
-#define FLOOR(x) (((tmpi = (long) (tmpx = (x))) > (x)) ? --tmpi : tmpi)
+#define FLOOR(x) floor(x)
#define ROUND(x) FLOOR((x) + 0.5)
@@ -138,7 +166,14 @@ struct stem { /* representation of a STEM hint */
struct segment *rthint, *rtrevhint; /* right or top hint adjustment */
};
-extern struct XYspace *IDENTITY;
+struct xobject *Type1Char(char *env, struct XYspace *S,
+ psobj *charstrP, psobj *subrsP, psobj *osubrsP,
+ struct blues_struct *bluesP, int *modeP);
+#ifdef BUILDCID
+struct xobject *CIDChar(char *env, struct XYspace *S,
+ psobj *charstrP, psobj *subrsP, psobj *osubrsP,
+ struct blues_struct *bluesP, int *modeP);
+#endif
static double escapementX, escapementY;
static double sidebearingX, sidebearingY;
@@ -158,24 +193,57 @@ static int *ModeP;
/************************/
/* Forward declarations */
/************************/
-static double Div();
-static double PSFakePop();
-static void DoCommand();
-static void Escape();
-static void HStem();
-static void VStem();
-static void RLineTo();
-static void RRCurveTo();
-static void DoClosePath();
-static void CallSubr();
-static void Return();
-static void EndChar();
-static void RMoveTo();
-static void DotSection();
-static void Seac();
-static void Sbw();
-static void CallOtherSubr();
-static void SetCurrentPoint();
+static struct segment *Applyhint ( struct segment *p, int stemnumber,
+ int half );
+static struct segment *Applyrevhint ( struct segment *p, int stemnumber,
+ int half );
+static void CallOtherSubr ( int othersubrno );
+static void CallSubr ( int subrno );
+static struct segment *CenterStem ( double edge1, double edge2 );
+static void ClearCallStack ( void );
+static void ClearPSFakeStack ( void );
+static void ClearStack ( void );
+static void ComputeAlignmentZones ( void );
+static void ComputeStem ( int stemno );
+static void Decode ( int Code );
+static unsigned char Decrypt ( unsigned char cipher );
+static double Div ( double num1, double num2 );
+static void DoClosePath ( void );
+static void DoCommand ( int Code );
+static int DoRead ( int *CodeP );
+static void DotSection ( void );
+static void EndChar ( void );
+static void Escape ( int Code );
+static struct segment *FindStems ( double x, double y, double dx, double dy );
+static void FinitStems ( void );
+static void FlxProc ( double c1x2, double c1y2, double c3x0, double c3y0,
+ double c3x1, double c3y1, double c3x2, double c3y2,
+ double c4x0, double c4y0, double c4x1, double c4y1,
+ double c4x2, double c4y2, double epY, double epX,
+ int idmin );
+static void FlxProc1 ( void );
+static void FlxProc2 ( void );
+static void HintReplace ( void );
+static void HStem ( double y, double dy );
+static void InitStems ( void );
+static void PopCall ( psobj **CurrStrPP, int *CurrIndexP,
+ unsigned short *CurrKeyP );
+static double PSFakePop ( void );
+static void PSFakePush ( double Num );
+static void Push ( double Num );
+static void PushCall ( psobj *CurrStrP, int CurrIndex,
+ unsigned short CurrKey );
+static void Return ( void );
+static void RLineTo ( double dx, double dy );
+static void RMoveTo ( double dx, double dy );
+static void RRCurveTo ( double dx1, double dy1, double dx2, double dy2,
+ double dx3, double dy3 );
+static void Sbw ( double sbx, double sby, double wx, double wy );
+static void Seac ( double asb, double adx, double ady, unsigned char bchar,
+ unsigned char achar );
+static void SetCurrentPoint ( double x, double y );
+static void StartDecrypt ( void );
+static void VStem ( double x, double dx );
/*****************************************/
/* statics for Flex procedures (FlxProc) */
@@ -197,7 +265,7 @@ static int numalignmentzones; /* total number of alignment zones */
/* Fill in the alignment zone structures. */
/******************************************/
static void
-ComputeAlignmentZones()
+ComputeAlignmentZones(void)
{
int i;
double dummy, bluezonepixels, familyzonepixels;
@@ -276,7 +344,7 @@ static double wsoffsetX, wsoffsetY; /* White space offset - for VSTEM3,HSTEM3 *
static int wsset; /* Flag for whether we've set wsoffsetX,Y */
static void
-InitStems() /* Initialize the STEM hint data structures */
+InitStems(void) /* Initialize the STEM hint data structures */
{
InDotSection = FALSE;
currstartstem = numstems = 0;
@@ -284,7 +352,7 @@ InitStems() /* Initialize the STEM hint data structures */
}
static void
-FinitStems() /* Terminate the STEM hint data structures */
+FinitStems(void) /* Terminate the STEM hint data structures */
{
int i;
@@ -301,8 +369,7 @@ FinitStems() /* Terminate the STEM hint data structures */
/* inside the stem. */
/*******************************************************************/
static void
-ComputeStem(stemno)
- int stemno;
+ComputeStem(int stemno)
{
int verticalondevice, idealwidth;
double stemstart, stemwidth;
@@ -450,10 +517,10 @@ ComputeStem(stemno)
if (unitpixels < blues->BlueScale)
suppressovershoot = TRUE;
else
- if (alignmentzones[i].topzone)
+ if (alignmentzones[i].topzone) {
if (stemtop >= alignmentzones[i].bottomy + blues->BlueShift)
enforceovershoot = TRUE;
- else
+ } else
if (stembottom <= alignmentzones[i].topy - blues->BlueShift)
enforceovershoot = TRUE;
@@ -492,20 +559,21 @@ ComputeStem(stemno)
it falls at least one pixel beyond the flat position. */
if (enforceovershoot)
- if (overshoot < onepixel)
+ if (overshoot < onepixel) {
if (alignmentzones[i].topzone)
stemshift += onepixel - overshoot;
else
stemshift -= onepixel - overshoot;
-
+ }
/* SUPPRESS overshoot by aligning the stem to the alignment zone's
flat position. */
- if (suppressovershoot)
+ if (suppressovershoot) {
if (alignmentzones[i].topzone)
stemshift -= overshoot;
else
stemshift += overshoot;
+ }
}
/************************************************************/
@@ -569,9 +637,8 @@ ComputeStem(stemno)
/* hint value or the right/top hint value depending on where the */
/* point lies in the stem. */
/*********************************************************************/
-static struct segment *Applyhint(p, stemnumber, half)
-struct segment *p;
-int stemnumber, half;
+static struct segment *
+Applyhint(struct segment *p, int stemnumber, int half)
{
if (half == LEFT || half == BOTTOM)
return Join(p, stems[stemnumber].lbhint); /* left or bottom hint */
@@ -584,9 +651,8 @@ int stemnumber, half;
/* hint value or the right/top hint value depending on where the */
/* point lies in the stem. */
/*********************************************************************/
-static struct segment *Applyrevhint(p, stemnumber, half)
-struct segment *p;
-int stemnumber, half;
+static struct segment *
+Applyrevhint(struct segment *p, int stemnumber, int half)
{
if (half == LEFT || half == BOTTOM)
return Join(p, stems[stemnumber].lbrevhint); /* left or bottom hint */
@@ -602,8 +668,8 @@ int stemnumber, half;
/* The actual hintvalue is returned as a location. */
/* Hints are ignored inside a DotSection. */
/***********************************************************************/
-static struct segment *FindStems(x, y, dx, dy)
-double x, y, dx, dy;
+static struct segment *
+FindStems(double x, double y, double dx, double dy)
{
int i;
int newvert, newhor;
@@ -697,30 +763,26 @@ static double PSFakeStack[MAXPSFAKESTACK];
static int PSFakeTop;
static void
-ClearStack()
+ClearStack(void)
{
Top = -1;
}
static void
-Push(Num)
- double Num;
+Push(double Num)
{
if (++Top < MAXSTACK) Stack[Top] = Num;
else Error0("Push: Stack full\n");
}
static void
-ClearCallStack()
+ClearCallStack(void)
{
CallTop = -1;
}
static void
-PushCall(CurrStrP, CurrIndex, CurrKey)
- psobj *CurrStrP;
- int CurrIndex;
- unsigned short CurrKey;
+PushCall(psobj *CurrStrP, int CurrIndex, unsigned short CurrKey)
{
if (++CallTop < MAXCALLSTACK) {
CallStack[CallTop].currstrP = CurrStrP; /* save CharString pointer */
@@ -731,10 +793,7 @@ PushCall(CurrStrP, CurrIndex, CurrKey)
}
static void
-PopCall(CurrStrPP, CurrIndexP, CurrKeyP)
- psobj **CurrStrPP;
- int *CurrIndexP;
- unsigned short *CurrKeyP;
+PopCall(psobj **CurrStrPP, int *CurrIndexP, unsigned short *CurrKeyP)
{
if (CallTop >= 0) {
*CurrStrPP = CallStack[CallTop].currstrP; /* restore CharString pointer */
@@ -745,23 +804,22 @@ PopCall(CurrStrPP, CurrIndexP, CurrKeyP)
}
static void
-ClearPSFakeStack()
+ClearPSFakeStack(void)
{
PSFakeTop = -1;
}
/* PSFakePush: Pushes a number onto the fake PostScript stack */
static void
-PSFakePush(Num)
- double Num;
+PSFakePush(double Num)
{
if (++PSFakeTop < MAXPSFAKESTACK) PSFakeStack[PSFakeTop] = Num;
else Error0("PSFakePush: Stack full\n");
}
/* PSFakePop: Removes a number from the top of the fake PostScript stack */
-static double
-PSFakePop ()
+static double
+PSFakePop (void)
{
if (PSFakeTop >= 0) return(PSFakeStack[PSFakeTop--]);
else Error0Ret("PSFakePop : Stack empty\n", 0.0);
@@ -771,9 +829,8 @@ PSFakePop ()
/***********************************************************************/
/* Center a stem on the pixel grid -- used by HStem3 and VStem3 */
/***********************************************************************/
-static struct segment *CenterStem(edge1, edge2)
- double edge1;
- double edge2;
+static struct segment *
+CenterStem(double edge1, double edge2)
{
int idealwidth, verticalondevice;
double leftx, lefty, rightx, righty, center, width;
@@ -842,8 +899,8 @@ static struct segment *CenterStem(edge1, edge2)
static unsigned short r; /* Pseudo-random sequence of keys */
-static unsigned char Decrypt(cipher)
-unsigned char cipher;
+static unsigned char
+Decrypt(unsigned char cipher)
{
unsigned char plain;
@@ -853,8 +910,8 @@ unsigned char cipher;
}
/* Get the next byte from the codestring being interpreted */
-static int DoRead(CodeP)
- int *CodeP;
+static int
+DoRead(int *CodeP)
{
if (strindex >= CharStringP->len) return(FALSE); /* end of string */
*CodeP = Decrypt((unsigned char) CharStringP->data.stringP[strindex++]);
@@ -864,7 +921,8 @@ static int DoRead(CodeP)
/* Strip blues->lenIV bytes from CharString and update encryption key */
/* (the lenIV entry in the Private dictionary specifies the number of */
/* random bytes at the beginning of each CharString; default is 4) */
-static void StartDecrypt()
+static void
+StartDecrypt(void)
{
int Code;
@@ -875,8 +933,7 @@ static void StartDecrypt()
}
static void
-Decode(Code)
- int Code;
+Decode(int Code)
{
int Code1, Code2, Code3, Code4;
@@ -906,8 +963,7 @@ ended: Error0("Decode: Premature end of Type 1 CharString");
/* Interpret a command code */
static void
-DoCommand(Code)
- int Code;
+DoCommand(int Code)
{
switch(Code) {
case HSTEM: /* |- y dy HSTEM |- */
@@ -1025,8 +1081,7 @@ DoCommand(Code)
}
static void
-Escape(Code)
- int Code;
+Escape(int Code)
{
int i, Num;
struct segment *p;
@@ -1094,7 +1149,14 @@ Escape(Code)
if (Top < Num+1) Error0("DoCommand: Stack low\n");
for (i = 0; i < Num; i++) PSFakePush(Stack[Top - i - 2]);
Top -= Num + 2;
+#ifdef BUILDCID
+ if ((int)Stack[Top + Num + 2] > 3)
+ ClearPSFakeStack();
+ else
+ CallOtherSubr((int)Stack[Top + Num + 2]);
+#else
CallOtherSubr((int)Stack[Top + Num + 2]);
+#endif
break;
case POP: /* - POP number */
/* Removes a number from the top of the */
@@ -1121,8 +1183,7 @@ Escape(Code)
/* between coordinates y and y + dy */
/* y is relative to the left sidebearing point */
static void
-HStem(y, dy)
- double y, dy;
+HStem(double y, double dy)
{
IfTrace2((FontDebug), "Hstem %f %f\n", &y, &dy);
if (ProcessHints) {
@@ -1142,9 +1203,9 @@ HStem(y, dy)
/* Declares the horizontal range of a vertical stem zone */
/* between coordinates x and x + dx */
/* x is relative to the left sidebearing point */
+
static void
-VStem(x, dx)
- double x, dx;
+VStem(double x, double dx)
{
IfTrace2((FontDebug), "Vstem %f %f\n", &x, &dx);
if (ProcessHints) {
@@ -1163,8 +1224,7 @@ VStem(x, dx)
/* |- dx dy RLINETO |- */
/* Behaves like RLINETO in PostScript */
static void
-RLineTo(dx, dy)
- double dx, dy;
+RLineTo(double dx, double dy)
{
struct segment *B;
@@ -1187,8 +1247,8 @@ RLineTo(dx, dy)
/* (dx1+dx2) (dy1+dy2) (dx1+dx2+dx3) */
/* (dy1+dy2+dy3) RCURVETO in PostScript */
static void
-RRCurveTo(dx1, dy1, dx2, dy2, dx3, dy3)
- double dx1, dy1, dx2, dy2, dx3, dy3;
+RRCurveTo(double dx1, double dy1, double dx2, double dy2,
+ double dx3, double dy3)
{
struct segment *B, *C, *D;
@@ -1211,17 +1271,17 @@ RRCurveTo(dx1, dy1, dx2, dy2, dx3, dy3)
/* Since XIMAGER is not completely relative, */
/* we need to add up the delta values */
- C = Join(C, Dup(B));
- D = Join(D, Dup(C));
+ C = Join(C, (struct segment *)Dup(B));
+ D = Join(D, (struct segment *)Dup(C));
- path = Join(path, Bezier(B, C, D));
+ path = Join(path, (struct segment *)Bezier(B, C, D));
}
/* - CLOSEPATH |- */
/* Closes a subpath WITHOUT repositioning the */
/* current point */
static void
-DoClosePath()
+DoClosePath(void)
{
struct segment *CurrentPoint;
@@ -1235,8 +1295,7 @@ DoClosePath()
/* Calls a CharString subroutine with index */
/* subr# from the Subrs array */
static void
-CallSubr(subrno)
- int subrno;
+CallSubr(int subrno)
{
IfTrace1((FontDebug), "CallSubr %d\n", subrno);
if ((subrno < 0) || (subrno >= SubrsP->len))
@@ -1250,7 +1309,7 @@ CallSubr(subrno)
/* Returns from a Subrs array CharString */
/* subroutine called with CALLSUBR */
static void
-Return()
+Return(void)
{
IfTrace0((FontDebug), "Return\n");
PopCall(&CharStringP, &strindex, &r);
@@ -1265,7 +1324,7 @@ Return()
/* or STROKE depending on the value of PaintType in the */
/* font dictionary */
static void
-EndChar()
+EndChar(void)
{
IfTrace0((FontDebug), "EndChar\n");
@@ -1283,8 +1342,7 @@ EndChar()
/* |- dx dy RMOVETO |- */
/* Behaves like RMOVETO in PostScript */
static void
-RMoveTo(dx,dy)
- double dx,dy;
+RMoveTo(double dx, double dy)
{
struct segment *B;
@@ -1306,7 +1364,7 @@ RMoveTo(dx,dy)
/* Brackets an outline section for the dots in */
/* letters such as "i", "j", and "!". */
static void
-DotSection()
+DotSection(void)
{
IfTrace0((FontDebug), "DotSection\n");
InDotSection = !InDotSection;
@@ -1315,9 +1373,8 @@ DotSection()
/* |- asb adx ady bchar achar SEAC |- */
/* Standard Encoding Accented Character. */
static void
-Seac(asb, adx, ady, bchar, achar)
- double asb, adx, ady;
- unsigned char bchar, achar;
+Seac(double asb, double adx, double ady,
+ unsigned char bchar, unsigned char achar)
{
int Code;
struct segment *mypath;
@@ -1337,7 +1394,7 @@ Seac(asb, adx, ady, bchar, achar)
path = NULL;
/* Go find the CharString for the accent's code via an upcall */
- CharStringP = GetType1CharString(Environment, achar);
+ CharStringP = GetType1CharString((psfont *)Environment, achar);
StartDecrypt();
ClearStack();
@@ -1357,7 +1414,7 @@ Seac(asb, adx, ady, bchar, achar)
accentoffsetX = accentoffsetY = 0;
/* go find the CharString for the base char's code via an upcall */
- CharStringP = GetType1CharString(Environment, bchar);
+ CharStringP = GetType1CharString((psfont *)Environment, bchar);
StartDecrypt();
ClearStack();
@@ -1380,8 +1437,7 @@ Seac(asb, adx, ady, bchar, achar)
/* Set the left sidebearing point to (sbx,sby), */
/* set the character width vector to (wx,wy). */
static void
-Sbw(sbx, sby, wx, wy)
- double sbx, sby, wx, wy;
+Sbw(double sbx, double sby, double wx, double wy)
{
IfTrace4((FontDebug), "SBW %f %f %f %f\n", &sbx, &sby, &wx, &wy);
@@ -1398,8 +1454,8 @@ Sbw(sbx, sby, wx, wy)
/* num1 num2 DIV quotient */
/* Behaves like DIV in the PostScript language */
-static double Div(num1, num2)
- double num1, num2;
+static double
+Div(double num1, double num2)
{
IfTrace2((FontDebug), "Div %f %f\n", &num1, &num2);
return(num1 / num2);
@@ -1485,14 +1541,11 @@ static double Div(num1, num2)
/* Calling sequence: 'idmin epX epY 3 0 callothersubr' */
/* Computes Flex values, and renders the Flex path, */
/* and returns (leaves) ending coordinates on stack */
-static void
-FlxProc(c1x2, c1y2, c3x0, c3y0, c3x1, c3y1, c3x2, c3y2,
- c4x0, c4y0, c4x1, c4y1, c4x2, c4y2, epY, epX, idmin)
- double c1x2, c1y2;
- double c3x0, c3y0, c3x1, c3y1, c3x2, c3y2;
- double c4x0, c4y0, c4x1, c4y1, c4x2, c4y2;
- double epX, epY;
- int idmin;
+static void
+FlxProc(double c1x2, double c1y2, double c3x0, double c3y0,
+ double c3x1, double c3y1, double c3x2, double c3y2,
+ double c4x0, double c4y0, double c4x1, double c4y1,
+ double c4x2, double c4y2, double epY, double epX, int idmin)
{
double dmin;
double c1x0, c1y0, c1x1, c1y1;
@@ -1656,7 +1709,8 @@ FlxProc(c1x2, c1y2, c3x0, c3y0, c3x1, c3y1, c3x2, c3y2,
/* FlxProc1() = OtherSubrs[1]; Part of Flex */
/* Calling sequence: '0 1 callothersubr' */
/* Saves and clears path, then restores currentpoint */
-static void FlxProc1()
+static void
+FlxProc1(void)
{
struct segment *CurrentPoint;
@@ -1669,7 +1723,8 @@ static void FlxProc1()
/* FlxProc2() = OtherSubrs[2]; Part of Flex */
/* Calling sequence: '0 2 callothersubr' */
/* Returns currentpoint on stack */
-static void FlxProc2()
+static void
+FlxProc2(void)
{
struct segment *CurrentPoint;
double CurrentX, CurrentY;
@@ -1686,7 +1741,8 @@ static void FlxProc2()
/* HintReplace() = OtherSubrs[3]; Hint Replacement */
/* Calling sequence: 'subr# 1 3 callothersubr pop callsubr' */
/* Reinitializes stem hint structure */
-static void HintReplace()
+static void
+HintReplace(void)
{
/* Effectively retire the current stems, but keep them around for */
/* revhint use in case we are in a stem when we replace hints. */
@@ -1699,8 +1755,7 @@ static void HintReplace()
/* Make calls on the PostScript interpreter (or call equivalent C code) */
/* NOTE: The n arguments have been pushed on the fake PostScript stack */
static void
-CallOtherSubr(othersubrno)
- int othersubrno;
+CallOtherSubr(int othersubrno)
{
IfTrace1((FontDebug), "CallOtherSubr %d\n", othersubrno);
@@ -1735,8 +1790,7 @@ CallOtherSubr(othersubrno)
/* character space coordinates without per- */
/* forming a CharString MOVETO command */
static void
-SetCurrentPoint(x, y)
- double x, y;
+SetCurrentPoint(double x, double y)
{
IfTrace2((FontDebug), "SetCurrentPoint %f %f\n", &x, &y);
@@ -1746,14 +1800,11 @@ SetCurrentPoint(x, y)
/* The Type1Char routine for use by PostScript. */
/************************************************/
-struct xobject *Type1Char(env, S, charstrP, subrsP, osubrsP, bluesP, modeP)
- char *env;
- struct XYspace *S;
- psobj *charstrP;
- psobj *subrsP;
- psobj *osubrsP;
- struct blues_struct *bluesP; /* FontID's ptr to the blues struct */
- int *modeP;
+struct xobject *
+Type1Char(char *env, struct XYspace *S, psobj *charstrP, psobj *subrsP,
+ psobj *osubrsP,
+ struct blues_struct *bluesP, /* FontID's ptr to the blues struct */
+ int *modeP)
{
int Code;
@@ -1804,7 +1855,66 @@ struct xobject *Type1Char(env, S, charstrP, subrsP, osubrsP, bluesP, modeP)
path = NULL; /* Indicate that character could not be built */
}
}
-
+
return((struct xobject *) path);
}
-
+
+#ifdef BUILDCID
+struct xobject *
+CIDChar(char *env, struct XYspace *S,
+ psobj *charstrP, psobj *subrsP, psobj *osubrsP,
+ struct blues_struct *bluesP, /* FontID's ptr to the blues struct */
+ int *modeP)
+{
+ int Code;
+
+ path = NULL;
+ errflag = FALSE;
+
+ /* Make parameters available to all CID routines */
+ Environment = env;
+ CharSpace = S; /* used when creating path elements */
+ CharStringP = charstrP;
+ SubrsP = subrsP;
+ OtherSubrsP = osubrsP;
+ ModeP = modeP;
+
+ blues = bluesP;
+
+ /* compute the alignment zones */
+ ComputeAlignmentZones();
+
+ StartDecrypt();
+
+ ClearStack();
+ ClearPSFakeStack();
+ ClearCallStack();
+
+ InitStems();
+
+ currx = curry = 0;
+ escapementX = escapementY = 0;
+ sidebearingX = sidebearingY = 0;
+ accentoffsetX = accentoffsetY = 0;
+ wsoffsetX = wsoffsetY = 0; /* No shift to preserve whitspace. */
+ wsset = 0; /* wsoffsetX,Y haven't been set yet. */
+
+ for (;;) {
+ if (!DoRead(&Code)) break;
+ Decode(Code);
+ if (errflag) break;
+ }
+
+ FinitStems();
+
+ /* Clean up if an error has occurred */
+ if (errflag) {
+ if (path != NULL) {
+ Destroy(path); /* Reclaim storage */
+ path = NULL; /* Indicate that character could not be built */
+ }
+ }
+
+ return((struct xobject *) path);
+}
+#endif
diff --git a/src/Type1/util.c b/src/Type1/util.c
index aafe7c5..9bd8a83 100644
--- a/src/Type1/util.c
+++ b/src/Type1/util.c
@@ -27,11 +27,35 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/util.c,v 1.6 2001/01/17 19:43:24 dawes Exp $ */
/* Author: Katherine A. Hitchcock IBM Almaden Research Laboratory */
+#ifndef FONTMODULE
#include <stdio.h>
+#else
+#include "Xdefs.h"
+#include "Xmd.h"
+#include "xf86_ansic.h"
+#endif
#include "util.h"
-#include "fontmisc.h"
+#include "fontmisc.h" /* for xalloc/xfree */
static char *vm_base = NULL; /* Start of virtual memory area */
char *vm_next = NULL; /* Pointer to first free byte */
@@ -41,10 +65,18 @@ static char *vm_base = NULL; /* Start of virtual memory area */
/*
* Initialize memory.
*/
-boolean vm_init(cnt)
-int cnt;
+boolean
+vm_init(int cnt)
{
+#ifdef BUILDCID
+ if (vm_base == NULL || (vm_base != NULL && vm_size != cnt)) {
+ if (vm_base != NULL) xfree(vm_base);
+ vm_next = vm_base = (char *)xalloc (cnt);
+ } else
+ vm_next = vm_base;
+#else
vm_next = vm_base = (char *)xalloc (cnt);
+#endif
if (vm_base != NULL) {
vm_free = cnt;
@@ -56,8 +88,8 @@ int cnt;
}
-char *vm_alloc(bytes)
- int bytes;
+char *
+vm_alloc(int bytes)
{
char *answer;
@@ -79,9 +111,8 @@ char *vm_alloc(bytes)
/*
* Format an Integer object
*/
-void objFormatInteger(objP,value)
- psobj *objP;
- int value;
+void
+objFormatInteger(psobj *objP, int value)
{
if (objP != NULL) {
objP->type = OBJ_INTEGER;
@@ -93,9 +124,8 @@ void objFormatInteger(objP,value)
/*
* Format a Real object
*/
-void objFormatReal(objP,value)
- psobj *objP;
- float value;
+void
+objFormatReal(psobj *objP, float value)
{
if (objP != NULL) {
objP->type = OBJ_REAL;
@@ -107,9 +137,8 @@ void objFormatReal(objP,value)
/*
* Format a Boolean object
*/
-void objFormatBoolean(objP,value)
- psobj *objP;
- boolean value;
+void
+objFormatBoolean(psobj *objP, boolean value)
{
if (objP != NULL) {
objP->type = OBJ_BOOLEAN;
@@ -121,10 +150,8 @@ void objFormatBoolean(objP,value)
/*
* Format an Encoding object
*/
-void objFormatEncoding(objP,length,valueP)
- psobj *objP;
- int length;
- psobj *valueP;
+void
+objFormatEncoding(psobj *objP, int length, psobj *valueP)
{
if (objP != NULL) {
objP->type = OBJ_ENCODING;
@@ -136,10 +163,8 @@ void objFormatEncoding(objP,length,valueP)
/*
* Format an Array object
*/
-void objFormatArray(objP,length,valueP)
- psobj *objP;
- int length;
- psobj *valueP;
+void
+objFormatArray(psobj *objP, int length, psobj *valueP)
{
if (objP != NULL) {
objP->type = OBJ_ARRAY;
@@ -152,10 +177,8 @@ void objFormatArray(objP,length,valueP)
/*
* Format a String object
*/
-void objFormatString(objP,length,valueP)
- psobj *objP;
- int length;
- char *valueP;
+void
+objFormatString(psobj *objP, int length, char *valueP)
{
if (objP != NULL) {
objP->type = OBJ_STRING;
@@ -167,10 +190,8 @@ void objFormatString(objP,length,valueP)
/*
* Format a Name object
*/
-void objFormatName(objP,length,valueP)
- psobj *objP;
- int length;
- char *valueP;
+void
+objFormatName(psobj *objP, int length, char *valueP)
{
if (objP != NULL) {
objP->type = OBJ_NAME;
@@ -182,9 +203,8 @@ void objFormatName(objP,length,valueP)
/*
* Format a File object
*/
-void objFormatFile(objP,valueP)
- psobj *objP;
- FILE *valueP;
+void
+objFormatFile(psobj *objP, FILE *valueP)
{
if (objP != NULL) {
objP->type = OBJ_FILE;
diff --git a/src/Type1/util.h b/src/Type1/util.h
index 20c14c4..7abc289 100644
--- a/src/Type1/util.h
+++ b/src/Type1/util.h
@@ -27,6 +27,25 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
+/* Copyright (c) 1994-1999 Silicon Graphics, Inc. All Rights Reserved.
+ *
+ * The contents of this file are subject to the CID Font Code Public Licence
+ * Version 1.0 (the "License"). You may not use this file except in compliance
+ * with the Licence. You may obtain a copy of the License at Silicon Graphics,
+ * Inc., attn: Legal Services, 2011 N. Shoreline Blvd., Mountain View, CA
+ * 94043 or at http://www.sgi.com/software/opensource/cid/license.html.
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis.
+ * ALL WARRANTIES ARE DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED
+ * WARRANTIES OF MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE OR OF
+ * NON-INFRINGEMENT. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Software is CID font code that was developed by Silicon
+ * Graphics, Inc.
+ */
+/* $XFree86: xc/lib/font/Type1/util.h,v 1.5 2001/01/17 19:43:24 dawes Exp $ */
+
#ifndef UTIL_H
#define UTIL_H
@@ -61,7 +80,11 @@ typedef int boolean;
/* this is the size of memory allocated for reading fonts */
+#ifdef BUILDCID
+#define VM_SIZE (100*1024)
+#else
#define VM_SIZE (50*1024)
+#endif
/***================================================================***/
#ifndef MIN
@@ -71,11 +94,13 @@ typedef int boolean;
/***================================================================***/
/* Routines for managing virtual memory */
/***================================================================***/
-extern boolean vm_init();
+
+extern boolean vm_init ( int cnt );
extern long vm_free;
extern long vm_size;
extern char *vm_next;
-extern char *vm_alloc();
+extern char *vm_alloc ( int bytes );
+
/***================================================================***/
/* Macros for managing virtual memory */
/***================================================================***/
@@ -173,10 +198,17 @@ typedef struct ps_dict {
#define objPSetString(o) ((o)->type = OBJ_STRING)
#define objPSetName(o) ((o)->type = OBJ_NAME)
#define objPSetFile(o) ((o)->type = OBJ_FILE)
-
-/***================================================================***/
-/* Entry point for Type1Char to get entry from CharStrings */
-/***================================================================***/
-extern psobj *GetType1CharString();
-
+
+/***================================================================***/
+/* Prototypes of object formatting functions */
+/***================================================================***/
+extern void objFormatInteger ( psobj *objP, int value );
+extern void objFormatReal ( psobj *objP, float value );
+extern void objFormatBoolean ( psobj *objP, boolean value );
+extern void objFormatEncoding ( psobj *objP, int length, psobj *valueP );
+extern void objFormatArray ( psobj *objP, int length, psobj *valueP );
+extern void objFormatString ( psobj *objP, int length, char *valueP );
+extern void objFormatName ( psobj *objP, int length, char *valueP );
+extern void objFormatFile ( psobj *objP, FILE *valueP );
+
#endif