Fixed test for font magic number; Consolidated grs_font_read() - patches by Kp

This commit is contained in:
zicodxx 2012-11-02 18:30:33 +01:00
parent 330c9f8f38
commit eb993337fd
2 changed files with 6 additions and 10 deletions

View file

@ -950,7 +950,7 @@ void gr_close_font( grs_font * font )
/*
* reads a grs_font structure from a PHYSFS_file
*/
void grs_font_read(grs_font *gf, PHYSFS_file *fp)
static void grs_font_read(grs_font *gf, PHYSFS_file *fp)
{
gf->ft_w = PHYSFSX_readShort(fp);
gf->ft_h = PHYSFSX_readShort(fp);
@ -959,10 +959,10 @@ void grs_font_read(grs_font *gf, PHYSFS_file *fp)
gf->ft_minchar = PHYSFSX_readByte(fp);
gf->ft_maxchar = PHYSFSX_readByte(fp);
gf->ft_bytewidth = PHYSFSX_readShort(fp);
gf->ft_data = (ubyte *)(size_t)PHYSFSX_readInt(fp);
gf->ft_data = (ubyte *)((size_t)PHYSFSX_readInt(fp) - GRS_FONT_SIZE);
gf->ft_chars = (ubyte **)(size_t)PHYSFSX_readInt(fp);
gf->ft_widths = (short *)(size_t)PHYSFSX_readInt(fp);
gf->ft_kerndata = (ubyte *)(size_t)PHYSFSX_readInt(fp);
gf->ft_widths = (short *)((size_t)PHYSFSX_readInt(fp) - GRS_FONT_SIZE);
gf->ft_kerndata = (ubyte *)((size_t)PHYSFSX_readInt(fp) - GRS_FONT_SIZE);
}
grs_font * gr_init_font( const char * fontname )
@ -1001,7 +1001,7 @@ grs_font * gr_init_font( const char * fontname )
}
PHYSFS_read(fontfile, file_id, 4, 1);
if ( !strncmp( file_id, "NFSP", 4 ) ) {
if (memcmp( file_id, "PSFN", 4 )) {
con_printf(CON_NORMAL, "File %s is not a font file\n", fontname);
return NULL;
}
@ -1018,11 +1018,6 @@ grs_font * gr_init_font( const char * fontname )
open_font[fontnum].ptr = font;
open_font[fontnum].dataptr = font_data;
// make these offsets relative to font_data
font->ft_data = (ubyte *)((size_t)font->ft_data - GRS_FONT_SIZE);
font->ft_widths = (short *)((size_t)font->ft_widths - GRS_FONT_SIZE);
font->ft_kerndata = (ubyte *)((size_t)font->ft_kerndata - GRS_FONT_SIZE);
nchars = font->ft_maxchar - font->ft_minchar + 1;
if (font->ft_flags & FT_PROPORTIONAL) {

View file

@ -9,6 +9,7 @@ include/maths.h, include/texmap.h, include/ui.h, main/object.c, maths/fixc.c, ma
main/object.h: use struct type explicitly - patch by Kp
include/error.h: Renamed __format to __attribute_gcc_format due to possible C++ conflict; allow arguments - patch by Kp
include/console.h, main/console.c: Marked con_printf fmt as const, Increased console lines from 512 to 2048; Marked console private entries as static - patches by Kp
2d/font.c: Fixed test for font magic number; Consolidated grs_font_read() - patches by Kp
20121031
--------