summaryrefslogtreecommitdiff
path: root/Build/source/texk/ttfdump/libttf
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-17 21:41:51 +0000
committerKarl Berry <karl@freefriends.org>2006-01-17 21:41:51 +0000
commit487ca4806cc046076293cf6cc5fbba0db282bac7 (patch)
tree847b412ab5158dd7bdd7ed7e5a4cc3fbca94be32 /Build/source/texk/ttfdump/libttf
parenta3d3111bfe26b8e5f5bc6049dfb2a4ca2edc7881 (diff)
texk 1
git-svn-id: svn://tug.org/texlive/trunk@1485 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/ttfdump/libttf')
-rw-r--r--Build/source/texk/ttfdump/libttf/Makefile.in102
-rw-r--r--Build/source/texk/ttfdump/libttf/cmap.c748
-rw-r--r--Build/source/texk/ttfdump/libttf/cvt.c68
-rw-r--r--Build/source/texk/ttfdump/libttf/depend.mak386
-rw-r--r--Build/source/texk/ttfdump/libttf/disasm.c22
-rw-r--r--Build/source/texk/ttfdump/libttf/fixed.c16
-rw-r--r--Build/source/texk/ttfdump/libttf/font.c160
-rw-r--r--Build/source/texk/ttfdump/libttf/fpgm.c53
-rw-r--r--Build/source/texk/ttfdump/libttf/gasp.c95
-rw-r--r--Build/source/texk/ttfdump/libttf/gcache.c423
-rw-r--r--Build/source/texk/ttfdump/libttf/glyf.c438
-rw-r--r--Build/source/texk/ttfdump/libttf/gstate.c43
-rw-r--r--Build/source/texk/ttfdump/libttf/hdmx.c110
-rw-r--r--Build/source/texk/ttfdump/libttf/head.c108
-rw-r--r--Build/source/texk/ttfdump/libttf/hhea.c95
-rw-r--r--Build/source/texk/ttfdump/libttf/hmtx.c111
-rw-r--r--Build/source/texk/ttfdump/libttf/interp.c864
-rw-r--r--Build/source/texk/ttfdump/libttf/kern.c179
-rw-r--r--Build/source/texk/ttfdump/libttf/loca.c110
-rw-r--r--Build/source/texk/ttfdump/libttf/ltsh.c82
-rw-r--r--Build/source/texk/ttfdump/libttf/maxp.c92
-rw-r--r--Build/source/texk/ttfdump/libttf/name.c182
-rw-r--r--Build/source/texk/ttfdump/libttf/os2.c181
-rw-r--r--Build/source/texk/ttfdump/libttf/pclt.c113
-rw-r--r--Build/source/texk/ttfdump/libttf/post.c178
-rw-r--r--Build/source/texk/ttfdump/libttf/prep.c53
-rw-r--r--Build/source/texk/ttfdump/libttf/stack.c101
-rw-r--r--Build/source/texk/ttfdump/libttf/tabledir.c121
-rw-r--r--Build/source/texk/ttfdump/libttf/ttc.c97
-rw-r--r--Build/source/texk/ttfdump/libttf/ttfread.c129
-rw-r--r--Build/source/texk/ttfdump/libttf/ttfutil.c57
-rw-r--r--Build/source/texk/ttfdump/libttf/vdmx.c157
-rw-r--r--Build/source/texk/ttfdump/libttf/vhea.c102
-rw-r--r--Build/source/texk/ttfdump/libttf/vmtx.c115
-rw-r--r--Build/source/texk/ttfdump/libttf/win32.mak57
35 files changed, 5948 insertions, 0 deletions
diff --git a/Build/source/texk/ttfdump/libttf/Makefile.in b/Build/source/texk/ttfdump/libttf/Makefile.in
new file mode 100644
index 00000000000..4781a8c015e
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/Makefile.in
@@ -0,0 +1,102 @@
+# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+# @configure_input@
+
+SHELL = /bin/sh
+
+#### Start of system configuration section. ####
+
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+# If you use gcc, you should either run the fixincludes script that
+# comes with it or else use gcc with the -traditional option. Otherwise
+# ioctl calls will be compiled incorrectly on some systems.
+CC = @CC@
+AR = ar
+
+# set make command
+@SET_MAKE@
+
+# Set RANLIB = echo if your system doesn't have or need ranlib.
+RANLIB = @RANLIB@
+
+# Use cp if you don't have install.
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+DEFS = @DEFS@
+LIBS = @LIBS@
+
+INCLUDES = -I@top_srcdir@ -I@top_srcdir@/include
+CFLAGS = @CFLAGS@ $(INCLUDES)
+LDFLAGS = @LDFLAGS@
+
+MAKEINFO = makeinfo
+TEXI2DVI = texi2dvi
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+# Where to install the executables.
+bindir = $(exec_prefix)/bin
+
+# Where to put the include header
+includedir = $(prefix)/include
+
+# Where to put the Info files
+infodir = $(prefix)/info
+
+# Where to put the library file
+libdir = $(prefix)/lib
+
+# Where to put the manual pages.
+mandir = $(prefix)/man
+
+#### End of system configuration section. ####
+
+#CFLAGS = -g -pg -Wall -m486 -DMEMCHECK -DTESTCODE -DCOPYDELETE -I/usr/local/include
+#CFLAGS = -O3 -Wall -m486 -DTESTCODE -DCOPYDELETE -I/usr/local/include -I../ -I../include
+#LDFLAGS = -L/usr/local/lib
+#LIBS = -ldmalloc
+#LIBS = -lefence
+#LIBS = -lc_p
+OBJS = ttfread.o tabledir.o ttfutil.o font.o cmap.o glyf.o gcache.o \
+ head.o hhea.o hmtx.o loca.o maxp.o name.o os2.o post.o \
+ cvt.o fpgm.o gasp.o hdmx.o kern.o ltsh.o prep.o pclt.o vdmx.o vhea.o \
+ vmtx.o gstate.o stack.o interp.o disasm.o ttc.o
+
+all: libttf.a
+
+libttf.a: ${OBJS}
+ $(AR) r $@ $?
+ ranlib $@ || $(AR) ts $@ || true
+
+clean:
+ rm -f *.a *.o *~
+.PHONY: clean
+
+distclean: clean
+ rm -f tags TAGS Makefile
+.PHONY: distclean
+
+install:
+ @echo Nothing to install from this directory
+
+check:
+ @echo Nothing to check in this directory
diff --git a/Build/source/texk/ttfdump/libttf/cmap.c b/Build/source/texk/ttfdump/libttf/cmap.c
new file mode 100644
index 00000000000..3374829b4d8
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/cmap.c
@@ -0,0 +1,748 @@
+/* cmap.c -- Load and Print the content of cmap table
+ * Copyright (C) 1996 Li-Da Lho, All right reserved
+ *
+ * The structure of a cmap is really complex, it depends on which format the
+ * cmap is and loading a cmap is a kind of confusing thing.
+ * The structure of CMAP:
+ * A cmap begins with a general description of the table
+ * USHORT version indicates the version of this cmap.
+ * USHORT numEncodings is the number of encodings in the cmap table.
+ * Then follow 'numEncodings' of encoding tables, each of which contains
+ * the following informations for each subtable. The subtable contains the
+ * true data to map character code to glyph index
+ * USHORT PlatformID shows which platform the subtable is to be used
+ * (e.g. Mac, PC)
+ * USHORT Platfrom specofic EncodingID shows what kind of encoding scheme
+ * this table uses (e.g. Big5, iso8859, Unicode etc.)
+ * ULONG offset is the offset from the beginning of the whole cmap table
+ * to the beginning of the corresponding subtable
+ * ----------------------- --- ---
+ * | USHORT version | ^ ^
+ * ----------------------- | |
+ * | USHORT numEncodings | | |
+ * ----------------------- | |
+ * | Encoding Table 1 | | |
+ * | USHORT PlatformID | | |
+ * | USHORT EncodingID | | |
+ * | ULONG offset 1 |------ | |
+ * ----------------------- | | offset 1 | offset 2
+ * | Encoding Table 2 | | | |
+ * | USHORT PlatformID | | | |
+ * | USHORT EncodingID | | | |
+ * | ULONG offset 2 |--- | v |
+ * ----------------------- | | --- |
+ * | Subtable 1 |<----- |
+ * | with format 0 | | v
+ * ----------------------- | ---
+ * | Subtable 2 |<--
+ * | with format 2 |
+ * ----------------------|
+ *
+ * Problem with Character Code vs. Byte Endianess.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: cmap.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: cmap.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+static CMAPPtr ttfAllocCMAP(TTFontPtr font);
+static void ttfLoadCMAP(FILE *fp,CMAPPtr cmap,ULONG offset);
+
+static void ttfLoadEncodingTable(FILE *fp,SubTablePtr subTable,ULONG offset);
+static SubTablePtr ttfAllocSubTable(CMAPPtr cmap);
+static void ttfLoadSubTable(FILE *fp,SubTablePtr subTable,ULONG offset);
+static void ttfPrintSubTable(FILE* fp,SubTablePtr ptable);
+static void ttfFreeSubTable(SubTablePtr ptable);
+
+static CMAP0 * ttfAllocCMAP0(SubTablePtr subTable);
+static void ttfLoadCMAP0(FILE *fp,SubTablePtr subTable,ULONG offset);
+static void ttfPrintCMAP0(FILE *fp,SubTablePtr subTable);
+static USHORT ttfLookUpCMAP0(SubTablePtr subTable,USHORT cc);
+static void ttfFreeCMAP0(SubTablePtr subTable);
+
+static void ttfLoadCMAP2(FILE *fp,SubTablePtr subTable,ULONG offset);
+static void ttfPrintCMAP2(FILE *fp,SubTablePtr subTable);
+static USHORT ttfLookUpCMAP2(SubTablePtr subTable,USHORT cc);
+static void ttfFreeCMAP2(SubTablePtr subTable);
+
+static void ttfLoadCMAP4(FILE *fp,SubTablePtr subTable,ULONG offset);
+static void ttfPrintCMAP4(FILE *fp,SubTablePtr subTable);
+static USHORT ttfLookUpCMAP4(SubTablePtr subTable,USHORT cc);
+static void ttfFreeCMAP4(SubTablePtr subTable);
+
+static void ttfLoadCMAP6(FILE *fp,SubTablePtr subTable,ULONG offset);
+static void ttfPrintCMAP6(FILE *fp, SubTablePtr sbuTable);
+static USHORT ttfLookUpCMAP6(SubTablePtr subTable,USHORT cc);
+static void ttfFreeCMAP6(SubTablePtr subTable);
+
+void ttfInitCMAP(TTFontPtr font)
+{
+ ULONG tag = 'c' | 'm' << 8 | 'a' << 16 | 'p' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->cmap = ttfAllocCMAP(font);
+ ttfLoadCMAP(font->fp,font->cmap,ptd->offset);
+ }
+}
+static CMAPPtr ttfAllocCMAP(TTFontPtr font)
+{
+ CMAPPtr cmap;
+ if ((cmap = (CMAPPtr) calloc(1,sizeof(CMAP))) == NULL)
+ {
+ ttfError("Out Of Memory in __FILE_ : __LINE__ \n");
+ return NULL;
+ }
+ return cmap;
+}
+static void ttfLoadCMAP(FILE *fp,CMAPPtr cmap,ULONG offset)
+{
+ USHORT i,n;
+ ULONG posEnc; /* beginning of the Encoding Table */
+ ULONG baseSub = offset; /* base of SubTable offset */
+
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLOADCMAP \n");
+
+ cmap->version = ttfGetUSHORT(fp);
+ cmap->numberOfEncodings = n = ttfGetUSHORT(fp);
+ cmap->subTables = ttfAllocSubTable(cmap);
+
+ posEnc = baseSub + sizeof(USHORT)*2; /* step over the beginning of encoding
+ * table */
+
+ /* for each encoding scheme, load the encoding table (EncodingTable) and
+ * the real cmap data (SubTable) */
+ for (i=0;i<n;i++,posEnc += 8)
+ { /* 8 == ushort*2 + ulong*1 */
+ ttfLoadEncodingTable(fp,cmap->subTables+i,posEnc);
+ ttfLoadSubTable(fp,cmap->subTables+i,baseSub);
+ }
+}
+void ttfPrintCMAP(FILE *fp,CMAPPtr cmap)
+{
+ USHORT i;
+
+ fprintf(fp,"'cmap' Table - Character to Glyph Index Mapping Table\n");
+ fprintf(fp,"-----------------------------------------------------\n");
+ fprintf(fp,"\t 'cmap' version: %d\n",cmap->version);
+ fprintf(fp,"\t number of encoding: %d\n\n",cmap->numberOfEncodings);
+
+ for (i=0;i<cmap->numberOfEncodings;i++)
+ {
+ fprintf(fp,"Subtable %3d.\t",i);
+ ttfPrintSubTable(fp,cmap->subTables+i);
+ fprintf(fp,"\n");
+ }
+}
+USHORT ttfLookUpCMAP(SubTablePtr subTable,USHORT cc)
+{
+ USHORT idx,format = subTable->format;
+
+ switch (format)
+ {
+ case 0:
+ idx = ttfLookUpCMAP0(subTable,cc);
+ break;
+ case 2:
+ idx = ttfLookUpCMAP2(subTable,cc);
+ break;
+ case 4:
+ idx = ttfLookUpCMAP4(subTable,cc);
+ break;
+ case 6:
+ idx = ttfLookUpCMAP6(subTable,cc);
+ break;
+ default:
+ ttfError("Unrecognized CMAP format\n");
+ return 0;
+ }
+ return idx;
+}
+SubTablePtr ttfSelectCMAP(CMAPPtr cmap, USHORT PlatformID, USHORT EncodingID)
+{
+ USHORT i;
+
+ for (i=0;i<cmap->numberOfEncodings;i++)
+ {
+ if ((cmap->subTables+i)->PlatformID == PlatformID &&
+ (cmap->subTables+i)->EncodingID == EncodingID)
+ return cmap->subTables+i;
+ }
+ return NULL;
+}
+void ttfFreeCMAP(CMAPPtr cmap)
+{
+ USHORT i;
+
+ for (i=0;i<cmap->numberOfEncodings;i++)
+ ttfFreeSubTable(cmap->subTables+i);
+
+ free(cmap->subTables);
+ free(cmap);
+}
+
+/* actually, EncodingTable is a part of SubTable */
+static void ttfLoadEncodingTable(FILE *fp,SubTablePtr subTable,ULONG offset)
+{
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLoadEncodingTable \n");
+
+ subTable->PlatformID = ttfGetUSHORT(fp);
+ subTable->EncodingID = ttfGetUSHORT(fp);
+ subTable->offset = ttfGetULONG(fp);
+}
+static SubTablePtr ttfAllocSubTable(CMAPPtr cmap)
+{
+ SubTablePtr subTable;
+
+ if ((subTable = (SubTablePtr) calloc(cmap->numberOfEncodings,sizeof(SubTable))) == NULL)
+ {
+ ttfError("Out Of Memory in __FILE__ : __LINE__ \n");
+ return NULL;
+ }
+ return subTable;
+}
+/* should this one be static ? */
+static void ttfLoadSubTable(FILE *fp,SubTablePtr subTable,ULONG base)
+{
+ ULONG pos;
+ USHORT format;
+
+ /* seek to the actuall position for this subtable
+ * base: beginning of cmap
+ * offset: offset field of each encoding table */
+ pos = base + subTable->offset;
+ if (fseek(fp,pos,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLoadSubTable\n");
+
+ subTable->format = format = ttfGetUSHORT(fp);
+ subTable->length = ttfGetUSHORT(fp);
+ subTable->version = ttfGetUSHORT(fp);
+
+ pos += 6;/* step over format independent data,USHORT*3 */
+
+ switch(format)
+ {
+ case 0:
+ ttfLoadCMAP0(fp,subTable,pos);
+ break;
+ case 2:
+ ttfLoadCMAP2(fp,subTable,pos);
+ break;
+ case 4:
+ ttfLoadCMAP4(fp,subTable,pos);
+ break;
+ case 6:
+ ttfLoadCMAP6(fp,subTable,pos);
+ break;
+ default:
+ ttfError("Unrecognized CMAP format\n");
+ }
+}
+static void ttfPrintSubTable(FILE* fp,SubTablePtr ptable)
+{
+ USHORT format = ptable->format;
+
+ /* print encoding table */
+ fprintf(fp, " PlatformID: %2d\n",ptable->PlatformID);
+ fprintf(fp,"\t\t EcodingID: %2d\n",ptable->EncodingID);
+ fprintf(fp,"\t\t 'cmap' Offset: 0x%08x\n",ptable->offset);
+
+ /* print SubTable part */
+ fprintf(fp,"\t\t Length: %6d\n",ptable->length);
+ fprintf(fp,"\t\t Version: %6d\n",ptable->version);
+
+ switch(format)
+ {
+ case 0:
+ fprintf(fp,"\t\t Format 0 - Byte encoding table\n");
+ ttfPrintCMAP0(fp,ptable);
+ break;
+ case 2:
+ fprintf(fp,"\t\t Format 2 - High-byte mapping through table\n");
+ ttfPrintCMAP2(fp,ptable);
+ break;
+ case 4:
+ fprintf(fp,"\t\t Format 4 - Segment mapping to delta values\n");
+ ttfPrintCMAP4(fp,ptable);
+ break;
+ case 6:
+ fprintf(fp,"\t\t Format 6 - Trimmed table mapping\n");
+ ttfPrintCMAP6(fp,ptable);
+ break;
+ default:
+ ttfError("Unrecognized CMAP format\n");
+ }
+}
+static void ttfFreeSubTable(SubTablePtr ptable)
+{
+ USHORT format = ptable->format;
+
+ switch(format)
+ {
+ case 0:
+ ttfFreeCMAP0(ptable);
+ break;
+ case 2:
+ ttfFreeCMAP2(ptable);
+ break;
+ case 4:
+ ttfFreeCMAP4(ptable);
+ break;
+ case 6:
+ ttfFreeCMAP6(ptable);
+ break;
+ }
+}
+
+static CMAP0 * ttfAllocCMAP0(SubTablePtr subTable)
+{
+ CMAP0 * cmap0;
+
+ if ((cmap0 = (CMAP0 *) calloc(1,sizeof(CMAP0))) == NULL)
+ {
+ ttfError("Out Of Memory in __FILE__ : __LINE__ \n");
+ return NULL;
+ }
+ return cmap0;
+}
+static void ttfLoadCMAP0(FILE *fp,SubTablePtr subTable,ULONG offset)
+{
+ BYTE * array;
+
+ subTable->map.cmap0 = ttfAllocCMAP0(subTable);
+ array = subTable->map.cmap0->glyphIndexArray;
+
+ if (fseek(fp,offset,SEEK_SET) != 0)
+ ttfError("Fseek Failed in ttfLoadCMAP0 \n");
+
+ /* Attention: we get lots of bytes at once as a work around of the
+ * usual ttfGet*, this cause byte sex trouble as will be seen
+ * in the fellowing procedures */
+ if (fread(array,sizeof(BYTE),256,fp) != 256)
+ ttfError("Error when getting glyphIndexArray \n");
+}
+static void ttfPrintCMAP0(FILE *fp,SubTablePtr subTable)
+{
+ USHORT index;
+ int i;
+
+ for (i=0;i<256;i++)
+ {
+ index = ttfLookUpCMAP(subTable,i);
+ fprintf(fp,"\t\t Char %3d -> Index %4d \n",i,index);
+ }
+}
+static USHORT ttfLookUpCMAP0(SubTablePtr subTable,USHORT cc)
+{
+ return subTable->map.cmap0->glyphIndexArray[cc & 0x00ff];
+}
+static void ttfFreeCMAP0(SubTablePtr subTable)
+{
+ free(subTable->map.cmap0);
+}
+
+static void ttfLoadCMAP2(FILE *fp,SubTablePtr subTable,ULONG offset)
+{
+ USHORT * array,i,n = 0;
+ USHORT numGlyphId;
+ SubHeaderPtr header;
+
+ if (fseek(fp,offset,SEEK_SET) != 0)
+ ttfError("Fseek Failed in ttfLoadCMAP2 \n");
+
+ subTable->map.cmap2 = (CMAP2 *) calloc(1,sizeof(CMAP2));
+ array = subTable->map.cmap2->subHeaderKeys;
+
+ if (fread(array,sizeof(USHORT),256,fp) != 256)
+ ttfError("Error when getting subHeaderKeys \n");
+#ifndef WORDS_BIGENDIAN
+ TwoByteSwap((unsigned char *) array,256*sizeof(USHORT));
+#endif
+
+ for (i=0;i<256;i++)
+ {
+ array[i] /= 8;
+ if (n< array[i])
+ n = array[i]; /* find the max of subHeaderKeys */
+ }
+ n += 1; /* the number of subHeaders is one plus the max of subHeaderKeys */
+
+ subTable->map.cmap2->subHeaders = header =
+ (SubHeaderPtr) calloc(n,sizeof(SubHeader));
+ for (i=0;i<n;i++)
+ {
+ (header+i)->firstCode = ttfGetUSHORT(fp);
+ (header+i)->entryCount = ttfGetUSHORT(fp);
+ (header+i)->idDelta = ttfGetSHORT(fp);
+ (header+i)->idRangeOffset = ttfGetUSHORT(fp);
+
+ /* it makes things easier to let the offset starts from
+ * the beginning of glyphIndexArray */
+ if ((header+i)->idRangeOffset != 0)
+ (header+i)->idRangeOffset -= (sizeof(USHORT) +
+ (n-i-1) * sizeof(SubHeader)) ;
+ }
+
+ /* caculate the length of glyphIndexArray, this is ugly, there should be
+ * a better way to get this information. */
+ numGlyphId =
+ subTable->length - (256 + 3) * sizeof(USHORT) - n * sizeof(SubHeader);
+ numGlyphId /= sizeof(USHORT);
+ subTable->map.cmap2->glyphIndexArray =
+ (USHORT *) calloc(numGlyphId,sizeof(USHORT));
+ for (i=0;i<numGlyphId;i++)
+ {
+ subTable->map.cmap2->glyphIndexArray[i] = ttfGetUSHORT(fp);
+ }
+}
+static void ttfPrintCMAP2(FILE *fp,SubTablePtr subTable)
+{
+ USHORT i,j,numGlyphId;
+ USHORT *array,n=0,index;
+ SubHeaderPtr header;
+ unsigned short cc;
+
+ array = subTable->map.cmap2->subHeaderKeys;
+ header = subTable->map.cmap2->subHeaders;
+
+ for (i=0;i<256;i++)
+ {
+ /* find the number of subHeader */
+ if (n< array[i])
+ n = array[i];
+ fprintf(fp,"\t\t subHeaderKeys[%d] = %d\n",i,array[i]);
+ }
+ n += 1; /* the number of subHeaders is one plus the max of subHeaderKeys */
+ fprintf(fp,"\t\t Number of SubHeaders is %d\n",n);
+
+ for (i=0;i<=n;i++)
+ {
+ fprintf(fp,"\t\t SubHeader[%d]\n",i);
+ fprintf(fp,"\t\t firstCode \t 0x%04x\n",(header+i)->firstCode);
+ fprintf(fp,"\t\t entryCount \t %d\n",(header+i)->entryCount);
+ fprintf(fp,"\t\t idDelta \t %d\n",(header+i)->idDelta);
+ fprintf(fp,"\t\t idRangeOffset \t 0x%04x\n\n",
+ (header+i)->idRangeOffset);
+ }
+
+ /* caculate the length of glyphIndexArray, this is ugly, there should be
+ * a better way to get this information. */
+ numGlyphId =
+ subTable->length - (256 + 3) * sizeof(USHORT) - n * sizeof(SubHeader);
+ numGlyphId /= sizeof(USHORT);
+ fprintf(fp,"Number of glyphIndex: %d\n", numGlyphId);
+ for (i=0;i<numGlyphId;i++)
+ {
+ fprintf(fp,"\t\t glyphIdArray[%d] = %4d\n",i,
+ subTable->map.cmap2->glyphIndexArray[i]);
+ }
+
+ i = 0;
+ fprintf(fp,"\t\t First Byte:\t %2x\n",i);
+ for(j=0;j<=255;j++)
+ {
+#ifndef WORDS_BIGENDIAN
+ cc = i + (j << 8);
+#else
+ cc = j + (i << 8);
+#endif
+ index = ttfLookUpCMAP2(subTable,cc);
+ fprintf(fp,"\t\t Char %2x -> Index %d\n",j,index);
+ }
+ for (i=128;i<=255;i++)
+ {
+ fprintf(fp,"\t\t First Byte:\t %2x\n",i);
+ for(j=0;j<=255;j++)
+ {
+#ifndef WORDS_BIGENDIAN
+ cc = i + (j << 8);
+#else
+ cc = j + (i << 8);
+#endif
+ index = ttfLookUpCMAP2(subTable,cc);
+ fprintf(fp,"\t\t Char %2x -> Index %d\n",j,index);
+ }
+ }
+}
+static USHORT ttfLookUpCMAP2(SubTablePtr subTable,USHORT cc)
+{
+ USHORT index,idx = 0;
+ USHORT *array = subTable->map.cmap2->subHeaderKeys;
+ SubHeaderPtr headers = subTable->map.cmap2->subHeaders;
+ SHORT idDelta;
+ USHORT firstCode, entryCount, idRangeOffset;
+ unsigned char first,second;
+
+
+ /* On little endian platforms "low byte" is the "first byte".
+ * It determines that if it is necessary to use the second byte to
+ * fully interprete the character code, for expamle, if the first byte
+ * is obivously an ASCII character then it is not necessary to
+ * interpret the second byte, on the other hand, if the first byte is
+ * zero then the second byte is a ASCII char, when the first byte
+ * is not an ASCII char nor zero, those two bytes together determine
+ * the meanning of the character code
+ */
+#ifndef WORDS_BIGENDIAN
+ first = cc & 0x00ff;
+ second = cc >> 8;
+#else
+ first = cc >> 8;
+ second = cc & 0x00ff;
+#endif
+
+ /* select which subHeader to use */
+ idx = array[first];
+
+ firstCode = (headers+idx)->firstCode;
+ entryCount = (headers+idx)->entryCount;
+ idDelta = (headers+idx)->idDelta;
+ idRangeOffset = (headers+idx)->idRangeOffset / sizeof (USHORT);
+
+ if (second >= firstCode && second < firstCode+entryCount)
+ {
+ /* use idRangeOffset to find where in the glyphIndexArray
+ * the correspinding index is */
+ idRangeOffset += (second - firstCode);
+ index = subTable->map.cmap2->glyphIndexArray[idRangeOffset];
+ if (index != 0)
+ /* if the character is not a missing character then
+ * add idDelta to it */
+ index += idDelta;
+ }
+ else
+ /* The second code is out ranged then return the
+ * missing glyph character */
+ index = 0;
+
+ return index;
+}
+static void ttfFreeCMAP2(SubTablePtr subTable)
+{
+ free(subTable->map.cmap2->subHeaders);
+ free(subTable->map.cmap2->glyphIndexArray);
+ free(subTable->map.cmap2);
+}
+
+static void ttfLoadCMAP4(FILE *fp,SubTablePtr subTable,ULONG offset)
+{
+ USHORT segCount;
+ USHORT * array,len;
+
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLoadCMAP4 \n");
+
+ subTable->map.cmap4 = (CMAP4 *) calloc(1,sizeof(CMAP4));
+
+ subTable->map.cmap4->segCountX2 = segCount = ttfGetUSHORT(fp);
+ subTable->map.cmap4->searchRange = ttfGetUSHORT(fp);
+ subTable->map.cmap4->entrySelector = ttfGetUSHORT(fp);
+ subTable->map.cmap4->rangeShift = ttfGetUSHORT(fp);
+
+ segCount /= 2;
+ subTable->map.cmap4->endCount = array =
+ (USHORT *) calloc(segCount,sizeof(USHORT));
+ if (fread(array,sizeof(USHORT),segCount,fp) != segCount)
+ ttfError("Error when getting endCount\n");
+#ifndef WORDS_BIGENDIAN
+ TwoByteSwap((unsigned char *) array,segCount*sizeof(USHORT));
+#endif
+
+ subTable->map.cmap4->reservedPad = ttfGetUSHORT(fp);
+
+ subTable->map.cmap4->startCount = array =
+ (USHORT *) calloc(segCount,sizeof(USHORT));
+ if (fread(array,sizeof(USHORT),segCount,fp) != segCount)
+ ttfError("Error when getting startCount\n");
+#ifndef WORDS_BIGENDIAN
+ TwoByteSwap((unsigned char *) array,segCount*sizeof(USHORT));
+#endif
+
+ subTable->map.cmap4->idDelta = array =
+ (USHORT *) calloc(segCount,sizeof(USHORT));
+ if (fread(array,sizeof(USHORT),segCount,fp) != segCount)
+ ttfError("Error when getting idDelta\n");
+#ifndef WORDS_BIGENDIAN
+ TwoByteSwap((unsigned char *) array,segCount*sizeof(USHORT));
+#endif
+
+ subTable->map.cmap4->idRangeOffset = array =
+ (USHORT *) calloc(segCount,sizeof(USHORT));
+ if (fread(array,sizeof(USHORT),segCount,fp) != segCount)
+ ttfError("Error when getting idRangeOffset\n");
+#ifndef WORDS_BIGENDIAN
+ TwoByteSwap((unsigned char *) array,segCount*sizeof(USHORT));
+#endif
+
+ /* caculate the length of glyphIndexArray, this is ugly, there should be
+ * a better way to get this information. */
+ len = subTable->length - 8*sizeof(USHORT) - 4*segCount*sizeof(USHORT);
+ len /= sizeof(USHORT);
+ subTable->map.cmap4->glyphIndexArray = array =
+ (USHORT *) calloc(len,sizeof(USHORT));
+ if (fread(array,sizeof(USHORT),len,fp) != len)
+ ttfError("Error when getting idRangeOffset\n");
+#ifndef WORDS_BIGENDIAN
+ TwoByteSwap((unsigned char *) array,len*sizeof(USHORT));
+#endif
+}
+static void ttfPrintCMAP4(FILE *fp,SubTablePtr subTable)
+{
+ USHORT i;
+ USHORT segCount,len;
+
+ segCount = subTable->map.cmap4->segCountX2/2;
+ fprintf(fp, "\t\t segCount:\t %d\n", segCount);
+ fprintf(fp, "\t\t searchRange:\t %d\n", subTable->map.cmap4->searchRange);
+ fprintf(fp, "\t\t entrySelector:\t %d\n", subTable->map.cmap4->entrySelector);
+ fprintf(fp, "\t\t rangeShift:\t %d\n", subTable->map.cmap4->rangeShift);
+
+ for (i=0;i<segCount;i++)
+ {
+ fprintf(fp, "\t\t Seg %3d :", i);
+ fprintf(fp, " St = %04x,", subTable->map.cmap4->startCount[i]);
+ fprintf(fp, " En = %04x,", subTable->map.cmap4->endCount[i]);
+ /* should this filed be SHORT or USHORT ?? */
+ fprintf(fp, " D = %6d," ,
+ (subTable->map.cmap4->idDelta[i]));
+ fprintf(fp, " RO = %6d," , subTable->map.cmap4->idRangeOffset[i]);
+
+ /* find the glyphIndex correpsonding to this segment */
+ if (subTable->map.cmap4->idRangeOffset[i] != 0)
+ {
+ USHORT j;
+ j = subTable->map.cmap4->segCountX2/2 - i;
+ j = subTable->map.cmap4->idRangeOffset[i] -
+ j*sizeof(USHORT);
+ fprintf(fp, " gId# = %d\n",j/sizeof(USHORT));
+ }
+ else
+ fprintf(fp, " gId# = N/A\n");
+ }
+
+ /* caculate the length of glyphIndexArray, this is ugly, there should be
+ * a better way to get this information. */
+ len = subTable->length - 8*sizeof(USHORT) - 4*segCount*sizeof(USHORT);
+ len /= sizeof(USHORT);
+ fprintf(fp,"\t\t Number of glyphIndex %d\n",len);
+ for (i=0;i<len;i++)
+ {
+ fprintf(fp,"\t\t glyphIdArray[%d] = %d\n",i,
+ subTable->map.cmap4->glyphIndexArray[i]);
+ }
+
+ for (i=0;i<segCount;i++)
+ {
+ int j,index;
+ fprintf(fp,"Segment %d:\n",i);
+ for (j=subTable->map.cmap4->startCount[i];
+ j<=subTable->map.cmap4->endCount[i];j++)
+ {
+ index = ttfLookUpCMAP4(subTable,j);
+ fprintf(fp,"\t\tChar 0x%04x -> Index %d\n",j,index);
+ }
+ }
+}
+static USHORT ttfLookUpCMAP4(SubTablePtr subTable,USHORT cc)
+{
+ USHORT i;
+ USHORT index=0, segCount = subTable->map.cmap4->segCountX2/2;
+
+ for (i=0;i<segCount;i++)
+ {
+ if (cc <= subTable->map.cmap4->endCount[i] &&
+ cc >= subTable->map.cmap4->startCount[i])
+ {
+ USHORT j;
+ if (subTable->map.cmap4->idRangeOffset[i] != 0)
+ {
+ j = subTable->map.cmap4->idRangeOffset[i] -
+ (segCount - i)*sizeof(USHORT);
+ j = cc - subTable->map.cmap4->startCount[i] + j/2;
+ index = subTable->map.cmap4->glyphIndexArray[j];
+ if (index != 0)
+ index += subTable->map.cmap4->idDelta[i];
+ }
+ else
+ {
+ index = cc + subTable->map.cmap4->idDelta[i];
+ }
+ break;
+ }
+ }
+
+ return index;
+}
+static void ttfFreeCMAP4(SubTablePtr subTable)
+{
+ free(subTable->map.cmap4->endCount);
+ free(subTable->map.cmap4->startCount);
+ free(subTable->map.cmap4->idDelta);
+ free(subTable->map.cmap4->idRangeOffset);
+ free(subTable->map.cmap4->glyphIndexArray);
+ free(subTable->map.cmap4);
+}
+
+static void ttfLoadCMAP6(FILE *fp,SubTablePtr subTable,ULONG offset)
+{
+ USHORT * array,len;
+
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLoadCMAP6 \n");
+
+ subTable->map.cmap6 = (CMAP6 *) calloc(1,sizeof(CMAP6));
+ subTable->map.cmap6->firstCode = ttfGetUSHORT(fp);
+ subTable->map.cmap6->entryCount = len = ttfGetUSHORT(fp);
+ subTable->map.cmap6->glyphIndexArray = array =
+ (USHORT *) calloc(subTable->map.cmap6->entryCount,sizeof(USHORT));
+
+ if (fread(array,sizeof(USHORT),len,fp) != len)
+ ttfError("Error when getting idRangeOffset\n");
+#ifndef WORDS_BIGENDIAN
+ TwoByteSwap((unsigned char *) array,len*sizeof(USHORT));
+#endif
+}
+static void ttfPrintCMAP6(FILE *fp, SubTablePtr subTable)
+{
+ USHORT i;
+ fprintf(fp,"\t\t First Code: 0x%04x\n",subTable->map.cmap6->firstCode);
+ fprintf(fp,"\t\t Entry Count: %d\n",subTable->map.cmap6->entryCount);
+
+ for (i=0;i<subTable->map.cmap6->entryCount;i++)
+ {
+ fprintf(fp,"\t\t glyphIdArray[%d] = %d\n",i,
+ subTable->map.cmap6->glyphIndexArray[i]);
+ }
+}
+static USHORT ttfLookUpCMAP6(SubTablePtr subTable,USHORT cc)
+{
+ USHORT index;
+
+ index = cc - subTable->map.cmap6->firstCode;
+ if (index < subTable->map.cmap6->entryCount)
+ return subTable->map.cmap6->glyphIndexArray[index];
+ else
+ /* index out of range, return missing glyph */
+ return 0;
+}
+static void ttfFreeCMAP6(SubTablePtr subTable)
+{
+ free(subTable->map.cmap6->glyphIndexArray);
+ free(subTable->map.cmap6);
+}
+
diff --git a/Build/source/texk/ttfdump/libttf/cvt.c b/Build/source/texk/ttfdump/libttf/cvt.c
new file mode 100644
index 00000000000..364ae66f21a
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/cvt.c
@@ -0,0 +1,68 @@
+/* cvt.c -- Control Value Table
+ * Copyright (C) 1996 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: cvt.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: cvt.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+static void ttfLoadCVT(FILE *fp,FWord *cvt,USHORT lenght,ULONG offset);
+
+void ttfInitCVT(TTFontPtr font)
+{
+ ULONG tag = 'c' | 'v' << 8 | 't' << 16 | ' ' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->cvtLength = ptd->length / sizeof(FWord);
+ font->cvt = (FWord *) calloc(font->cvtLength, sizeof(FWord));
+ if (font->cvt != NULL)
+ ttfLoadCVT(font->fp,font->cvt,font->cvtLength,ptd->offset);
+ }
+}
+
+static void ttfLoadCVT(FILE *fp,FWord *cvt,USHORT length,ULONG offset)
+{
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLoadCVT \n");
+
+ if (fread(cvt, sizeof(FWord), length, fp) != length)
+ ttfError("Error when getting CVT\n");
+
+#ifndef WORDS_BIGENDIAN
+ TwoByteSwap((unsigned char *) cvt,length*sizeof(FWord));
+#endif
+}
+
+void ttfPrintCVT(FILE *fp, FWord *cvt, USHORT cvtLength)
+{
+ USHORT i;
+
+ fprintf(fp,"'cvt ' Table - Control Value Table\n");
+ fprintf(fp,"----------------------------------\n");
+ fprintf(fp,"Size = %d bytes, %d entries\n",cvtLength*sizeof(FWord),
+ cvtLength);
+
+ for (i=0;i<cvtLength;i++)
+ {
+ fprintf(fp,"\t %4d. \t %d\n",i,cvt[i]);
+ }
+ fprintf(fp,"\n");
+}
+
+void ttfFreeCVT(FWord *cvt)
+{
+ if (cvt != NULL)
+ free(cvt);
+}
diff --git a/Build/source/texk/ttfdump/libttf/depend.mak b/Build/source/texk/ttfdump/libttf/depend.mak
new file mode 100644
index 00000000000..21e51bc79bc
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/depend.mak
@@ -0,0 +1,386 @@
+$(objdir)/interp.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/gcache.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/prep.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/ttfutil.obj: \
+ ../include/ttf.h \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/tabledir.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/maxp.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/os2.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h \
+ ../include/os2_P.h
+
+$(objdir)/fpgm.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/name.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/ttfread.obj: \
+ ../include/ttf.h \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/ltsh.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/vdmx.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/cmap.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/cvt.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/pclt.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/fixed.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/hdmx.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/vmtx.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/disasm.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/head.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/glyf.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/stack.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/font.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/ttc.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h \
+ ../include/ttc.h
+
+$(objdir)/hhea.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/kern.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/hmtx.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/loca.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/gasp.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/gstate.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/post.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
+$(objdir)/vhea.obj: \
+ ../config.h \
+ $(kpathseadir)/c-auto.h \
+ $(kpathseadir)/c-memstr.h \
+ ../include/ttf.h \
+ ../include/tables.h \
+ ../include/gcache.h \
+ ../include/gstate.h \
+ ../include/loadtable.h \
+ ../include/ttfutil.h \
+ ../include/protos.h
+
diff --git a/Build/source/texk/ttfdump/libttf/disasm.c b/Build/source/texk/ttfdump/libttf/disasm.c
new file mode 100644
index 00000000000..fc263ddcda9
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/disasm.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: disasm.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: disasm.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+void ttfPrintInstructions(FILE *fp, BYTE * ins)
+{
+ /* not implemented yet */
+}
+
+/* Pushing data onto the interpreter stack */
diff --git a/Build/source/texk/ttfdump/libttf/fixed.c b/Build/source/texk/ttfdump/libttf/fixed.c
new file mode 100644
index 00000000000..3b5276ff209
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/fixed.c
@@ -0,0 +1,16 @@
+/* fixed.c -- dealing with fixed point arithmetic
+ * Copyright (C) 1996 Li-Da Lho, All right reserved.
+ */
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: fixed.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: fixed.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
diff --git a/Build/source/texk/ttfdump/libttf/font.c b/Build/source/texk/ttfdump/libttf/font.c
new file mode 100644
index 00000000000..474d4f008e4
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/font.c
@@ -0,0 +1,160 @@
+/* font.c -- general font init and clean up codes
+ * Copyright (C) 1996 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+#include "protos.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: font.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: font.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+static void ttfInitInterpreter(TTFontPtr font);
+
+TTFontPtr ttfInitFont(char *filename)
+{
+ TTFontPtr font;
+
+ font = (TTFontPtr) calloc(1,sizeof(TTFont));
+
+ font->ttfname = filename;
+ if ((font->fp = fopen (filename,"r")) == NULL)
+ {
+ fprintf(stderr,"Can't open ttf file %s\n",filename);
+ free(font);
+ return NULL;
+ }
+
+ ttfLoadFont(font, 0);
+ return font;
+}
+void ttfLoadFont(TTFontPtr font, ULONG offset)
+{
+ if (fseek(font->fp,offset,SEEK_SET) != 0)
+ ttfError("Fseek Failed\n");
+
+ /* offset table */
+ font->version = ttfGetFixed(font->fp);
+ font->numTables = ttfGetUSHORT(font->fp);
+
+ ttfInitTableDir(font,offset);
+
+ ttfLoadRequiredTables(font);
+ ttfLoadOptionalTables(font);
+
+ ttfInitInterpreter(font);
+
+ /* initialize the reference count to 1 */
+ font->refcount = (int *) calloc(1, sizeof(int));
+ *(font->refcount) = 1;
+}
+void ttfFreeFont(TTFontPtr font)
+{
+ ttfFreeRequiredTables(font);
+
+ ttfFreeOptionalTables(font);
+
+ ttfFreeTableDir(font->dir);
+ free(font->refcount);
+ free(font);
+}
+
+void ttfLoadRequiredTables(TTFontPtr font)
+{
+ ttfInitCMAP(font);
+ ttfInitNAME(font);
+
+ ttfInitMAXP(font);
+ ttfInitHEAD(font);
+ ttfInitLOCA(font);
+
+ ttfInitGlyphCache(font);
+ ttfInitGLYF(font);
+
+ ttfInitHHEA(font);
+ ttfInitHMTX(font);
+
+ ttfInitPOST(font);
+ ttfInitOS2(font);
+}
+
+void ttfFreeRequiredTables(TTFontPtr font)
+{
+ ttfFreeCMAP(font->cmap);
+ ttfFreeNAME(font->name);
+
+ ttfCleanUpGlyphCache(font);
+ ttfFreeLOCA(font->loca);
+ ttfFreeHEAD(font->head);
+ ttfFreeMAXP(font->maxp);
+
+ ttfFreeHMTX(font->hmtx);
+ ttfFreeHHEA(font->hhea);
+
+ ttfFreePOST(font->post);
+ ttfFreeOS2(font->os2);
+}
+
+void ttfLoadOptionalTables(TTFontPtr font)
+{
+ ttfInitCVT(font);
+ ttfInitFPGM(font);
+ ttfInitGASP(font);
+ ttfInitHDMX(font);
+ ttfInitKERN(font);
+ ttfInitPREP(font);
+ ttfInitLTSH(font);
+ ttfInitPCLT(font);
+ ttfInitVDMX(font);
+ ttfInitVHEA(font);
+ ttfInitVMTX(font);
+}
+void ttfFreeOptionalTables(TTFontPtr font)
+{
+ ttfFreeCVT(font->cvt);
+ ttfFreeFPGM(font->fpgm);
+ ttfFreeGASP(font->gasp);
+ ttfFreeHDMX(font->hdmx);
+ ttfFreeKERN(font->kern);
+ ttfFreePREP(font->prep);
+ ttfFreeLTSH(font->ltsh);
+ ttfFreePCLT(font->pclt);
+ ttfFreeVDMX(font->vdmx);
+ ttfFreeVHEA(font->vhea);
+ ttfFreeVMTX(font->vmtx);
+}
+
+/* make a clone of the origional font
+ * This is use for fonts that support more than one encoding scheme
+ *
+ * Problems:
+ * 1. which of those members can be shared between two instances
+ * 2. How can we free a font safely
+ */
+TTFontPtr ttfCloneFont(TTFontPtr font)
+{
+ TTFontPtr newfont;
+
+ newfont = (TTFontPtr) calloc(1,sizeof(TTFont));
+
+ memcpy(newfont, font, sizeof(TTFont));
+ newfont->refcount += 1;
+
+ return newfont;
+}
+static void ttfInitInterpreter(TTFontPtr font)
+{
+ ttfInitStorageArea(font);
+ ttfInitStack(font);
+ ttfInitGraphicsState(font);
+}
diff --git a/Build/source/texk/ttfdump/libttf/fpgm.c b/Build/source/texk/ttfdump/libttf/fpgm.c
new file mode 100644
index 00000000000..ad6ed3ee68d
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/fpgm.c
@@ -0,0 +1,53 @@
+/* fpgm.c -- Font Program
+ * Copyright (C) 1996 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: fpgm.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: fpgm.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+static void ttfLoadFPGM(FILE *fp,BYTE *fpgm,USHORT lenght,ULONG offset);
+
+void ttfInitFPGM(TTFontPtr font)
+{
+ ULONG tag = 'f' | 'p' << 8 | 'g' << 16 | 'm' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->fpgmLength = ptd->length;
+ font->fpgm = (BYTE *) calloc(font->fpgmLength, sizeof(BYTE));
+ if (font->fpgm != NULL)
+ ttfLoadFPGM(font->fp,font->fpgm,font->fpgmLength,ptd->offset);
+ }
+}
+
+static void ttfLoadFPGM(FILE *fp,BYTE *fpgm,USHORT length,ULONG offset)
+{
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLoadCVT \n");
+
+ if (fread(fpgm, sizeof(BYTE), length, fp) != length)
+ ttfError("Error when getting CVT\n");
+}
+
+void ttfPrintFPGM(FILE *fp, BYTE *fpgm, USHORT length)
+{
+ ttfPrintInstructions(fp, fpgm);
+}
+
+void ttfFreeFPGM(BYTE *fpgm)
+{
+ if (fpgm != NULL)
+ free(fpgm);
+}
diff --git a/Build/source/texk/ttfdump/libttf/gasp.c b/Build/source/texk/ttfdump/libttf/gasp.c
new file mode 100644
index 00000000000..4ab1aaaf11e
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/gasp.c
@@ -0,0 +1,95 @@
+/* gasp.c -- Grid-fitting And Scan-conversion Procedure
+ * Copyright (C) 1996 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: gasp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: gasp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+static GASPPtr ttfAllocGASP(TTFontPtr font);
+static void ttfLoadGASP(FILE *fp,GASPPtr gasp,ULONG offset);
+
+void ttfInitGASP(TTFontPtr font)
+{
+ ULONG tag = 'g' | 'a' << 8 | 's' << 16 | 'p' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->gasp = ttfAllocGASP(font);
+ ttfLoadGASP(font->fp,font->gasp,ptd->offset);
+ }
+}
+static GASPPtr ttfAllocGASP(TTFontPtr font)
+{
+ GASPPtr gasp;
+
+ if ((gasp = (GASPPtr) calloc(1,sizeof(GASP))) == NULL)
+ {
+ ttfError("Out of Memory in __FILE__:__LINE__\n");
+ return NULL;
+ }
+ return gasp;
+}
+static void ttfLoadGASP (FILE *fp,GASPPtr gasp,ULONG offset)
+{
+ int i;
+
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLoadGASP \n");
+
+ gasp->version = ttfGetUSHORT(fp);
+ gasp->numRanges = ttfGetUSHORT(fp);
+
+ gasp->gaspRange = (GASPRANGE *) calloc(gasp->numRanges, sizeof(GASPRANGE));
+
+ if (gasp->gaspRange == NULL)
+ ttfError("Out of Memory in __FILE__:__LINE__\n");
+ else
+ for (i=0;i<gasp->numRanges;i++)
+ {
+ gasp->gaspRange[i].rangeMaxPPEM = ttfGetUSHORT(fp);
+ gasp->gaspRange[i].rangeGaspBehavior = ttfGetUSHORT(fp);
+ }
+}
+
+void ttfPrintGASP(FILE *fp,GASPPtr gasp)
+{
+ int i;
+
+ fprintf(fp,"'gasp' Table - Grid-fitting And Scan-conversion Procedure\n");
+ fprintf(fp,"---------------------------------------------------------\n");
+
+ fprintf(fp,"'gasp' version:\t %d\n",gasp->version);
+ fprintf(fp,"numRanges: \t %d\n\n",gasp->numRanges);
+
+ for (i=0;i<gasp->numRanges;i++)
+ {
+ fprintf(fp,"\t gasp Range %d\n",i);
+ fprintf(fp,"\t rangeMaxPPEM:\t %d\n",
+ gasp->gaspRange[i].rangeMaxPPEM);
+ fprintf(fp,"\t rangeGaspBehavior:\t 0x%04x\n\n",
+ gasp->gaspRange[i].rangeGaspBehavior);
+ }
+ fprintf(fp,"\n");
+}
+
+void ttfFreeGASP(GASPPtr gasp)
+{
+ if (gasp != NULL)
+ {
+ free(gasp->gaspRange);
+ free(gasp);
+ }
+}
diff --git a/Build/source/texk/ttfdump/libttf/gcache.c b/Build/source/texk/ttfdump/libttf/gcache.c
new file mode 100644
index 00000000000..d926bebd680
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/gcache.c
@@ -0,0 +1,423 @@
+/*
+ * gcache.c -- Provide the cache mechanicsm for outlines
+ * Copyright (C) 1996 Li-Da Lho, All right reserved
+ *
+ * This file is a little bit more complicated, the structure of the cache is
+ * described as fellow:
+ * Basically the cache can be divided onto two parts, the first one is a
+ * linear part which is a least recently utilitied list (LRU),
+ * the second part is the nonlinear one which is a binary serach tree.
+ * Normally each cache element is one the LRU as well as on the BST.
+ * Those glyph elements are allocated at once as an array of glyph cache
+ * elements at the init phase of glyph cache.
+ *
+ * font->gcache--
+ * |
+ * ________|
+ * |
+ * v
+ * ------------------------------------------------------------------
+ * |element 0| 1 | 2 | 3 | 4 | 5 | 6 | 7 | ...
+ * ------------------------------------------------------------------
+ * The first element of the glyph cache array serves as a dummy header
+ * for two purposes, one is for the head and tail of the LRU, the other is
+ * to point to the root of the BST. As a pointer to the root of the
+ * BST, the right subtree points to the root of the BST while the left one is
+ * not used and arbitrarly points to itself.
+ *
+ * After initialization, all the glyph cache element are on the LRU but
+ * none of them is on the BST.
+ *
+ * |-----------------------------------------------------------|
+ * | ------------- ------ ------ |
+ * |-> |head & tail| <-----> | |<-----> ...<----->| | <--|
+ * ------------- ------ ------
+ * / \ / \ / \
+ * / \ / \ / \
+ * left=self right=root left right left right
+ *
+ * The cached data are pointed by the entries of the glyph cache element
+ * in a strait forward fashion.
+ *
+ * |-----------------------------------------------------------|
+ * | ------------- ------ ------ |
+ * |-> |head & tail| <-----> | |<-----> ...<----->| | <--|
+ * ------------- ------ ------
+ * | | -------------|--|--------------------------------
+ * | |---->| | |-> array for flag, instruction|
+ * | -------------|-----------------------------------
+ * | -------------|-----------------------------------
+ * |------->| |----> xcoordinates, ycoordinates|
+ * -------------------------------------------------
+ * Implementation in this way is effecient for the reason that when we
+ * need to free the cache, we only need to do the two things
+ * 1. free the data pointed by the entries in the dummy header
+ * 2. free the dummy header
+ *
+ * Every time a glyph outline is required and ttfLoadGlyphCached is called,
+ * the glyph is searched on the BST with its offset as a key.
+ * If the glyph is on the BST then the address of the glyph cache is returned
+ * and the glyph cache is moved to the tail of the LRU such that the order of
+ * LRU is mantained.
+ * When the glyph required is not on the BST, something more complicated should
+ * be done.
+ * 1. Remove the first element on the LRU from the BST.
+ * 2. Load the glyph data to the cache element.
+ * 3. Insert the element back to the BST.
+ * 4. Move the element to the tail of the LRU.
+ *
+ * The only problem remain is how to deal with composite components.
+ * The asnwer simply is not to support cache for composite components at the
+ * current stage for the two reasons:
+ * 1. It will makes the code an order of magnitude more complicate to support
+ * composite glyf cache.
+ * 2. The space occupied by composite glyf is not very much
+ *
+ * It is not clear right now if it is wise to add tree balancing code.
+ * The overhaed introduced by BST seems minimal for 256 elements cache.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: gcache.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: gcache.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+static GlyphCachePtr ttfAllocCache(TTFontPtr font);
+static void ttfInitCache(TTFontPtr font);
+static void ttfFreeCache(TTFontPtr font);
+static void ttfRotateCache(TTFontPtr font);
+static void ttfAllocCacheData(TTFontPtr font);
+static void ttfInitCacheData(TTFontPtr font);
+static void ttfFreeCacheData(TTFontPtr font);
+static void ttfInsertBST(TTFontPtr font,GlyphCachePtr gcache);
+static GlyphCachePtr ttfSearchBST(TTFontPtr font,ULONG offset);
+static void ttfDeleteBST(TTFontPtr font,ULONG offset);
+static void merge(GlyphCachePtr *root);
+static void copy(GlyphCachePtr *root);
+
+void ttfInitGlyphCache(TTFontPtr font)
+{
+ /* this should be made configurable */
+ if (font->maxp->numGlyphs > 256)
+ font->numCacheElements = 128;
+ else
+ font->numCacheElements = 64;
+
+ font->gcache = ttfAllocCache(font);
+ ttfInitCache(font);
+
+ ttfAllocCacheData(font);
+ ttfInitCacheData(font);
+}
+void ttfCleanUpGlyphCache(TTFontPtr font)
+{
+ ttfFreeCacheData(font);
+ ttfFreeCache(font);
+}
+
+/* provide cache mechanism for glyph */
+GLYFPtr ttfLoadGlyphCached(TTFontPtr font,ULONG offset)
+{
+#ifdef OLDCODE
+ GLYFPtr glyf;
+
+ glyf = &(font->gcache->next->glyf);
+ font->gcache->next->offset = offset;
+ ttfRotateCache(font);
+ ttfLoadGLYF(font->fp,glyf,offset);
+ return glyf;
+
+#else
+ GlyphCachePtr gcache;
+
+ if ((gcache = ttfSearchBST(font,offset)) == NULL)
+ {
+ /* if the glyph is not in the cache */
+ ttfDeleteBST(font,font->gcache->next->offset);
+ gcache = font->gcache->next;
+ font->gcache->next->offset = offset;
+ ttfRotateCache(font);
+ ttfLoadGLYF(font->fp,&gcache->glyf,offset);
+ ttfInsertBST(font,gcache);
+ }
+ return &gcache->glyf;
+#endif
+}
+
+/* alloc GlyphCache headers */
+static GlyphCachePtr ttfAllocCache(TTFontPtr font)
+{
+ USHORT numCache = font->numCacheElements+1;
+ GlyphCachePtr gcache;
+
+ if ((gcache = (GlyphCachePtr) calloc(numCache,sizeof(GlyphCache))) == NULL)
+ {
+ ttfError("Out of Memory");
+ return NULL;
+ }
+ return gcache;
+}
+/* threading glyph cache headers */
+static void ttfInitCache(TTFontPtr font)
+{
+ USHORT i,numCache = font->numCacheElements;
+ GlyphCachePtr cur,tmp;
+
+ cur = tmp = font->gcache;
+ tmp++;
+ /* there are numGlyph+1 of cache header, the first one is for
+ * mark as the head and tail of the queue */
+ for (i=0;i<numCache;i++)
+ {
+ cur->right = cur->left = NULL;
+ cur->next = tmp;
+ tmp->prev = cur;
+ cur = tmp;
+ tmp++;
+ }
+
+ /* make the LRU circular */
+ cur->next = font->gcache;
+ font->gcache->prev = cur;
+
+ /* make the dummy header point to it self on the BST */
+ font->gcache->left = font->gcache;
+ font->gcache->offset = 0;
+}
+static void ttfFreeCache(TTFontPtr font)
+{
+ free(font->gcache);
+}
+/* move the first element on the LRU the the tail */
+static void ttfRotateCache(TTFontPtr font)
+{
+ GlyphCachePtr gcache = font->gcache, tmp = font->gcache->next;
+
+ /* remove the first element */
+ gcache->next = tmp->next;
+ tmp->next->prev = gcache;
+ /* add the element to the tail */
+ tmp->next = gcache;
+ tmp->prev = gcache->prev;
+ gcache->prev->next = tmp;
+ gcache->prev = tmp;
+}
+static void ttfAllocCacheData(TTFontPtr font)
+{
+ USHORT numCache = font->numCacheElements+1;
+ USHORT maxPoints = font->maxp->maxPoints;
+ USHORT maxContours = font->maxp->maxContours;
+ USHORT insLength = font->maxp->maxSizeOfInstructions;
+
+ font->gcache->glyf.endPtsOfContours = (USHORT *) calloc(numCache*maxContours,
+ sizeof(USHORT));
+ font->gcache->glyf.instructions = (BYTE *) calloc(numCache*insLength,
+ sizeof(BYTE));
+ font->gcache->glyf.flags = (BYTE *) calloc(numCache*maxPoints,
+ sizeof(BYTE));
+ font->gcache->glyf.xCoordinates = (SHORT *) calloc(numCache*maxPoints,
+ sizeof(SHORT));
+ font->gcache->glyf.yCoordinates = (SHORT *) calloc(numCache*maxPoints,
+ sizeof(SHORT));
+ font->gcache->glyf.comp = NULL;
+}
+static void ttfInitCacheData(TTFontPtr font)
+{
+ USHORT i;
+ USHORT numCache = font->numCacheElements;
+ USHORT maxPoints = font->maxp->maxPoints;
+ USHORT maxContours = font->maxp->maxContours;
+ USHORT insLength = font->maxp->maxSizeOfInstructions;
+ GlyphCachePtr cur,tmp;
+
+ tmp = font->gcache;
+ cur = font->gcache->next;
+
+ for (i=0;i<numCache;i++)
+ {
+ /* makes the pointer in the cache element point to correct
+ * addresses in the data area */
+ cur->glyf.endPtsOfContours = tmp->glyf.endPtsOfContours + maxContours;
+ cur->glyf.instructions = tmp->glyf.instructions + insLength;
+ cur->glyf.flags = tmp->glyf.flags + maxPoints;
+ cur->glyf.xCoordinates = tmp->glyf.xCoordinates + maxPoints;
+ cur->glyf.yCoordinates = tmp->glyf.yCoordinates + maxPoints;
+ tmp = cur;
+ cur = cur++;
+ }
+}
+static void ttfFreeCacheData(TTFontPtr font)
+{
+ USHORT i,numCache = font->numCacheElements;
+ GlyphCachePtr cur = font->gcache+1;
+
+ /* free components of composite glyfs */
+ for (i=0;i<numCache;i++)
+ {
+ ttfFreeGLYF(&cur->glyf);
+ cur++;
+ }
+ free(font->gcache->glyf.endPtsOfContours);
+ free(font->gcache->glyf.instructions);
+ free(font->gcache->glyf.flags);
+ free(font->gcache->glyf.xCoordinates);
+ free(font->gcache->glyf.yCoordinates);
+}
+
+/* code to deal with nonlinear part of glyph cache */
+static void ttfInsertBST(TTFontPtr font,GlyphCachePtr gcache)
+{
+ GlyphCachePtr root,parent;
+
+ parent = font->gcache;
+ root = parent->right;
+
+ while (root)
+ {
+ parent = root;
+ if (root->offset > gcache->offset)
+ root = root->left;
+ else
+ root = root->right;
+ }
+
+ if (parent->offset > gcache->offset)
+ parent->left = gcache;
+ else
+ parent->right = gcache;
+}
+static GlyphCachePtr ttfSearchBST(TTFontPtr font,ULONG offset)
+{
+ GlyphCachePtr root = font->gcache->right;
+
+ while (root)
+ {
+ if (root->offset == offset)
+ return root;
+ if (root->offset > offset)
+ root = root->left;
+ else
+ root = root->right;
+ }
+ return NULL;
+}
+/* Deleting a node form a BST is a little bit tricky.
+ * Basically, there are three different situations for deleteing a node
+ * 1. The node to delete is a leaf, then just delete the node and make the
+ * node's parent point to null.
+ * 2. The node has one subtree, the let the node's parent adopt it.
+ * 3. The node has both subtrees, in this situation, there are two
+ * alternatives
+ * a. let the parent adopt one of the subtree and the subtree adopt the
+ * other. (delete by merge)
+ * b. replace the node with its precedeer, and leave the topology almost
+ * unchanged.
+ */
+static void ttfDeleteBST(TTFontPtr font,ULONG offset)
+{
+ GlyphCachePtr root,parent;
+
+ parent = font->gcache;
+ root = parent->right;
+
+ /* find the node to delete */
+ while (root)
+ {
+ if (root->offset == offset)
+ break;
+ parent = root;
+ if (root->offset > offset)
+ root = root->left;
+ else
+ root = root->right;
+ }
+ if (root != NULL)
+ {
+ /* the node to be deleted is on the tree */
+ if (root->glyf.numberOfContours < 0)
+ /* a composite glyf with components */
+ ttfFreeGLYF(&root->glyf);
+
+#ifdef MERGEDELETE
+ if (parent == font->gcache)
+ /* delete root */
+ merge(&parent->right);
+ else if (parent->left == root)
+ merge(&parent->left);
+ else
+ merge(&parent->right);
+#else
+ if (parent == font->gcache)
+ /* delete root */
+ copy(&parent->right);
+ else if (parent->left == root)
+ copy(&parent->left);
+ else
+ copy(&parent->right);
+#endif
+
+ root->left = root->right = NULL;
+ }
+ else
+ ; /* the tree is empty or the node is not on the tree */
+
+}
+
+static void merge(GlyphCachePtr *root)
+{
+ GlyphCachePtr tmp;
+
+ if ((*root)->right == NULL)
+ *root = (*root)->left;
+ else if ((*root)->left == NULL)
+ *root = (*root)->right;
+ else
+ {
+ /* the node to be attached has both left and right
+ * subtrees */
+ tmp = (*root)->left;
+ while (tmp->right)
+ {
+ tmp = tmp->right;
+ }
+ tmp->right = (*root)->right;
+ *root = (*root)->left;
+ }
+}
+static void copy(GlyphCachePtr *root)
+{
+ GlyphCachePtr tmp, parent;
+
+ if ((*root)->right == NULL)
+ *root = (*root)->left;
+ else if ((*root)->left == NULL)
+ *root = (*root)->right;
+ else
+ {
+ tmp = (*root)->left;
+ parent = *root;
+ while (tmp->right)
+ {
+ parent = tmp;
+ tmp = tmp->right;
+ }
+ tmp->right = (*root)->right;
+ if (parent != *root)
+ {
+ parent->right = tmp->left;
+ tmp->left = parent;
+ }
+ *root = tmp;
+ }
+}
diff --git a/Build/source/texk/ttfdump/libttf/glyf.c b/Build/source/texk/ttfdump/libttf/glyf.c
new file mode 100644
index 00000000000..e19eb7fb170
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/glyf.c
@@ -0,0 +1,438 @@
+/* glyf.c -- Load and print Glyf outline data
+ * Copyright (C) 1996 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: glyf.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: glyf.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+static void ttfLoadSimpleGlyph(FILE *fp,GLYFPtr glyf,ULONG offset);
+static void ttfPrintSimpleGlyph(FILE *fp,GLYFPtr glyf);
+static void ttfLoadCompositeGlyph(FILE *fp,GLYFPtr glyf,ULONG offset);
+static void ttfPrintCompositeGlyph(FILE*fp,GLYFPtr glyf);
+static void ttfFreeCompositeGlyph(GLYFPtr glyf);
+double fix2dbl(F2Dot14 fixed);
+
+/* Naming convention about GLYF and Glyph:
+ * High level functions which are exported should have their name
+ * contain GLYF, on the other hand, low level function (or structures)
+ * which is not intended to be exported should have their name
+ * contain Glyph
+ */
+void ttfInitGLYF(TTFontPtr font)
+{
+ ULONG tag = 'g' | 'l' << 8 | 'y' << 16 | 'f' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag, font)) != NULL)
+ {
+ font->glyphOffset = ptd->offset;
+ }
+}
+/* offset: where the specified glyph really starts
+ * callers should compute this themself form the loca tables */
+void ttfLoadGLYF(FILE *fp, GLYFPtr glyf, ULONG offset)
+{
+ if (fseek(fp, offset, SEEK_SET) != 0)
+ ttfError("Fseek Failed in ttfLoadGLYF\n");
+
+ glyf->numberOfContours = ttfGetSHORT(fp);
+ glyf->xMin = ttfGetFWord(fp);
+ glyf->yMin = ttfGetFWord(fp);
+ glyf->xMax = ttfGetFWord(fp);
+ glyf->yMax = ttfGetFWord(fp);
+
+ offset += sizeof(USHORT) + 4*sizeof(FWord);
+
+ if (glyf->numberOfContours >= 0)
+ ttfLoadSimpleGlyph(fp, glyf, offset);
+ else
+ ttfLoadCompositeGlyph(fp, glyf, offset);
+}
+void ttfPrintGLYF(FILE *fp, GLYFPtr glyf)
+{
+ fprintf(fp,"\t numberOfContours:\t %d %s\n", glyf->numberOfContours,
+ glyf->numberOfContours == -1 ? "(Composite)": "");
+ fprintf(fp,"\t xMin:\t\t\t %d\n", glyf->xMin);
+ fprintf(fp,"\t yMin:\t\t\t %d\n", glyf->yMin);
+ fprintf(fp,"\t xMax:\t\t\t %d\n", glyf->xMax);
+ fprintf(fp,"\t yMax:\t\t\t %d\n\n", glyf->yMax);
+
+ if (glyf->numberOfContours >= 0)
+ ttfPrintSimpleGlyph(fp, glyf);
+ else
+ ttfPrintCompositeGlyph(fp, glyf);
+}
+void ttfFreeGLYF(GLYFPtr glyf)
+{
+ if (glyf->numberOfContours < 0)
+ ttfFreeCompositeGlyph(glyf);
+}
+static void ttfLoadSimpleGlyph(FILE *fp, GLYFPtr glyf, ULONG offset)
+{
+ SHORT nCnts = glyf->numberOfContours;
+ USHORT i,nIns,nPts;
+
+ if (fseek(fp, offset, SEEK_SET) != 0)
+ ttfError("Fseek Failed in ttfLoadSimpleGlyph\n");
+
+ if (fread(glyf->endPtsOfContours, sizeof(USHORT), nCnts, fp) != nCnts)
+ ttfError("Error when getting endPtsOfContours\n");
+#ifndef WORDS_BIGENDIAN
+ TwoByteSwap((unsigned char *) glyf->endPtsOfContours,
+ nCnts*sizeof(USHORT));
+#endif
+
+ if (nCnts != 0)
+ nPts = (glyf->endPtsOfContours)[nCnts-1]+1;
+ else
+ /* there seems to be something wrong with my interpretation of
+ * NOGLYPH chars, doing this way in case there is a char that has
+ * zero contour */
+ nPts = 0;
+
+ /* how to deal with zero instruction glyf properly ?? */
+ glyf->instructionLength = nIns = ttfGetUSHORT(fp);
+ if (nIns != 0)
+ {
+ if (fread(glyf->instructions, sizeof(BYTE), nIns, fp) != nIns)
+ ttfError("Error when getting instructions\n");
+ }
+
+ for (i=0;i<nPts;i++)
+ {
+ BYTE j,c;
+ if (((glyf->flags)[i] = c = ttfGetBYTE(fp)) & FLAGS_REPEAT)
+ { /* if this flag should be repeated */
+ j = ttfGetBYTE(fp); /* j times */
+ while (j--)
+ {
+ i++;
+ (glyf->flags)[i] = c;
+
+ }
+ }
+ }
+
+ for (i=0;i<nPts;i++)
+ {
+ BYTE flag;
+ flag = (glyf->flags)[i];
+
+ if (flag & FLAGS_X_SHORT_VECTOR)
+ { /* if the coordinate is a BYTE */
+ if (flag & FLAGS_X_SAME)
+ (glyf->xCoordinates)[i] = (SHORT) ttfGetBYTE(fp);
+ else
+ (glyf->xCoordinates)[i] = (SHORT) -ttfGetBYTE(fp);
+ }
+ else
+ { /* the coordiante is a SHORT */
+ if (flag & FLAGS_X_SAME)
+ (glyf->xCoordinates)[i] = 0;
+ else
+ (glyf->xCoordinates)[i] = ttfGetSHORT(fp);
+ }
+ }
+ for (i=0;i<nPts;i++)
+ {
+ BYTE flag;
+ flag = (glyf->flags)[i];
+
+ if (flag & FLAGS_Y_SHORT_VECTOR)
+ { /* if the coordinate is a BYTE */
+ if (flag & FLAGS_Y_SAME)
+ (glyf->yCoordinates)[i] = (SHORT) ttfGetBYTE(fp);
+ else
+ (glyf->yCoordinates)[i] = (SHORT) -ttfGetBYTE(fp);
+ }
+ else
+ { /* the coordiante is a SHORT */
+ if (flag & FLAGS_Y_SAME)
+ (glyf->yCoordinates)[i] = 0;
+ else
+ (glyf->yCoordinates)[i] = ttfGetSHORT(fp);
+ }
+ }
+}
+static void ttfPrintSimpleGlyph(FILE *fp, GLYFPtr glyf)
+{
+ USHORT i, nPts, nCnts;
+ SHORT x=0, y=0;
+
+ nPts = (glyf->endPtsOfContours)[glyf->numberOfContours-1]+1;
+ nCnts = glyf->numberOfContours;
+
+ fprintf(fp,"\t EndPoints\n");
+ fprintf(fp,"\t ---------\n");
+ for (i=0;i<nCnts;i++)
+ fprintf(fp,"\t %d: %2d\n",i,(glyf->endPtsOfContours)[i]);
+ fprintf(fp,"\n");
+
+ fprintf(fp,"\t Length of Instructions: %2d\n\n",glyf->instructionLength);
+ ttfPrintInstructions(fp,glyf->instructions);
+
+ fprintf(fp,"\t Flags\n");
+ fprintf(fp,"\t -----\n");
+ for (i=0;i<nPts;i++)
+ {
+ BYTE flag;
+ char buf[80];
+
+ flag = (glyf->flags)[i];
+
+ if (flag & FLAGS_Y_SAME)
+ sprintf(buf,"YDual ");
+ else
+ sprintf(buf," ");
+ if (flag & FLAGS_X_SAME)
+ strcat(buf,"XDual ");
+ else
+ strcat(buf," ");
+ if (flag & FLAGS_REPEAT)
+ strcat(buf,"Repeat ");
+ else
+ strcat(buf," ");
+ if (flag & FLAGS_Y_SHORT_VECTOR)
+ strcat(buf,"Y-Short ");
+ else
+ strcat(buf," ");
+ if (flag & FLAGS_X_SHORT_VECTOR)
+ strcat(buf,"X-Short ");
+ else
+ strcat(buf," ");
+ if (flag & FLAGS_ON_CURVE)
+ strcat(buf,"On \n");
+ else
+ strcat(buf,"Off\n");
+
+ fprintf(fp,"\t %2d: %s",i,buf);
+ }
+ fprintf(fp,"\n");
+ fprintf(fp,"\t Coordinates\n");
+ fprintf(fp,"\t -----------\n");
+ for (i=0;i<nPts;i++)
+ {
+ x += (glyf->xCoordinates)[i];
+ y += (glyf->yCoordinates)[i];
+ fprintf(fp,"\t %2d Rel ( %6d, %6d) -> Abs ( %6d, %6d)\n", i,
+ (glyf->xCoordinates)[i], (glyf->yCoordinates)[i], x, y);
+ }
+ fprintf(fp,"\n");
+}
+
+static void ttfLoadCompositeGlyph(FILE *fp, GLYFPtr glyf, ULONG offset)
+{
+ USHORT nIns,flags;
+ Component *cur;
+
+ if (fseek(fp, offset, SEEK_SET) != 0)
+ ttfError("Fseek Failed in ttfLoadCompositeGlyph\n");
+
+ if((glyf->comp = cur = (Component *) calloc(1, sizeof(Component))) == NULL)
+ ttfError("Out Of Memory\n");
+ cur->previous = NULL; /* beginning of a linked list */
+
+ do {
+ cur->flags = flags = ttfGetUSHORT(fp);
+ cur->glyphIndex = ttfGetUSHORT(fp);
+ if (flags & ARG_1_AND_2_ARE_WORDS)
+ {
+ (cur->data).args[0] = ttfGetSHORT(fp);
+ (cur->data).args[1] = ttfGetSHORT(fp);
+ }
+ else
+ (cur->data).args[0] = ttfGetUSHORT(fp);
+
+ if (flags & WE_HAVE_A_SCALE)
+ {
+ (cur->data).transform.scale = ttfGetF2Dot14(fp);
+ }
+ else if (flags & WE_HAVE_AN_X_AND_Y_SCALE)
+ {
+ (cur->data).transform.vector.xscale = ttfGetF2Dot14(fp);
+ (cur->data).transform.vector.yscale = ttfGetF2Dot14(fp);
+ }
+ else if (flags & WE_HAVE_A_TWO_BY_TWO)
+ {
+ (cur->data).transform.tensor.xscale = ttfGetF2Dot14(fp);
+ (cur->data).transform.tensor.scale01 = ttfGetF2Dot14(fp);
+ (cur->data).transform.tensor.scale10 = ttfGetF2Dot14(fp);
+ (cur->data).transform.tensor.yscale = ttfGetF2Dot14(fp);
+ }
+ /* allocate next component */
+ if ((cur->next = (Component *) calloc(1, sizeof(Component))) == NULL)
+ ttfError("Out Of Memory\n");
+
+ cur->next->previous = cur;
+ cur = cur->next; /* move to next component */
+ } while (flags & MORE_COMPONENT);
+ cur->next = NULL; /* end of the linked list */
+
+ if (flags & WE_HAVE_INSTRUCTIONS)
+ {
+ glyf->instructionLength = nIns = ttfGetUSHORT(fp);
+ if (fread(glyf->instructions, sizeof(BYTE), nIns, fp) != nIns)
+ ttfError("Error when loading instructions\n");
+ }
+ else
+ {
+ glyf->instructionLength = 0;
+ }
+}
+static void ttfPrintCompositeGlyph(FILE *fp, GLYFPtr glyf)
+{
+ int i = 0;
+ char buf[80];
+ USHORT flags;
+ Component *cur;
+
+ cur = glyf->comp;
+
+ do {
+ flags = cur->flags;
+ fprintf(fp, "\t %d: Flags:\t 0x%x\n", i, flags);
+ fprintf(fp, "\t Glyf Index:\t %d\n", cur->glyphIndex);
+ if (flags & ARGS_ARE_XY_VALUES)
+ {
+ if (flags & ARG_1_AND_2_ARE_WORDS)
+ {
+ fprintf(fp, "\t X WOffset:\t %d\n", (cur->data).args[0]);
+ fprintf(fp, "\t Y WOffset:\t %d\n", (cur->data).args[1]);
+ }
+ else
+ {
+ fprintf(fp, "\t X BOffset:\t %d\n",
+ (signed char) ((cur->data).args[0] >> 8 & 0xff));
+ fprintf(fp, "\t Y BOffset:\t %d\n",
+ (signed char) ((cur->data).args[0] & 0xff));
+ }
+ }
+ else
+ {
+ /* what the hell are the "patch points" ?? */
+ }
+
+ if (flags & WE_HAVE_A_SCALE)
+ {
+ fprintf(fp, "\t X,Y Scale:\t %f\n",
+ fix2dbl((cur->data).transform.scale));
+ }
+ else if (flags & WE_HAVE_AN_X_AND_Y_SCALE)
+ {
+ fprintf(fp, "\t X Scale:\t %f\n",
+ fix2dbl((cur->data).transform.vector.xscale));
+ fprintf(fp, "\t Y Scale:\t %f\n",
+ fix2dbl((cur->data).transform.vector.yscale));
+ }
+ else if (flags & WE_HAVE_A_TWO_BY_TWO)
+ {
+ fprintf(fp, "\t X Scale:\t %f\n",
+ fix2dbl((cur->data).transform.tensor.xscale));
+ fprintf(fp, "\t X,Y Scale:\t %f\n",
+ fix2dbl((cur->data).transform.tensor.scale01));
+ fprintf(fp, "\t Y,X Scale:\t %f\n",
+ fix2dbl((cur->data).transform.tensor.scale10));
+ fprintf(fp, "\t Y Scale:\t %f\n",
+ fix2dbl((cur->data).transform.tensor.yscale));
+ }
+
+ if (flags & ROUND_XY_TO_GRID)
+ sprintf(buf, "Round X,Y to Grid ");
+ else
+ sprintf(buf, " ");
+
+ if (flags & NO_OVERLAP)
+ strcat(buf, "NO Overlap ");
+ else
+ strcat(buf, " ");
+
+ if (flags & USE_MY_METRICS)
+ strcat(buf, "Use My Metrics ");
+ else
+ strcat(buf, " ");
+
+ fprintf(fp, "\t Others:\t %s\n\n", buf);
+
+ i++;
+ cur = cur->next;
+ } while (cur->next != NULL);
+
+ fprintf(fp, "\n");
+
+ if (flags & WE_HAVE_INSTRUCTIONS)
+ {
+ fprintf(fp,"\t Length of Instructions: %2d\n\n",
+ glyf->instructionLength);
+ ttfPrintInstructions(fp, glyf->instructions);
+ }
+}
+static void ttfFreeCompositeGlyph(GLYFPtr glyf)
+{
+ Component *cur,*next;
+
+ cur = glyf->comp;
+
+ do {
+ next = cur->next;
+ free(cur);
+ cur = next;
+ } while (cur != NULL);
+}
+
+/* what I want:
+ * outter procedures should not have any ideas about where the glyph starts,
+ *
+ * it just provide the TTFont structure and the character code or the index
+ * of that glyph. Procedures below should do:
+ * 1. look up where the glyph data is.
+ * 2. provided some glyph cache mechanism for the reason that
+ * a. it is not necessary to load all glyph into memory, especially for
+ * eastern languages.
+ * b. if a glyph data has been loaded previously, it is not necessary to
+ * load it again.
+ * c. malloc and free are SLOW !!
+ */
+/* Load a glyph by glyph index */
+GLYFPtr ttfLoadGlyphIndex(TTFont *font, USHORT idx)
+{
+ ULONG pos;
+ GLYFPtr glyf;
+
+ /* compute the actual place where the glyph stored */
+ pos = font->glyphOffset + ttfLookUpGlyfLOCA(font->loca, idx);
+ glyf = ttfLoadGlyphCached(font, pos);
+
+ return glyf;
+}
+/* Load a glyph by character code in the current encoding scheme */
+GLYFPtr ttfLoadGlyphCode(TTFont *font,USHORT cc)
+{
+ USHORT index;
+
+ index = ttfLookUpCMAP(font->encoding,cc);
+ return ttfLoadGlyphIndex(font,index);
+}
+
+double fix2dbl(F2Dot14 fixed)
+{
+ double mantissa, fraction;
+
+ mantissa = (double) (fixed >> 14);
+
+ fraction = (double) (double)(fixed & 0x3fff) / 16384.0;
+
+ return mantissa+fraction;
+}
diff --git a/Build/source/texk/ttfdump/libttf/gstate.c b/Build/source/texk/ttfdump/libttf/gstate.c
new file mode 100644
index 00000000000..ba94ca69c79
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/gstate.c
@@ -0,0 +1,43 @@
+/* gstate.c -- manage graphics state
+ * Copyright (C) 1996 Li-Da Lho, All right reserved.
+ */
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: gstate.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: gstate.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+GraphicsState gsdefault;
+
+void ttfInitGraphicsState(TTFontPtr font)
+{
+ /*font->gstate = GS_DEFAULT;
+ font->gstate_init = GS_DEFAULT;*/
+
+ /*ttfExecuteInstruction(font, font->fpgm);
+ ttfExecuteInstruction(font, font->prep);*/
+}
+
+void ttfInitStack(TTFontPtr font)
+{
+ font->vm.sp = 0;
+ font->vm.Stack = (LONG *) calloc (font->maxp->maxStackElements, sizeof(LONG));
+ if (font->vm.Stack == NULL)
+ ttfError("Out of memory\n");
+}
+
+void ttfInitStorageArea(TTFontPtr font)
+{
+ font->vm.StorageArea = (LONG *) calloc (font->maxp->maxStorage, sizeof(LONG));
+ if (font->vm.StorageArea == NULL)
+ ttfError("Out of memory\n");
+}
diff --git a/Build/source/texk/ttfdump/libttf/hdmx.c b/Build/source/texk/ttfdump/libttf/hdmx.c
new file mode 100644
index 00000000000..a1bd36d6ae7
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/hdmx.c
@@ -0,0 +1,110 @@
+/* hdmx.c -- Horizontal Device Metrics
+ * Copyright (C) 1996 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: hdmx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: hdmx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+static HDMXPtr ttfAllocHDMX(TTFontPtr font);
+static void ttfLoadHDMX(FILE *fp,HDMXPtr hdmx,ULONG offset);
+
+void ttfInitHDMX(TTFontPtr font)
+{
+ ULONG tag = 'h' | 'd' << 8 | 'm' << 16 | 'x' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->hdmx = ttfAllocHDMX(font);
+ font->hdmx->numGlyphs = font->maxp->numGlyphs;
+ ttfLoadHDMX(font->fp,font->hdmx,ptd->offset);
+ }
+}
+static HDMXPtr ttfAllocHDMX(TTFontPtr font)
+{
+ HDMXPtr hdmx;
+
+ if ((hdmx = (HDMXPtr) calloc(1,sizeof(HDMX))) == NULL)
+ {
+ ttfError("Out of Memory in __FILE__:__LINE__\n");
+ return NULL;
+ }
+ return hdmx;
+}
+static void ttfLoadHDMX (FILE *fp,HDMXPtr hdmx,ULONG offset)
+{
+ int i;
+
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLoadHDMX \n");
+
+ hdmx->version = ttfGetUSHORT(fp);
+ hdmx->numDevices = ttfGetUSHORT(fp);
+ hdmx->size = ttfGetLONG(fp);
+
+ hdmx->Records = (DeviceRecord *) calloc(hdmx->numDevices,
+ sizeof(DeviceRecord));
+
+ if (hdmx->Records == NULL)
+ ttfError("Out of Memory in __FILE__:__LINE__\n");
+ else
+ for (i=0;i<hdmx->numDevices;i++)
+ {
+ hdmx->Records[i].PixelSize = ttfGetBYTE(fp);
+ hdmx->Records[i].MaxWidth = ttfGetBYTE(fp);
+ hdmx->Records[i].Width = (BYTE *) calloc(hdmx->size,
+ sizeof(BYTE));
+ fread ((hdmx->Records+i)->Width, sizeof(BYTE),
+ hdmx->numGlyphs+1,fp);
+ }
+}
+
+void ttfPrintHDMX(FILE *fp,HDMXPtr hdmx)
+{
+ int i;
+
+ fprintf(fp,"'hdmx' Table - Horizontal Device Metrics\n");
+ fprintf(fp,"----------------------------------------\n");
+
+ fprintf(fp,"\t 'hdmx' version:\t %d\n",hdmx->version);
+ fprintf(fp,"\t # device records:\t %d\n",hdmx->numDevices);
+ fprintf(fp,"\t Record length:\t %d\n",hdmx->size);
+
+ for (i=0;i<hdmx->numDevices;i++)
+ {
+ int j;
+ fprintf(fp,"\t DevRec %d: ppem = %d, maxWid = %d\n",
+ i,hdmx->Records[i].PixelSize,hdmx->Records[i].MaxWidth);
+
+ for (j=0;j<hdmx->numGlyphs;j++)
+ fprintf(fp,"\t %d. \t %d\n",j,(hdmx->Records+i)->Width[j]);
+ fprintf(fp,"\n");
+ }
+ fprintf(fp,"\n");
+}
+
+void ttfFreeHDMX(HDMXPtr hdmx)
+{
+ int i;
+
+ if (hdmx != NULL)
+ {
+ for (i=0;i<hdmx->numDevices;i++)
+ free(hdmx->Records[i].Width);
+
+ free(hdmx->Records);
+ free(hdmx);
+ }
+}
diff --git a/Build/source/texk/ttfdump/libttf/head.c b/Build/source/texk/ttfdump/libttf/head.c
new file mode 100644
index 00000000000..93365d8f485
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/head.c
@@ -0,0 +1,108 @@
+/* head.c -- Header Table
+ * Copyright (C) 1996 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: head.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: head.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+static HEADPtr ttfAllocHEAD(TTFontPtr font);
+static void ttfLoadHEAD(FILE *fp,HEADPtr head,ULONG offset);
+
+void ttfInitHEAD(TTFontPtr font)
+{
+ ULONG tag = 'h' | 'e' << 8 | 'a' << 16 | 'd' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->head = ttfAllocHEAD(font);
+ ttfLoadHEAD(font->fp,font->head,ptd->offset);
+ }
+}
+static HEADPtr ttfAllocHEAD(TTFontPtr font)
+{
+ HEADPtr head;
+
+ if ((head = (HEADPtr) calloc(1,sizeof(HEAD))) == NULL)
+ {
+ ttfError("Out of Memory in __FILE__:__LINE__\n");
+ return NULL;
+ }
+ return head;
+}
+static void ttfLoadHEAD(FILE *fp,HEADPtr head,ULONG offset)
+{
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLoadHEAD \n");
+
+ head->version = ttfGetFixed(fp);
+ head->fontRevision = ttfGetFixed(fp);
+ head->checkSumAdj = ttfGetULONG(fp);
+ head->magicNumber = ttfGetULONG(fp);
+ head->flags = ttfGetUSHORT(fp);
+ head->unitsPerEm = ttfGetUSHORT(fp);
+
+ fread(head->created,sizeof(char),8,fp);
+ fread(head->modified,sizeof(char),8,fp);
+
+ head->xMin = ttfGetFWord(fp);
+ head->yMin = ttfGetFWord(fp);
+ head->xMax = ttfGetFWord(fp);
+ head->yMax = ttfGetFWord(fp);
+
+ head->macStyle = ttfGetUSHORT(fp);
+ head->lowestRecPPEM = ttfGetUSHORT(fp);
+
+ head->fontDirectionHint = ttfGetSHORT(fp);
+ head->indexToLocFormat = ttfGetSHORT(fp);
+ head->glyphDataFormat = ttfGetSHORT(fp);
+}
+
+void ttfPrintHEAD(FILE *fp,HEADPtr head)
+{
+ int b1[2],b2[2];
+
+ FixedSplit(head->version,b1);
+ FixedSplit(head->fontRevision,b2);
+
+ fprintf(fp,"'head' Table - Font Header\n");
+ fprintf(fp,"--------------------------\n");
+ fprintf(fp,"\t 'head' version:\t %2d.%2d\n",b1[1],b1[0]);
+ fprintf(fp,"\t fontReversion:\t\t %2d.%2d\n",b2[1],b2[0]);
+ fprintf(fp,"\t checkSumAdjustment:\t 0x%08x\n",head->checkSumAdj);
+ fprintf(fp,"\t magicNumber:\t\t 0x%08x\n",head->magicNumber);
+ fprintf(fp,"\t flags:\t\t\t 0x%04x\n",head->flags);
+ fprintf(fp,"\t unitsPerEm:\t\t %d\n",head->unitsPerEm);
+
+ /* don't know how to compute */
+ fprintf(fp,"\t created:\n");
+ fprintf(fp,"\t modified:\n");
+
+ fprintf(fp,"\t xMin:\t\t\t %d\n",head->xMin);
+ fprintf(fp,"\t yMin:\t\t\t %d\n",head->yMin);
+ fprintf(fp,"\t xMax:\t\t\t %d\n",head->xMax);
+ fprintf(fp,"\t yMax:\t\t\t %d\n",head->yMax);
+ fprintf(fp,"\t macStyle bits:\t\t 0x%04x\n",head->macStyle);
+ fprintf(fp,"\t lowestRecPPEM:\t\t %d\n",head->lowestRecPPEM);
+ fprintf(fp,"\t fontDirectionHint:\t %d\n",head->fontDirectionHint);
+ fprintf(fp,"\t indexToLocFormat:\t %d\n",head->indexToLocFormat);
+ fprintf(fp,"\t glyphDataFormat:\t %d\n",head->glyphDataFormat);
+ fprintf(fp,"\n");
+}
+
+void ttfFreeHEAD(HEADPtr head)
+{
+ free(head);
+}
diff --git a/Build/source/texk/ttfdump/libttf/hhea.c b/Build/source/texk/ttfdump/libttf/hhea.c
new file mode 100644
index 00000000000..086f3b7c300
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/hhea.c
@@ -0,0 +1,95 @@
+/* hhea.c -- Horizontal header
+ * Copyright (C) 1996 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: hhea.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: hhea.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+static HHEAPtr ttfAllocHHEA(TTFontPtr font);
+static void ttfLoadHHEA(FILE *fp,HHEAPtr hhea,ULONG offset);
+
+void ttfInitHHEA(TTFontPtr font)
+{
+ ULONG tag = 'h' | 'h' << 8 | 'e' << 16 | 'a' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->hhea = ttfAllocHHEA(font);
+ ttfLoadHHEA(font->fp,font->hhea,ptd->offset);
+ }
+}
+static HHEAPtr ttfAllocHHEA(TTFontPtr font)
+{
+ HHEAPtr hhea;
+
+ if ((hhea = (HHEAPtr) calloc(1,sizeof(HHEA))) == NULL)
+ {
+ ttfError("Out of Memory in __FILE__:__LINE__\n");
+ return NULL;
+ }
+ return hhea;
+}
+static void ttfLoadHHEA (FILE *fp,HHEAPtr hhea,ULONG offset)
+{
+ int i;
+
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLOADCMAP \n");
+
+ hhea->version = ttfGetFixed(fp);
+ hhea->Ascender = ttfGetFWord(fp);
+ hhea->Descender = ttfGetFWord(fp);
+ hhea->LineGap = ttfGetFWord(fp);
+ hhea->advanceWidthMax = ttfGetuFWord(fp);
+ hhea->minLeftSideBearing = ttfGetFWord(fp);
+ hhea->minRightSideBearing = ttfGetFWord(fp);
+ hhea->xMaxExtent = ttfGetFWord(fp);
+ hhea->caretSlopeRise = ttfGetSHORT(fp);
+ hhea->caretSlopeRun = ttfGetSHORT(fp);
+ for(i=0;i<5;i++)
+ (hhea->reserved)[i] = ttfGetSHORT(fp);
+ hhea->metricDataFormat = ttfGetSHORT(fp);
+ hhea->numberOfHMetrics = ttfGetUSHORT(fp);
+}
+
+void ttfPrintHHEA(FILE *fp,HHEAPtr hhea)
+{
+ int i,b[2];
+
+ FixedSplit(hhea->version,b);
+
+ fprintf(fp,"'hhea' Table - Horizontal Header\n");
+ fprintf(fp,"--------------------------\n");
+ fprintf(fp,"\t 'hhea' version:\t %2d.%2d\n",b[1],b[0]);
+ fprintf(fp,"\t yAscender:\t\t %d\n",hhea->Ascender);
+ fprintf(fp,"\t yDescender:\t\t %d\n",hhea->Descender);
+ fprintf(fp,"\t yLineGap:\t\t %d\n",hhea->LineGap);
+ fprintf(fp,"\t advanceWidthMax:\t %d\n",hhea->advanceWidthMax);
+ fprintf(fp,"\t minLeftSideBearing:\t %d\n",hhea->minLeftSideBearing);
+ fprintf(fp,"\t minRightSideBearing:\t %d\n",hhea->minRightSideBearing);
+ fprintf(fp,"\t xMaxExtent:\t\t %d\n",hhea->xMaxExtent);
+ fprintf(fp,"\t caretSlopeRise:\t %d\n",hhea->caretSlopeRise);
+ fprintf(fp,"\t caretSlopeRun:\t\t %d\n",hhea->caretSlopeRun);
+ for (i=0;i<5;i++)
+ fprintf(fp,"\t reserved%d:\t\t %d\n",i,(hhea->reserved)[i]);
+ fprintf(fp,"\t metricDataFormat:\t %d\n",hhea->metricDataFormat);
+ fprintf(fp,"\t numberOfHMetrics:\t %d\n",hhea->numberOfHMetrics);
+}
+
+void ttfFreeHHEA(HHEAPtr hhea)
+{
+ free(hhea);
+}
diff --git a/Build/source/texk/ttfdump/libttf/hmtx.c b/Build/source/texk/ttfdump/libttf/hmtx.c
new file mode 100644
index 00000000000..4d71edfe956
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/hmtx.c
@@ -0,0 +1,111 @@
+/* hmtx.c -- Horizontal Metrics Table
+ * Copyright (C) 1997 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: hmtx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: hmtx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+static HMTXPtr ttfAllocHMTX(TTFontPtr font);
+static void ttfLoadHMTX(FILE *fp,HMTXPtr hmtx,ULONG offset);
+
+/* Caution: Because of interdependency between tables,
+ * table hhea and maxp should be well initalized before
+ * ttfInitHMTX is been called
+ */
+void ttfInitHMTX(TTFontPtr font)
+{
+ ULONG tag = 'h' | 'm' << 8 | 't' << 16 | 'x' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->hmtx = ttfAllocHMTX(font);
+ font->hmtx->numberOfHMetrics = font->hhea->numberOfHMetrics;
+ font->hmtx->numberOfLSB = font->maxp->numGlyphs -
+ font->hhea->numberOfHMetrics;
+ ttfLoadHMTX(font->fp,font->hmtx,ptd->offset);
+ }
+}
+static HMTXPtr ttfAllocHMTX(TTFontPtr font)
+{
+ HMTXPtr hmtx;
+
+ if ((hmtx = (HMTXPtr) calloc(1,sizeof(HMTX))) == NULL)
+ {
+ ttfError("Out of Memory in __FILE__:__LINE__\n");
+ return NULL;
+ }
+ return hmtx;
+}
+static void ttfLoadHMTX(FILE *fp,HMTXPtr hmtx,ULONG offset)
+{
+ USHORT i,n = hmtx->numberOfHMetrics,m=hmtx->numberOfLSB;
+
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLOADHMTX \n");
+
+ if ((hmtx->hMetrics = (longHorMetric *) calloc(n,sizeof(longHorMetric))) != NULL)
+ {
+ for (i=0;i<n;i++)
+ {
+ (hmtx->hMetrics+i)->advanceWidth = ttfGetuFWord(fp);
+ (hmtx->hMetrics+i)->lsb = ttfGetFWord(fp);
+ }
+ }
+ else
+ {
+ ttfError("Out Of Memory in __FILE__ : __LINE__\n");
+ }
+
+ /* codes dealing with leftSideBearing entry */
+ if (m && ((hmtx->leftSideBearing = (FWord *) calloc(m,sizeof(FWord))) != NULL))
+ {
+ for (i=0;i<m;i++)
+ {
+ (hmtx->leftSideBearing)[i] = ttfGetFWord(fp);
+ }
+ }
+}
+
+void ttfPrintHMTX(FILE *fp,HMTXPtr hmtx)
+{
+ int i;
+
+ fprintf(fp,"'hmtx' Table - Horizontal Metrics\n");
+ fprintf(fp,"---------------------------------\n");
+
+ for (i=0;i<hmtx->numberOfHMetrics;i++)
+ {
+ fprintf(fp,"\t %4d. advWid: %4d, LSBear: %4d\n",i,
+ (hmtx->hMetrics+i)->advanceWidth,
+ (hmtx->hMetrics+i)->lsb);
+ }
+
+ for (i=0;i<hmtx->numberOfLSB;i++)
+ {
+ fprintf(fp,"\t %4d. LSbear: %4d\n",i+hmtx->numberOfHMetrics,
+ (hmtx->leftSideBearing)[i]);
+ }
+}
+
+void ttfFreeHMTX(HMTXPtr hmtx)
+{
+ free(hmtx->hMetrics);
+
+ if (hmtx->numberOfLSB)
+ free(hmtx->leftSideBearing);
+
+ free(hmtx);
+}
diff --git a/Build/source/texk/ttfdump/libttf/interp.c b/Build/source/texk/ttfdump/libttf/interp.c
new file mode 100644
index 00000000000..6adfbee38bc
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/interp.c
@@ -0,0 +1,864 @@
+/* interp.c -- Instruction Interpreter
+ * Copyright (C) 1996 Li-Da Lho, All right reserved.
+ */
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: interp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: interp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+/* A bit about error checking: The execution of a TrueType instruction is
+ * "atomic" which mean that we don't process the error until a single
+ * instruction is fully decoded and exectued */
+
+/* Pushing data onto the interpreter stack */
+
+void Interp_NPUSHB (VirtualMachine *vm)
+{
+ BYTE i,n;
+ ULONG l;
+
+ n = GetBYTE(vm);
+
+ for (i=1;i<=n;i++)
+ {
+ /* unsigned extension to four bytes */
+ l = (ULONG) GetBYTE(vm);
+ Push(vm, l);
+ }
+}
+
+void Interp_NPUSHW(VirtualMachine *vm)
+{
+ BYTE i,n;
+ LONG l;
+
+ n = GetBYTE(vm);
+
+ for (i=1;i<=n;i++)
+ {
+ /* signed extension to four bytes */
+ l = (LONG) GetSHORT(vm);
+ Push(vm, l);
+ }
+
+}
+
+void Interp_PUSHB(VirtualMachine *vm)
+{
+ BYTE opcode,n,i;
+ ULONG l;
+
+ opcode = (vm->iStream)[vm->ip];
+ n = opcode - 0xB0;
+
+ for (i=0;i<=n;i++)
+ {
+ l = (ULONG) GetBYTE(vm);
+ Push(vm, l);
+ }
+}
+/* PUSHW[abc] Push Words
+ * Code Range 0xB8 - 0x0BF
+ * From IS w0,w1,...wn
+ * Pushes w0,w1,...wn */
+void Interp_PUSHW(VirtualMachine *vm)
+{
+ BYTE opcode,n,i;
+ LONG l;
+
+ opcode = (vm->iStream)[vm->ip];
+ n = opcode - 0xB8;
+
+ for (i=0;i<=n;i++)
+ {
+ l = (LONG) GetSHORT(vm);
+ Push(vm,l);
+ }
+}
+
+/* Managing the Storage Area */
+
+/* RS[] Read Store
+ * Code Range 0x43
+ * Pops location: Storage Area location (ULONG)
+ * Pushes value: Storage Area value (ULONG)
+ * Gets Storage Area value */
+void Interp_RS(VirtualMachine *vm)
+{
+ ULONG location,value;
+
+ location = Pop(vm);
+ value = (vm->StorageArea)[location];
+ Push(vm,value);
+}
+/* WS[] Write Store
+ * Code Range 0x42
+ * Pops value: Storage Area value (ULONG)
+ * location: Storage Area location (ULONG)
+ * Pushes -
+ * Sets Storage Area */
+void Interp_WS(VirtualMachine *vm)
+{
+ ULONG location,value;
+
+ value = Pop(vm);
+ location = Pop(vm);
+ (vm->StorageArea)[location] = value;
+}
+
+/* Managing the Control Value Table */
+
+/* WCVTP[] Write control Value Table in Pixel units
+ * Code Range 0x44
+ * Pops value: number in pixels (F26Dot6)
+ * location: Control Value Table location (ULONG)
+ * Pushes -
+ * Sets Control Value Table entry */
+void Interp_WCVTP(VirtualMachine *vm)
+{
+ F26Dot6 value;
+ ULONG location;
+
+ value = Pop(vm);
+ location = Pop(vm);
+
+ (vm->cvt)[location] = value;
+}
+/* WCVTF[] Write Control Value Table in FUnits
+ * Code Range 0x70
+ * Pops value: number in FUnits (ULONG) (LONG actually,i think)
+ * location: Control Value (ULONG)
+ * Pushes -
+ * Sets Control Value Table entry
+ */
+void Interp_WCVTF(VirtualMachine *vm)
+{
+ ULONG location;
+ LONG value;
+
+ value = Pop(vm);
+ location = Pop(vm);
+
+ value = ScaleToPoints(vm,value);
+ (vm->cvt)[location] = value;
+}
+/* RCVT[] Read Control Value Table
+ * Code Range 0x45
+ * Pops location: CVT entry number (ULONG)
+ * Pushes value: CVT value (F26Dot6)
+ * Gets Control Value Table entry
+ */
+void Interp_RCVT(VirtualMachine *vm)
+{
+ ULONG location;
+ F26Dot6 value;
+
+ location = Pop(vm);
+ value = (vm->cvt)[location];
+ Push(vm,value);
+}
+
+/* Managing Graphics State */
+
+/* SVTCA[a] Set freedom and projection vector to Coordinate Axia
+ * Code Range 0x00 - 0x01
+ * a 0: set to y axis
+ * 1: set to x axis
+ * Pops -
+ * Pushes -
+ * Sets projection_vector
+ * freedom_vector
+ */
+void Interp_SVTCA(VirtualMachine *vm)
+{
+ BYTE opcode;
+ TTFUnitVector vect;
+
+ opcode = (vm->iStream)[vm->ip];
+ switch (opcode)
+ {
+ case 0x00:
+ vect.x = 0;
+ vect.y = F2Dot14_ONE;
+ break;
+ case 0x01:
+ vect.x = F2Dot14_ONE;
+ vect.y = 0;
+ break;
+ }
+ vm->gstate.projection_vector = vm->gstate.freedom_vector = vect;
+}
+/* SPVCA[a] Set projection vector to coordinate axis
+ * Code Range 0x02 - 0x03
+ * a 0: set to y axis
+ * 1: set to x axis
+ * Pops -
+ * Pushes -
+ * Sets projection vector
+ */
+void Interp_SPVTCA(VirtualMachine *vm)
+{
+ BYTE opcode;
+ TTFUnitVector vect;
+
+ opcode = (vm->iStream)[vm->ip];
+ switch (opcode)
+ {
+ case 0x02:
+ vect.x = 0;
+ vect.y = F2Dot14_ONE;
+ break;
+ case 0x03:
+ vect.x = F2Dot14_ONE;
+ vect.y = 0;
+ break;
+ }
+ vm->gstate.projection_vector = vect;
+}
+/* SFVTCA[a] Set freedom vector to coordinate axis
+ * Code Range 0x04 - 0x05
+ * a 0: set to y axis
+ * 1: set to x axis
+ * Pops -
+ * Pushes -
+ * Sets freedom vector
+ */
+void Interp_SFVTCA(VirtualMachine *vm)
+{
+ BYTE opcode;
+ TTFUnitVector vect;
+
+ opcode = (vm->iStream)[vm->ip];
+ switch (opcode)
+ {
+ case 0x04:
+ vect.x = 0;
+ vect.y = F2Dot14_ONE;
+ break;
+ case 0x05:
+ vect.x = F2Dot14_ONE;
+ vect.y = 0;
+ break;
+ }
+ vm->gstate.freedom_vector = vect;
+}
+/* SPVTL[a] Set projection vector to line
+ * Code Range 0x06 - 0x07
+ * a 0: set projection_vector to be parallel to line segment from p1
+ * to p2
+ * 1: set projection_vector to be perpendicular to line segment from
+ * p1 to p2; the vector is retated counter clockwise 90 degrees
+ * Pops p1: point number (ULONG)
+ * p2: point number (ULONG)
+ * Pushes -
+ * Uses point p1 in the zone pointed at by zp2
+ * point p2 in the zone pointed at by zp1
+ * Sets projection vector
+ */
+void Interp_SPVTL(VirtualMachine *vm)
+{
+ ULONG p1,p2;
+ BYTE opcode;
+ TTFUnitVector vect;
+
+ opcode = (vm->iStream)[vm->ip];
+ p1 = Pop(vm);
+ p2 = Pop(vm);
+
+ switch (opcode)
+ {
+ /* not finished yet */
+ case 0x06:
+ break;
+ case 0x07:
+ break;
+ }
+ vm->gstate.projection_vector = vect;
+}
+/* SFVTL[a] Set freedom vector to line
+ * Code Range 0x08 - 0x09
+ * a 0: set freedom_vector to be parallel to line segment from p1
+ * to p2
+ * 1: set freedom_vector to be perpendicular to line segment from
+ * p1 to p2; the vector is retated counter clockwise 90 degrees
+ * Pops p1: point number (ULONG)
+ * p2: point number (ULONG)
+ * Pushes -
+ * Uses point p1 in the zone pointed at by zp2
+ * point p2 in the zone pointed at by zp1
+ * Sets freedom vector
+ */
+void Interp_SFVTL(VirtualMachine *vm)
+{
+ ULONG p1,p2;
+ BYTE opcode;
+ TTFUnitVector vect;
+
+ opcode = (vm->iStream)[vm->ip];
+ p1 = Pop(vm);
+ p2 = Pop(vm);
+ switch (opcode)
+ {
+ /* not finished yet */
+ case 0x08:
+ break;
+ case 0x09:
+ break;
+ }
+ vm->gstate.freedom_vector = vect;
+}
+/* SFVTPV[] Set freedom vector to projection vector
+ * Code Range 0x0E
+ * Pops -
+ * Pushes -
+ * Sets freedom vector
+ */
+void Interp_SFVTPV(VirtualMachine *vm)
+{
+ vm->gstate.freedom_vector = vm->gstate.projection_vector;
+}
+/* SDPVTL[a] Set dual projection vector to line
+ * Code Range 0x86 - 0x87
+ * a 0: vectors are parallel to line
+ * 1: vectors are perpendicular to line
+ * Pops p1: first point number (ULONG)
+ * p2: second point number (ULONG)
+ * Pushes -
+ * Sets dual_projection_vector and projection_vector
+ * Uses point p1 in the zone pointed by zp2
+ * point p2 in the zone pointed by zp1
+ */
+void Interp_SDPVTL(VirtualMachine *vm)
+{
+ ULONG p1,p2;
+ BYTE opcode;
+ TTFUnitVector vect;
+
+ opcode = (vm->iStream)[vm->ip];
+ p1 = Pop(vm);
+ p2 = Pop(vm);
+ switch (opcode)
+ {
+ /* not finished yet */
+ case 0x86:
+ break;
+ case 0x87:
+ break;
+ }
+ vm->gstate.dual_projection_vector = vm->gstate.projection_vector = vect;
+}
+/* SPVFS[] Set projection vector from stack
+ * Code Range 0x0A
+ * Pops y: y component of projection vector (2.14 padded with zeros)
+ * x: x component of projection vector (2.14 padded with zeros)
+ * Pushes -
+ * Sets projection_vector
+ */
+void Inpterp_SPVFS(VirtualMachine *vm)
+{
+ F2Dot14 x,y;
+
+ x = Pop(vm);
+ y = Pop(vm);
+
+ vm->gstate.projection_vector.x = x;
+ vm->gstate.projection_vector.y = y;
+ /* vm->gstate.projection = Normalize(vm->gstate.projection); ?? */
+}
+/* SFVFS[] Set freedom vector form stack
+ * Code Range 0x0B
+ * Pops y: y component of freedom vector (2.14 padded with zeros)
+ * x: x component of freedom vector (2.14 padded with zeros)
+ * Pushes -
+ * Sets freedom_vector
+ */
+void Inpterp_SFVFS(VirtualMachine *vm)
+{
+ F2Dot14 x,y;
+
+ x = Pop(vm);
+ y = Pop(vm);
+
+ vm->gstate.freedom_vector.x = x;
+ vm->gstate.freedom_vector.y = y;
+ /* vm->gstate.freedom = Normalize(vm->gstate.freedom); ?? */
+}
+/* GPV[] Get projection vector
+ * Code Range 0x0C
+ * Pops -
+ * Pushes x: x component of projection vector (2.14 padded with zeros)
+ * y: y component of projection vector (2.14 padded with zeros)
+ * Gets projection vector
+ */
+void Interp_GPV(VirtualMachine *vm)
+{
+ ULONG l;
+
+ l = (ULONG) vm->gstate.projection_vector.x;
+ Push(vm,l);
+ l = (ULONG) vm->gstate.projection_vector.y;
+ Push(vm,l);
+}
+/* GFV[] Get freedom vector
+ * Code Range 0x0D
+ * Pops -
+ * Pushes x: x component of freedom vector (2.14 padded with zeros)
+ * y: y component of freedom vector (2.14 padded with zeros)
+ * Gets freedom vector
+ */
+void Interp_GFV(VirtualMachine *vm)
+{
+ ULONG l;
+
+ l = (ULONG) vm->gstate.freedom_vector.x;
+ Push(vm,l);
+ l = (ULONG) vm->gstate.freedom_vector.y;
+ Push(vm,l);
+}
+/* SRP0[] Set reference point 0
+ * Code Range 0x10
+ * Pops p: point number (ULONG)
+ * Pushes -
+ * Sets rp0
+ * Affects IP,MDAP,MIAP,MIRP,MSIRP,SHC,SHE,SHP
+ */
+void Inpter_SRP0(VirtualMachine *vm)
+{
+ vm->gstate.rp0 = Pop(vm);
+}
+/* SRP1[] Set reference point 1
+ * Code Range 0x11
+ * Pops p: point number (ULONG)
+ * Pushes -
+ * Sets rp1
+ * Affects IP,MDAP,MIAP,MIRP,MSIRP,SHC,SHE,SHP
+ */
+void Inpter_SRP1(VirtualMachine *vm)
+{
+ vm->gstate.rp1 = Pop(vm);
+}
+/* SRP2[] Set reference point 2
+ * Code Range 0x12
+ * Pops p: point number (ULONG)
+ * Pushes -
+ * Sets rp2
+ * Affects IP,MDAP,MIAP,MIRP,MSIRP,SHC,SHE,SHP
+ */
+void Inpter_SRP2(VirtualMachine *vm)
+{
+ vm->gstate.rp2 = Pop(vm);
+}
+/* SZP0[] Set zone pointer 0
+ * Code Range 0x13
+ * Pops n: zone number (ULONG)
+ * Pushes -
+ * Sets zp0
+ * Affects ALIGNPTS,ALIGNRP,DELTAP1,DELTAP2,DELTAP3,IP,ISECT,MD,MDAP,MIAP,
+ * MIRP,MSIRP,SHC,SHE,SHP,UTP
+ */
+void Inpterp_SZP0(VirtualMachine *vm)
+{
+ vm->gstate.zp0 = Pop(vm);
+}
+/* SZP1[] Set zone pointer 1
+ * Code Range 0x14
+ * Pops n: zone number (ULONG)
+ * Pushes -
+ * Sets zp1
+ * Affects ALIGNPTS,ALIGNRP,DELTAP1,DELTAP2,DELTAP3,IP,ISECT,MD,MDAP,MIAP,
+ * MIRP,MSIRP,SHC,SHE,SHP,UTP
+ */
+void Inpterp_SZP1(VirtualMachine *vm)
+{
+ vm->gstate.zp1 = Pop(vm);
+}
+/* SZP2[] Set zone pointer 2
+ * Code Range 0x15
+ * Pops n: zone number (ULONG)
+ * Pushes -
+ * Sets zp2
+ * Affects ALIGNPTS,ALIGNRP,DELTAP1,DELTAP2,DELTAP3,IP,ISECT,MD,MDAP,MIAP,
+ * MIRP,MSIRP,SHC,SHE,SHP,UTP
+ */
+void Inpterp_SZP2(VirtualMachine *vm)
+{
+ vm->gstate.zp2 = Pop(vm);
+}
+/* SZPS[] Set zone pointerS
+ * Code Range 0x16
+ * Pops n: zone number (ULONG)
+ * Pushes -
+ * Sets zp0,zp1,zp2
+ * Affects ALIGNPTS,ALIGNRP,DELTAP1,DELTAP2,DELTAP3,IP,ISECT,MD,MDAP,MIAP,
+ * MIRP,MSIRP,SHC,SHE,SHP,UTP
+ */
+void Inpterp_SZPS(VirtualMachine *vm)
+{
+ vm->gstate.zp0 = vm->gstate.zp1 = vm->gstate.zp2 = Pop(vm);
+}
+/* RTHG[] Round to half grid
+ * Code Range 0x19
+ * Pops -
+ * Pushes -
+ * Sets round_state
+ * Affects MDAP,MDRP,MDIAP,MIRP,ROUND
+ * Uses freedom_vector, projection_vetor
+ */
+void Interp_RTHG(VirtualMachine *vm)
+{
+ vm->gstate.round_state = 0;
+}
+/* RTG[] Round to grid
+ * Code Range 0x18
+ * Pops -
+ * Pushes -
+ * Sets round_state
+ * Affects MDAP,MDRP,MDIAP,MIRP,ROUND
+ * Uses freedom_vector, projection_vetor
+ */
+void Interp_RTG(VirtualMachine *vm)
+{
+ vm->gstate.round_state = 1;
+}
+/* RTDG[] Round to double grid
+ * Code Range 0x3D
+ * Pops -
+ * Pushes -
+ * Sets round_state
+ * Affects MDAP,MDRP,MDIAP,MIRP,ROUND
+ * Uses freedom_vector, projection_vetor
+ */
+void Interp_RTDG(VirtualMachine *vm)
+{
+ vm->gstate.round_state = 2;
+}
+/* RTHG[] Round down to grid
+ * Code Range 0x7D
+ * Pops -
+ * Pushes -
+ * Sets round_state
+ * Affects MDAP,MDRP,MDIAP,MIRP,ROUND
+ * Uses freedom_vector, projection_vetor
+ */
+void Interp_RDTG(VirtualMachine *vm)
+{
+ vm->gstate.round_state = 3;
+}
+/* RUTG[] Round up to grid
+ * Code Range 0x7C
+ * Pops -
+ * Pushes -
+ * Sets round_state
+ * Affects MDAP,MDRP,MDIAP,MIRP,ROUND
+ * Uses freedom_vector, projection_vetor
+ */
+void Interp_RUTG(VirtualMachine *vm)
+{
+ vm->gstate.round_state = 4;
+}
+/* ROFF[] Round off
+ * Code Range 0x7A
+ * Pops -
+ * Pushes -
+ * Sets round_state
+ * Affects MDAP,MDRP,MDIAP,MIRP,ROUND
+ * Uses freedom_vector, projection_vetor
+ */
+void Interp_ROFF(VirtualMachine *vm)
+{
+ vm->gstate.round_state = 5;
+}
+/* SROUND[] Super round
+ * Code Range 0x76
+ * Pops n: number (ULONG) decomposed to obtain period, phase, threshold
+ * Pushes -
+ * Sets round_state
+ * Affects MDAP,MDRP,MIAP,MIRP,ROUND
+ */
+void Interp_SROUND(VirtualMachine *vm)
+{
+ ULONG n;
+
+ n = Pop(vm);
+ /* not finished yet */
+}
+/* S45ROUND[] Super round 45 degrees
+ * Code Range 0x77
+ * Pops n: number (ULONG) decomposed to obtain period, phase, threshold
+ * Pushes -
+ * Sets round_state
+ * Affects MDAP,MDRP,MIAP,MIRP,ROUND
+ */
+void Interp_S45ROUND(VirtualMachine *vm)
+{
+ ULONG n;
+
+ n = Pop(vm);
+ /* not finished yet */
+}
+/* SLOOP[] Set LOOP variable
+ * Code Range 0x17
+ * Pops n: value for loop graphics state variable
+ * Pushes -
+ * Set loop
+ * Affects ALIGNRP,FLIPPT,IP,SHP,SHIP
+ */
+void Interp_SLOOP(VirtualMachine *vm)
+{
+ vm->gstate.loop = Pop(vm);
+}
+/* SMD[] Set minimum_distance
+ * Code Range 0x1a
+ * Pops distance: value for minimum_distance (F26Dot6)
+ * Pushes -
+ * Sets minimum_distance
+ */
+void Interp_SMD(VirtualMachine *vm)
+{
+ vm->gstate.minimum_distance = Pop(vm);
+}
+/* INSTCTRL[] Instruction execution control
+ * Code Range 0x8E
+ * Pops s: selector flags
+ * value: USHORT padded to 32 bits used to set value of
+ * instruction control
+ * Pushes -
+ * Sets instruction_control
+ */
+void Interp_INSTCTRL(VirtualMachine *vm)
+{
+ ULONG flag;
+
+ flag = Pop(vm);
+ vm->gstate.instruction_control = Pop(vm);
+ /* not finished yet */
+}
+/* SCANCTRL[] Scan conversion cotrol
+ * Code Range 0x85
+ * Pops n: flags indication when to turn on dropout mode (16 bits padded
+ * to 32 bits)
+ * Pushes -
+ * Sets scan_control
+ */
+void Interp_SCANCTRL(VirtualMachine *vm)
+{
+ USHORT flag;
+
+ flag = Pop(vm);
+ /* not finished yet */
+}
+/* SCANTYPE[] Scantype
+ * Code Range 0x8D
+ * Pops n: 16 bit interger
+ * Pushes -
+ * Sets scan_control
+ */
+void Interp_SCANTYPE(VirtualMachine *vm)
+{
+ /* not finished yet */
+}
+/* SCVTCI[] Set control value table cut in
+ * Code Range 0x1D
+ * Pops n: value for cut_in (F26Dot6)
+ * Pushes -
+ * Sets control_value_cut_in
+ * Affects MIAP,MIRP
+ */
+void Interp_SCVTCI(VirtualMachine *vm)
+{
+ vm->gstate.control_value_cut_in = Pop(vm);
+}
+/* SSWCI[] Single width cut in
+ * Code Range 0x1E
+ * Pops n: value for single_width_cut_in
+ * Pushes -
+ * Sets signel_width_cut_in
+ * Affects MIAP,MIRP
+ */
+void Interp_SSWCI(VirtualMachine *vm)
+{
+ vm->gstate.single_width_cut_in = Pop(vm);
+}
+/* SSW[] Set single width
+ * Code Range 0x1F
+ * Pops n: value for single_width_value (FUnits)
+ * Pushes -
+ * Sets single_width_value
+ */
+void Interp_SSW(VirtualMachine *vm)
+{
+ vm->gstate.single_width_cut_in = Pop(vm);
+}
+/* FLIPON[] Set the auto_flip on
+ * Code Range 0x4D
+ * Pops -
+ * Pushes -
+ * Sets auto_flip
+ * Affects MIRP
+ */
+void Interp_FLIPON(VirtualMachine *vm)
+{
+ vm->gstate.auto_flip = 1;
+}
+/* FLIPOFF[] Set the auto_flip off
+ * Code Range 0x4E
+ * Pops -
+ * Pushes -
+ * Sets auto_flip
+ * Affects MIRP
+ */
+void Interp_FLIPOFF(VirtualMachine *vm)
+{
+ vm->gstate.auto_flip = 0;
+}
+/* SDB Set delta_base in the graphics state
+ * Code Range 0x5E
+ * Pops n: value for delta_base (ULONG)
+ * Pushes -
+ * Sets delta_base
+ * Affects DELTAP1,DELTAP2,DELTAP3,DELTAC1,DELTAC2,DELTAC3
+ */
+void Interp_SDB(VirtualMachine *vm)
+{
+ vm->gstate.delta_base = Pop(vm);
+}
+/* SDS Set delta_shift in the graphics state
+ * Code Range 0x5F
+ * Pops n: value for delat_shift (ULONG)
+ * Sets delta_shift
+ * Affects DELTAP1,DELTAP2,DELTAP3,DELATC1,DELTAC2,DELTAC3
+ */
+void Interp_SDS(VirtualMachine *vm)
+{
+ vm->gstate.delta_shift = Pop(vm);
+}
+
+/* Reading and writing data */
+
+/* GC[a] Get coordinate projected on to the projection_vector
+ * Code Range 0x46 - 0x47
+ * a 0: use current position of point p
+ * 1: use the position of point p in the original outline
+ * Pops p: point number (ULONG)
+ * Pushes value: coordinate location (F26Dot6)
+ * Uses zp2,projection
+ */
+void Interp_GC(VirtualMachine *vm)
+{
+ ULONG point;
+ TTFVector pos;
+
+ point = Pop(vm);
+
+ /* not finished yet */
+}
+/* SCFS[] Sets coordinate from the stack using projection_vector and
+ * freedom_vector
+ * Code Range 0x48
+ * Pops value: distance from origin to move point (F26Dot6)
+ * p: point number (ULONG)
+ * Pushes -
+ * Uses zp2, freedom_vector, projection_vector
+ */
+void Interp_SCFS(VirtualMachine *vm)
+{
+#ifdef WIN32
+ __int64 tmp;
+#else
+ long long tmp;
+#endif
+ F26Dot6 value;
+ ULONG point;
+
+ value = Pop(vm);
+ point = Pop(vm);
+ /* not finished yet */
+}
+/* MD[a] Measure Distance
+ *
+ * Code Range 0x49-0x4A
+ * a 0: measure distance in grid-fitted outline
+ * 1: measure distance in original outline
+ * Pops p1: point number (ULONG)
+ * p2: point number (ULONG);
+ * Pushes distance (F26Dot6)
+ * uses zp1 with point p1, zp2 withe point p2, projection_vector
+ */
+void Interp_MD(VirtualMachine *vm)
+{
+ ULONG p1,p2;
+ BYTE opcode;
+ TTFUnitVector vect;
+
+ opcode = (vm->iStream)[vm->ip];
+ p1 = Pop(vm);
+ p2 = Pop(vm);
+ switch (opcode)
+ {
+ /* not finished yet */
+ case 0x49:
+ break;
+ case 0x4A:
+ break;
+ }
+ /* not finished yet */
+}
+/* MPPEM[] Measure Pixel Per EM
+ *
+ * Code Range 0x4B
+ * Pops -
+ * Pushes ppem:pixel per em (ULONG)
+ */
+void Interp_MPPEM(VirtualMachine *vm)
+{
+ /* not finished yet */
+}
+/* MPS[] Measure Point Size
+ *
+ * Code Range 0x4C
+ * Pops -
+ * Pushes pointSize: the size in points of the current glyph (F26Dot6)
+ */
+void Interp_MPS(VirtualMachine *vm)
+{
+ F26Dot6 pointSize = vm->pointsize;
+
+ Push(vm,pointSize);
+}
+
+/* Mananging Outlines */
+
+/* FLIPPT[] Flip point
+ * Code Range 0x80
+ * Pops p: point number (ULONG)
+ * Pushes -
+ * Uses loop, p is referenced in zp0
+ */
+void Interp_FLIPPT(VirtualMachine *vm)
+{
+ ULONG point;
+
+ point = Pop(vm);
+
+ /* not finished yet */
+}
+/* FLIPRGON[] Filp range on
+ * Code Range 0x81
+ * Pops hightpoint: highest point number in range of points to be flipped
+ * lowpoint: lowest point number in range of points to be flipped
+ * both are ULONG
+ * Pushes -
+ */
+void Interp_FLIPRGON(VirtualMachine *vm)
+{
+
+}
diff --git a/Build/source/texk/ttfdump/libttf/kern.c b/Build/source/texk/ttfdump/libttf/kern.c
new file mode 100644
index 00000000000..79e8cb6ebd3
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/kern.c
@@ -0,0 +1,179 @@
+/* kern.c -- Kerning Table
+ * Copyright (C) 1996 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: kern.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: kern.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+static KERNPtr ttfAllocKERN(TTFontPtr font);
+static void ttfLoadKERN(FILE *fp,KERNPtr kern,ULONG offset);
+
+void ttfInitKERN(TTFontPtr font)
+{
+ ULONG tag = 'k' | 'e' << 8 | 'r' << 16 | 'n' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->kern = ttfAllocKERN(font);
+ ttfLoadKERN(font->fp,font->kern,ptd->offset);
+ }
+}
+static KERNPtr ttfAllocKERN(TTFontPtr font)
+{
+ KERNPtr kern;
+
+ if ((kern = (KERNPtr) calloc(1,sizeof(KERN))) == NULL)
+ {
+ ttfError("Out of Memory in __FILE__:__LINE__\n");
+ return NULL;
+ }
+ return kern;
+}
+static void ttfLoadKERN (FILE *fp,KERNPtr kern,ULONG offset)
+{
+ int i;
+
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLoadKERN \n");
+
+ kern->version = ttfGetUSHORT(fp);
+ kern->nTables = ttfGetUSHORT(fp);
+
+ kern->subtable = (KernSubtable *) calloc(kern->nTables,
+ sizeof(KernSubtable));
+
+ for (i=0;i<kern->nTables;i++)
+ {
+ struct kernpair *pairs;
+ int j,n;
+ (kern->subtable+i)->version = ttfGetUSHORT(fp);
+ (kern->subtable+i)->length = ttfGetUSHORT(fp);
+ (kern->subtable+i)->coverage = ttfGetUSHORT(fp);
+
+ switch ((kern->subtable+i)->coverage >> 8)
+ {
+ case 0:
+ (kern->subtable+i)->kern.kern0.nPairs = n =
+ ttfGetUSHORT(fp);
+ (kern->subtable+i)->kern.kern0.searchRange =
+ ttfGetUSHORT(fp);
+ (kern->subtable+i)->kern.kern0.entrySelector =
+ ttfGetUSHORT(fp);
+ (kern->subtable+i)->kern.kern0.rangeShift =
+ ttfGetUSHORT(fp);
+ (kern->subtable+i)->kern.kern0.pairs = pairs =
+ (struct kernpair *) calloc(n,sizeof (struct kernpair));
+
+ for (j=0;j<n;j++)
+ {
+ (pairs+j)->left = ttfGetUSHORT(fp);
+ (pairs+j)->right = ttfGetUSHORT(fp);
+ (pairs+j)->value = ttfGetFWord(fp);
+ }
+ break;
+ case 2:
+ /* not implemented yet */
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+ }
+}
+
+void ttfPrintKERN(FILE *fp,KERNPtr kern)
+{
+ int i;
+
+ fprintf(fp,"'kern' Table - Kerning Data\n");
+ fprintf(fp,"---------------------------\n");
+ fprintf(fp,"'kern' Version:\t %d\n", kern->version);
+ fprintf(fp,"Number of subtables:\t %d\n\n",kern->nTables);
+
+ for (i=0;i<kern->nTables;i++)
+ {
+ struct kernpair *pairs;
+ int j,n;
+
+ fprintf(fp,"\t Subtable format \t %d\n",
+ (kern->subtable+i)->coverage >> 8);
+ fprintf(fp,"\t Subtable version \t %d\n",
+ (kern->subtable+i)->version);
+ fprintf(fp,"\t Bytes in subtable \t %d\n",
+ (kern->subtable+i)->length);
+ fprintf(fp,"\t Coverage bits \t 0x%x \n",
+ (kern->subtable+i)->coverage);
+ switch ((kern->subtable+i)->coverage >> 8)
+ {
+ case 0:
+ n = (kern->subtable+i)->kern.kern0.nPairs;
+ pairs = (kern->subtable+i)->kern.kern0.pairs;
+
+ fprintf(fp,"\t Number of pairs %d\n",n);
+ fprintf(fp,"\t Search Range %d\n",
+ (kern->subtable+i)->kern.kern0.searchRange);
+ fprintf(fp,"\t Entry Selector %d\n",
+ (kern->subtable+i)->kern.kern0.entrySelector);
+ fprintf(fp,"\t Range Shift %d\n",
+ (kern->subtable+i)->kern.kern0.rangeShift);
+
+ fprintf(fp,"\t Left Glyph \t Right Glyph \t Kern Move\n");
+ fprintf(fp,"\t ---------- \t ----------- \t ---------\n");
+
+ for (j=0;j<n;j++)
+ {
+ fprintf(fp,"\t\t %d \t\t %d \t\t %d\n",
+ (pairs+j)->left,(pairs+j)->right,
+ (pairs+j)->value);
+ }
+ break;
+ case 2:
+ /* not implemented yet */
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+ fprintf(fp,"\n");
+ }
+
+}
+
+void ttfFreeKERN(KERNPtr kern)
+{
+ int i;
+
+ if (kern != NULL)
+ {
+ for (i=0;i<kern->nTables;i++)
+ {
+ switch ((kern->subtable+i)->coverage >> 8)
+ {
+ case 0:
+ free((kern->subtable+i)->kern.kern0.pairs);
+ break;
+ case 2:
+ /* not implemented yet */
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+ }
+ free(kern->subtable);
+ free(kern);
+ }
+}
diff --git a/Build/source/texk/ttfdump/libttf/loca.c b/Build/source/texk/ttfdump/libttf/loca.c
new file mode 100644
index 00000000000..3d09b8959a8
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/loca.c
@@ -0,0 +1,110 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: loca.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: loca.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+static LOCAPtr ttfAllocLOCA(TTFontPtr font);
+static void ttfLoadLOCA(FILE *fp,LOCAPtr loca,ULONG offset);
+
+void ttfInitLOCA(TTFontPtr font)
+{
+ ULONG tag = 'l' | 'o' << 8 | 'c' << 16 | 'a' <<24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->loca = (LOCAPtr) ttfAllocLOCA(font);
+ ttfLoadLOCA(font->fp,font->loca,ptd->offset);
+ }
+}
+static LOCAPtr ttfAllocLOCA(TTFontPtr font)
+{
+ USHORT n=0;
+ LOCAPtr loca;
+
+ if ((loca = (LOCAPtr) calloc(1,sizeof(LOCA))) == NULL)
+ {
+ ttfError("Out of Memory\n");
+ }
+ else
+ {
+ loca->indexToLocFormat = font->head->indexToLocFormat;
+ loca->numGlyphs = n = font->maxp->numGlyphs;
+ }
+
+ n += 1;/* the number of loca entry is numberOfGlyph+1 */
+ if ((loca->offset = (ULONG *) calloc(n,sizeof(ULONG))) == NULL)
+ {
+ ttfError("Out Of Memory\n");
+ free (loca);
+ return NULL;
+ }
+
+ return loca;
+}
+static void ttfLoadLOCA(FILE *fp,LOCAPtr loca,ULONG offset)
+{
+ /* warrning: the number of loca entry is numberOfGlyph+1 !! */
+ USHORT i,n = loca->numGlyphs+1;
+
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLOADLOCA \n");
+
+ switch (loca->indexToLocFormat)
+ {
+ case LOCA_OFFSET_SHORT:
+ for (i=0;i<n;i++)
+ {
+ (loca->offset)[i] = (ULONG) ttfGetUSHORT(fp)*2;
+ }
+ break;
+ case LOCA_OFFSET_LONG:
+ if (fread(loca->offset,sizeof(ULONG),n,fp) != n)
+ ttfError("Error reading loca data\n");
+#ifndef WORDS_BIGENDIAN
+ FourByteSwap((unsigned char *) loca->offset,n*sizeof(ULONG));
+#endif
+ break;
+ }
+}
+
+void ttfPrintLOCA(FILE *fp,LOCAPtr loca)
+{
+ USHORT i;
+
+ fprintf(fp,"'loca' Table - Index to Location\n");
+ fprintf(fp,"--------------------------------\n");
+ for (i=0;i<loca->numGlyphs;i++)
+ {
+ fprintf(fp,"\t Idx %6d -> GlyphOffset 0x%08x\n",i,
+ (loca->offset)[i]);
+ }
+ fprintf (fp,"\t Ended at 0x%08x\n",(loca->offset)[loca->numGlyphs]);
+}
+
+void ttfFreeLOCA(LOCAPtr loca)
+{
+ free (loca->offset);
+ free (loca);
+}
+
+ULONG ttfLookUpGlyfLOCA(LOCAPtr loca,USHORT idx)
+{
+ /* out of bound or it is a non-glyph character */
+ if (idx >= loca->numGlyphs ||
+ loca->offset[idx] == loca->offset[idx+1])
+ return (loca->offset)[0];
+
+ return (loca->offset)[idx];
+}
diff --git a/Build/source/texk/ttfdump/libttf/ltsh.c b/Build/source/texk/ttfdump/libttf/ltsh.c
new file mode 100644
index 00000000000..7f50b22f73b
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/ltsh.c
@@ -0,0 +1,82 @@
+/* ltsh.c -- Linear Threshold table
+ * Copyright (C) 1996 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: ltsh.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: ltsh.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+static LTSHPtr ttfAllocLTSH(TTFontPtr font);
+static void ttfLoadLTSH(FILE *fp,LTSHPtr ltsh,ULONG offset);
+
+void ttfInitLTSH(TTFontPtr font)
+{
+ ULONG tag = 'L' | 'T' << 8 | 'S' << 16 | 'H' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->ltsh = ttfAllocLTSH(font);
+ ttfLoadLTSH(font->fp,font->ltsh,ptd->offset);
+ }
+}
+static LTSHPtr ttfAllocLTSH(TTFontPtr font)
+{
+ LTSHPtr ltsh;
+
+ if ((ltsh = (LTSHPtr) calloc(1,sizeof(LTSH))) == NULL)
+ {
+ ttfError("Out of Memory in __FILE__:__LINE__\n");
+ return NULL;
+ }
+ return ltsh;
+}
+static void ttfLoadLTSH (FILE *fp,LTSHPtr ltsh,ULONG offset)
+{
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLoadLTSH \n");
+
+ ltsh->version = ttfGetUSHORT(fp);
+ ltsh->numGlyphs = ttfGetUSHORT(fp);
+
+ ltsh->yPels = (BYTE *) calloc(ltsh->numGlyphs, sizeof(BYTE));
+
+ if(fread(ltsh->yPels, sizeof(BYTE), ltsh->numGlyphs, fp) != ltsh->numGlyphs)
+ ttfError("Error when getting yPels\n");
+}
+
+void ttfPrintLTSH(FILE *fp,LTSHPtr ltsh)
+{
+ int i;
+
+ fprintf(fp,"'LTSH' Table - Linear Threshold Table\n");
+ fprintf(fp,"-------------------------------------\n");
+ fprintf(fp,"'LTSH' Version:\t %d\n",ltsh->version);
+ fprintf(fp,"Number of Glyphs:\t %d\n",ltsh->numGlyphs);
+ fprintf(fp,"\t Glyph # \t Threshold\n");
+
+ for (i=0;i<ltsh->numGlyphs;i++)
+ {
+ fprintf(fp,"\t %d. \t\t %d\n",i,ltsh->yPels[i]);
+ }
+}
+
+void ttfFreeLTSH(LTSHPtr ltsh)
+{
+ if (ltsh != NULL)
+ {
+ free(ltsh->yPels);
+ free(ltsh);
+ }
+}
diff --git a/Build/source/texk/ttfdump/libttf/maxp.c b/Build/source/texk/ttfdump/libttf/maxp.c
new file mode 100644
index 00000000000..8a8a81eb74a
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/maxp.c
@@ -0,0 +1,92 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: maxp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: maxp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+static MAXPPtr ttfAllocMAXP(TTFontPtr font);
+static void ttfLoadMAXP(FILE *fp,MAXPPtr maxp,ULONG offset);
+
+void ttfInitMAXP(TTFontPtr font)
+{
+ ULONG tag = 'm' | 'a' << 8 | 'x' << 16 | 'p' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->maxp = ttfAllocMAXP(font);
+ ttfLoadMAXP(font->fp,font->maxp,ptd->offset);
+ }
+}
+static MAXPPtr ttfAllocMAXP(TTFontPtr font)
+{
+ MAXPPtr maxp;
+
+ if ((maxp = (MAXPPtr) calloc(1,sizeof(MAXP))) == NULL)
+ {
+ ttfError("Out of Memory in __FILE__:__LINE__\n");
+ return NULL;
+ }
+ return maxp;
+}
+static void ttfLoadMAXP(FILE *fp,MAXPPtr maxp,ULONG offset)
+{
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLOADCMAP \n");
+
+ maxp->version = ttfGetFixed(fp);
+ maxp->numGlyphs = ttfGetUSHORT(fp);
+ maxp->maxPoints = ttfGetUSHORT(fp);
+ maxp->maxContours = ttfGetUSHORT(fp);
+ maxp->maxCompositePoints = ttfGetUSHORT(fp);
+ maxp->maxCompositeContours = ttfGetUSHORT(fp);
+ maxp->maxZones = ttfGetUSHORT(fp);
+ maxp->maxTwilightPoints = ttfGetUSHORT(fp);
+ maxp->maxStorage = ttfGetUSHORT(fp);
+ maxp->maxFunctionDefs = ttfGetUSHORT(fp);
+ maxp->maxInstructionDefs = ttfGetUSHORT(fp);
+ maxp->maxStackElements = ttfGetUSHORT(fp);
+ maxp->maxSizeOfInstructions = ttfGetUSHORT(fp);
+ maxp->maxComponentElements = ttfGetUSHORT(fp);
+ maxp->maxComponentDepth = ttfGetUSHORT(fp);
+}
+
+void ttfPrintMAXP(FILE *fp,MAXPPtr maxp)
+{
+ int b[2];
+
+ FixedSplit(maxp->version,b);
+
+ fprintf(fp,"'maxp' Table - Maximum Profile\n");
+ fprintf(fp,"------------------------------\n");
+ fprintf(fp,"\t 'maxp' version:\t %2d.%2d\n",b[1],b[0]);
+ fprintf(fp,"\t numGlyphs:\t\t %d\n",maxp->numGlyphs);
+ fprintf(fp,"\t maxPoints:\t\t %d\n",maxp->maxPoints);
+ fprintf(fp,"\t maxContours:\t\t %d\n",maxp->maxContours);
+ fprintf(fp,"\t maxCompositePoints:\t %d\n",maxp->maxCompositePoints);
+ fprintf(fp,"\t maxCompositeContours:\t %d\n",maxp->maxCompositeContours);
+ fprintf(fp,"\t maxZones:\t\t %d\n",maxp->maxZones);
+ fprintf(fp,"\t maxTwilightPoints:\t %d\n",maxp->maxTwilightPoints);
+ fprintf(fp,"\t maxStorage:\t\t %d\n",maxp->maxStorage);
+ fprintf(fp,"\t maxFunctionDefs:\t %d\n",maxp->maxFunctionDefs);
+ fprintf(fp,"\t maxInstructionDefs:\t %d\n",maxp->maxInstructionDefs);
+ fprintf(fp,"\t maxStackElements:\t %d\n",maxp->maxStackElements);
+ fprintf(fp,"\t maxSizeOfInstructions:\t %d\n",maxp->maxSizeOfInstructions);
+ fprintf(fp,"\t maxComponentElements:\t %d\n",maxp->maxComponentElements);
+ fprintf(fp,"\t maxCompoenetDepth:\t %d\n",maxp->maxComponentDepth);
+}
+
+void ttfFreeMAXP(MAXPPtr maxp)
+{
+ free(maxp);
+}
diff --git a/Build/source/texk/ttfdump/libttf/name.c b/Build/source/texk/ttfdump/libttf/name.c
new file mode 100644
index 00000000000..968af094c7e
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/name.c
@@ -0,0 +1,182 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: name.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: name.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+static NAMEPtr ttfAllocNAME(TTFontPtr font);
+static void ttfLoadNAME(FILE *fp,NAMEPtr name,ULONG offset);
+static void ttfLoadNameRecord(FILE *fp,NameRecordPtr rec,ULONG offset);
+static void ttfPrintNameRecord(FILE *fp,NameRecordPtr rec);
+static void ttfLoadNameRecordData(FILE *fp,NameRecordPtr rec,ULONG offset);
+static void ttfPrintNameRecordData(FILE *fp,NameRecordPtr rec);
+static void ttfFreeNameRecordData(NameRecordPtr rec);
+static void HexDump(char *p,char *hex,char *asc,int len);
+
+void ttfInitNAME(TTFontPtr font)
+{
+ ULONG tag = 'n' | 'a' << 8 | 'm' << 16 | 'e' <<24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->name = ttfAllocNAME(font);
+ ttfLoadNAME(font->fp,font->name,ptd->offset);
+ }
+}
+static NAMEPtr ttfAllocNAME(TTFontPtr font)
+{
+ NAMEPtr name;
+
+ if((name = (NAMEPtr) calloc(1,sizeof(NAME))) == NULL)
+ {
+ ttfError("Out of Memory in __FILE__:__LINE__\n");
+ return NULL;
+ }
+ return name;
+}
+static void ttfLoadNAME(FILE *fp,NAMEPtr name,ULONG offset)
+{
+ USHORT i,n;
+ ULONG pos;
+
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLOADNAME \n");
+
+ name->format = ttfGetUSHORT(fp);
+ name->numberOfRecords = n = ttfGetUSHORT(fp);
+ name->offset = ttfGetUSHORT(fp);
+
+ if ((name->NameRecords = (NameRecordPtr) calloc(n,sizeof(NameRecord))) == NULL)
+ ttfError("Out Of Memory\n");
+
+ pos = offset + sizeof(USHORT)*3;
+
+ for(i=0;i<n;i++,pos+=12 /*sizeof(NameRecord)*/)
+ {
+ ttfLoadNameRecord(fp,name->NameRecords+i,pos);
+ ttfLoadNameRecordData(fp,name->NameRecords+i,offset+name->offset);
+ }
+}
+void ttfPrintNAME(FILE *fp,NAMEPtr name)
+{
+ USHORT i;
+
+ fprintf(fp,"'name' Table - Naming Table\n");
+ fprintf(fp,"---------------------------\n");
+ fprintf(fp,"\t Format:\t\t %d\n",name->format);
+ fprintf(fp,"\t Number of Record:\t %d\n",name->numberOfRecords);
+ fprintf(fp,"\t Storage offset:\t %d\n",name->offset);
+
+ for (i=0;i<name->numberOfRecords;i++)
+ {
+ fprintf(fp,"Name table %3d.\t",i);
+ ttfPrintNameRecord(fp,name->NameRecords+i);
+ }
+
+}
+void ttfFreeNAME(NAMEPtr name)
+{
+ USHORT i;
+ for (i=0;i<name->numberOfRecords;i++)
+ ttfFreeNameRecordData(name->NameRecords+i);
+ free(name->NameRecords);
+ free(name);
+}
+/* offset: address of the beginning of the name record */
+static void ttfLoadNameRecord(FILE *fp,NameRecordPtr rec,ULONG offset)
+{
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLoadNameRecord \n");
+
+ rec->PlatformID = ttfGetUSHORT(fp);
+ rec->EncodingID = ttfGetUSHORT(fp);
+ rec->LanguageID = ttfGetUSHORT(fp);
+ rec->NameID = ttfGetUSHORT(fp);
+ rec->length = ttfGetUSHORT(fp);
+ rec->offset = ttfGetUSHORT(fp);
+}
+static void ttfPrintNameRecord(FILE *fp,NameRecordPtr rec)
+{
+ fprintf(fp," PlatformID:\t %d\n",rec->PlatformID);
+ fprintf(fp,"\t\t EncodingID:\t %d\n",rec->EncodingID);
+ fprintf(fp,"\t\t LanguageID:\t %d\n",rec->LanguageID);
+ fprintf(fp,"\t\t NameID:\t %d\n",rec->NameID);
+ fprintf(fp,"\t\t Length:\t %d\n",rec->length);
+ fprintf(fp,"\t\t Offset:\t %d\n",rec->offset);
+ ttfPrintNameRecordData(fp,rec);
+}
+/* ULONG offset: address of the beginning of the actual data (base actually)
+ * base: start of data storage, specified by NAME.offset
+ * offset: specified by NameRecord.offset */
+static void ttfLoadNameRecordData(FILE *fp,NameRecordPtr rec,ULONG offset)
+{
+ ULONG pos;
+
+ pos = offset + rec->offset;
+ if (fseek(fp,pos,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLoadSubTable\n");
+
+ if ((rec->data = (char *) calloc(rec->length,sizeof(char))) == NULL)
+ ttfError("Out Of Memory\n");
+ if (fread(rec->data,sizeof(char),rec->length,fp) != rec->length)
+ ttfError("Error when getting Name Record Data\n");
+}
+
+static void ttfPrintNameRecordData(FILE *fp,NameRecordPtr rec)
+{
+ USHORT i,j;
+ char hexbuf[100],ascbuf[100],*p;
+
+ p = rec->data;
+ for (i=0;i<rec->length/10;i++,p+=10)
+ {
+ HexDump(p,hexbuf,ascbuf,10);
+ fprintf(fp,"\t\t %s > %s\n",hexbuf,ascbuf);
+ }
+ HexDump(p,hexbuf,ascbuf,rec->length % 10);
+ /* i know that this is ugly, but this makes output beautiful */
+ i = strlen(hexbuf);
+ for (j=i;j<30;j++)
+ {
+ hexbuf[j] = ' ';
+ }
+ fprintf(fp,"\t\t %s > %s\n",hexbuf,ascbuf);
+
+}
+static void HexDump(char *p,char *hex,char *asc,int len)
+{
+ int i;
+ unsigned char c;
+ char buf[100];
+
+ *hex = '\0';
+ *asc = '\0';
+ for (i=0;i<len;i++)
+ {
+ c = *(p+i);
+ sprintf(buf,"%02x ",c);
+ strcat(hex,buf);
+ if (isprint(c))
+ *(asc+i) = c;
+ else
+ *(asc+i) = '.';
+ }
+ *(asc+len) = *(hex+len*3) = '\0';
+}
+static void ttfFreeNameRecordData(NameRecordPtr rec)
+{
+ free(rec->data);
+}
diff --git a/Build/source/texk/ttfdump/libttf/os2.c b/Build/source/texk/ttfdump/libttf/os2.c
new file mode 100644
index 00000000000..b6d21072e5f
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/os2.c
@@ -0,0 +1,181 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#define __TTF_OS2
+#include "os2_P.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: os2.c,v 1.2 1998/07/06 06:07:01 werner Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: os2.c,v 1.2 1998/07/06 06:07:01 werner Exp $";
+#endif /* lint */
+
+static OS_2Ptr ttfAllocOS2(TTFontPtr font);
+static void ttfLoadOS2(FILE *fp, OS_2Ptr os2, ULONG offset);
+
+void ttfInitOS2(TTFontPtr font)
+{
+ ULONG tag = 'O' | 'S' << 8 | '/' << 16 | '2' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag, font)) != NULL)
+ {
+ font->os2 = ttfAllocOS2(font);
+ ttfLoadOS2(font->fp, font->os2, ptd->offset);
+ }
+}
+
+static OS_2Ptr ttfAllocOS2(TTFontPtr font)
+{
+ OS_2Ptr os2;
+
+ if ((os2 = (OS_2Ptr) calloc(1, sizeof(OS_2))) == NULL)
+ {
+ ttfError("Out of Memofy in __FILE__:__LINE__\n");
+ return NULL;
+ }
+ return os2;
+}
+
+static void ttfLoadOS2(FILE *fp, OS_2Ptr os2, ULONG offset)
+{
+ if (fseek(fp, offset, SEEK_SET) != 0)
+ ttfError("Fseek Failed in ttfLoadGLYF\n");
+
+ os2->version = ttfGetUSHORT(fp);
+ os2->xAvgCharWidth = ttfGetSHORT(fp);
+ os2->usWeightClass = ttfGetUSHORT(fp);
+ os2->usWidthClass = ttfGetUSHORT(fp);
+ os2->fsType = ttfGetUSHORT(fp);
+ os2->ySubscriptXSize = ttfGetSHORT(fp);
+ os2->ySubscriptYSize = ttfGetSHORT(fp);
+ os2->ySubscriptXOffset = ttfGetSHORT(fp);
+ os2->ySubscriptYOffset = ttfGetSHORT(fp);
+ os2->ySuperscriptXSize = ttfGetSHORT(fp);
+ os2->ySuperscriptYSize = ttfGetSHORT(fp);
+ os2->ySuperscriptXOffset = ttfGetSHORT(fp);
+ os2->ySuperscriptYOffset = ttfGetSHORT(fp);
+ os2->yStrikeoutSize = ttfGetSHORT(fp);
+ os2->yStrikeoutPosition = ttfGetSHORT(fp);
+ os2->sFamilyClass = ttfGetSHORT(fp);
+
+ if (fread(os2->panose, sizeof(CHAR), 10, fp) != 10)
+ ttfError("Error readind PANOSE\n");
+
+ os2->ulUnicodeRange1 = ttfGetULONG(fp);
+ os2->ulUnicodeRange2 = ttfGetULONG(fp);
+ os2->ulUnicodeRange3 = ttfGetULONG(fp);
+ os2->ulUnicodeRange4 = ttfGetULONG(fp);
+
+ if (fread(os2->achVendID, sizeof(CHAR), 4, fp) != 4)
+ ttfError("Error readind achVendID\n");
+ os2->achVendID[4] = 0x0;
+
+ os2->fsSelection = ttfGetUSHORT(fp);
+ os2->usFirstCharIndex = ttfGetUSHORT(fp);
+ os2->usLastCharIndex = ttfGetUSHORT(fp);
+ os2->sTypoAscender = ttfGetSHORT(fp);
+ os2->sTypoDescender = ttfGetSHORT(fp);
+ os2->sTypoLineGap = ttfGetSHORT(fp);
+ os2->usWinAscent = ttfGetUSHORT(fp);
+ os2->usWinDescent = ttfGetUSHORT(fp);
+ os2->ulCodePageRange1 = ttfGetULONG(fp);
+ os2->ulCodePageRange2 = ttfGetULONG(fp);
+}
+
+void ttfPrintOS2(FILE *fp,OS_2Ptr os2)
+{
+ char buf[80];
+
+ fprintf(fp,"'OS/2' Table - OS/2 and Windows Metrics\n");
+ fprintf(fp,"---------------------------------------\n");
+
+ fprintf(fp,"\t 'OS/2' version:\t %d\n",os2->version);
+ fprintf(fp,"\t xAvgCharWidth:\t\t %d\n",os2->xAvgCharWidth);
+ fprintf(fp,"\t usWeightClass:\t\t %d \t '%s'\n",os2->usWeightClass,
+ WeightClassName[os2->usWeightClass/100 - 1] );
+ fprintf(fp,"\t usWidthClass:\t\t %d \t '%s'\n",os2->usWidthClass,
+ WidthClassName[os2->usWidthClass - 1]);
+ fprintf(fp,"\t fsType:\t\t %d\n",os2->fsType);
+ fprintf(fp,"\t ySubscriptXSize:\t %d\n",os2->ySubscriptXSize);
+ fprintf(fp,"\t ySubscriptYSize:\t %d\n",os2->ySubscriptYSize);
+ fprintf(fp,"\t ySubscriptXOffset:\t %d\n",os2->ySubscriptXOffset);
+ fprintf(fp,"\t ySubscriptYOffset:\t %d\n",os2->ySubscriptYOffset);
+ fprintf(fp,"\t ySuperscriptXSize:\t %d\n",os2-> ySuperscriptXSize);
+ fprintf(fp,"\t ySuperscriptYSize:\t %d\n",os2->ySuperscriptYSize);
+ fprintf(fp,"\t ySuperscriptXOffset:\t %d\n",os2->ySuperscriptXOffset);
+ fprintf(fp,"\t ySuperscriptYOffset:\t %d\n",os2->ySuperscriptYOffset);
+ fprintf(fp,"\t yStrikeoutSize:\t %d\n",os2->yStrikeoutSize);
+ fprintf(fp,"\t yStrikeoutPosition\t %d\n",os2->yStrikeoutPosition);
+ fprintf(fp,"\t sFamilyClass:\t %d \t subclass = %d\n",
+ (os2->sFamilyClass) >> 8,(os2->sFamilyClass) & 0x00ff);
+ fprintf(fp,"\t PANOSE:\n");
+ fprintf(fp,"\t\t Family Kind:\t %d \t '%s'\n",os2->panose[0],
+ PanoseFamily[os2->panose[0]]);
+ fprintf(fp,"\t\t Serif Style:\t %d \t '%s'\n",os2->panose[1],
+ PanoseSerif[os2->panose[1]]);
+ fprintf(fp,"\t\t Weight:\t %d \t '%s'\n",os2->panose[2],
+ PanoseWeight[os2->panose[2]]);
+ fprintf(fp,"\t\t Proportion:\t %d \t '%s'\n",os2->panose[3],
+ PanoseProportion[os2->panose[3]]);
+ fprintf(fp,"\t\t Contrast:\t %d \t '%s'\n",os2->panose[4],
+ PanoseContrast[os2->panose[4]]);
+ fprintf(fp,"\t\t Stroke:\t %d \t '%s'\n",os2->panose[5],
+ PanoseStroke[os2->panose[5]]);
+ fprintf(fp,"\t\t Arm Style:\t %d \t '%s'\n",os2->panose[6],
+ PanoseArm[os2->panose[6]]);
+ fprintf(fp,"\t\t Lettreform:\t %d \t '%s'\n",os2->panose[7],
+ PanoseLetterform[os2->panose[7]]);
+ fprintf(fp,"\t\t Midline:\t %d \t '%s'\n",os2->panose[8],
+ PanoseMidline[os2->panose[8]]);
+ fprintf(fp,"\t\t X-height:\t %d \t '%s'\n",os2->panose[9],
+ PanoseXHeight[os2->panose[9]]);
+ fprintf(fp,"\t Unicode Range 1( Bits 0 - 31 ): \t 0x%08x\n",
+ os2->ulUnicodeRange1);
+ fprintf(fp,"\t Unicode Range 2( Bits 32 - 63 ): \t 0x%08x\n",
+ os2->ulUnicodeRange2);
+ fprintf(fp,"\t Unicode Range 3( Bits 64 - 95 ): \t 0x%08x\n",
+ os2->ulUnicodeRange3);
+ fprintf(fp,"\t Unicode Range 4( Bits 96 - 128 ): \t 0x%08x\n",
+ os2->ulUnicodeRange4);
+
+ fprintf(fp,"\t achVendID:\t\t '%s'\n",os2->achVendID);
+
+ buf[0] = 0x0;
+ if (os2->fsSelection & FS_FLAGS_REGULAR)
+ {
+ strcat(buf,"Regular ");
+ }
+ else
+ {
+ if (os2->fsSelection & FS_FLAGS_BOLD)
+ strcat(buf,"Bold ");
+ if (os2->fsSelection & FS_FLAGS_ITALIC)
+ strcat(buf,"Italic ");
+ }
+ fprintf(fp,"\t fsSelection:\t\t 0x%04x \t '%s'\n",os2->fsSelection,buf);
+ fprintf(fp,"\t usFirstCharIndex:\t 0x%04x\n ",os2->usFirstCharIndex);
+ fprintf(fp,"\t usLastCharIndex:\t 0x%04x\n",os2->usLastCharIndex);
+ fprintf(fp,"\t sTypoAscender:\t\t %d\n",os2->sTypoAscender);
+ fprintf(fp,"\t sTypoDescender:\t %d\n",os2->sTypoDescender);
+ fprintf(fp,"\t sTypoLineGap:\t\t %d\n",os2->sTypoLineGap);
+ fprintf(fp,"\t usWinAscent:\t\t %d\n",os2->usWinAscent);
+ fprintf(fp,"\t usWinDescent:\t\t %d\n",os2->usWinDescent);
+ fprintf(fp,"\t CodePage Range 1( Bits 0 - 31 ):\t 0x%08x\n",
+ os2->ulCodePageRange1);
+ fprintf(fp,"\t CodePage Range 2( Bits 32- 63 ):\t 0x%08x\n",
+ os2->ulCodePageRange2);
+}
+
+void ttfFreeOS2(OS_2Ptr os2)
+{
+ free(os2);
+}
diff --git a/Build/source/texk/ttfdump/libttf/pclt.c b/Build/source/texk/ttfdump/libttf/pclt.c
new file mode 100644
index 00000000000..e62574a7f04
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/pclt.c
@@ -0,0 +1,113 @@
+/* pclt.c -- PCL5 Table
+ * Copyright (C) 1997 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: pclt.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: pclt.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+static PCLTPtr ttfAllocPCLT(TTFontPtr font);
+static void ttfLoadPCLT(FILE *fp,PCLTPtr pclt,ULONG offset);
+
+void ttfInitPCLT(TTFontPtr font)
+{
+ ULONG tag = 'P' | 'C' << 8 | 'L' << 16 | 'T' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->pclt = ttfAllocPCLT(font);
+ ttfLoadPCLT(font->fp,font->pclt,ptd->offset);
+ }
+}
+static PCLTPtr ttfAllocPCLT(TTFontPtr font)
+{
+ PCLTPtr pclt;
+
+ if ((pclt = (PCLTPtr) calloc(1,sizeof(PCLT))) == NULL)
+ {
+ ttfError("Out of Memory in __FILE__:__LINE__\n");
+ return NULL;
+ }
+ return pclt;
+}
+static void ttfLoadPCLT(FILE *fp,PCLTPtr pclt,ULONG offset)
+{
+ int i;
+
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLOADCMAP \n");
+
+ pclt->version = ttfGetFixed(fp);
+ pclt->FontNumber = ttfGetULONG(fp);
+ pclt->Pitch = ttfGetUSHORT(fp);
+ pclt->xHeight = ttfGetUSHORT(fp);
+ pclt->Style = ttfGetUSHORT(fp);
+ pclt->TypeFamily = ttfGetUSHORT(fp);
+ pclt->CapHeight = ttfGetUSHORT(fp);
+ pclt->SymbolSet = ttfGetUSHORT(fp);
+ for (i=0;i<16;i++)
+ pclt->Typeface[i] = ttfGetCHAR(fp);
+ for (i=0;i<8;i++)
+ pclt->CharacterComplement[i] = ttfGetCHAR(fp);
+ for (i=0;i<6;i++)
+ pclt->FileName[i] = ttfGetCHAR(fp);
+ pclt->StrokeWeight = ttfGetCHAR(fp);
+ pclt->WidthType = ttfGetCHAR(fp);
+ pclt->SerifStyle = ttfGetBYTE(fp);
+}
+
+void ttfPrintPCLT(FILE *fp,PCLTPtr pclt)
+{
+ int i;
+ int b[2];
+
+ FixedSplit(pclt->version,b);
+
+ fprintf(fp,"`PCLT' Table - Printer Command Language Table\n");
+ fprintf(fp,"---------------------------------------------\n");
+ fprintf(fp,"\t version \t %d.%d\n",b[1],b[0]);
+ fprintf(fp,"\t fontNumber \t %d (0x%x) \n",pclt->FontNumber,
+ pclt->FontNumber );
+ fprintf(fp,"\t pitch \t %d\n",pclt->Pitch);
+ fprintf(fp,"\t xHeight \t %d\n",pclt->xHeight);
+ fprintf(fp,"\t style \t %d\n",pclt->Style);
+ fprintf(fp,"\t typeFamily \t %x\n",pclt->TypeFamily);
+ fprintf(fp,"\t capHeight \t %d\n",pclt->CapHeight);
+ fprintf(fp,"\t symbolSet \t %d\n",pclt->SymbolSet);
+ fprintf(fp,"\t typeFace \t ");
+ for (i=0;i<6;i++)
+ fprintf(fp,"%c",pclt->Typeface[i]);
+ fprintf(fp,"\n");
+
+ fprintf(fp,"\t characterComplement 0x");
+ for (i=0;i<8;i++)
+ fprintf(fp,"%02hx",(unsigned char)pclt->CharacterComplement[i]);
+ fprintf(fp,"\n");
+
+ fprintf(fp,"\t fileName \t ");
+ for (i=0;i<6;i++)
+ fprintf(fp,"%c",pclt->FileName[i]);
+ fprintf(fp,"\n");
+
+ fprintf(fp,"\t strokeWeight \t %d\n",pclt->StrokeWeight);
+ fprintf(fp,"\t widthType \t %d\n",pclt->WidthType);
+ fprintf(fp,"\t serifStyle \t %d\n",pclt->SerifStyle);
+}
+
+void ttfFreePCLT(PCLTPtr pclt)
+{
+ if (pclt != NULL)
+ free(pclt);
+}
diff --git a/Build/source/texk/ttfdump/libttf/post.c b/Build/source/texk/ttfdump/libttf/post.c
new file mode 100644
index 00000000000..6757ddd5979
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/post.c
@@ -0,0 +1,178 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: post.c,v 1.3 1998/06/06 12:55:53 werner Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: post.c,v 1.3 1998/06/06 12:55:53 werner Exp $";
+#endif /* lint */
+
+static POSTPtr ttfAllocPOST(TTFontPtr font);
+static void ttfLoadPOST(FILE *fp, POSTPtr post, ULONG offset);
+
+void ttfInitPOST(TTFontPtr font)
+{
+ ULONG tag = 'p' | 'o' << 8 | 's' << 16 | 't' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag, font)) != NULL)
+ {
+ font->post = ttfAllocPOST(font);
+ ttfLoadPOST(font->fp, font->post, ptd->offset);
+ }
+}
+static POSTPtr ttfAllocPOST(TTFontPtr font)
+{
+ POSTPtr post;
+
+ if ((post = (POSTPtr) calloc(1, sizeof(POST))) == NULL)
+ {
+ ttfError("Out of Memofy in __FILE__:__LINE__\n");
+ return NULL;
+ }
+ return post;
+}
+static void ttfLoadPOST(FILE *fp, POSTPtr post, ULONG offset)
+{
+ USHORT i,numGlyphs;
+ if (fseek(fp, offset, SEEK_SET) != 0)
+ ttfError("Fseek Failed in ttfLoadPOST\n");
+
+ post->format = ttfGetFixed(fp);
+ post->italicAngle = ttfGetFixed(fp);
+ post->underlinePosition = ttfGetFWord(fp);
+ post->underlineThickness = ttfGetFWord(fp);
+ post->isFixedPitch = ttfGetULONG(fp);
+ post->minMemType42 = ttfGetULONG(fp);
+ post->maxMemType42 = ttfGetULONG(fp);
+ post->minMemType1 = ttfGetULONG(fp);
+ post->maxMemType1 = ttfGetULONG(fp);
+
+ switch (post->format)
+ {
+ case 0x00020000:
+ post->name.format20 = (Format20 *) calloc(1, sizeof(Format20));
+ post->name.format20->numGlyphs = numGlyphs = ttfGetUSHORT(fp);
+ post->name.format20->glyphNameIndex =
+ (USHORT *) calloc(numGlyphs, sizeof(USHORT));
+ post->name.format20->GlyphName =
+ (CHAR **) calloc(numGlyphs, sizeof(CHAR *));
+ fread(post->name.format20->glyphNameIndex, sizeof(USHORT),
+ numGlyphs, fp);
+#ifndef WORDS_BIGENDIAN
+ TwoByteSwap((unsigned char *) post->name.format20->glyphNameIndex,
+ numGlyphs*sizeof(USHORT));
+#endif
+
+ for (i=0;i<numGlyphs;i++)
+ {
+ unsigned char len;
+ if (post->name.format20->glyphNameIndex[i] <= 257)
+ {
+ /* do nothing for standard Mac glyf name */
+ }
+ else if (post->name.format20->glyphNameIndex[i] <= 32767)
+ {
+ /* non-standard glyf name is stored as a Pascal
+ * string in the file i.e.
+ * the first byte is the length of the string
+ * but the string is not ended with a null
+ * character */
+ len = (unsigned char) ttfGetCHAR(fp);
+ post->name.format20->GlyphName[i] =
+ (CHAR *) calloc(len+1, sizeof(CHAR));
+ if (len)
+ fread(post->name.format20->GlyphName[i],
+ sizeof(CHAR), len, fp);
+ post->name.format20->GlyphName[i][len] = 0x0;
+ }
+ }
+ break;
+ case 0x00028000: /* 2.5 in 16.16 format */
+ /* not implemented yet */
+ break;
+ default:
+ /* do nothing */ ;
+ }
+}
+
+void ttfPrintPOST(FILE *fp,POSTPtr post)
+{
+ int b[2],b1[2];
+ USHORT i,numGlyphs;
+
+ FixedSplit(post->format, b);
+ FixedSplit(post->italicAngle, b1);
+ fprintf(fp,"'post' Table - PostScript\n");
+ fprintf(fp,"-------------------------\n");
+ fprintf(fp,"\t 'post' format:\t\t %d.%d\n", b[1], b[0]);
+ fprintf(fp,"\t italicAngle:\t\t %d.%d\n", b1[1], b1[0]);
+ fprintf(fp,"\t underlinePosition:\t %d\n", post->underlinePosition);
+ fprintf(fp,"\t underlineThichness:\t %d\n", post->underlineThickness);
+ fprintf(fp,"\t isFixedPitch:\t\t %ud\n", post->isFixedPitch);
+ fprintf(fp,"\t minMemType42:\t\t %ud\n", post->minMemType42);
+ fprintf(fp,"\t maxMemType42:\t\t %ud\n", post->maxMemType42);
+ fprintf(fp,"\t minMemType1:\t\t %ud\n", post->minMemType1);
+ fprintf(fp,"\t maxMemType1:\t\t %ud\n", post->maxMemType1);
+
+ switch (post->format)
+ {
+ case 0x00020000:
+ numGlyphs = post->name.format20->numGlyphs;
+ fprintf(fp, "\t Format 2.0: Non-Standard (for PostScript) TrueType Glyph Set.\n");
+ fprintf(fp,"\t\t numGlyphs:\t %d\n",
+ post->name.format20->numGlyphs);
+ for (i=0;i<numGlyphs;i++)
+ {
+ if (post->name.format20->glyphNameIndex[i] < 257)
+ {
+ fprintf(fp,"\t\t Glyf %3d -> Mac Glyph # %3d\n", i,
+ post->name.format20->glyphNameIndex[i]);
+ }
+ else if (post->name.format20->glyphNameIndex[i] < 32767)
+ {
+ fprintf(fp,"\t\t Glyf %3d -> PSGlyf Name # %3d, '%s'\n",
+ i, post->name.format20->glyphNameIndex[i] - 257,
+ post->name.format20->GlyphName[i]);
+ }
+ }
+ break;
+ case 0x00020005:
+ /* not implemented yet */
+ break;
+ default:
+ /* do nothing */;
+ }
+}
+
+void ttfFreePOST(POSTPtr post)
+{
+ USHORT i, numGlyphs;
+ switch (post->format)
+ {
+ case 0x00020000:
+ numGlyphs = post->name.format20->numGlyphs;
+ for (i=0;i<numGlyphs;i++)
+ {
+ if (post->name.format20->glyphNameIndex[i] > 257)
+ free(post->name.format20->GlyphName[i]);
+ }
+ free(post->name.format20->glyphNameIndex);
+ free(post->name.format20->GlyphName);
+ free(post->name.format20);
+ break;
+ case 0x00020005:
+ /* not implemented yet */
+ break;
+ default:
+ /* do nothing */;
+ }
+ free(post);
+}
diff --git a/Build/source/texk/ttfdump/libttf/prep.c b/Build/source/texk/ttfdump/libttf/prep.c
new file mode 100644
index 00000000000..55d674b7521
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/prep.c
@@ -0,0 +1,53 @@
+/* prep.c -- Control Value Program
+ * Copyright (C) 1996 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: prep.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: prep.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+static void ttfLoadPREP(FILE *fp,BYTE *prep,USHORT lenght,ULONG offset);
+
+void ttfInitPREP(TTFontPtr font)
+{
+ ULONG tag = 'p' | 'r' << 8 | 'e' << 16 | 'p' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->prepLength = ptd->length;
+ font->prep = (BYTE *) calloc(font->prepLength, sizeof(BYTE));
+ if (font->prep != NULL)
+ ttfLoadPREP(font->fp,font->prep,font->prepLength,ptd->offset);
+ }
+}
+
+static void ttfLoadPREP(FILE *fp,BYTE *prep,USHORT length,ULONG offset)
+{
+ if (fseek(fp,offset,SEEK_SET) != 0)
+ ttfError("Fseek Failed in ttfLoadPREP \n");
+
+ if (fread(prep, sizeof(BYTE), length, fp) != length)
+ ttfError("Error when getting PREP\n");
+}
+
+void ttfPrintPREP(FILE *fp, BYTE *prep, USHORT length)
+{
+ ttfPrintInstructions(fp, prep);
+}
+
+void ttfFreePREP(BYTE *prep)
+{
+ if (prep != NULL)
+ free(prep);
+}
diff --git a/Build/source/texk/ttfdump/libttf/stack.c b/Build/source/texk/ttfdump/libttf/stack.c
new file mode 100644
index 00000000000..e47b3b0af09
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/stack.c
@@ -0,0 +1,101 @@
+/* stack.c -- primitives for managing instruction stack and stream
+ * Copyright (C) 1996 Li-Da Lho, All right reserved.
+ */
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: stack.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: stack.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+#define stack (vm->Stack)
+#define sp (vm->sp)
+#define limit (vm->stklimit)
+#define ins (vm->iStream)
+#define ip (vm->ip)
+
+enum TTF_ERROR {StackOverflow ,InstructionOverflow};
+
+/* Push LONG l onto the stack of vm */
+inline void Push(VirtualMachine *vm, LONG l)
+{
+ if (sp < limit)
+ {
+ stack[sp] = l;
+ sp += 1;
+ }
+ else
+ vm->Error_State = StackOverflow;
+}
+/* Pop LONG from the stack of vm and store in l */
+inline LONG Pop(VirtualMachine *vm)
+{
+ LONG l;
+
+ if (sp > 0)
+ {
+ l = stack[sp];
+ sp -= 1;
+ return l;
+ }
+ else
+ {
+ vm->Error_State = StackOverflow;
+ return 0;
+ }
+}
+
+/* read one byte from the instruction stream */
+inline BYTE GetBYTE(VirtualMachine *vm)
+{
+ if (ip < vm->insLength+1)
+ return ins[ip++];
+ else
+ {
+ vm->Error_State = InstructionOverflow;
+ return 0;
+ }
+}
+/* read two bytes from the instruction stream */
+inline SHORT GetSHORT(VirtualMachine *vm)
+{
+ SHORT n = 0;
+
+ if (ip < vm->insLength + 2)
+ {
+ n = ins[ip++] << 8;
+ n |= ins[ip++];
+ return n;
+ }
+ else
+ {
+ vm->Error_State = InstructionOverflow;
+ return 0;
+ }
+}
+/* read four bytes from the instruction steam */
+inline LONG GetLONG(VirtualMachine *vm)
+{
+ LONG n = 0;
+
+ if (ip < vm->insLength + 4)
+ {
+ n = ins[ip++] << 24;
+ n |= ins[ip++] << 16;
+ n |= ins[ip++] << 8;
+ n |= ins[ip++] ;
+ return n;
+ }
+ else
+ {
+ vm->Error_State = InstructionOverflow;
+ return 0;
+ }
+}
diff --git a/Build/source/texk/ttfdump/libttf/tabledir.c b/Build/source/texk/ttfdump/libttf/tabledir.c
new file mode 100644
index 00000000000..2e2f328beb1
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/tabledir.c
@@ -0,0 +1,121 @@
+/* loadtable.c
+ * Load the tables of the Table Directory of a True Type font file
+ * Copyright (C) 1996 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: tabledir.c,v 1.2 1998/07/04 13:17:51 werner Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: tabledir.c,v 1.2 1998/07/04 13:17:51 werner Exp $";
+#endif /* lint */
+
+static TableDirPtr ttfAllocTableDir(TTFontPtr font);
+static void ttfLoadTableDir(FILE *fp,TableDirPtr p,ULONG offset);
+
+#define Offset 12 /* start point of table dir */
+
+void ttfInitTableDir(TTFontPtr font, ULONG offset)
+{
+ int i,pos; /* table directory starts form position 12 */
+
+ font->dir = ttfAllocTableDir(font);
+ pos = Offset + offset;
+ for (i=0;i<font->numTables;i++)
+ {
+ ttfLoadTableDir(font->fp,font->dir+i,pos);
+ pos += sizeof(TableDir);
+ }
+}
+
+static TableDirPtr ttfAllocTableDir(TTFontPtr font)
+{
+ TableDirPtr ptable;
+
+ if ((ptable = (TableDirPtr) calloc(font->numTables,sizeof(TableDir))) == NULL)
+ {
+ ttfError("Out Of memory\n in __FILE__:__LINE__");
+ return NULL;
+ }
+ return ptable;
+}
+
+static void ttfLoadTableDir(FILE *fp,TableDirPtr p,ULONG offset)
+{
+ if (fseek(fp,offset,SEEK_SET) != 0)
+ ttfError("Fseek Failed\n");
+
+ p -> tag = (ULONG) ttfGetLSB32(fp);
+ p -> checksum = ttfGetULONG(fp);
+ p -> offset = ttfGetULONG(fp);
+ p -> length = ttfGetULONG(fp);
+}
+
+void ttfPrintTableDir(FILE *fp,TableDirPtr p)
+{
+ char tagname[5];
+
+ /* make ULONG tag names more like a string */
+ bcopy(&(p->tag),tagname,4);
+ tagname[4] = '\0';
+#ifdef WORDS_BIGENDIAN
+ FourByteSwap((unsigned char *)tagname,4);
+#endif
+
+ fprintf(fp,"'%s' - chechsum = 0x%08x, offset = 0x%08x, len = %9u \n",
+ tagname,p->checksum,p->offset,p->length);
+}
+
+void ttfFreeTableDir(TableDirPtr p)
+{
+ free(p);
+}
+
+/* ttfLookUpTableDir
+ * lookup the specified table in an array of TableDir
+ * Linear search at present, should change to binary search in the
+ * future to improve effcience
+ * The tag name are sorted in ascent order in ttf file.
+ */
+TableDirPtr ttfLookUpTableDir(ULONG tagname,TTFontPtr font)
+{
+ USHORT i,n = font->numTables;
+ TableDirPtr ptable = font->dir;
+
+ for (i=0;i<n;i++,ptable++)
+ {
+ if (ptable->tag == tagname)
+ return ptable;
+ }
+ return NULL;
+}
+
+/* calculate table check sum */
+/* can't be done until the data abstraction have been finished */
+/* not finished yet */
+ULONG ttfCalcTableCheckSum(ULONG tagname,TTFontPtr font)
+{
+ ULONG sum = 0L,Length;
+ TableDirPtr ptable;
+
+ Length = ((ptable->length+3) & ~3) / sizeof(ULONG);
+
+ ptable = ttfLookUpTableDir(tagname, font);
+ fseek(font->fp,ptable->offset,SEEK_SET);
+
+ while (Length--)
+ {
+ sum += ttfGetULONG(font->fp);
+ }
+
+ return sum;
+}
diff --git a/Build/source/texk/ttfdump/libttf/ttc.c b/Build/source/texk/ttfdump/libttf/ttc.c
new file mode 100644
index 00000000000..853fcc103b5
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/ttc.c
@@ -0,0 +1,97 @@
+/* ttc.c -- True Type Collection Support
+ * Copyright (C) 1997 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+#include "ttc.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: ttc.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: ttc.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+TTCHeaderPtr ttfLoadTTCHeader(char * filename)
+{
+ ULONG tag = 't' | 't' << 8 | 'c' << 16 | 'f' << 24;
+ TTCHeaderPtr ttc;
+ FILE *fp;
+
+ if ((fp = fopen (filename,"r")) == NULL)
+ {
+ fprintf(stderr,"Can't open ttc file %s\n",filename);
+ return NULL;
+ }
+ ttc = (TTCHeaderPtr) calloc(1, sizeof(TTCHeader));
+
+ /* True Type Collection's TTCHeader */
+ if ((ttc->TTCTag = (ULONG) ttfGetLSB32(fp)) == tag)
+ {
+ ttc->version = ttfGetFixed(fp);
+ ttc->DirCount = (USHORT) ttfGetULONG(fp);
+ ttc->offset = (ULONG *) calloc(ttc->DirCount,
+ sizeof(ULONG));
+ if (fread(ttc->offset, sizeof(ULONG),
+ ttc->DirCount,fp) != ttc->DirCount)
+ {
+ ttfError("Error when reading Table Direcotry Offset/n");
+ }
+#ifndef WORDS_BIGENDIAN
+ FourByteSwap((unsigned char *) ttc->offset,
+ ttc->DirCount*sizeof(ULONG));
+#endif
+ ttfLoadTTCFont(ttc,fp);
+ return ttc;
+ }
+ else
+ /* a file with ttc in name but no ttc tag in it */
+ return NULL;
+}
+
+void ttfLoadTTCFont(TTCHeaderPtr ttc,FILE *fp)
+{
+ int i;
+
+ ttc->font = (TTFontPtr) calloc(ttc->DirCount, sizeof(TTFont));
+
+ if (ttc->font == NULL)
+ {
+ ttfError("Out of Memory");
+ return;
+ }
+ /* currently, we are loading all fonts in a TTC file.
+ * I still can't find a good way to share the data. */
+ for (i=0;i<ttc->DirCount;i++)
+ {
+ (ttc->font+i) -> fp = fp;
+ ttfLoadFont((ttc->font+i),(ttc->offset)[i]);
+ }
+}
+
+void ttfFreeTTCFont(TTCHeaderPtr ttc)
+{
+ int i;
+
+ for (i=0;i<ttc->DirCount;i++)
+ {
+ ttfFreeRequiredTables(ttc->font+i);
+
+ ttfFreeOptionalTables(ttc->font+i);
+
+ ttfFreeTableDir((ttc->font+i)->dir);
+ free((ttc->font+i)->refcount);
+ }
+
+ free(ttc->offset);
+ free(ttc->font);
+ free(ttc);
+}
diff --git a/Build/source/texk/ttfdump/libttf/ttfread.c b/Build/source/texk/ttfdump/libttf/ttfread.c
new file mode 100644
index 00000000000..5315509ce21
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/ttfread.c
@@ -0,0 +1,129 @@
+/* ttfread.c
+ * read data element form ttf file
+ * swap byte order carefully for MSBFirst
+ * presume that int is 32 bits
+ */
+#include <stdio.h>
+
+#if defined(__GNUC__) && defined(_IBMR2)
+/* Workaround for missing typedef in gcc (egcs-2.90.27 980315 (egcs-1.0.2 release)) */
+typedef long blkcnt_t; /* number of blocks in the file */
+#endif
+
+#include "ttf.h"
+#include "ttfutil.h"
+
+/* $Id: ttfread.c,v 1.2 1998/07/04 13:17:51 werner Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: ttfread.c,v 1.2 1998/07/04 13:17:51 werner Exp $";
+#endif /* lint */
+
+inline BYTE ttfGetBYTE(FILE *fp)
+{
+ int cc;
+ if ((cc = fgetc(fp)) == EOF)
+ {
+ /*if (feof(fp) != 0)
+ ttfError("Unexpected EOF \n");
+ else
+ ttfError("Error Getting BYTE\n");*/
+ }
+ return (BYTE) cc;
+}
+short ttfGetLSB16(FILE *fp)
+{
+ int cc;
+ cc = ttfGetBYTE(fp);
+ cc |= ttfGetBYTE(fp) <<8;
+ return cc;
+}
+
+int ttfGetLSB32(FILE *fp)
+{
+ int cc;
+ cc = ttfGetBYTE(fp);
+ cc |= ttfGetBYTE(fp) << 8;
+ cc |= ttfGetBYTE(fp) << 16;
+ cc |= ttfGetBYTE(fp) << 24;
+ return cc;
+}
+
+CHAR ttfGetCHAR(FILE *fp)
+{
+ int cc;
+ if ((cc = fgetc(fp)) == EOF)
+ {
+ if (feof(fp) != 0)
+ ttfError("Unexpected EOF \n");
+ else
+ ttfError("Error Getting CHAR\n");
+ }
+ return (CHAR) cc;
+}
+
+USHORT ttfGetUSHORT(FILE *fp)
+{
+ int cc;
+ cc = ttfGetBYTE(fp) << 8;
+ cc |= ttfGetBYTE(fp);
+
+ return (USHORT) cc;
+}
+
+USHORT ttfGetSHORT(FILE *fp)
+{
+ int cc;
+ cc = ttfGetBYTE(fp) << 8;
+ cc |= ttfGetBYTE(fp);
+
+ return (SHORT) cc;
+}
+
+ULONG ttfGetULONG(FILE *fp)
+{
+ int cc;
+ cc = ttfGetBYTE(fp) << 24;
+ cc |= ttfGetBYTE(fp) << 16;
+ cc |= ttfGetBYTE(fp) << 8;
+ cc |= ttfGetBYTE(fp);
+
+ return (ULONG) cc;
+}
+
+LONG ttfGetLONG(FILE *fp)
+{
+ int cc;
+ cc = ttfGetBYTE(fp) << 24;
+ cc |= ttfGetBYTE(fp) << 16;
+ cc |= ttfGetBYTE(fp) << 8;
+ cc |= ttfGetBYTE(fp);
+
+ return (LONG) cc;
+}
+
+Fixed ttfGetFixed(FILE *fp)
+{
+ return (Fixed) ttfGetULONG(fp);
+}
+
+FUnit ttfGetFUnit(FILE *fp)
+{
+ return (FUnit) ttfGetUSHORT(fp);
+}
+
+FWord ttfGetFWord(FILE *fp)
+{
+ return (FWord) ttfGetSHORT(fp);
+}
+
+uFWord ttfGetuFWord(FILE *fp)
+{
+ return (uFWord) ttfGetUSHORT(fp);
+}
+
+F2Dot14 ttfGetF2Dot14(FILE *fp)
+{
+ return (F2Dot14) ttfGetUSHORT(fp);
+}
+
diff --git a/Build/source/texk/ttfdump/libttf/ttfutil.c b/Build/source/texk/ttfdump/libttf/ttfutil.c
new file mode 100644
index 00000000000..d2ae4f31580
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/ttfutil.c
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include "ttf.h"
+#include "ttfutil.h"
+
+/* $Id: ttfutil.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: ttfutil.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+/* FixedSplit: split Fixed in to two interger (16.16) */
+void FixedSplit(Fixed f,int b[])
+{
+ b[0] = f & 0xff00;
+ b[1] = f >> 16;
+}
+
+/*
+ * Invert byte order within each 16-bits of an array.
+ */
+void
+TwoByteSwap(unsigned char *buf, int nbytes)
+{
+ register unsigned char c;
+
+ for (; nbytes > 0; nbytes -= 2, buf += 2)
+ {
+ c = buf[0];
+ buf[0] = buf[1];
+ buf[1] = c;
+ }
+}
+
+/*
+ * Invert byte order within each 32-bits of an array.
+ */
+
+void
+FourByteSwap(unsigned char *buf, int nbytes)
+{
+ register unsigned char c;
+
+ for (; nbytes > 0; nbytes -= 4, buf += 4)
+ {
+ c = buf[0];
+ buf[0] = buf[3];
+ buf[3] = c;
+ c = buf[1];
+ buf[1] = buf[2];
+ buf[2] = c;
+ }
+}
+
+void ttfError(char * msg)
+{
+ fprintf(stderr,"%s",msg);
+}
diff --git a/Build/source/texk/ttfdump/libttf/vdmx.c b/Build/source/texk/ttfdump/libttf/vdmx.c
new file mode 100644
index 00000000000..ad5629acfe7
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/vdmx.c
@@ -0,0 +1,157 @@
+/* vdmx.c -- Vertical Device Metrics
+ * Copyright (C) 1996 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: vdmx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: vdmx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+static VDMXPtr ttfAllocVDMX(TTFontPtr font);
+static void ttfLoadVDMX(FILE *fp,VDMXPtr vdmx,ULONG offset);
+
+void ttfInitVDMX(TTFontPtr font)
+{
+ ULONG tag = 'V' | 'D' << 8 | 'M' << 16 | 'X' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->vdmx = ttfAllocVDMX(font);
+ ttfLoadVDMX(font->fp,font->vdmx,ptd->offset);
+ }
+}
+static VDMXPtr ttfAllocVDMX(TTFontPtr font)
+{
+ VDMXPtr vdmx;
+
+ if ((vdmx = (VDMXPtr) calloc(1,sizeof(VDMX))) == NULL)
+ {
+ ttfError("Out of Memory in __FILE__:__LINE__\n");
+ return NULL;
+ }
+ return vdmx;
+}
+static void ttfLoadVDMX (FILE *fp,VDMXPtr vdmx,ULONG offset)
+{
+ int i;
+
+ if (fseek(fp,offset,SEEK_SET) != 0)
+ ttfError("Fseek Failed in ttfLoadVDMX \n");
+
+ vdmx->version = ttfGetUSHORT(fp);
+ vdmx->numRecs = ttfGetUSHORT(fp);
+ vdmx->numRatios = ttfGetUSHORT(fp);
+ vdmx->ratRange = (Ratios *) calloc(vdmx->numRatios, sizeof(Ratios));
+ vdmx->offset = (USHORT *) calloc(vdmx->numRatios, sizeof(USHORT));
+ vdmx->groups = (Vdmx *) calloc(vdmx->numRecs, sizeof(Vdmx));
+
+ for (i=0;i<vdmx->numRatios;i++)
+ {
+ (vdmx->ratRange+i)->CharSet = ttfGetBYTE(fp);
+ (vdmx->ratRange+i)->xRatio = ttfGetBYTE(fp);
+ (vdmx->ratRange+i)->yStartRatio = ttfGetBYTE(fp);
+ (vdmx->ratRange+i)->yEndRatio = ttfGetBYTE(fp);
+
+ }
+ if (fread(vdmx->offset, sizeof(USHORT), vdmx->numRatios,fp) !=
+ vdmx->numRatios)
+ ttfError("Error when getting Offset\n");
+#ifndef WORDS_BIGENDIAN
+ TwoByteSwap((unsigned char *) vdmx->offset,
+ vdmx->numRatios*sizeof(USHORT));
+#endif
+
+ for (i=0;i<vdmx->numRecs;i++)
+ {
+ int j;
+ (vdmx->groups+i)->recs = ttfGetUSHORT(fp);
+ (vdmx->groups+i)->startsz = ttfGetBYTE(fp);
+ (vdmx->groups+i)->endsz = ttfGetBYTE(fp);
+
+ (vdmx->groups+i)->entry =
+ (vTable *) calloc((vdmx->groups+i)->recs, sizeof(vTable));
+
+ for (j=0;j<(vdmx->groups+i)->recs;j++)
+ {
+ ((vdmx->groups+i)->entry+j)->yPelHeight = ttfGetUSHORT(fp);
+ ((vdmx->groups+i)->entry+j)->yMax = ttfGetSHORT(fp);
+ ((vdmx->groups+i)->entry+j)->yMin = ttfGetSHORT(fp);
+ }
+ }
+}
+
+void ttfPrintVDMX(FILE *fp,VDMXPtr vdmx)
+{
+ int i;
+
+ fprintf(fp,"'VDMX' Table - Precomputed Vertical Device Metrics\n");
+ fprintf(fp,"--------------------------------------------------\n");
+
+
+ fprintf(fp,"Version:\t %d\n", vdmx->version);
+ fprintf(fp,"Number of Hgt Records:\t %d\n",vdmx->numRecs);
+ fprintf(fp,"Number of Ratio Records:\t %d\n",vdmx->numRecs);
+
+ for (i=0;i<vdmx->numRatios;i++)
+ {
+ fprintf(fp,"\t Ratio Record #%d\n",i+1);
+ fprintf(fp,"\t\t CharSetId \t %d\n",(vdmx->ratRange+i)->CharSet);
+ fprintf(fp,"\t\t xRatio \t %d\n",(vdmx->ratRange+i)->xRatio);
+ fprintf(fp,"\t\t yStartRatio \t %d\n",(vdmx->ratRange+i)->yStartRatio);
+ fprintf(fp,"\t\t yEndRatio \t %d\n",(vdmx->ratRange+i)->yEndRatio);
+ fprintf(fp,"\t\t Record Offset %d (group #%d)\n\n",vdmx->offset[i],i);
+ }
+
+ fprintf(fp,"\t VDMX Height Record Groups\n");
+ fprintf(fp,"\t -------------------------\n\n");
+
+ for (i=0;i<vdmx->numRecs;i++)
+ {
+ int j;
+
+ fprintf(fp,"\t %d. Number of Hgt Records %d\n",i,
+ (vdmx->groups+i)->recs);
+ fprintf(fp,"\t Starting Y Pel Height %d\n",
+ (vdmx->groups+i)->startsz);
+ fprintf(fp,"\t Ending Y Pel Height %d\n",
+ (vdmx->groups+i)->endsz);
+
+ for (j=0;j<(vdmx->groups+i)->recs;j++)
+ {
+ fprintf(fp,"\t\t %d. Pel Height= %d\n",j+1,
+ ((vdmx->groups+i)->entry+j)->yPelHeight);
+ fprintf(fp,"\t\t yMax= \t %d\n",
+ ((vdmx->groups+i)->entry+j)->yMax);
+ fprintf(fp,"\t\t yMin= \t %d\n\n",
+ ((vdmx->groups+i)->entry+j)->yMin);
+ }
+ }
+
+}
+
+void ttfFreeVDMX(VDMXPtr vdmx)
+{
+ int i;
+ if (vdmx != NULL)
+ {
+ for (i=0;i<vdmx->numRecs;i++)
+ {
+ free((vdmx->groups+i)->entry);
+ }
+ free(vdmx->ratRange);
+ free(vdmx->offset);
+ free(vdmx->groups);
+ free(vdmx);
+ }
+}
diff --git a/Build/source/texk/ttfdump/libttf/vhea.c b/Build/source/texk/ttfdump/libttf/vhea.c
new file mode 100644
index 00000000000..e00c4f2268f
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/vhea.c
@@ -0,0 +1,102 @@
+/* vhea.c -- Vertical Header Table
+ * Copyright (C) 1997 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: vhea.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: vhea.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+
+static VHEAPtr ttfAllocVHEA(TTFontPtr font);
+static void ttfLoadVHEA(FILE *fp,VHEAPtr vhea,ULONG offset);
+
+void ttfInitVHEA(TTFontPtr font)
+{
+ ULONG tag = 'v' | 'h' << 8 | 'e' << 16 | 'a' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->vhea = ttfAllocVHEA(font);
+ ttfLoadVHEA(font->fp,font->vhea,ptd->offset);
+ }
+}
+static VHEAPtr ttfAllocVHEA(TTFontPtr font)
+{
+ VHEAPtr vhea;
+
+ if ((vhea = (VHEAPtr) calloc(1,sizeof(VHEA))) == NULL)
+ {
+ ttfError("Out of Memory in __FILE__:__LINE__\n");
+ return NULL;
+ }
+ return vhea;
+}
+static void ttfLoadVHEA (FILE *fp,VHEAPtr vhea,ULONG offset)
+{
+ int i;
+
+ if (fseek(fp,offset,SEEK_SET) != 0)
+ ttfError("Fseek Failed in ttfLoadVHEA \n");
+
+ vhea->version = ttfGetFixed(fp);
+ vhea->ascent = ttfGetSHORT(fp);
+ vhea->descent = ttfGetSHORT(fp);
+ vhea->lineGap = ttfGetSHORT(fp);
+ vhea->advanceHeightMax = ttfGetSHORT(fp);
+ vhea->minTopSideBearing = ttfGetSHORT(fp);
+ vhea->minBottomSideBearing = ttfGetSHORT(fp);
+ vhea->yMaxExtent = ttfGetSHORT(fp);
+ vhea->caretSlopeRise = ttfGetSHORT(fp);
+ vhea->caretSlopeRun = ttfGetSHORT(fp);
+ vhea->caretOffset = ttfGetSHORT(fp);
+ for(i=0;i<4;i++)
+ (vhea->reserved)[i] = ttfGetSHORT(fp);
+ vhea->metricDataFormat = ttfGetSHORT(fp);
+ vhea->numOfLongVerMetrics = ttfGetUSHORT(fp);
+}
+
+void ttfPrintVHEA(FILE *fp,VHEAPtr vhea)
+{
+ int i,b[2];
+
+ fprintf(fp,"'VHEA' - Vertical Header Table\n");
+ fprintf(fp,"------------------------------\n");
+
+ FixedSplit(vhea->version,b);
+
+ fprintf(fp,"\t version:\t %d.%d\n",b[1],b[0]);
+ fprintf(fp,"\t ascent:\t %d\n",vhea->ascent);
+ fprintf(fp,"\t descent:\t %d\n",vhea->descent);
+ fprintf(fp,"\t lineGap:\t %d\n",vhea->lineGap);
+ fprintf(fp,"\t advanceHeightMax: %d\n",vhea->advanceHeightMax);
+ fprintf(fp,"\t minTopSideBearing: %d\n",vhea->minTopSideBearing);
+ fprintf(fp,"\t minBottomBearing: %d\n",vhea->minBottomSideBearing);
+ fprintf(fp,"\t yMaxExtent:\t %d\n",vhea->yMaxExtent);
+ fprintf(fp,"\t caretSlopeRise: %d\n", vhea->caretSlopeRise);
+ fprintf(fp,"\t caretSlopeRun: %d\n", vhea->caretSlopeRun);
+ fprintf(fp,"\t caretOffset:\t %d\n", vhea->caretOffset);
+ for(i=0;i<4;i++)
+ fprintf(fp,"\t reserved %d:\t %d\n",i,(vhea->reserved)[i]);
+ fprintf(fp,"\t metricDataFormat:\t %d\n", vhea->metricDataFormat);
+ fprintf(fp,"\t numOfLongVerMetrics: %d\n",vhea->numOfLongVerMetrics);
+}
+
+void ttfFreeVHEA(VHEAPtr vhea)
+{
+ if (vhea != NULL)
+ {
+ free(vhea);
+ }
+}
diff --git a/Build/source/texk/ttfdump/libttf/vmtx.c b/Build/source/texk/ttfdump/libttf/vmtx.c
new file mode 100644
index 00000000000..990f824a66a
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/vmtx.c
@@ -0,0 +1,115 @@
+/* vmtx.c -- Vertical Metrics Table
+ * Copyright (C) 1997 Li-Da Lho, All right reserved
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include "config.h"
+#include "ttf.h"
+#include "ttfutil.h"
+
+#ifdef MEMCHECK
+#include <dmalloc.h>
+#endif
+
+/* $Id: vmtx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
+
+#ifndef lint
+static char vcid[] = "$Id: vmtx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
+#endif /* lint */
+
+static VMTXPtr ttfAllocVMTX(TTFontPtr font);
+static void ttfLoadVMTX(FILE *fp,VMTXPtr vmtx,ULONG offset);
+
+/* Caution: Because of interdependency between tables,
+ * table vhea and maxp should be well initalized before
+ * ttfInitVMTX has been called
+ */
+void ttfInitVMTX(TTFontPtr font)
+{
+ ULONG tag = 'v' | 'm' << 8 | 't' << 16 | 'x' << 24;
+ TableDirPtr ptd;
+
+ if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
+ {
+ font->vmtx = ttfAllocVMTX(font);
+ font->vmtx->numOfLongVerMetrics =
+ font->vhea->numOfLongVerMetrics;
+ font->vmtx->numOfTSB = font->maxp->numGlyphs -
+ font->vhea->numOfLongVerMetrics;
+ ttfLoadVMTX(font->fp,font->vmtx,ptd->offset);
+ }
+}
+static VMTXPtr ttfAllocVMTX(TTFontPtr font)
+{
+ VMTXPtr vmtx;
+
+ if ((vmtx = (VMTXPtr) calloc(1,sizeof(VMTX))) == NULL)
+ {
+ ttfError("Out of Memory in __FILE__:__LINE__\n");
+ return NULL;
+ }
+ return vmtx;
+}
+static void ttfLoadVMTX(FILE *fp,VMTXPtr vmtx,ULONG offset)
+{
+ USHORT i,n = vmtx->numOfLongVerMetrics,m=vmtx->numOfTSB;
+
+ if (fseek(fp,offset,SEEK_SET) !=0)
+ ttfError("Fseek Failed in ttfLOADVMTX \n");
+
+ if ((vmtx->vMetrics = (longVerMetric *) calloc(n,sizeof(longVerMetric))) != NULL)
+ {
+ for (i=0;i<n;i++)
+ {
+ (vmtx->vMetrics+i)->advanceHeight = ttfGetuFWord(fp);
+ (vmtx->vMetrics+i)->topSideBearing = ttfGetFWord(fp);
+ }
+ }
+ else
+ {
+ ttfError("Out Of Memory in __FILE__ : __LINE__\n");
+ }
+
+ /* codes dealing with leftSideBearing entry */
+ if (m && ((vmtx->topSideBearing = (FWord *) calloc(m,sizeof(FWord))) != NULL))
+ {
+ for (i=0;i<m;i++)
+ {
+ (vmtx->topSideBearing)[i] = ttfGetFWord(fp);
+ }
+ }
+}
+
+void ttfPrintVMTX(FILE *fp,VMTXPtr vmtx)
+{
+ int i;
+
+ fprintf(fp,"'vmtx' Table - Vertical Metrics\n");
+ fprintf(fp,"---------------------------------\n");
+
+ for (i=0;i<vmtx->numOfLongVerMetrics;i++)
+ {
+ fprintf(fp,"\t %4d. advWid: %4d, TSBear: %4d\n",i,
+ (vmtx->vMetrics+i)->advanceHeight,
+ (vmtx->vMetrics+i)->topSideBearing);
+ }
+
+ for (i=0;i<vmtx->numOfTSB;i++)
+ {
+ fprintf(fp,"\t %4d. TSBear: %4d\n",i+vmtx->numOfLongVerMetrics,
+ (vmtx->topSideBearing)[i]);
+ }
+}
+
+void ttfFreeVMTX(VMTXPtr vmtx)
+{
+ if (vmtx != NULL)
+ {
+ free(vmtx->vMetrics);
+
+ if (vmtx->numOfTSB)
+ free(vmtx->topSideBearing);
+
+ free(vmtx);
+ }
+}
diff --git a/Build/source/texk/ttfdump/libttf/win32.mak b/Build/source/texk/ttfdump/libttf/win32.mak
new file mode 100644
index 00000000000..8a93b0bf86a
--- /dev/null
+++ b/Build/source/texk/ttfdump/libttf/win32.mak
@@ -0,0 +1,57 @@
+################################################################################
+#
+# Makefile : TtfDump / Lib TTF
+# Author : Fabrice Popineau <Fabrice.Popineau@supelec.fr>
+# Platform : Win32, Microsoft VC++ 6.0, depends upon fpTeX 0.5 sources
+# Time-stamp: <02/01/21 12:08:28 popineau>
+#
+################################################################################
+root_srcdir = ..\..\..
+!ifdef DEVELOPMENT
+INCLUDE=$(INCLUDE);$(root_srcdir)\texk.development
+!else
+INCLUDE=$(INCLUDE);$(root_srcdir)\texk
+!endif
+
+USE_GNUW32 = 1
+USE_KPATHSEA = 1
+
+!include <msvc/common.mak>
+
+DEFS = -I..\include -I. -I.. $(DEFS)
+
+objects = $(objdir)\ttfread.obj $(objdir)\tabledir.obj $(objdir)\ttfutil.obj \
+ $(objdir)\font.obj $(objdir)\cmap.obj $(objdir)\glyf.obj \
+ $(objdir)\gcache.obj $(objdir)\head.obj $(objdir)\hhea.obj \
+ $(objdir)\hmtx.obj $(objdir)\loca.obj $(objdir)\maxp.obj \
+ $(objdir)\name.obj $(objdir)\os2.obj $(objdir)\post.obj \
+ $(objdir)\cvt.obj $(objdir)\fpgm.obj $(objdir)\gasp.obj \
+ $(objdir)\hdmx.obj $(objdir)\kern.obj $(objdir)\ltsh.obj \
+ $(objdir)\prep.obj $(objdir)\pclt.obj $(objdir)\vdmx.obj \
+ $(objdir)\vhea.obj $(objdir)\vmtx.obj $(objdir)\gstate.obj \
+ $(objdir)\stack.obj $(objdir)\interp.obj $(objdir)\disasm.obj \
+ $(objdir)\ttc.obj
+
+default: all
+
+all: $(objdir) $(objdir)\libttf.lib
+
+$(objdir)\libttf.lib: $(objects)
+ $(archive) $(objects)
+
+..\config.h:
+ pushd .. & $(make) config.h & popd
+
+!include <msvc/config.mak>
+!include <msvc/install.mak>
+
+!include <msvc/clean.mak>
+!include <msvc/rdepend.mak>
+!include "./depend.mak"
+
+#
+# Local Variables:
+# mode: makefile
+# End:
+
+