xref: /plan9/sys/src/cmd/gs/src/ttfinp.c (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 2003 Aladdin Enterprises.  All rights reserved.
2 
3   This software is provided AS-IS with no warranty, either express or
4   implied.
5 
6   This software is distributed under license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 /* $Id: ttfinp.c,v 1.1 2003/10/01 13:44:56 igor Exp $ */
18 /* A TT font input support. */
19 
20 
21 #include "ttmisc.h"
22 
23 #include "ttfoutl.h"
24 #include "ttfsfnt.h"
25 #include "ttfinp.h"
26 
ttfReader__Byte(ttfReader * r)27 unsigned char ttfReader__Byte(ttfReader *r)
28 {   unsigned char b;
29 
30     r->Read(r, &b, 1);
31     return b;
32 }
33 
ttfReader__SignedByte(ttfReader * r)34 signed char ttfReader__SignedByte(ttfReader *r)
35 {   signed char b;
36 
37     r->Read(r, &b, 1);
38     return b;
39 }
40 
ttfReader__Short(ttfReader * r)41 signed short ttfReader__Short(ttfReader *r)
42 {   unsigned char buf[2];
43 
44     r->Read(r, buf, 2);
45     return ((int16)buf[0] << 8) | (int16)buf[1];
46 }
47 
ttfReader__UShort(ttfReader * r)48 unsigned short ttfReader__UShort(ttfReader *r)
49 {   unsigned char buf[2];
50 
51     r->Read(r, buf, 2);
52     return ((uint16)buf[0] << 8) | (uint16)buf[1];
53 }
54 
ttfReader__UInt(ttfReader * r)55 unsigned int ttfReader__UInt(ttfReader *r)
56 {   unsigned char buf[4];
57 
58     r->Read(r, buf, 4);
59     return ((int32)buf[0] << 24) | ((int32)buf[1] << 16) |
60 	   ((int32)buf[2] <<  8) |  (int32)buf[3];
61 }
62 
ttfReader__Int(ttfReader * r)63 signed int ttfReader__Int(ttfReader *r)
64 {
65     return (int)ttfReader__UInt(r);
66 }
67 
68