mirror of
https://github.com/Cesarus85/ringfall-mjolnir-vr.git
synced 2026-10-17 13:00:25 +02:00
Merge pull request #286 from hkmodd/fix/hires-text-fit
This commit is contained in:
commit
bbe00a4049
4 files changed
+91
-31
No files matched your search
@@ -88,7 +88,8 @@ struct text_hires_glyph
|
||||
float advance;
|
||||
};
|
||||
|
||||
long text_hires_font(char const *tag_name, float cap_height, float oversample);
|
||||
#define TEXT_HIRES_FIT_LETTERS 52
|
||||
long text_hires_font(char const *tag_name, float cap_height, short const *letter_widths, float oversample);
|
||||
int text_hires_covers(long font, unsigned long code);
|
||||
int text_hires_glyph(long font, unsigned long code, struct text_hires_glyph *glyph);
|
||||
void text_hires_register_atlas(unsigned long const *texture, unsigned long width, unsigned long height);
|
||||
@@ -239,6 +240,15 @@ static void rasterizer_draw_hires_character_with_dropshadow(
|
||||
static struct hardware_character_cache hardware_character_cache;
|
||||
static struct bitmap_data *hires_text_atlas = NULL;
|
||||
static long hires_text_font = NONE;
|
||||
/* port: the high-res text's fonts of the font tags of the map (forgotten
|
||||
when its tags are, by rasterizer_text_cache_flush) */
|
||||
static struct
|
||||
{
|
||||
struct font_header *font;
|
||||
real oversample;
|
||||
long hires_font;
|
||||
} hires_text_fonts[MAXIMUM_HIRES_TEXT_FONTS];
|
||||
static short hires_text_next_font = 0;
|
||||
/* port: the text's scale about a point (rasterizer_text_set_scale) */
|
||||
static real text_scale = 1.0f;
|
||||
static real text_scale_origin_x = 0.0f;
|
||||
@@ -347,6 +357,9 @@ rasterizer_text_cache_flush(
|
||||
hardware_character++;
|
||||
} while (--hardware_character_count);
|
||||
}
|
||||
/* port: the next map's font tags may be at the same addresses */
|
||||
memset(hires_text_fonts, 0, sizeof(hires_text_fonts));
|
||||
hires_text_next_font = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -793,22 +806,17 @@ static void rasterizer_text_draw_scaled_character(
|
||||
}
|
||||
|
||||
/* port: the high-res text's font for a font tag, sized by the height of its
|
||||
capital H (its rows with ink), its glyphs drawn with oversample times the
|
||||
pixels (for text scaled up), or NONE */
|
||||
capital H (its rows with ink) and fitted to the widths of its letters, its
|
||||
glyphs drawn with oversample times the pixels (for text scaled up), or NONE */
|
||||
static long hires_text_font_get(
|
||||
long font_index,
|
||||
real oversample)
|
||||
{
|
||||
static struct
|
||||
{
|
||||
struct font_header *font;
|
||||
real oversample;
|
||||
long hires_font;
|
||||
} fonts[MAXIMUM_HIRES_TEXT_FONTS];
|
||||
static short next_font = 0;
|
||||
struct font_header *font;
|
||||
struct font_character *capital;
|
||||
short letter_widths[TEXT_HIRES_FIT_LETTERS];
|
||||
short font_slot;
|
||||
short letter;
|
||||
short top = NONE;
|
||||
short bottom = NONE;
|
||||
short row;
|
||||
@@ -819,8 +827,16 @@ static long hires_text_font_get(
|
||||
font = font_definition_get(font_index);
|
||||
for (font_slot = 0; font_slot < MAXIMUM_HIRES_TEXT_FONTS; font_slot++)
|
||||
{
|
||||
if (fonts[font_slot].font == font && fonts[font_slot].oversample == oversample)
|
||||
return fonts[font_slot].hires_font;
|
||||
if (hires_text_fonts[font_slot].font == font && hires_text_fonts[font_slot].oversample == oversample)
|
||||
return hires_text_fonts[font_slot].hires_font;
|
||||
}
|
||||
/* (A to Z, then a to z; none where the tag has not the letter) */
|
||||
for (letter = 0; letter < TEXT_HIRES_FIT_LETTERS; letter++)
|
||||
{
|
||||
struct font_character *character = font_get_character_by_ascii_code(font,
|
||||
(word)(letter < 26 ? 'A' + letter : 'a' + letter - 26));
|
||||
|
||||
letter_widths[letter] = character ? character->character_width : 0;
|
||||
}
|
||||
capital = font_get_character_by_ascii_code(font, 'H');
|
||||
if (capital)
|
||||
@@ -844,13 +860,13 @@ static long hires_text_font_get(
|
||||
}
|
||||
}
|
||||
hires_font = top == NONE ? NONE :
|
||||
text_hires_font(tag_get_name(font_index), (float)(bottom - top + 1), (float)oversample);
|
||||
text_hires_font(tag_get_name(font_index), (float)(bottom - top + 1), letter_widths, (float)oversample);
|
||||
if (hires_font < 0)
|
||||
hires_font = NONE;
|
||||
fonts[next_font].font = font;
|
||||
fonts[next_font].oversample = oversample;
|
||||
fonts[next_font].hires_font = hires_font;
|
||||
next_font = (short)((next_font + 1) % MAXIMUM_HIRES_TEXT_FONTS);
|
||||
hires_text_fonts[hires_text_next_font].font = font;
|
||||
hires_text_fonts[hires_text_next_font].oversample = oversample;
|
||||
hires_text_fonts[hires_text_next_font].hires_font = hires_font;
|
||||
hires_text_next_font = (short)((hires_text_next_font + 1) % MAXIMUM_HIRES_TEXT_FONTS);
|
||||
|
||||
return hires_font;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user