version 1.8 | | version 1.9 |
---|
| | |
* Graphical routines for drawing fonts. | | * Graphical routines for drawing fonts. |
* | | * |
* $Log$ | | * $Log$ |
| | * Revision 1.9 1999/10/15 05:36:00 donut |
| | * byteswap stuff for font loading |
| | * |
* Revision 1.8 1999/10/14 04:48:21 donut | | * Revision 1.8 1999/10/14 04:48:21 donut |
* alpha fixes, and gl_font args | | * alpha fixes, and gl_font args |
* | | * |
| | |
#include "cfile.h" | | #include "cfile.h" |
#include "mono.h" | | #include "mono.h" |
| | |
| | #include "byteswap.h" |
| | |
#ifdef __MSDOS__ | | #ifdef __MSDOS__ |
#include "vesa.h" | | #include "vesa.h" |
#endif | | #endif |
| | |
unsigned char * ptr; | | unsigned char * ptr; |
int nchars; | | int nchars; |
CFILE *fontfile; | | CFILE *fontfile; |
int file_id; | | u_int32_t file_id; |
int datasize; //size up to (but not including) palette | | int32_t datasize; //size up to (but not including) palette |
| | |
fontfile = cfopen(fontname, "rb"); | | fontfile = cfopen(fontname, "rb"); |
| | |
| | |
Error( "Can't open font file %s", fontname ); | | Error( "Can't open font file %s", fontname ); |
| | |
cfread(&file_id,sizeof(file_id),1,fontfile); | | cfread(&file_id,sizeof(file_id),1,fontfile); |
| | file_id=swapint(file_id); |
cfread(&datasize,sizeof(datasize),1,fontfile); | | cfread(&datasize,sizeof(datasize),1,fontfile); |
| | datasize=swapint(datasize); |
| | |
if (file_id != 0x4e465350) /* 'NFSP' */ | | if (file_id != 0x4e465350) /* 'NFSP' */ |
Error( "File %s is not a font file", fontname ); | | Error( "File %s is not a font file", fontname ); |
| | |
| | |
cfread(font,1,datasize,fontfile); | | cfread(font,1,datasize,fontfile); |
| | |
newfont->ft_flags=font->ft_flags; | | newfont->ft_flags=swapint(font->ft_flags); |
newfont->ft_w=font->ft_w; | | newfont->ft_w=swapshort(font->ft_w); |
newfont->ft_h=font->ft_h; | | newfont->ft_h=swapshort(font->ft_h); |
newfont->ft_baseline=font->ft_baseline; | | newfont->ft_baseline=swapshort(font->ft_baseline); |
newfont->ft_maxchar=font->ft_maxchar; | | newfont->ft_maxchar=font->ft_maxchar; |
newfont->ft_minchar=font->ft_minchar; | | newfont->ft_minchar=font->ft_minchar; |
newfont->ft_bytewidth=font->ft_bytewidth; | | newfont->ft_bytewidth=swapshort(font->ft_bytewidth); |
| | |
nchars = font->ft_maxchar-font->ft_minchar+1; | | nchars = newfont->ft_maxchar-newfont->ft_minchar+1; |
| | |
if (font->ft_flags & FT_PROPORTIONAL) { | | if (newfont->ft_flags & FT_PROPORTIONAL) { |
| | |
newfont->ft_widths = (short *) (font->ft_widths + ((ubyte *) font)); | | newfont->ft_widths = (short *) (swapint(font->ft_widths) + ((ubyte *) font)); |
| | |
newfont->ft_data = (font->ft_data) + ((ubyte *) font); | | newfont->ft_data = (swapint(font->ft_data)) + ((ubyte *) font); |
| | |
newfont->ft_chars = (unsigned char **)malloc( nchars * sizeof(unsigned char *)); | | newfont->ft_chars = (unsigned char **)malloc( nchars * sizeof(unsigned char *)); |
| | |
| | |
} | | } |
| | |
if (newfont->ft_flags & FT_KERNED) | | if (newfont->ft_flags & FT_KERNED) |
newfont->ft_kerndata = (font->ft_kerndata) + ((ubyte *) font); | | newfont->ft_kerndata = swapint(font->ft_kerndata) + ((ubyte *) font); |
| | |
| | |
if (newfont->ft_flags & FT_COLOR) { //remap palette | | if (newfont->ft_flags & FT_COLOR) { //remap palette |