Author: alink
Date: Sun Jun 29 02:22:06 2008
New Revision: 27576
URL: http://svn.gna.org/viewcvs/wesnoth?rev=27576&view=rev
Log:
Improve rendering support of blank lines and fix bug #11925 (about blank label)
Now can render blank lines by using a double end-of-line in WML.
This is probably active in various places but mainly usefull for tooltips.
There is maybe newly visible blank lines, I can filter the last one if needed
but better clean the WML and keep the possibily to use this.
Modified:
trunk/src/font.cpp
Modified: trunk/src/font.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/font.cpp?rev=27576&r1=27575&r2=27576&view=diff
==============================================================================
--- trunk/src/font.cpp (original)
+++ trunk/src/font.cpp Sun Jun 29 02:22:06 2008
@@ -562,23 +562,23 @@
static surface render_text(const std::string& text, int fontsize, const
SDL_Color& colour, int style)
{
- const std::vector<std::string> lines = utils::split(text, '\n',
utils::REMOVE_EMPTY);
+ // we keep blank lines and spaces (may be wanted for indentation)
+ const std::vector<std::string> lines = utils::split(text, '\n', 0);
std::vector<std::vector<surface> > surfaces;
surfaces.reserve(lines.size());
size_t width = 0, height = 0;
text_surface txt_surf(fontsize, colour, style);
for(std::vector< std::string >::const_iterator ln = lines.begin(),
ln_end = lines.end(); ln != ln_end; ++ln) {
- if (!ln->empty()) {
- txt_surf.set_text(*ln);
- const text_surface& cached_surf =
text_cache::find(txt_surf);
- const std::vector<surface>&res =
cached_surf.get_surfaces();
-
- if (!res.empty()) {
- surfaces.push_back(res);
- width = maximum<size_t>(cached_surf.width(),
width);
- height += cached_surf.height();
- }
+ // we replace empty line by a space (to have a line height)
+ txt_surf.set_text(ln->empty() ? " " : *ln);
+ const text_surface& cached_surf = text_cache::find(txt_surf);
+ const std::vector<surface>&res = cached_surf.get_surfaces();
+
+ if (!res.empty()) {
+ surfaces.push_back(res);
+ width = maximum<size_t>(cached_surf.width(), width);
+ height += cached_surf.height();
}
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits