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

This commit is contained in:
zicodxx 2012-11-02 18:30:37 +01:00
parent f394398499
commit 77b8100455
2 changed files with 7 additions and 15 deletions

View file

@ -977,7 +977,7 @@ void gr_remap_mono_fonts()
/*
* 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);
@ -986,10 +986,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 )
@ -1028,7 +1028,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;
}
@ -1045,11 +1045,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) {
@ -1140,11 +1135,6 @@ void gr_remap_font( grs_font *font, char * fontname, char *font_data )
PHYSFS_read(fontfile, font_data, 1, datasize); //read raw 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

@ -8,6 +8,8 @@ include/maths.h, include/texmap.h, include/ui.h, main/object.c, maths/fixc.c, ma
3d/clipper.c, 3d/draw.c, editor/meddraw.c, include/3d.h, main/automap.c, main/render.c: in g3s_codes renamed or,and to uor,uand - patch by Kp
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
--------