summaryrefslogtreecommitdiff
path: root/src/Type1
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:50 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:50 +0000
commit3795e9702b3b3a6fe0594d09cdd110adeb5e42f9 (patch)
treecaec4aaf13f12f0a31c15cb24ad2127eff834dd2 /src/Type1
parent153e8da44452905ae04a0e20ad0d85f40399b4ca (diff)
Initial revision
Diffstat (limited to 'src/Type1')
-rw-r--r--src/Type1/AFM.h58
-rw-r--r--src/Type1/afm.c187
-rw-r--r--src/Type1/cidchar.c617
-rw-r--r--src/Type1/range.h44
-rw-r--r--src/Type1/t1unicode.c248
-rw-r--r--src/Type1/t1unicode.h25
6 files changed, 1179 insertions, 0 deletions
diff --git a/src/Type1/AFM.h b/src/Type1/AFM.h
new file mode 100644
index 0000000..4f44b08
--- /dev/null
+++ b/src/Type1/AFM.h
@@ -0,0 +1,58 @@
+/* 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.
+ */
+#ifdef BUILDCID
+#ifndef AFM_H
+#define AFM_H
+
+/* Bounding box definition. Used for the Font BBox as well as the
+ * Character BBox.
+ */
+typedef struct
+{
+ int llx; /* lower left x-position */
+ int lly; /* lower left y-position */
+ int urx; /* upper right x-position */
+ int ury; /* upper right y-position */
+} BBox;
+
+/* Character Metric Information. This structure is used only if ALL
+ * character metric information is requested. If only the character
+ * widths is requested, then only an array of the character x-widths
+ * is returned.
+ *
+ * The key that each field is associated with is in comments. For an
+ * explanation about each key and its value please refer to the
+ * Character Metrics section of the AFM documentation (full title
+ * & version given above).
+ */
+typedef struct
+{
+ long code; /* CID code */
+ int wx; /* key: WX or W0X */
+ BBox charBBox; /* key: B */
+} Metrics;
+
+typedef struct
+{
+ int nChars; /* number of entries in char metrics array */
+ Metrics *metrics; /* ptr to char metrics array */
+} FontInfo;
+
+int CIDAFM(FILE *, FontInfo **);
+#endif /* AFM_H */
+#endif
diff --git a/src/Type1/afm.c b/src/Type1/afm.c
new file mode 100644
index 0000000..960e76f
--- /dev/null
+++ b/src/Type1/afm.c
@@ -0,0 +1,187 @@
+/* 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/afm.c,v 1.3 2001/08/27 19:49:52 dawes Exp $ */
+
+#ifdef BUILDCID
+#ifndef FONTMODULE
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#else
+#include "Xmd.h" /* For INT32 declaration */
+#include "Xdefs.h" /* For Bool */
+#include "xf86_ansic.h"
+#endif
+#include "fontmisc.h" /* for xalloc/xfree */
+#include "AFM.h"
+
+#define PBUF 256
+#define KBUF 20
+
+char *gettoken(FILE *);
+
+static char *afmbuf = NULL;
+
+char *gettoken(FILE *fd) {
+ char *bp;
+ int c, found;
+
+ bp = afmbuf;
+ found = 0;
+
+ while((c = getc(fd)) != EOF) {
+ if (found == 0 && (c == ' ' || c == '\t' || c == '\n' || c == '\r' ||
+ c == ';' || c == ',')) continue;
+ found = 1;
+ if (c != ' ' && c != '\t' && c != '\n' && c != '\r' && c != ';') {
+ *bp++ = c;
+ if (bp - afmbuf >= PBUF) {
+ bp = afmbuf;
+ break;
+ }
+ } else
+ break;
+ }
+
+ *bp = 0;
+ return(afmbuf);
+}
+
+int CIDAFM(FILE *fd, FontInfo **pfi) {
+ char *p = 0;
+ int i, j, k = 0, found = 0;
+ FontInfo *fi;
+
+ if (fd == NULL || pfi == NULL) return(1);
+
+ *pfi = NULL;
+
+ if ((afmbuf = (char *)xalloc(PBUF)) == NULL)
+ return(1);
+
+ while(1) {
+ if (!(p = gettoken(fd))) {
+ xfree(afmbuf);
+ return(1);
+ }
+
+ if (strncmp(p, "StartFontMetrics", 16) == 0) {
+ if (!(p = gettoken(fd))) {
+ xfree(afmbuf);
+ return(1);
+ }
+ if (strncmp(p, "4", 1) < 0) {
+ free(afmbuf);
+ return(1);
+ }
+ found = 1;
+ } else if (strncmp(p, "StartCharMetrics", 16) == 0) {
+ if (!found) {
+ xfree(afmbuf);
+ return(1);
+ }
+
+ if (!(p = gettoken(fd))) {
+ xfree(afmbuf);
+ return(1);
+ }
+
+ fi = (FontInfo *)xalloc(sizeof(FontInfo));
+
+ if (fi == NULL) {
+ xfree(afmbuf);
+ return(1);
+ }
+ bzero(fi, sizeof(FontInfo));
+
+ fi->nChars = atoi(p);
+
+ fi->metrics = (Metrics *)xalloc(fi->nChars *
+ sizeof(Metrics));
+ if (fi->metrics == NULL) {
+ xfree(afmbuf);
+ xfree(fi);
+ return(1);
+ }
+
+ j = 0;
+ for (i = 0; i < fi->nChars; i++) {
+ k = 0;
+ while(1) {
+ if (!(p = gettoken(fd))) {
+ k = KBUF;
+ break;
+ }
+ if (strncmp(p, "W0X", 3) == 0) {
+ if (!(p = gettoken(fd))) {
+ k = KBUF;
+ break;
+ }
+ fi->metrics[j].wx = atoi(p);
+ } else if (strncmp(p, "N", 1) == 0) {
+ if (!(p = gettoken(fd))) {
+ k = KBUF;
+ break;
+ }
+ fi->metrics[j].code = (long)atoi(p);
+ } else if (strncmp(p, "B", 1) == 0) {
+ if (!(p = gettoken(fd))) {
+ k = KBUF;
+ break;
+ }
+ fi->metrics[j].charBBox.llx = atoi(p);
+ if (!(p = gettoken(fd))) {
+ k = KBUF;
+ break;
+ }
+ fi->metrics[j].charBBox.lly = atoi(p);
+ if (!(p = gettoken(fd))) {
+ k = KBUF;
+ break;
+ }
+ fi->metrics[j].charBBox.urx = atoi(p);
+ if (!(p = gettoken(fd))) {
+ k = KBUF;
+ break;
+ }
+ fi->metrics[j].charBBox.ury = atoi(p);
+ j++;
+ break;
+ }
+ k++;
+ if (k >= KBUF) break;
+ }
+ if (k >= KBUF) break;
+ }
+ if (k >= KBUF || j != fi->nChars) {
+ xfree(fi->metrics);
+ xfree(fi);
+ xfree(afmbuf);
+ return(1);
+ } else {
+ *pfi = fi;
+ xfree(afmbuf);
+ return(0);
+ }
+ }
+ }
+
+ xfree(afmbuf);
+ return(1);
+}
+#endif
diff --git a/src/Type1/cidchar.c b/src/Type1/cidchar.c
new file mode 100644
index 0000000..e70d371
--- /dev/null
+++ b/src/Type1/cidchar.c
@@ -0,0 +1,617 @@
+/* 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/cidchar.c,v 1.9 2001/10/28 03:32:44 tsi Exp $ */
+
+#ifdef BUILDCID
+#ifndef FONTMODULE
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#ifdef USE_MMAP
+#include <sys/mman.h>
+#ifndef MAP_FAILED
+#define MAP_FAILED ((caddr_t)(-1))
+#endif
+#endif
+#else
+#include "Xmd.h" /* For INT32 declaration */
+#include "Xdefs.h" /* For Bool */
+#include "xf86_ansic.h"
+#endif
+#ifndef FONTMODULE
+#ifdef _XOPEN_SOURCE
+#include <math.h>
+#else
+#define _XOPEN_SOURCE
+#include <math.h>
+#undef _XOPEN_SOURCE
+#endif
+#endif
+#include "fntfilst.h"
+#include "objects.h"
+#include "spaces.h"
+#include "range.h"
+#include "util.h"
+#include "fontfcn.h"
+#include "blues.h"
+#include "AFM.h"
+#include "t1intf.h"
+
+#define BSIZE 4096
+
+extern cidfont *CIDFontP;
+extern psfont *FDArrayP;
+extern psfont *FontP;
+
+static unsigned char sd[] = "StartData";
+
+CharInfoPtr
+CIDGetGlyphInfo(FontPtr pFont, unsigned int cidcode, CharInfoPtr pci, int *rc)
+{
+ CharInfoPtr cp = NULL;
+#ifdef USE_MMAP
+ int fd;
+ unsigned char *buf;
+ long total_len = 0;
+#else
+ FILE *fp;
+ unsigned char buf[BSIZE];
+ unsigned int count = 0;
+#endif
+ cidglyphs *cid;
+ unsigned char *p1 = NULL;
+#ifndef USE_MMAP
+ unsigned char *p2;
+#endif
+ register int i = 0, j;
+ long byteoffset;
+ int FDindex, FDBytes, GDBytes, SDBytes, SubrCount, CIDMapOffset, len;
+ psobj *arrayP;
+ psobj charstring;
+ long *subroffsets = NULL, cstringoffset, nextcstringoffset;
+ struct blues_struct *blues;
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+#ifdef USE_MMAP
+ if (!cid->CIDdata) {
+ if (!(fd = open(cid->CIDFontName, O_RDONLY, 0))) {
+ *rc = BadFontName;
+ return(cp);
+ }
+ cid->CIDsize = lseek(fd, 0, SEEK_END);
+ cid->CIDdata = (unsigned char *)
+ mmap(0, (size_t)cid->CIDsize, PROT_READ, MAP_SHARED, fd, 0);
+ close(fd);
+ if (cid->CIDdata == (unsigned char *)MAP_FAILED) {
+ *rc = AllocError;
+ cid->CIDdata = NULL;
+ return (cp);
+ }
+ }
+#else
+ if (!(fp = fopen(cid->CIDFontName,"rb"))) {
+ *rc = BadFontName;
+ return(cp);
+ }
+#endif
+
+#ifdef USE_MMAP
+ if (cid->dataoffset == 0) {
+ if ((p1 = (unsigned char *)strstr((char *)cid->CIDdata, (char *)sd))
+ != NULL) {
+ cid->dataoffset = (p1 - cid->CIDdata) + strlen((char *)sd);
+ }
+ else {
+ *rc = BadFontFormat;
+ return(cp);
+ }
+ }
+#else /* USE_MMAP */
+ if (cid->dataoffset == 0) {
+ p2 = sd;
+
+ /* find "StartData" */
+ while (*p2) {
+ cid->dataoffset += count;
+ if ((count = fread(buf, 1, BSIZE, fp)) == 0)
+ break;
+ p1 = buf;
+ for (i=0; i < count && *p2; i++) {
+ if (*p1 == *p2)
+ p2++;
+ else {
+ p2 = sd;
+ if (*p1 == *p2)
+ p2++;
+ }
+ p1++;
+ }
+ }
+
+ /* if "StartData" not found, or end of file */
+ if (*p2 || count == 0) {
+ *rc = BadFontFormat;
+ fclose(fp);
+ return(cp);
+ }
+
+ if (i >= count) {
+ cid->dataoffset += count;
+ count = fread(buf, 1, BSIZE, fp);
+ p1 = buf;
+ } else {
+ cid->dataoffset += p1 - buf;
+ count = count - (p1 - buf);
+ }
+ } else {
+ if (fseek(fp, cid->dataoffset, SEEK_SET)) {
+ *rc = BadFontFormat;
+ fclose(fp);
+ return(cp);
+ }
+ if ((count = fread(buf, 1, BSIZE, fp)) == 0) {
+ *rc = BadFontFormat;
+ fclose(fp);
+ return(cp);
+ }
+ p1 = buf;
+ }
+
+ /* if "StartData" not found, or "Binary" data and the next character */
+ /* is not the space character (0x20) */
+
+ if (count == 0 || (CIDFontP->binarydata && (*p1 != ' '))) {
+ *rc = BadFontFormat;
+ fclose(fp);
+ return(cp);
+ }
+#endif /* USE_MMAP */
+
+ FDBytes = CIDFontP->CIDfontInfoP[CIDFDBYTES].value.data.integer;
+ GDBytes = CIDFontP->CIDfontInfoP[CIDGDBYTES].value.data.integer;
+ CIDMapOffset = CIDFontP->CIDfontInfoP[CIDMAPOFFSET].value.data.integer;
+ byteoffset = cid->dataoffset + 1 + CIDMapOffset +
+ cidcode * (FDBytes + GDBytes);
+#ifdef USE_MMAP
+ buf = &cid->CIDdata[byteoffset];
+#else
+ if (fseek(fp, byteoffset, SEEK_SET)) {
+ *rc = BadFontFormat;
+ fclose(fp);
+ return(cp);
+ }
+ if ((count = fread(buf, 1, BSIZE, fp)) < 2*(FDBytes + GDBytes)) {
+ *rc = BadFontFormat;
+ fclose(fp);
+ return(cp);
+ }
+#endif
+
+ /* if FDBytes is equal to 0, the CIDMap contains no FD indices, and the */
+ /* FD index of 0 is assumed. */
+ if (FDBytes == 0)
+ FDindex = 0;
+ else {
+ FDindex = 0;
+ for (i = 0; i < FDBytes; i++)
+ FDindex += (unsigned char)buf[i] << (8 * (FDBytes - 1 - i));
+ }
+
+ if (FDindex >= CIDFontP->CIDfontInfoP[CIDFDARRAY].value.len) {
+ *rc = BadFontFormat;
+#ifndef USE_MMAP
+ fclose(fp);
+#endif
+ return(cp);
+ }
+
+ cstringoffset = 0;
+ for (i = 0; i < GDBytes; i++)
+ cstringoffset += (unsigned char)buf[FDBytes + i] <<
+ (8 * (GDBytes - 1 - i));
+
+ nextcstringoffset = 0;
+ for (i = 0; i < GDBytes; i++)
+ nextcstringoffset += (unsigned char)buf[2*FDBytes + GDBytes + i] <<
+ (8 * (GDBytes - 1 - i));
+
+ len = nextcstringoffset - cstringoffset;
+
+ if (len <= 0) { /* empty interval, missing glyph */
+ *rc = BadFontFormat;
+#ifndef USE_MMAP
+ fclose(fp);
+#endif
+ return(cp);
+ }
+
+ FontP = &FDArrayP[FDindex];
+
+ charstring.type = OBJ_INTEGER;
+ charstring.len = len;
+
+#ifndef USE_MMAP
+ if (!(charstring.data.stringP = (unsigned char *)xalloc(len))) {
+ *rc = AllocError;
+ fclose(fp);
+ return(cp);
+ }
+#endif
+
+ byteoffset = cid->dataoffset + 1 + cstringoffset;
+
+#ifdef USE_MMAP
+ charstring.data.stringP = &cid->CIDdata[byteoffset];
+#else
+ if (fseek(fp, byteoffset, SEEK_SET)) {
+ *rc = BadFontFormat;
+ xfree(charstring.data.stringP);
+ fclose(fp);
+ return(cp);
+ }
+
+ if ((count = fread(charstring.data.stringP, 1, len, fp)) != len) {
+ *rc = BadFontFormat;
+ xfree(charstring.data.stringP);
+ fclose(fp);
+ return(cp);
+ }
+#endif
+
+ if (FontP->Subrs.data.arrayP == NULL) {
+ /* get subroutine data */
+ byteoffset = cid->dataoffset + 1 +
+ FDArrayP[FDindex].Private[CIDT1SUBMAPOFF].value.data.integer;
+
+ SDBytes = FDArrayP[FDindex].Private[CIDT1SDBYTES].value.data.integer;
+
+ SubrCount = FDArrayP[FDindex].Private[CIDT1SUBRCNT].value.data.integer;
+#ifdef USE_MMAP
+ buf = &cid->CIDdata[byteoffset];
+#else
+ if (fseek(fp, byteoffset, SEEK_SET)) {
+ *rc = BadFontFormat;
+ fclose(fp);
+ return(cp);
+ }
+
+ if ((count = fread(buf, 1, BSIZE, fp)) < SDBytes * (SubrCount + 1)) {
+ *rc = BadFontFormat;
+ fclose(fp);
+ return(cp);
+ }
+#endif
+
+ arrayP = (psobj *)vm_alloc(SubrCount*sizeof(psobj));
+ if (!arrayP) {
+ *rc = AllocError;
+#ifndef USE_MMAP
+ fclose(fp);
+#endif
+ return(cp);
+ }
+
+ if (!(subroffsets = (long *)xalloc((SubrCount + 1)*sizeof(long)))) {
+ *rc = AllocError;
+#ifndef USE_MMAP
+ fclose(fp);
+#endif
+ return(cp);
+ }
+
+ for (i = 0; i <= SubrCount; i++) {
+ subroffsets[i] = 0;
+ for (j = 0; j < SDBytes; j++)
+ subroffsets[i] += (unsigned char)buf[i * SDBytes + j] <<
+ (8 * (SDBytes - 1 - j));
+ }
+
+ byteoffset = cid->dataoffset + 1 + subroffsets[0];
+
+ /* get subroutine info */
+#ifndef USE_MMAP
+ if (fseek(fp, byteoffset, SEEK_SET)) {
+ *rc = BadFontFormat;
+ xfree(subroffsets);
+ fclose(fp);
+ return(cp);
+ }
+#else
+ total_len = byteoffset;
+#endif
+ for (i = 0; i < SubrCount; i++) {
+ len = subroffsets[i + 1] - subroffsets[i];
+#ifndef USE_MMAP
+ arrayP[i].data.valueP = vm_alloc(len);
+ if (!arrayP[i].data.valueP) {
+ *rc = AllocError;
+ xfree(subroffsets);
+ fclose(fp);
+ return(cp);
+ }
+#endif
+ arrayP[i].len = len;
+#ifdef USE_MMAP
+ arrayP[i].data.valueP = (char *)&cid->CIDdata[total_len];
+ total_len += len;
+#else
+ if ((count = fread(arrayP[i].data.valueP, 1, len, fp)) != len) {
+ *rc = BadFontFormat;
+ xfree(subroffsets);
+ fclose(fp);
+ return(cp);
+ }
+#endif
+ }
+
+ FontP->Subrs.len = SubrCount;
+ FontP->Subrs.data.arrayP = arrayP;
+ xfree(subroffsets);
+ }
+
+ if (FontP->BluesP == NULL) {
+ blues = (struct blues_struct *) vm_alloc(sizeof(struct blues_struct));
+ if (!blues) {
+ *rc = AllocError;
+#ifndef USE_MMAP
+ xfree(subroffsets);
+ fclose(fp);
+#endif
+ return(cp);
+ }
+ bzero(blues, sizeof(struct blues_struct));
+ blues->numBlueValues =
+ FDArrayP[FDindex].Private[CIDT1BLUEVALUES].value.len;
+ for (i = 0; i < blues->numBlueValues; i++)
+ blues->BlueValues[i] =
+ FDArrayP[FDindex].Private[CIDT1BLUEVALUES].value.data.arrayP[i].data.integer;
+ blues->numOtherBlues =
+ FDArrayP[FDindex].Private[CIDT1OTHERBLUES].value.len;
+ for (i = 0; i < blues->numOtherBlues; i++)
+ blues->OtherBlues[i] =
+ FDArrayP[FDindex].Private[CIDT1OTHERBLUES].value.data.arrayP[i].data.integer;
+ blues->numFamilyBlues =
+ FDArrayP[FDindex].Private[CIDT1FAMBLUES].value.len;
+ for (i = 0; i < blues->numFamilyBlues; i++)
+ blues->FamilyBlues[i] =
+ FDArrayP[FDindex].Private[CIDT1FAMBLUES].value.data.arrayP[i].data.integer;
+ blues->numFamilyOtherBlues =
+ FDArrayP[FDindex].Private[CIDT1FAMOTHERBLUES].value.len;
+ for (i = 0; i < blues->numFamilyOtherBlues; i++)
+ blues->FamilyOtherBlues[i] =
+ FDArrayP[FDindex].Private[CIDT1FAMOTHERBLUES].value.data.arrayP[i].data.integer;
+ blues->BlueScale = FDArrayP[FDindex].Private[CIDT1BLUESCALE].value.data.real;
+ blues->BlueShift = FDArrayP[FDindex].Private[CIDT1BLUESHIFT].value.data.integer;
+ blues->BlueFuzz = FDArrayP[FDindex].Private[CIDT1BLUEFUZZ].value.data.integer;
+ blues->StdHW = (double)FDArrayP[FDindex].Private[CIDT1STDHW].value.data.arrayP[0].data.integer;
+ blues->StdVW = (double)FDArrayP[FDindex].Private[CIDT1STDVW].value.data.arrayP[0].data.integer;
+
+ blues->numStemSnapH =
+ FDArrayP[FDindex].Private[CIDT1STEMSNAPH].value.len;
+ for (i = 0; i < blues->numStemSnapH; i++)
+ blues->StemSnapH[i] =
+ FDArrayP[FDindex].Private[CIDT1STEMSNAPH].value.data.arrayP[i].data.integer;
+ blues->numStemSnapV =
+ FDArrayP[FDindex].Private[CIDT1STEMSNAPV].value.len;
+ for (i = 0; i < blues->numStemSnapV; i++)
+ blues->StemSnapV[i] =
+ FDArrayP[FDindex].Private[CIDT1STEMSNAPV].value.data.arrayP[i].data.integer;
+ blues->ForceBold =
+ FDArrayP[FDindex].Private[CIDT1FORCEBOLD].value.data.boolean;
+
+ blues->LanguageGroup =
+ FDArrayP[FDindex].Private[CIDT1LANGGROUP].value.data.integer;
+
+ blues->RndStemUp =
+ FDArrayP[FDindex].Private[CIDT1RNDSTEMUP].value.data.boolean;
+
+ blues->lenIV =
+ FDArrayP[FDindex].Private[CIDT1LENIV].value.data.integer;
+
+ blues->ExpansionFactor =
+ FDArrayP[FDindex].Private[CIDT1EXPFACTOR].value.data.real;
+
+ FontP->BluesP = blues;
+ }
+
+ cp = CIDRenderGlyph(pFont, &charstring, &FontP->Subrs, FontP->BluesP, pci, rc);
+
+#ifndef USE_MMAP
+ xfree(charstring.data.stringP);
+
+ fclose(fp);
+#endif
+ return(cp);
+}
+
+static int
+node_compare(const void *node1, const void *node2)
+{
+ return (((Metrics *)node1)->code - ((Metrics *)node2)->code);
+}
+
+static CharInfoRec *
+CIDGetCharMetrics(FontPtr pFont, FontInfo *fi, unsigned int charcode, double sxmult)
+{
+ CharInfoPtr cp;
+ Metrics *p, node;
+ unsigned int cidcode;
+
+ cidcode = node.code = getCID(pFont, charcode);
+ if ((cidcode < fi->nChars) && (cidcode == fi->metrics[cidcode].code))
+ p = &fi->metrics[cidcode];
+ else
+ p = (Metrics *)bsearch(&node, fi->metrics, fi->nChars, sizeof(Metrics), node_compare);
+
+ if (!p)
+ p = &fi->metrics[0];
+
+ if (!(cp = (CharInfoRec *)Xalloc(sizeof(CharInfoRec))))
+ return NULL;
+ bzero(cp, sizeof(CharInfoRec));
+
+ /* indicate that character bitmap is not defined */
+ cp->bits = (char *)CID_BITMAP_UNDEFINED;
+
+
+ /* get metric data for this CID code from the CID AFM file */
+ cp->metrics.leftSideBearing =
+ floor(p->charBBox.llx / sxmult + 0.5);
+ cp->metrics.rightSideBearing =
+ floor(p->charBBox.urx / sxmult + 0.5);
+ cp->metrics.characterWidth = floor(p->wx / sxmult + 0.5);
+ cp->metrics.ascent = floor(p->charBBox.ury / sxmult + 0.5);
+ cp->metrics.descent = -floor(p->charBBox.lly / sxmult + 0.5);
+
+ cp->metrics.attributes = p->wx;
+
+ return cp;
+}
+
+int
+CIDGetAFM(FontPtr pFont, unsigned long count, unsigned char *chars, FontEncoding charEncoding, unsigned long *glyphCount, CharInfoPtr *glyphs, char *cidafmfile)
+{
+ int rc;
+ FILE *fp;
+ FontInfo *fi = NULL;
+ cidglyphs *cid;
+ CharInfoPtr *glyphsBase;
+ register unsigned int c;
+
+ register CharInfoPtr pci;
+ CharInfoPtr pDefault;
+ unsigned int firstRow, firstCol, numRows, code, char_row, char_col;
+ double sxmult;
+
+ cid = (cidglyphs *)pFont->fontPrivate;
+
+ if (cid->AFMinfo == NULL) {
+ if (!(fp = fopen(cidafmfile, "rb")))
+ return(BadFontName);
+
+ if ((rc = CIDAFM(fp, &fi)) != 0) {
+ fprintf(stderr,
+ "There is something wrong with Adobe Font Metric file %s.\n",
+ cidafmfile);
+ fclose(fp);
+ return(BadFontName);
+ }
+ fclose(fp);
+ cid->AFMinfo = fi;
+ }
+ fi = cid->AFMinfo;
+
+ firstCol = pFont->info.firstCol;
+ pDefault = cid->pDefault;
+ glyphsBase = glyphs;
+
+ /* multiplier for computation of raw values */
+ sxmult = hypot(cid->pixel_matrix[0], cid->pixel_matrix[1]);
+ if (sxmult > EPS) sxmult = 1000.0 / sxmult;
+ if (sxmult == 0.0) return(0);
+
+ 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]))
+ pci = CIDGetCharMetrics(pFont, fi, c, sxmult);
+ if (pci && EXIST(pci)) {
+ *glyphs++ = pci;
+ cid->glyphs[code] = pci;
+ }
+ } 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]))
+ pci = CIDGetCharMetrics(pFont, fi, c, sxmult);
+ 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]))
+ pci = CIDGetCharMetrics(pFont, fi, c, sxmult);
+ 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;
+
+#undef EXIST
+
+ return Successful;
+
+}
+#endif
diff --git a/src/Type1/range.h b/src/Type1/range.h
new file mode 100644
index 0000000..c611e72
--- /dev/null
+++ b/src/Type1/range.h
@@ -0,0 +1,44 @@
+/* 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.
+ */
+#ifdef BUILDCID
+#define CID_NAME_MAX 255 /* max # of characters in a file name */
+#define CID_PATH_MAX 1024 /* max # of characters in a path name */
+
+typedef struct spacerange_code {
+ unsigned int srcCodeLo;
+ unsigned int srcCodeHi;
+} spacerangecode;
+
+typedef struct space_range {
+ struct space_range *next;
+ int rangecnt;
+ struct spacerange_code *spacecode;
+} spacerange;
+
+typedef struct cidrange_code {
+ unsigned int srcCodeLo;
+ unsigned int srcCodeHi;
+ unsigned int dstCIDLo;
+} cidrangecode;
+
+typedef struct cid_range {
+ struct cid_range *next;
+ int rangecnt;
+ struct cidrange_code *range;
+} cidrange;
+#endif
diff --git a/src/Type1/t1unicode.c b/src/Type1/t1unicode.c
new file mode 100644
index 0000000..c6b1cd9
--- /dev/null
+++ b/src/Type1/t1unicode.c
@@ -0,0 +1,248 @@
+/*
+Copyright (c) 1998 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/* $XFree86: xc/lib/font/Type1/t1unicode.c,v 1.1 1999/01/31 04:59:30 dawes Exp $ */
+
+#include "t1unicode.h"
+
+static char* table_32[] =
+{ "space", "exclam", "quotedbl", "numbersign", "dollar", "percent",
+ "ampersand", "quotesingle", "parenleft", "parenright", "asterisk",
+ "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two",
+ "three", "four", "five", "six", "seven", "eight", "nine", "colon",
+ "semicolon", "less", "equal", "greater", "question", "at", "A", "B",
+ "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P",
+ "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft",
+ "backslash", "bracketright", "asciicircum", "underscore", "grave",
+ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
+ "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
+ "braceleft", "bar", "braceright", "asciitilde", 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, "space", "exclamdown", "cent", "sterling", "currency", "yen",
+ "brokenbar", "section", "dieresis", "copyright", "ordfeminine",
+ "guillemotleft", "logicalnot", "hyphen", "registered", "macron",
+ "degree", "plusminus", "twosuperior", "threesuperior", "acute", "mu",
+ "paragraph", "periodcentered", "cedilla", "onesuperior",
+ "ordmasculine", "guillemotright", "onequarter", "onehalf",
+ "threequarters", "questiondown", "Agrave", "Aacute", "Acircumflex",
+ "Atilde", "Adieresis", "Aring", "AE", "Ccedilla", "Egrave", "Eacute",
+ "Ecircumflex", "Edieresis", "Igrave", "Iacute", "Icircumflex",
+ "Idieresis", "Eth", "Ntilde", "Ograve", "Oacute", "Ocircumflex",
+ "Otilde", "Odieresis", "multiply", "Oslash", "Ugrave", "Uacute",
+ "Ucircumflex", "Udieresis", "Yacute", "Thorn", "germandbls", "agrave",
+ "aacute", "acircumflex", "atilde", "adieresis", "aring", "ae",
+ "ccedilla", "egrave", "eacute", "ecircumflex", "edieresis", "igrave",
+ "iacute", "icircumflex", "idieresis", "eth", "ntilde", "ograve",
+ "oacute", "ocircumflex", "otilde", "odieresis", "divide", "oslash",
+ "ugrave", "uacute", "ucircumflex", "udieresis", "yacute", "thorn",
+ "ydieresis", "Amacron", "amacron", "Abreve", "abreve", "Aogonek",
+ "aogonek", "Cacute", "cacute", "Ccircumflex", "ccircumflex",
+ "Cdotaccent", "cdotaccent", "Ccaron", "ccaron", "Dcaron", "dcaron",
+ "Dcroat", "dcroat", "Emacron", "emacron", "Ebreve", "ebreve",
+ "Edotaccent", "edotaccent", "Eogonek", "eogonek", "Ecaron", "ecaron",
+ "Gcircumflex", "gcircumflex", "Gbreve", "gbreve", "Gdotaccent",
+ "gdotaccent", "Gcommaaccent", "gcommaaccent", "Hcircumflex",
+ "hcircumflex", "Hbar", "hbar", "Itilde", "itilde", "Imacron",
+ "imacron", "Ibreve", "ibreve", "Iogonek", "iogonek", "Idotaccent",
+ "dotlessi", "IJ", "ij", "Jcircumflex", "jcircumflex", "Kcommaaccent",
+ "kcommaaccent", "kgreenlandic", "Lacute", "lacute", "Lcommaaccent",
+ "lcommaaccent", "Lcaron", "lcaron", "Ldot", "ldot", "Lslash",
+ "lslash", "Nacute", "nacute", "Ncommaaccent", "ncommaaccent",
+ "Ncaron", "ncaron", "napostrophe", "Eng", "eng", "Omacron", "omacron",
+ "Obreve", "obreve", "Ohungarumlaut", "ohungarumlaut", "OE", "oe",
+ "Racute", "racute", "Rcommaaccent", "rcommaaccent", "Rcaron",
+ "rcaron", "Sacute", "sacute", "Scircumflex", "scircumflex",
+ "Scommaaccent", "scommaaccent", "Scaron", "scaron", "Tcommaaccent",
+ "tcommaaccent", "Tcaron", "tcaron", "Tbar", "tbar", "Utilde",
+ "utilde", "Umacron", "umacron", "Ubreve", "ubreve", "Uring", "uring",
+ "Uhungarumlaut", "uhungarumlaut", "Uogonek", "uogonek", "Wcircumflex",
+ "wcircumflex", "Ycircumflex", "ycircumflex", "Ydieresis", "Zacute",
+ "zacute", "Zdotaccent", "zdotaccent", "Zcaron", "zcaron", "longs", 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "florin", 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Ohorn", "ohorn", 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, "Uhorn", "uhorn", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Gcaron",
+ "gcaron", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ "Aringacute", "aringacute", "AEacute", "aeacute", "Oslashacute",
+ "oslashacute", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii57929", "afii64937", 0, 0, 0, 0, 0, 0,
+ 0, 0, "circumflex", "caron", 0, "macron", 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, "breve", "dotaccent", "ring", "ogonek", "tilde",
+ "hungarumlaut", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "gravecomb",
+ "acutecomb", 0, "tildecomb", 0, 0, 0, 0, 0, "hookabovecomb", 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ "dotbelowcomb", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, "tonos", "dieresistonos", "Alphatonos",
+ "anoteleia", "Epsilontonos", "Etatonos", "Iotatonos", 0,
+ "Omicrontonos", 0, "Upsilontonos", "Omegatonos", "iotadieresistonos",
+ "Alpha", "Beta", "Gamma", "Delta", "Epsilon", "Zeta", "Eta", "Theta",
+ "Iota", "Kappa", "Lambda", "Mu", "Nu", "Xi", "Omicron", "Pi", "Rho",
+ 0, "Sigma", "Tau", "Upsilon", "Phi", "Chi", "Psi", "Omega",
+ "Iotadieresis", "Upsilondieresis", "alphatonos", "epsilontonos",
+ "etatonos", "iotatonos", "upsilondieresistonos", "alpha", "beta",
+ "gamma", "delta", "epsilon", "zeta", "eta", "theta", "iota", "kappa",
+ "lambda", "mu", "nu", "xi", "omicron", "pi", "rho", "sigma1", "sigma",
+ "tau", "upsilon", "phi", "chi", "psi", "omega", "iotadieresis",
+ "upsilondieresis", "omicrontonos", "upsilontonos", "omegatonos", 0, 0,
+ "theta1", "Upsilon1", 0, 0, "phi1", "omega1", 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii10023", "afii10051",
+ "afii10052", "afii10053", "afii10054", "afii10055", "afii10056",
+ "afii10057", "afii10058", "afii10059", "afii10060", "afii10061", 0,
+ "afii10062", "afii10145", "afii10017", "afii10018", "afii10019",
+ "afii10020", "afii10021", "afii10022", "afii10024", "afii10025",
+ "afii10026", "afii10027", "afii10028", "afii10029", "afii10030",
+ "afii10031", "afii10032", "afii10033", "afii10034", "afii10035",
+ "afii10036", "afii10037", "afii10038", "afii10039", "afii10040",
+ "afii10041", "afii10042", "afii10043", "afii10044", "afii10045",
+ "afii10046", "afii10047", "afii10048", "afii10049", "afii10065",
+ "afii10066", "afii10067", "afii10068", "afii10069", "afii10070",
+ "afii10072", "afii10073", "afii10074", "afii10075", "afii10076",
+ "afii10077", "afii10078", "afii10079", "afii10080", "afii10081",
+ "afii10082", "afii10083", "afii10084", "afii10085", "afii10086",
+ "afii10087", "afii10088", "afii10089", "afii10090", "afii10091",
+ "afii10092", "afii10093", "afii10094", "afii10095", "afii10096",
+ "afii10097", 0, "afii10071", "afii10099", "afii10100", "afii10101",
+ "afii10102", "afii10103", "afii10104", "afii10105", "afii10106",
+ "afii10107", "afii10108", "afii10109", 0, "afii10110", "afii10193", 0,
+ 0, "afii10146", "afii10194", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ "afii10147", "afii10195", "afii10148", "afii10196", 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ "afii10050", "afii10098", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii10846", 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ "afii57799", "afii57801", "afii57800", "afii57802", "afii57793",
+ "afii57794", "afii57795", "afii57798", "afii57797", "afii57806", 0,
+ "afii57796", "afii57807", "afii57839", "afii57645", "afii57841",
+ "afii57842", "afii57804", "afii57803", "afii57658", 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, "afii57664", "afii57665", "afii57666", "afii57667",
+ "afii57668", "afii57669", "afii57670", "afii57671", "afii57672",
+ "afii57673", "afii57674", "afii57675", "afii57676", "afii57677",
+ "afii57678", "afii57679", "afii57680", "afii57681", "afii57682",
+ "afii57683", "afii57684", "afii57685", "afii57686", "afii57687",
+ "afii57688", "afii57689", "afii57690", 0, 0, 0, 0, 0, "afii57716",
+ "afii57717", "afii57718", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii57388", 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, "afii57403", 0, 0, 0, "afii57407", 0, "afii57409",
+ "afii57410", "afii57411", "afii57412", "afii57413", "afii57414",
+ "afii57415", "afii57416", "afii57417", "afii57418", "afii57419",
+ "afii57420", "afii57421", "afii57422", "afii57423", "afii57424",
+ "afii57425", "afii57426", "afii57427", "afii57428", "afii57429",
+ "afii57430", "afii57431", "afii57432", "afii57433", "afii57434", 0, 0,
+ 0, 0, 0, "afii57440", "afii57441", "afii57442", "afii57443",
+ "afii57444", "afii57445", "afii57446", "afii57470", "afii57448",
+ "afii57449", "afii57450", "afii57451", "afii57452", "afii57453",
+ "afii57454", "afii57455", "afii57456", "afii57457", "afii57458", 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii57392", "afii57393",
+ "afii57394", "afii57395", "afii57396", "afii57397", "afii57398",
+ "afii57399", "afii57400", "afii57401", "afii57381", 0, 0, "afii63167",
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii57511", 0, 0, 0, 0, "afii57506",
+ 0, 0, 0, 0, 0, 0, 0, "afii57507", 0, "afii57512", 0, 0, 0, 0, 0, 0, 0,
+ 0, "afii57513", 0, 0, 0, 0, 0, 0, "afii57508", 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, "afii57505", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii57509", 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, "afii57514", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii57519", 0, 0, "afii57534", 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+static char* table_2000[] = /* general punctuation, s*scripts, currency */
+{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii61664", "afii301", "afii299",
+ "afii300", 0, 0, "figuredash", "endash", "emdash", "afii00208", 0,
+ "underscoredbl", "quoteleft", "quoteright", "quotesinglbase",
+ "quotereversed", "quotedblleft", "quotedblright", "quotedblbase", 0,
+ "dagger", "daggerdbl", "bullet", 0, "onedotenleader",
+ "twodotenleader", "ellipsis", 0, 0, 0, 0, 0, "afii61573", "afii61574",
+ "afii61575", 0, "perthousand", 0, "minute", "second", 0, 0, 0, 0, 0,
+ "guilsinglleft", "guilsinglright", 0, "exclamdbl", 0, 0, 0, 0, 0, 0,
+ 0, "fraction", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, "zerosuperior", 0, 0, 0, "foursuperior", "fivesuperior",
+ "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", 0, 0,
+ 0, "parenleftsuperior", "parenrightsuperior", "nsuperior",
+ "zeroinferior", "oneinferior", "twoinferior", "threeinferior",
+ "fourinferior", "fiveinferior", "sixinferior", "seveninferior",
+ "eightinferior", "nineinferior", 0, 0, 0, "parenleftinferior",
+ "parenrightinferior", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, "colonmonetary", 0, "franc", "lira", 0, 0, "peseta", 0, 0,
+ "afii57636", "dong", "Euro", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+static char* table_2500[]= /* line and box drawing */
+{ "SF100000", 0, "SF110000", 0, 0, 0, 0, 0, 0, 0, 0, 0, "SF010000", 0,
+ 0, 0, "SF030000", 0, 0, 0, "SF020000", 0, 0, 0, "SF040000", 0, 0, 0,
+ "SF080000", 0, 0, 0, 0, 0, 0, 0, "SF090000", 0, 0, 0, 0, 0, 0, 0,
+ "SF060000", 0, 0, 0, 0, 0, 0, 0, "SF070000", 0, 0, 0, 0, 0, 0, 0,
+ "SF050000", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ "SF430000", "SF240000", "SF510000", "SF520000", "SF390000",
+ "SF220000", "SF210000", "SF250000", "SF500000", "SF490000",
+ "SF380000", "SF280000", "SF270000", "SF260000", "SF360000",
+ "SF370000", "SF420000", "SF190000", "SF200000", "SF230000",
+ "SF470000", "SF480000", "SF410000", "SF450000", "SF460000",
+ "SF400000", "SF540000", "SF530000", "SF440000", 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "upblock", 0, 0, 0, "dnblock", 0,
+ 0, 0, "block", 0, 0, 0, "lfblock", 0, 0, 0, "rtblock", "ltshade",
+ "shade", "dkshade", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+static char* table_FB00[] = /* alphabetic presentation forms */
+{ "ff", "fi", "fl", "ffi", "ffl", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "afii57705", 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, "afii57694", "afii57695", 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ "afii57723", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, "afii57700", 0, 0, 0, 0 };
+
+char*
+unicodetoPSname(unsigned short code)
+{
+ if(code<32) return 0;
+ else if(code<0x6FF) return table_32[code-32];
+ else if(code<0x2000) return 0;
+ else if(code<0x20D0) return table_2000[code-0x2000];
+ else if(code==0x2116) return "afii61352"; /* numero sign, for Koi */
+ else if(code==0x2122) return "trademark";
+ else if(code<0x2500) return 0;
+ else if(code<0x25A0) return table_2500[code-0x2500];
+ else if(code<0xFB00) return 0;
+ else if(code<0xFB50) return table_FB00[code-0xFB00];
+ else return 0;
+}
diff --git a/src/Type1/t1unicode.h b/src/Type1/t1unicode.h
new file mode 100644
index 0000000..f2a13fd
--- /dev/null
+++ b/src/Type1/t1unicode.h
@@ -0,0 +1,25 @@
+/*
+Copyright (c) 1998 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/* $XFree86: xc/lib/font/Type1/t1unicode.h,v 1.1 1999/01/31 04:59:31 dawes Exp $ */
+
+char *unicodetoPSname(unsigned short code);