Date: | 2014-07-18 05:11:35 (9 years 8 months 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 | ||
---|---|---|
59 | 59 | else return 1; |
60 | 60 | } |
61 | 61 | |
62 | void 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 | ||
85 | void Font::writeLine(Surface *surface, std::string const& text, | |
62 | void Font::write(Surface *surface, std::string const& text, | |
86 | 63 | int x, int y, HAlign halign, VAlign valign) |
87 | 64 | { |
88 | 65 | if (!font) { |
src/font.h | ||
---|---|---|
41 | 41 | private: |
42 | 42 | Font(TTF_Font *font); |
43 | 43 | |
44 | void writeLine(Surface *surface, std::string const& text, | |
45 | int x, int y, HAlign halign, VAlign valign); | |
46 | ||
47 | 44 | TTF_Font *font; |
48 | 45 | int lineSpacing; |
49 | 46 | }; |
Branches:
install_locations
master
opkrun
packages