SDLPP TextRenderer: change font size based on rectangle height

This commit is contained in:
2020-12-18 15:10:13 +01:00
parent 57143262ac
commit 7267cb7b9a
2 changed files with 14 additions and 7 deletions
+11 -4
View File
@@ -7,7 +7,7 @@ TextRenderer::TextRenderer( double x, double y, double w, double h,
TextRenderer::TextRenderer( double x, double y, double w, double h,
std::shared_ptr< Renderer > &r, Font &font,
const std::string &text, const std::string &color,
const std::string &outline_color, int outline_size,
const std::string &outline_color, double outline_size,
int flags )
: RectangleRender( x, y, w, h, r ) {
position_flags = flags;
@@ -16,14 +16,21 @@ TextRenderer::TextRenderer( double x, double y, double w, double h,
void TextRenderer::setText( Font &font, const std::string &text,
const std::string &color,
const std::string &outline_color,
int outline_size ) {
double outline_size ) {
_text = text;
setTextColor( font, color, outline_color, outline_size );
}
void TextRenderer::setTextColor( Font &font, const std::string &color,
const std::string &outline_color,
int outline_size ) {
setTexture( font, _text, color, outline_color, outline_size );
double outline_size ) {
int fontSize = 0.6 * getRect().h;
font.changeFontSize(fontSize);
int intOutline = outline_size;
if(intOutline != -1) {
intOutline = outline_size * fontSize;
}
setTexture( font, _text, color, outline_color, intOutline );
font.revertSize();
updateDstRect();
}
void TextRenderer::changeText( const std::string &text ) {