summaryrefslogtreecommitdiff
path: root/Build/source/texk/ttfdump/libttf/pclt.c
blob: 73bbaf7ddd93fe5347d9dd9107a4a61c74f595fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* pclt.c -- PCL5 Table
 * Copyright (C) 1997 Li-Da Lho, All right reserved  
 */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include "ttf.h"
#include "ttfutil.h"

/* 	$Id: pclt.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $	 */

static void ttfLoadPCLT(FILE *fp,PCLTPtr pclt,ULONG offset);

void ttfInitPCLT(TTFontPtr font)
{
    ULONG tag = FT_MAKE_TAG ('P', 'C', 'L', 'T');
    TableDirPtr ptd;

    if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
	{
	    font->pclt = XCALLOC1 (PCLT);
	    ttfLoadPCLT(font->fp,font->pclt,ptd->offset);
	}
}

static void ttfLoadPCLT(FILE *fp,PCLTPtr pclt,ULONG offset)
{
    int i;

    xfseek(fp, offset, SEEK_SET, "ttfLoadPCLT");
    
    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,"%02x",(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);
}