summaryrefslogtreecommitdiff
path: root/Build/source/texk/ttfdump/libttf/ttfutil.c
blob: d2ae4f31580865fe864da76cf3929d231194fb74 (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
#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);
}