| 1 |
/* pclt.c -- PCL5 Table |
| 2 |
* Copyright (C) 1997 Li-Da Lho, All right reserved |
| 3 |
*/ |
| 4 |
#ifdef HAVE_CONFIG_H |
| 5 |
#include <config.h> |
| 6 |
#endif |
| 7 |
|
| 8 |
#include <stdio.h> |
| 9 |
#include <stdlib.h> |
| 10 |
#include "ttf.h" |
| 11 |
#include "ttfutil.h" |
| 12 |
|
| 13 |
/* $Id: pclt.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ |
| 14 |
|
| 15 |
static void ttfLoadPCLT(FILE *fp,PCLTPtr pclt,ULONG offset); |
| 16 |
|
| 17 |
void ttfInitPCLT(TTFontPtr font) |
| 18 |
{ |
| 19 |
ULONG tag = FT_MAKE_TAG ('P', 'C', 'L', 'T'); |
| 20 |
TableDirPtr ptd; |
| 21 |
|
| 22 |
if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) |
| 23 |
{ |
| 24 |
font->pclt = XCALLOC1 (PCLT); |
| 25 |
ttfLoadPCLT(font->fp,font->pclt,ptd->offset); |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
static void ttfLoadPCLT(FILE *fp,PCLTPtr pclt,ULONG offset) |
| 30 |
{ |
| 31 |
int i; |
| 32 |
|
| 33 |
xfseek(fp, offset, SEEK_SET, "ttfLoadPCLT"); |
| 34 |
|
| 35 |
pclt->version = ttfGetFixed(fp); |
| 36 |
pclt->FontNumber = ttfGetULONG(fp); |
| 37 |
pclt->Pitch = ttfGetUSHORT(fp); |
| 38 |
pclt->xHeight = ttfGetUSHORT(fp); |
| 39 |
pclt->Style = ttfGetUSHORT(fp); |
| 40 |
pclt->TypeFamily = ttfGetUSHORT(fp); |
| 41 |
pclt->CapHeight = ttfGetUSHORT(fp); |
| 42 |
pclt->SymbolSet = ttfGetUSHORT(fp); |
| 43 |
for (i=0;i<16;i++) |
| 44 |
pclt->Typeface[i] = ttfGetCHAR(fp); |
| 45 |
for (i=0;i<8;i++) |
| 46 |
pclt->CharacterComplement[i] = ttfGetCHAR(fp); |
| 47 |
for (i=0;i<6;i++) |
| 48 |
pclt->FileName[i] = ttfGetCHAR(fp); |
| 49 |
pclt->StrokeWeight = ttfGetCHAR(fp); |
| 50 |
pclt->WidthType = ttfGetCHAR(fp); |
| 51 |
pclt->SerifStyle = ttfGetBYTE(fp); |
| 52 |
} |
| 53 |
|
| 54 |
void ttfPrintPCLT(FILE *fp,PCLTPtr pclt) |
| 55 |
{ |
| 56 |
int i; |
| 57 |
int b[2]; |
| 58 |
|
| 59 |
FixedSplit(pclt->version,b); |
| 60 |
|
| 61 |
fprintf(fp,"`PCLT' Table - Printer Command Language Table\n"); |
| 62 |
fprintf(fp,"---------------------------------------------\n"); |
| 63 |
fprintf(fp,"\t version \t %d.%d\n",b[1],b[0]); |
| 64 |
fprintf(fp,"\t fontNumber \t %d (0x%x)\n",pclt->FontNumber, |
| 65 |
pclt->FontNumber ); |
| 66 |
fprintf(fp,"\t pitch \t %d\n",pclt->Pitch); |
| 67 |
fprintf(fp,"\t xHeight \t %d\n",pclt->xHeight); |
| 68 |
fprintf(fp,"\t style \t %d\n",pclt->Style); |
| 69 |
fprintf(fp,"\t typeFamily \t %x\n",pclt->TypeFamily); |
| 70 |
fprintf(fp,"\t capHeight \t %d\n",pclt->CapHeight); |
| 71 |
fprintf(fp,"\t symbolSet \t %d\n",pclt->SymbolSet); |
| 72 |
fprintf(fp,"\t typeFace \t "); |
| 73 |
for (i=0;i<6;i++) |
| 74 |
fprintf(fp,"%c",pclt->Typeface[i]); |
| 75 |
fprintf(fp,"\n"); |
| 76 |
|
| 77 |
fprintf(fp,"\t characterComplement 0x"); |
| 78 |
for (i=0;i<8;i++) |
| 79 |
fprintf(fp,"%02x",(unsigned char)pclt->CharacterComplement[i]); |
| 80 |
fprintf(fp,"\n"); |
| 81 |
|
| 82 |
fprintf(fp,"\t fileName \t "); |
| 83 |
for (i=0;i<6;i++) |
| 84 |
fprintf(fp,"%c",pclt->FileName[i]); |
| 85 |
fprintf(fp,"\n"); |
| 86 |
|
| 87 |
fprintf(fp,"\t strokeWeight \t %d\n",pclt->StrokeWeight); |
| 88 |
fprintf(fp,"\t widthType \t %d\n",pclt->WidthType); |
| 89 |
fprintf(fp,"\t serifStyle \t %d\n",pclt->SerifStyle); |
| 90 |
} |
| 91 |
|
| 92 |
void ttfFreePCLT(PCLTPtr pclt) |
| 93 |
{ |
| 94 |
if (pclt != NULL) |
| 95 |
free(pclt); |
| 96 |
} |