From eb993337fd346a5f1ff1290d57178c37791b1116 Mon Sep 17 00:00:00 2001 From: zicodxx Date: Fri, 2 Nov 2012 18:30:33 +0100 Subject: [PATCH] Fixed test for font magic number; Consolidated grs_font_read() - patches by Kp --- 2d/font.c | 15 +++++---------- CHANGELOG.txt | 1 + 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/2d/font.c b/2d/font.c index c36881eab..568c58d54 100644 --- a/2d/font.c +++ b/2d/font.c @@ -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) { diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 99f1df0bc..87b85f8dc 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -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 --------