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
|
/* 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"
/* $Id: hdmx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */
static void ttfLoadHDMX(FILE *fp,HDMXPtr hdmx,ULONG offset);
void ttfInitHDMX(TTFontPtr font)
{
ULONG tag = FT_MAKE_TAG ('h', 'd', 'm', 'x');
TableDirPtr ptd;
if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
{
font->hdmx = XCALLOC1 (HDMX);
font->hdmx->numGlyphs = font->maxp->numGlyphs;
ttfLoadHDMX(font->fp,font->hdmx,ptd->offset);
}
}
static void ttfLoadHDMX (FILE *fp,HDMXPtr hdmx,ULONG offset)
{
int i;
xfseek(fp, offset, SEEK_SET, "ttfLoadHDMX");
hdmx->version = ttfGetUSHORT(fp);
hdmx->numDevices = ttfGetUSHORT(fp);
hdmx->size = ttfGetLONG(fp);
hdmx->Records = XCALLOC (hdmx->numDevices, DeviceRecord);
for (i=0;i<hdmx->numDevices;i++)
{
hdmx->Records[i].PixelSize = ttfGetBYTE(fp);
hdmx->Records[i].MaxWidth = ttfGetBYTE(fp);
hdmx->Records[i].Width = XCALLOC (hdmx->size, 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);
}
}
|