Date:2014-07-18 05:11:35 (3 months 4 days ago)
Author:Maarten ter Huurne
Commit:0908aa7bb751a11cc035ceec3af282fed622f72c
Message:Removed support for multi-line text drawing

When trying to test the previous commit, I couldn't find any place in
the application where strings containing newlines are drawn. So I'm
assuming this is an unnecessary feature, until someone comes up with
a test case proving otherwise.

Yeah, I'm too lazy to review all the code that draws text...
Files: src/font.cpp (1 diff)
src/font.h (1 diff)

Change Details

src/font.cpp
5959    else return 1;
6060}
6161
62void Font::write(Surface *surface, const string &text,
63            int x, int y, HAlign halign, VAlign valign)
64{
65    if (!font) {
66        return;
67    }
68
69    size_t pos = text.find('\n', 0);
70    if (pos == string::npos) {
71        writeLine(surface, text, x, y, halign, valign);
72    } else {
73        size_t prev = 0;
74        do {
75            writeLine(surface, text.substr(prev, pos - prev),
76                    x, y, halign, valign);
77            y += lineSpacing;
78            prev = pos + 1;
79            pos = text.find('\n', prev);
80        } while (pos != string::npos);
81        writeLine(surface, text.substr(prev), x, y, halign, valign);
82    }
83}
84
85void Font::writeLine(Surface *surface, std::string const& text,
62void Font::write(Surface *surface, std::string const& text,
8663                int x, int y, HAlign halign, VAlign valign)
8764{
8865    if (!font) {
src/font.h
4141private:
4242    Font(TTF_Font *font);
4343
44    void writeLine(Surface *surface, std::string const& text,
45                int x, int y, HAlign halign, VAlign valign);
46
4744    TTF_Font *font;
4845    int lineSpacing;
4946};

Archive Download the corresponding diff file



interactive