summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/sdlfont.cpp45
-rw-r--r--src/gui/sdlfont.h24
2 files changed, 18 insertions, 51 deletions
diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp
index 0b4f57baa..7df00260a 100644
--- a/src/gui/sdlfont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -152,7 +152,7 @@ void SDLTextChunk::generate(TTF_Font *const font, const float alpha)
|| color.b != color2.b)
{ // outlining
SDL_Color sdlCol2;
- SDL_Surface *background = imageHelper->create32BitSurface(
+ SDL_Surface *const background = imageHelper->create32BitSurface(
width, height);
if (!background)
{
@@ -314,7 +314,9 @@ void TextChunkList::clear()
static int fontCounter;
-SDLFont::SDLFont(std::string filename, const int size, const int style) :
+SDLFont::SDLFont(std::string filename,
+ const int size,
+ const int style) :
mFont(nullptr),
mCreateCounter(0),
mDeleteCounter(0),
@@ -369,7 +371,9 @@ SDLFont::~SDLFont()
}
}
-void SDLFont::loadFont(std::string filename, const int size, const int style)
+void SDLFont::loadFont(std::string filename,
+ const int size,
+ const int style)
{
const ResourceManager *const resman = ResourceManager::getInstance();
@@ -421,7 +425,7 @@ void SDLFont::drawString(gcn::Graphics *const graphics,
return;
gcn::Color col = g->getColor();
- gcn::Color col2 = g->getColor2();
+ const gcn::Color col2 = g->getColor2();
const float alpha = static_cast<float>(col.a) / 255.0f;
/* The alpha value is ignored at string generation so avoid caching the
@@ -506,37 +510,6 @@ int SDLFont::getWidth(const std::string &text) const
return 0;
}
-/*
-#ifdef DEBUG_FONT
- int cnt = 0;
-#endif
-
- SDLTextChunk *i = cache->start;
- while (i)
- {
- if (i->text == text)
- {
- // Raise priority: move it to front
- // Assumption is that TTF::draw will be called next
- cache->moveToFirst(i);
- const Image *const image = i->img;
- if (image)
- return image->getWidth();
- else
- return 0;
- }
- i = i->next;
-#ifdef DEBUG_FONT
- cnt ++;
-#endif
- }
-
-#ifdef DEBUG_FONT
- logger->log(std::string("getWidth: ").append(text).append(
- ", iterations: ").append(toString(cnt)));
-#endif
-*/
-
// if string was not drawed
int w, h;
getSafeUtf8String(text, strBuf);
@@ -591,7 +564,7 @@ void SDLFont::doClean()
}
}
-TextChunkList *SDLFont::getCache()
+TextChunkList *SDLFont::getCache() const
{
return mCache;
}
diff --git a/src/gui/sdlfont.h b/src/gui/sdlfont.h
index f7fa15d6b..09b93f87a 100644
--- a/src/gui/sdlfont.h
+++ b/src/gui/sdlfont.h
@@ -114,36 +114,30 @@ class TextChunkList final
class SDLFont final : public gcn::Font
{
public:
- /**
- * Constructor.
- *
- * @param filename Font filename.
- * @param size Font size.
- */
- SDLFont(std::string filename, const int size, const int style = 0);
+ SDLFont(std::string filename,
+ const int size,
+ const int style = 0);
A_DELETE_COPY(SDLFont)
- /**
- * Destructor.
- */
~SDLFont();
- void loadFont(std::string filename, const int size,
+ void loadFont(std::string filename,
+ const int size,
const int style = 0);
- virtual int getWidth(const std::string &text) const A_WARN_UNUSED;
+ int getWidth(const std::string &text) const override A_WARN_UNUSED;
- virtual int getHeight() const A_WARN_UNUSED;
+ int getHeight() const override A_WARN_UNUSED;
- TextChunkList *getCache() A_WARN_UNUSED;
+ TextChunkList *getCache() const A_WARN_UNUSED;
/**
* @see Font::drawString
*/
void drawString(gcn::Graphics *const graphics,
const std::string &text,
- const int x, const int y);
+ const int x, const int y) override;
void clear();