| 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 |
#include "fnt.h" |
| 26 |
|
| 27 |
|
| 28 |
extern int _fntIsSwapped ; |
| 29 |
extern FILE *_fntCurrImageFd ; |
| 30 |
|
| 31 |
|
| 32 |
inline void _fnt_swab_short ( unsigned short *x ) |
| 33 |
{ |
| 34 |
if ( _fntIsSwapped ) |
| 35 |
*x = (( *x >> 8 ) & 0x00FF ) | |
| 36 |
(( *x << 8 ) & 0xFF00 ) ; |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
inline void _fnt_swab_int ( unsigned int *x ) |
| 41 |
{ |
| 42 |
if ( _fntIsSwapped ) |
| 43 |
*x = (( *x >> 24 ) & 0x000000FF ) | |
| 44 |
(( *x >> 8 ) & 0x0000FF00 ) | |
| 45 |
(( *x << 8 ) & 0x00FF0000 ) | |
| 46 |
(( *x << 24 ) & 0xFF000000 ) ; |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
inline void _fnt_swab_int_array ( int *x, int leng ) |
| 51 |
{ |
| 52 |
if ( ! _fntIsSwapped ) |
| 53 |
return ; |
| 54 |
|
| 55 |
for ( int i = 0 ; i < leng ; i++ ) |
| 56 |
{ |
| 57 |
*x = (( *x >> 24 ) & 0x000000FF ) | |
| 58 |
(( *x >> 8 ) & 0x0000FF00 ) | |
| 59 |
(( *x << 8 ) & 0x00FF0000 ) | |
| 60 |
(( *x << 24 ) & 0xFF000000 ) ; |
| 61 |
x++ ; |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
inline unsigned char _fnt_readByte () |
| 67 |
{ |
| 68 |
unsigned char x ; |
| 69 |
fread ( & x, sizeof(unsigned char), 1, _fntCurrImageFd ) ; |
| 70 |
return x ; |
| 71 |
} |
| 72 |
|
| 73 |
inline unsigned short _fnt_readShort () |
| 74 |
{ |
| 75 |
unsigned short x ; |
| 76 |
fread ( & x, sizeof(unsigned short), 1, _fntCurrImageFd ) ; |
| 77 |
_fnt_swab_short ( & x ) ; |
| 78 |
return x ; |
| 79 |
} |
| 80 |
|
| 81 |
inline unsigned int _fnt_readInt () |
| 82 |
{ |
| 83 |
unsigned int x ; |
| 84 |
fread ( & x, sizeof(unsigned int), 1, _fntCurrImageFd ) ; |
| 85 |
_fnt_swab_int ( & x ) ; |
| 86 |
return x ; |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
#define FNT_BYTE_FORMAT 0 |
| 91 |
#define FNT_BITMAP_FORMAT 1 |
| 92 |
|
| 93 |
struct TXF_Glyph |
| 94 |
{ |
| 95 |
unsigned short ch ; |
| 96 |
unsigned char w ; |
| 97 |
unsigned char h ; |
| 98 |
signed char x_off ; |
| 99 |
signed char y_off ; |
| 100 |
signed char step ; |
| 101 |
signed char unknown ; |
| 102 |
short x ; |
| 103 |
short y ; |
| 104 |
|
| 105 |
sgVec2 tx0 ; sgVec2 vx0 ; |
| 106 |
sgVec2 tx1 ; sgVec2 vx1 ; |
| 107 |
sgVec2 tx2 ; sgVec2 vx2 ; |
| 108 |
sgVec2 tx3 ; sgVec2 vx3 ; |
| 109 |
} ; |
| 110 |
|
| 111 |
|
| 112 |
void fntSetError(int, const char* format, ...); |