(svn r23472) -Fix [FS#4877]: the monospace font broke the bootstrap GUI's ability to find a font

This commit is contained in:
rubidium 2011-12-10 12:56:37 +00:00
parent 6cbeb9e745
commit ebb3ad33ff
3 changed files with 10 additions and 7 deletions

View File

@ -1516,13 +1516,16 @@ void DoPaletteAnimations()
} }
/** Initialize _stringwidth_table cache */ /**
void LoadStringWidthTable() * Initialize _stringwidth_table cache
* @param monospace Whether to load the monospace cache or the normal fonts.
*/
void LoadStringWidthTable(bool monospace)
{ {
_max_char_height = 0; _max_char_height = 0;
_max_char_width = 0; _max_char_width = 0;
for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) { for (FontSize fs = monospace ? FS_MONO : FS_BEGIN; fs < (monospace ? FS_END : FS_MONO); fs++) {
_max_char_height = max<int>(_max_char_height, GetCharacterHeight(fs)); _max_char_height = max<int>(_max_char_height, GetCharacterHeight(fs));
for (uint i = 0; i != 224; i++) { for (uint i = 0; i != 224; i++) {
_stringwidth_table[fs][i] = GetGlyphWidth(fs, i + 32); _stringwidth_table[fs][i] = GetGlyphWidth(fs, i + 32);

View File

@ -125,7 +125,7 @@ Dimension GetStringBoundingBox(StringID strid);
uint32 FormatStringLinebreaks(char *str, const char *last, int maxw, FontSize start_fontsize = FS_NORMAL); uint32 FormatStringLinebreaks(char *str, const char *last, int maxw, FontSize start_fontsize = FS_NORMAL);
int GetStringHeight(StringID str, int maxw); int GetStringHeight(StringID str, int maxw);
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion); Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion);
void LoadStringWidthTable(); void LoadStringWidthTable(bool monospace = false);
void DrawDirtyBlocks(); void DrawDirtyBlocks();
void SetDirtyBlocks(int left, int top, int right, int bottom); void SetDirtyBlocks(int left, int top, int right, int bottom);

View File

@ -1778,7 +1778,7 @@ bool MissingGlyphSearcher::FindMissingGlyphs(const char **str)
InitFreeType(this->Monospace()); InitFreeType(this->Monospace());
const Sprite *question_mark[FS_END]; const Sprite *question_mark[FS_END];
for (FontSize size = FS_BEGIN; size < FS_END; size++) { for (FontSize size = this->Monospace() ? FS_MONO : FS_BEGIN; size < (this->Monospace() ? FS_END : FS_MONO); size++) {
question_mark[size] = GetGlyph(size, '?'); question_mark[size] = GetGlyph(size, '?');
} }
@ -1903,12 +1903,12 @@ void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
ShowErrorMessage(STR_JUST_RAW_STRING, INVALID_STRING_ID, WL_WARNING); ShowErrorMessage(STR_JUST_RAW_STRING, INVALID_STRING_ID, WL_WARNING);
/* Reset the font width */ /* Reset the font width */
LoadStringWidthTable(); LoadStringWidthTable(searcher->Monospace());
return; return;
} }
/* Update the font with cache */ /* Update the font with cache */
LoadStringWidthTable(); LoadStringWidthTable(searcher->Monospace());
#if !defined(WITH_ICU) #if !defined(WITH_ICU)
/* /*