added support for font definitions with different character offset and size
authorHolger Schemel <info@artsoft.org>
Sat, 21 Oct 2017 14:49:28 +0000 (16:49 +0200)
committerHolger Schemel <info@artsoft.org>
Fri, 23 Mar 2018 22:21:14 +0000 (23:21 +0100)
src/init.c
src/libgame/system.h
src/libgame/text.c

index eeb8af52d01dff918c67ccd82e3ad084cc4812bd..cf83e5043229b5cef9326927bf2ddd34db6e83f6 100644 (file)
@@ -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 =
index 2a888667737e51d03611383a6a0e8510663c70ad..7f6f17caae790a13cd330a0f8790752a065679b8 100644 (file)
@@ -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 */
 
index c8e90d116f47b462d37d585f4a165e71fc8f6dc7..e7765fc68282ee2582894df215a379548ececc2c 100644 (file)
@@ -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;
 }