mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Fixed unnecessary loadGlyph() calls
getKerning() now passes the bold flag to getGlyph() function, so already cached glyph can be used.
This commit is contained in:
parent
165b715d02
commit
84e0a25e04
@ -217,7 +217,7 @@ public:
|
|||||||
/// \return Kerning value for \a first and \a second, in pixels
|
/// \return Kerning value for \a first and \a second, in pixels
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
float getKerning(Uint32 first, Uint32 second, unsigned int characterSize) const;
|
float getKerning(Uint32 first, Uint32 second, unsigned int characterSize, bool bold = false) const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the line spacing
|
/// \brief Get the line spacing
|
||||||
|
@ -376,7 +376,7 @@ bool Font::hasGlyph(Uint32 codePoint) const
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
float Font::getKerning(Uint32 first, Uint32 second, unsigned int characterSize) const
|
float Font::getKerning(Uint32 first, Uint32 second, unsigned int characterSize, bool bold) const
|
||||||
{
|
{
|
||||||
// Special case where first or second is 0 (null character)
|
// Special case where first or second is 0 (null character)
|
||||||
if (first == 0 || second == 0)
|
if (first == 0 || second == 0)
|
||||||
@ -391,8 +391,8 @@ float Font::getKerning(Uint32 first, Uint32 second, unsigned int characterSize)
|
|||||||
FT_UInt index2 = FT_Get_Char_Index(face, second);
|
FT_UInt index2 = FT_Get_Char_Index(face, second);
|
||||||
|
|
||||||
// Retrieve position compensation deltas generated by FT_LOAD_FORCE_AUTOHINT flag
|
// Retrieve position compensation deltas generated by FT_LOAD_FORCE_AUTOHINT flag
|
||||||
float firstRsbDelta = getGlyph(first, characterSize, false).rsb_delta;
|
float firstRsbDelta = getGlyph(first, characterSize, bold).rsb_delta;
|
||||||
float secondLsbDelta = getGlyph(second, characterSize, false).lsb_delta;
|
float secondLsbDelta = getGlyph(second, characterSize, bold).lsb_delta;
|
||||||
|
|
||||||
// Get the kerning vector
|
// Get the kerning vector
|
||||||
FT_Vector kerning;
|
FT_Vector kerning;
|
||||||
|
@ -332,7 +332,7 @@ Vector2f Text::findCharacterPos(std::size_t index) const
|
|||||||
Uint32 curChar = m_string[i];
|
Uint32 curChar = m_string[i];
|
||||||
|
|
||||||
// Apply the kerning offset
|
// Apply the kerning offset
|
||||||
position.x += m_font->getKerning(prevChar, curChar, m_characterSize);
|
position.x += m_font->getKerning(prevChar, curChar, m_characterSize, isBold);
|
||||||
prevChar = curChar;
|
prevChar = curChar;
|
||||||
|
|
||||||
// Handle special characters
|
// Handle special characters
|
||||||
@ -451,7 +451,7 @@ void Text::ensureGeometryUpdate() const
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Apply the kerning offset
|
// Apply the kerning offset
|
||||||
x += m_font->getKerning(prevChar, curChar, m_characterSize);
|
x += m_font->getKerning(prevChar, curChar, m_characterSize, isBold);
|
||||||
|
|
||||||
// If we're using the underlined style and there's a new line, draw a line
|
// If we're using the underlined style and there's a new line, draw a line
|
||||||
if (isUnderlined && (curChar == L'\n' && prevChar != L'\n'))
|
if (isUnderlined && (curChar == L'\n' && prevChar != L'\n'))
|
||||||
|
Loading…
Reference in New Issue
Block a user