1 | #ifndef __FT_SYSTEM_IO_H__
|
---|
2 | #define __FT_SYSTEM_IO_H__
|
---|
3 |
|
---|
4 | /************************************************************************/
|
---|
5 | /************************************************************************/
|
---|
6 | /***** *****/
|
---|
7 | /***** NOTE: THE CONTENT OF THIS FILE IS NOT CURRENTLY USED *****/
|
---|
8 | /***** IN NORMAL BUILDS. CONSIDER IT EXPERIMENTAL. *****/
|
---|
9 | /***** *****/
|
---|
10 | /************************************************************************/
|
---|
11 | /************************************************************************/
|
---|
12 |
|
---|
13 |
|
---|
14 | /********************************************************************
|
---|
15 | *
|
---|
16 | * designing custom streams is a bit different now
|
---|
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 | #include <ft2build.h>
|
---|
44 | #include FT_INTERNAL_OBJECT_H
|
---|
45 |
|
---|
46 | FT_BEGIN_HEADER
|
---|
47 |
|
---|
48 | /*@*******************************************************************
|
---|
49 | *
|
---|
50 | * @type: FT_Stream
|
---|
51 | *
|
---|
52 | * @description:
|
---|
53 | * handle to an input stream object. These are also @FT_Object handles
|
---|
54 | */
|
---|
55 | typedef struct FT_StreamRec_* FT_Stream;
|
---|
56 |
|
---|
57 |
|
---|
58 | /*@*******************************************************************
|
---|
59 | *
|
---|
60 | * @type: FT_Stream_Class
|
---|
61 | *
|
---|
62 | * @description:
|
---|
63 | * opaque handle to a @FT_Stream_ClassRec class structure describing
|
---|
64 | * the methods of input streams
|
---|
65 | */
|
---|
66 | typedef const struct FT_Stream_ClassRec_* FT_Stream_Class;
|
---|
67 |
|
---|
68 |
|
---|
69 | /*@*******************************************************************
|
---|
70 | *
|
---|
71 | * @functype: FT_Stream_ReadFunc
|
---|
72 | *
|
---|
73 | * @description:
|
---|
74 | * a method used to read bytes from an input stream into memory
|
---|
75 | *
|
---|
76 | * @input:
|
---|
77 | * stream :: target stream handle
|
---|
78 | * buffer :: target buffer address
|
---|
79 | * size :: number of bytes to read
|
---|
80 | *
|
---|
81 | * @return:
|
---|
82 | * number of bytes effectively read. Must be <= 'size'.
|
---|
83 | */
|
---|
84 | typedef FT_ULong (*FT_Stream_ReadFunc)( FT_Stream stream,
|
---|
85 | FT_Byte* buffer,
|
---|
86 | FT_ULong size );
|
---|
87 |
|
---|
88 |
|
---|
89 | /*@*******************************************************************
|
---|
90 | *
|
---|
91 | * @functype: FT_Stream_SeekFunc
|
---|
92 | *
|
---|
93 | * @description:
|
---|
94 | * a method used to seek to a new position within a stream
|
---|
95 | *
|
---|
96 | * @input:
|
---|
97 | * stream :: target stream handle
|
---|
98 | * pos :: new read position, from start of stream
|
---|
99 | *
|
---|
100 | * @return:
|
---|
101 | * error code. 0 means success
|
---|
102 | */
|
---|
103 | typedef FT_Error (*FT_Stream_SeekFunc)( FT_Stream stream,
|
---|
104 | FT_ULong pos );
|
---|
105 |
|
---|
106 |
|
---|
107 | /*@*******************************************************************
|
---|
108 | *
|
---|
109 | * @struct: FT_Stream_ClassRec
|
---|
110 | *
|
---|
111 | * @description:
|
---|
112 | * a structure used to describe an input stream class
|
---|
113 | *
|
---|
114 | * @input:
|
---|
115 | * clazz :: root @FT_ClassRec fields
|
---|
116 | * stream_read :: stream byte read method
|
---|
117 | * stream_seek :: stream seek method
|
---|
118 | */
|
---|
119 | typedef struct FT_Stream_ClassRec_
|
---|
120 | {
|
---|
121 | FT_ClassRec clazz;
|
---|
122 | FT_Stream_ReadFunc stream_read;
|
---|
123 | FT_Stream_SeekFunc stream_seek;
|
---|
124 |
|
---|
125 | } FT_Stream_ClassRec;
|
---|
126 |
|
---|
127 | /* */
|
---|
128 |
|
---|
129 | #define FT_STREAM_CLASS(x) ((FT_Stream_Class)(x))
|
---|
130 | #define FT_STREAM_CLASS__READ(x) FT_STREAM_CLASS(x)->stream_read
|
---|
131 | #define FT_STREAM_CLASS__SEEK(x) FT_STREAM_CLASS(x)->stream_seek;
|
---|
132 |
|
---|
133 | /*@*******************************************************************
|
---|
134 | *
|
---|
135 | * @struct: FT_StreamRec
|
---|
136 | *
|
---|
137 | * @description:
|
---|
138 | * the input stream object structure. See @FT_Stream_ClassRec for
|
---|
139 | * its class descriptor
|
---|
140 | *
|
---|
141 | * @fields:
|
---|
142 | * object :: root @FT_ObjectRec fields
|
---|
143 | * size :: size of stream in bytes (0 if unknown)
|
---|
144 | * pos :: current position within stream
|
---|
145 | * base :: for memory-based streams, the address of the stream's
|
---|
146 | * first data byte in memory. NULL otherwise
|
---|
147 | *
|
---|
148 | * cursor :: the current cursor position within an input stream
|
---|
149 | * frame. Only valid within a FT_FRAME_ENTER .. FT_FRAME_EXIT
|
---|
150 | * block; NULL otherwise
|
---|
151 | *
|
---|
152 | * limit :: the current frame limit within a FT_FRAME_ENTER ..
|
---|
153 | * FT_FRAME_EXIT block. NULL otherwise
|
---|
154 | */
|
---|
155 | typedef struct FT_StreamRec_
|
---|
156 | {
|
---|
157 | FT_ObjectRec object;
|
---|
158 | FT_ULong size;
|
---|
159 | FT_ULong pos;
|
---|
160 | const FT_Byte* base;
|
---|
161 | const FT_Byte* cursor;
|
---|
162 | const FT_Byte* limit;
|
---|
163 |
|
---|
164 | } FT_StreamRec;
|
---|
165 |
|
---|
166 | /* some useful macros */
|
---|
167 | #define FT_STREAM(x) ((FT_Stream)(x))
|
---|
168 | #define FT_STREAM_P(x) ((FT_Stream*)(x))
|
---|
169 |
|
---|
170 | #define FT_STREAM__READ(x) FT_STREAM_CLASS__READ(FT_OBJECT__CLASS(x))
|
---|
171 | #define FT_STREAM__SEEK(x) FT_STREAM_CLASS__SEEK(FT_OBJECT__CLASS(x))
|
---|
172 |
|
---|
173 | #define FT_STREAM_IS_BASED(x) ( FT_STREAM(x)->base != NULL )
|
---|
174 |
|
---|
175 | /* */
|
---|
176 |
|
---|
177 | /* create new memory-based stream */
|
---|
178 | FT_BASE( FT_Error ) ft_stream_new_memory( const FT_Byte* stream_base,
|
---|
179 | FT_ULong stream_size,
|
---|
180 | FT_Memory memory,
|
---|
181 | FT_Stream *astream );
|
---|
182 |
|
---|
183 | FT_BASE( FT_Error ) ft_stream_new_iso( const char* pathanme,
|
---|
184 | FT_Memory memory,
|
---|
185 | FT_Stream *astream );
|
---|
186 |
|
---|
187 |
|
---|
188 | /* handle to default stream class implementation for a given build */
|
---|
189 | /* this is used by "FT_New_Face" */
|
---|
190 | /* */
|
---|
191 | FT_APIVAR( FT_Type ) ft_stream_default_type;
|
---|
192 |
|
---|
193 | FT_END_HEADER
|
---|
194 |
|
---|
195 | #endif /* __FT_SYSTEM_STREAM_H__ */
|
---|