From: Holger Schemel Date: Sat, 21 Oct 2017 14:49:28 +0000 (+0200) Subject: added support for font definitions with different character offset and size X-Git-Tag: 4.1.0.0~86 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=3f5f1e9af1b0c10a0b0486c579c55c5e6947807d;p=rocksndiamonds.git added support for font definitions with different character offset and size --- diff --git a/src/init.c b/src/init.c index eeb8af52..cf83e504 100644 --- a/src/init.c +++ b/src/init.c @@ -551,6 +551,15 @@ void InitFontGraphicInfo() font_bitmap_info[font_bitmap_id].width = graphic_info[graphic].width; font_bitmap_info[font_bitmap_id].height = graphic_info[graphic].height; + font_bitmap_info[font_bitmap_id].offset_x = + (graphic_info[graphic].offset_x != 0 ? + graphic_info[graphic].offset_x : + graphic_info[graphic].width); + font_bitmap_info[font_bitmap_id].offset_y = + (graphic_info[graphic].offset_y != 0 ? + graphic_info[graphic].offset_y : + graphic_info[graphic].height); + font_bitmap_info[font_bitmap_id].draw_xoffset = graphic_info[graphic].draw_xoffset; font_bitmap_info[font_bitmap_id].draw_yoffset = diff --git a/src/libgame/system.h b/src/libgame/system.h index 2a888667..7f6f17ca 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -874,6 +874,9 @@ struct FontBitmapInfo int src_x, src_y; /* start position of font characters */ int width, height; /* width / height of font characters */ + int offset_x; /* offset to next font character */ + int offset_y; /* offset to next font character */ + int draw_xoffset; /* offset for drawing font characters */ int draw_yoffset; /* offset for drawing font characters */ diff --git a/src/libgame/text.c b/src/libgame/text.c index c8e90d11..e7765fc6 100644 --- a/src/libgame/text.c +++ b/src/libgame/text.c @@ -103,8 +103,8 @@ void getFontCharSource(int font_nr, char c, Bitmap **bitmap, int *x, int *y) int font_pos = getFontCharPosition(font_nr, c); *bitmap = font->bitmap; - *x = font->src_x + (font_pos % font->num_chars_per_line) * font->width; - *y = font->src_y + (font_pos / font->num_chars_per_line) * font->height; + *x = font->src_x + (font_pos % font->num_chars_per_line) * font->offset_x; + *y = font->src_y + (font_pos / font->num_chars_per_line) * font->offset_y; }