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