+int getTextWidth(char *text, int font_nr)
+{
+ return (text != NULL ? strlen(text) * getFontWidth(font_nr) : 0);
+}
+
+static char getFontCharPosition(int font_nr, char c)
+{
+ int font_bitmap_id = gfx.select_font_function(font_nr);
+ struct FontBitmapInfo *font = &gfx.font_bitmap_info[font_bitmap_id];
+ boolean default_font = (font->num_chars == DEFAULT_NUM_CHARS_PER_FONT);
+ int font_pos = c - 32;
+
+ /* map some special characters to their ascii values in default font */
+ if (default_font)
+ font_pos = MAP_FONT_ASCII(c) - 32;
+
+ /* this allows dynamic special characters together with special font */
+ if (font_pos < 0 || font_pos >= font->num_chars)
+ font_pos = 0;
+
+ return font_pos;
+}
+
+void getFontCharSource(int font_nr, char c, Bitmap **bitmap, int *x, int *y)
+{
+ int font_bitmap_id = gfx.select_font_function(font_nr);
+ struct FontBitmapInfo *font = &gfx.font_bitmap_info[font_bitmap_id];
+ 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;
+}
+