diff --git a/include/eepp/graphics/text.hpp b/include/eepp/graphics/text.hpp index b74cf2f6d..5613dfa79 100644 --- a/include/eepp/graphics/text.hpp +++ b/include/eepp/graphics/text.hpp @@ -26,7 +26,7 @@ class EE_API Text { /** Create a text from a font */ void create(Graphics::Font * font, const String& text = "", ColorA FontColor = ColorA(255,255,255,255), ColorA FontShadowColor = ColorA(0,0,0,255) , Uint32 characterSize = 12); - void setText(const String& string); + void setString(const String& string); void setFont(Font * font); @@ -42,7 +42,7 @@ class EE_API Text { void setOutlineThickness(Float thickness); - String& getText(); + String& getString(); Font * getFont() const; diff --git a/src/eepp/graphics/console.cpp b/src/eepp/graphics/console.cpp index 7931bd6a3..ece4f4cca 100755 --- a/src/eepp/graphics/console.cpp +++ b/src/eepp/graphics/console.cpp @@ -198,7 +198,7 @@ void Console::draw() { if ( i < static_cast( mCmdLog.size() ) && i >= 0 ) { CurY = mTempY + mY + mCurHeight - Pos * mFontSize - mFontSize * 2; - mTextCache.setText( mCmdLog[i] ); + mTextCache.setString( mCmdLog[i] ); mTextCache.draw( mFontSize, CurY ); Pos++; @@ -208,19 +208,19 @@ void Console::draw() { CurY = mTempY + mY + mCurHeight - mFontSize - 1; mTextCache.setColor( ColorA ( mFontLineColor.r(), mFontLineColor.g(), mFontLineColor.b(), static_cast(mA) ) ); - mTextCache.setText( "> " + mTBuf->getBuffer() ); + mTextCache.setString( "> " + mTBuf->getBuffer() ); mTextCache.draw( mFontSize, CurY ); mTextCache.setColor( ColorA ( mFontLineColor.r(), mFontLineColor.g(), mFontLineColor.b(), static_cast(mCurAlpha) ) ); if ( (unsigned int)mTBuf->getCursorPos() == mTBuf->getBuffer().size() ) { Uint32 width = mTextCache.getTextWidth(); - mTextCache.setText( "_" ); + mTextCache.setString( "_" ); mTextCache.draw( mFontSize + width, CurY ); } else { - mTextCache.setText( "> " + mTBuf->getBuffer().substr( 0, mTBuf->getCursorPos() ) ); + mTextCache.setString( "> " + mTBuf->getBuffer().substr( 0, mTBuf->getCursorPos() ) ); Uint32 width = mFontSize + mTextCache.getTextWidth(); - mTextCache.setText( "_" ); + mTextCache.setString( "_" ); mTextCache.draw( width, CurY ); } @@ -231,7 +231,7 @@ void Console::draw() { if ( mShowFps && NULL != mFont ) { ColorA OldColor1( mTextCache.getColor() ); mTextCache.setColor( ColorA () ); - mTextCache.setText( "FPS: " + String::toStr( mWindow->getFPS() ) ); + mTextCache.setString( "FPS: " + String::toStr( mWindow->getFPS() ) ); mTextCache.draw( mWindow->getWidth() - mTextCache.getTextWidth() - 15, 6 ); mTextCache.setColor( OldColor1 ); } diff --git a/src/eepp/graphics/fonttruetype.cpp b/src/eepp/graphics/fonttruetype.cpp index 62d3ab510..3d4b3929f 100644 --- a/src/eepp/graphics/fonttruetype.cpp +++ b/src/eepp/graphics/fonttruetype.cpp @@ -291,7 +291,7 @@ Uint32 FontTrueType::getFontHeight(const Uint32 & characterSize) { FT_Face face = static_cast(mFace); if (face && setCurrentSize(characterSize)) { - return static_cast(face->height) / static_cast(1 << 6); + return static_cast( eemax( (Float)face->height, (Float)face->size->metrics.height ) ) / static_cast(1 << 6); } else { return 0.f; } diff --git a/src/eepp/graphics/text.cpp b/src/eepp/graphics/text.cpp index 1f596ec15..1de02ef10 100644 --- a/src/eepp/graphics/text.cpp +++ b/src/eepp/graphics/text.cpp @@ -248,7 +248,7 @@ void Text::create(Font * font, const String & text, ColorA FontColor, ColorA Fon ensureGeometryUpdate(); } -void Text::setText(const String& string) { +void Text::setString(const String& string) { if (mString != string) { mString = string; mGeometryNeedUpdate = true; @@ -323,7 +323,7 @@ void Text::setOutlineThickness(Float thickness) { } } -String& Text::getText() { +String& Text::getString() { return mString; } diff --git a/src/eepp/ui/uilistbox.cpp b/src/eepp/ui/uilistbox.cpp index 21aeff143..c3c7b856a 100644 --- a/src/eepp/ui/uilistbox.cpp +++ b/src/eepp/ui/uilistbox.cpp @@ -145,7 +145,7 @@ Uint32 UIListBox::addListBoxItem( const String& text ) { if ( NULL != mFontStyleConfig.Font ) { Text textCache( mFontStyleConfig.Font, mFontStyleConfig.FontCharacterSize ); - textCache.setText( text ); + textCache.setString( text ); Uint32 twidth = textCache.getTextWidth(); if ( twidth > mMaxTextWidth ) { @@ -340,7 +340,7 @@ void UIListBox::findMaxWidth() { if ( NULL != mItems[i] ) { width = (Int32)mItems[i]->getTextWidth(); } else { - textCache.setText( mTexts[i] ); + textCache.setString( mTexts[i] ); width = textCache.getTextWidth(); } diff --git a/src/eepp/ui/uitextedit.cpp b/src/eepp/ui/uitextedit.cpp index 307e95e38..2c1cfa36a 100644 --- a/src/eepp/ui/uitextedit.cpp +++ b/src/eepp/ui/uitextedit.cpp @@ -346,7 +346,7 @@ void UITextEdit::fixScrollToCursor() { Uint32 LineNum = mTextInput->getInputTextBuffer()->getCurPosLinePos( NLPos ); Text textCache( mTextInput->getTextCache()->getFont(), mTextInput->getFontStyleConfig().FontCharacterSize ); - textCache.setText( + textCache.setString( mTextInput->getInputTextBuffer()->getBuffer().substr( NLPos, mTextInput->getInputTextBuffer()->getCursorPos() - NLPos ) diff --git a/src/eepp/ui/uitextinput.cpp b/src/eepp/ui/uitextinput.cpp index c4f92b46e..1f17eff41 100644 --- a/src/eepp/ui/uitextinput.cpp +++ b/src/eepp/ui/uitextinput.cpp @@ -161,7 +161,7 @@ void UITextInput::alignFix() { Text textCache( mTextCache->getFont(), mTextCache->getCharacterSize() ); - textCache.setText( mTextBuffer.getBuffer().substr( NLPos, mTextBuffer.getCursorPos() - NLPos ) ); + textCache.setString( mTextBuffer.getBuffer().substr( NLPos, mTextBuffer.getCursorPos() - NLPos ) ); Float tW = textCache.getTextWidth(); Float tX = mRealAlignOffset.x + tW; @@ -239,11 +239,11 @@ const String& UITextInput::getText() { } void UITextInput::shrinkText( const Uint32& MaxWidth ) { - mTextCache->setText( mTextBuffer.getBuffer() ); + mTextCache->setString( mTextBuffer.getBuffer() ); UITextView::shrinkText( MaxWidth ); - mTextBuffer.setBuffer( mTextCache->getText() ); + mTextBuffer.setBuffer( mTextCache->getString() ); alignFix(); } @@ -257,7 +257,7 @@ Uint32 UITextInput::onMouseClick( const Vector2i& Pos, const Uint32 Flags ) { worldToControl( controlPos ); controlPos = PixelDensity::dpToPxI( controlPos ) - Vector2i( (Int32)mRealAlignOffset.x, (Int32)mRealAlignOffset.y ); - Int32 curPos = mTextCache->getFont()->findClosestCursorPosFromPoint( mTextCache->getText(), mTextCache->getCharacterSizePx(), mTextCache->getStyle() & Text::Bold, mTextCache->getOutlineThickness(), controlPos ); + Int32 curPos = mTextCache->getFont()->findClosestCursorPosFromPoint( mTextCache->getString(), mTextCache->getCharacterSizePx(), mTextCache->getStyle() & Text::Bold, mTextCache->getOutlineThickness(), controlPos ); if ( -1 != curPos ) { mTextBuffer.setCursorPos( curPos ); diff --git a/src/eepp/ui/uitextinputpassword.cpp b/src/eepp/ui/uitextinputpassword.cpp index ddf6da2bd..fd3b9c677 100644 --- a/src/eepp/ui/uitextinputpassword.cpp +++ b/src/eepp/ui/uitextinputpassword.cpp @@ -63,7 +63,7 @@ void UITextInputPassword::alignFix() { for ( size_t i = 0; i < curStr.size(); i++ ) pasStr += '*'; - mPassCache->setText( pasStr ); + mPassCache->setString( pasStr ); Float tW = mPassCache->getTextWidth(); Float tX = mRealAlignOffset.x + tW; @@ -107,7 +107,7 @@ void UITextInputPassword::autoAlign() { } void UITextInputPassword::updateText() { - updatePass( mTextCache->getText() ); + updatePass( mTextCache->getString() ); } void UITextInputPassword::updatePass( const String& pass ) { @@ -117,7 +117,7 @@ void UITextInputPassword::updatePass( const String& pass ) { newTxt += '*'; } - mPassCache->setText( newTxt ); + mPassCache->setString( newTxt ); } UITextView * UITextInputPassword::setText( const String& text ) { diff --git a/src/eepp/ui/uitextview.cpp b/src/eepp/ui/uitextview.cpp index daf913784..e02dab7b8 100644 --- a/src/eepp/ui/uitextview.cpp +++ b/src/eepp/ui/uitextview.cpp @@ -153,15 +153,15 @@ const String& UITextView::getText() { if ( mFlags & UI_WORD_WRAP ) return mString; - return mTextCache->getText(); + return mTextCache->getString(); } UITextView * UITextView::setText( const String& text ) { if ( mFlags & UI_WORD_WRAP ) { mString = text; - mTextCache->setText( mString ); + mTextCache->setString( mString ); } else { - mTextCache->setText( text ); + mTextCache->setString( text ); } autoShrink(); @@ -221,10 +221,10 @@ void UITextView::autoShrink() { void UITextView::shrinkText( const Uint32& MaxWidth ) { if ( mFlags & UI_WORD_WRAP ) { - mTextCache->setText( mString ); + mTextCache->setString( mString ); } - mTextCache->getFont()->shrinkText( mTextCache->getText(), mTextCache->getCharacterSizePx(), mTextCache->getStyle() & Text::Bold, mTextCache->getOutlineThickness(), MaxWidth ); + mTextCache->getFont()->shrinkText( mTextCache->getString(), mTextCache->getCharacterSizePx(), mTextCache->getStyle() & Text::Bold, mTextCache->getOutlineThickness(), MaxWidth ); mTextCache->cacheWidth(); } @@ -323,12 +323,12 @@ Uint32 UITextView::onMouseDoubleClick( const Vector2i& Pos, const Uint32 Flags ) worldToControl( controlPos ); controlPos = PixelDensity::dpToPxI( controlPos ); - Int32 curPos = mTextCache->getFont()->findClosestCursorPosFromPoint( mTextCache->getText(), mTextCache->getCharacterSizePx(), mTextCache->getStyle() & Text::Bold, mTextCache->getOutlineThickness(), controlPos ); + Int32 curPos = mTextCache->getFont()->findClosestCursorPosFromPoint( mTextCache->getString(), mTextCache->getCharacterSizePx(), mTextCache->getStyle() & Text::Bold, mTextCache->getOutlineThickness(), controlPos ); if ( -1 != curPos ) { Int32 tSelCurInit, tSelCurEnd; - mTextCache->getFont()->selectSubStringFromCursor( mTextCache->getText(), curPos, tSelCurInit, tSelCurEnd ); + mTextCache->getFont()->selectSubStringFromCursor( mTextCache->getString(), curPos, tSelCurInit, tSelCurEnd ); selCurInit( tSelCurInit ); selCurEnd( tSelCurEnd ); @@ -359,7 +359,7 @@ Uint32 UITextView::onMouseDown( const Vector2i& Pos, const Uint32 Flags ) { worldToControl( controlPos ); controlPos = PixelDensity::dpToPxI( controlPos ) - Vector2i( (Int32)mRealAlignOffset.x, (Int32)mRealAlignOffset.y ); - Int32 curPos = mTextCache->getFont()->findClosestCursorPosFromPoint( mTextCache->getText(), mTextCache->getCharacterSizePx(), mTextCache->getStyle() & Text::Bold, mTextCache->getOutlineThickness(), controlPos ); + Int32 curPos = mTextCache->getFont()->findClosestCursorPosFromPoint( mTextCache->getString(), mTextCache->getCharacterSizePx(), mTextCache->getStyle() & Text::Bold, mTextCache->getOutlineThickness(), controlPos ); if ( -1 != curPos ) { if ( -1 == selCurInit() || !( mControlFlags & UI_CTRL_FLAG_SELECTING ) ) { @@ -381,7 +381,7 @@ void UITextView::drawSelection( Text * textCache ) { Int32 init = eemin( selCurInit(), selCurEnd() ); Int32 end = eemax( selCurInit(), selCurEnd() ); - if ( init < 0 && end > (Int32)textCache->getText().size() ) { + if ( init < 0 && end > (Int32)textCache->getString().size() ) { return; } @@ -392,14 +392,14 @@ void UITextView::drawSelection( Text * textCache ) { P.setColor( mFontStyleConfig.FontSelectionBackColor ); do { - initPos = textCache->getFont()->getCursorPos( textCache->getText(), textCache->getCharacterSizePx(), textCache->getStyle() & Text::Bold, textCache->getOutlineThickness(), init ); - lastEnd = textCache->getText().find_first_of( '\n', init ); + initPos = textCache->getFont()->getCursorPos( textCache->getString(), textCache->getCharacterSizePx(), textCache->getStyle() & Text::Bold, textCache->getOutlineThickness(), init ); + lastEnd = textCache->getString().find_first_of( '\n', init ); if ( lastEnd < end && -1 != lastEnd ) { - endPos = textCache->getFont()->getCursorPos( textCache->getText(), textCache->getCharacterSizePx(), textCache->getStyle() & Text::Bold, textCache->getOutlineThickness(), lastEnd ); + endPos = textCache->getFont()->getCursorPos( textCache->getString(), textCache->getCharacterSizePx(), textCache->getStyle() & Text::Bold, textCache->getOutlineThickness(), lastEnd ); init = lastEnd + 1; } else { - endPos = textCache->getFont()->getCursorPos( textCache->getText(), textCache->getCharacterSizePx(), textCache->getStyle() & Text::Bold, textCache->getOutlineThickness(), end ); + endPos = textCache->getFont()->getCursorPos( textCache->getString(), textCache->getCharacterSizePx(), textCache->getStyle() & Text::Bold, textCache->getOutlineThickness(), end ); lastEnd = end; } diff --git a/src/eepp/ui/uitooltip.cpp b/src/eepp/ui/uitooltip.cpp index 1a717dabe..90ed74d7f 100644 --- a/src/eepp/ui/uitooltip.cpp +++ b/src/eepp/ui/uitooltip.cpp @@ -90,7 +90,7 @@ void UITooltip::hide() { } void UITooltip::draw() { - if ( mVisible && 0.f != mAlpha && mTextCache->getText().size() > 0 ) { + if ( mVisible && 0.f != mAlpha && mTextCache->getString().size() > 0 ) { UIControlAnim::draw(); if ( mTextCache->getTextWidth() ) { @@ -115,11 +115,11 @@ void UITooltip::setFont( Graphics::Font * font ) { } const String& UITooltip::getText() { - return mTextCache->getText(); + return mTextCache->getString(); } void UITooltip::setText( const String& text ) { - mTextCache->setText( text ); + mTextCache->setString( text ); autoPadding(); onAutoSize(); autoAlign(); diff --git a/src/examples/fonts/fonts.cpp b/src/examples/fonts/fonts.cpp index a43a0c22e..7fc5887e1 100644 --- a/src/examples/fonts/fonts.cpp +++ b/src/examples/fonts/fonts.cpp @@ -81,7 +81,7 @@ EE_MAIN_FUNC int main (int argc, char * argv []) text.setFillColor( 0xFFFFFFFF ); text.setOutlineThickness( 2 ); text.setFlags( FONT_DRAW_CENTER ); - text.setText( Txt ); + text.setString( Txt ); win->setBackColor( RGB(230,230,230) ); diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index 17615d3ad..9a1cefdd2 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -1393,7 +1393,7 @@ void EETest::render() { ); #endif - mInfoText.setText( mInfo ); + mInfoText.setString( mInfo ); } if ( !MultiViewportMode ) {