mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-15 09:01:24 +00:00
- fixed text size calculations in the status bar.
To avoid errors, all spacing calculations have been added to FFont::StringWidth which already performs proper escape filtering. # Conflicts: # src/common/fonts/font.cpp
This commit is contained in:
parent
086327666f
commit
9ca1e43292
3 changed files with 13 additions and 12 deletions
|
@ -1556,20 +1556,17 @@ void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, d
|
|||
{
|
||||
bool monospaced = monospacing != EMonospacing::MOff;
|
||||
double dx = 0;
|
||||
int spacingparm = monospaced ? -spacing : spacing;
|
||||
|
||||
switch (flags & DI_TEXT_ALIGN)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case DI_TEXT_ALIGN_RIGHT:
|
||||
dx = monospaced
|
||||
? static_cast<int> ((spacing)*cstring.CharacterCount()) //monospaced, so just multiply the character size
|
||||
: static_cast<int> (font->StringWidth(cstring) + (spacing * cstring.CharacterCount()));
|
||||
dx = font->StringWidth(cstring, spacingparm);
|
||||
break;
|
||||
case DI_TEXT_ALIGN_CENTER:
|
||||
dx = monospaced
|
||||
? static_cast<int> ((spacing)*cstring.CharacterCount()) / 2 //monospaced, so just multiply the character size
|
||||
: static_cast<int> (font->StringWidth(cstring) + (spacing * cstring.CharacterCount())) / 2;
|
||||
dx = font->StringWidth(cstring, spacingparm) / 2;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1777,7 +1777,7 @@ double GetBottomAlignOffset(FFont *font, int c)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
int FFont::StringWidth(const uint8_t *string) const
|
||||
int FFont::StringWidth(const uint8_t *string, int spacing) const
|
||||
{
|
||||
int w = 0;
|
||||
int maxw = 0;
|
||||
|
@ -1807,13 +1807,17 @@ int FFont::StringWidth(const uint8_t *string) const
|
|||
maxw = w;
|
||||
w = 0;
|
||||
}
|
||||
else if (spacing >= 0)
|
||||
{
|
||||
w += GetCharWidth(chr) + GlobalKerning + spacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
w += GetCharWidth(chr) + GlobalKerning;
|
||||
w -= spacing;
|
||||
}
|
||||
}
|
||||
|
||||
return MAX(maxw, w);
|
||||
return std::max(maxw, w);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -112,9 +112,9 @@ public:
|
|||
static void StaticPreloadFonts();
|
||||
|
||||
// Return width of string in pixels (unscaled)
|
||||
int StringWidth (const uint8_t *str) const;
|
||||
inline int StringWidth (const char *str) const { return StringWidth ((const uint8_t *)str); }
|
||||
inline int StringWidth (const FString &str) const { return StringWidth ((const uint8_t *)str.GetChars()); }
|
||||
int StringWidth (const uint8_t *str, int spacing = 0) const;
|
||||
inline int StringWidth (const char *str, int spacing = 0) const { return StringWidth ((const uint8_t *)str, spacing); }
|
||||
inline int StringWidth (const FString &str, int spacing = 0) const { return StringWidth ((const uint8_t *)str.GetChars(), spacing); }
|
||||
|
||||
inline bool CanPrint(const uint8_t *str) const { return true; } // hack hack
|
||||
|
||||
|
|
Loading…
Reference in a new issue