Author: baufo
Date: Sat Feb 7 14:00:40 2009
New Revision: 32635
URL: http://svn.gna.org/viewcvs/wesnoth?rev=32635&view=rev
Log:
making bold text in menus render correctly
Modified:
trunk/src/font.cpp
trunk/src/font.hpp
trunk/src/widgets/menu.cpp
Modified: trunk/src/font.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/font.cpp?rev=32635&r1=32634&r2=32635&view=diff
==============================================================================
--- trunk/src/font.cpp (original)
+++ trunk/src/font.cpp Sat Feb 7 14:00:40 2009
@@ -853,13 +853,19 @@
return res;
}
-std::string make_text_ellipsis(const std::string &text, int font_size, int
max_width, bool with_tags)
+std::string make_text_ellipsis(const std::string &text, int font_size,
+ int max_width, bool with_tags, bool parse_for_style)
{
static const std::string ellipsis = "...";
- if(line_width(with_tags ? text : del_tags(text), font_size) <=
max_width)
+ SDL_Color unused_color;
+ int unused_int;
+ int style = TTF_STYLE_NORMAL;
+ if(parse_for_style) parse_markup(text.begin(), text.end(), &unused_int,
&unused_color, &style);
+
+ if(line_width(with_tags ? text : del_tags(text), font_size, style) <=
max_width)
return text;
- if(line_width(ellipsis, font_size) > max_width)
+ if(line_width(ellipsis, font_size, style) > max_width)
return "";
std::string current_substring;
@@ -871,7 +877,7 @@
tmp.append(itor.substr().first, itor.substr().second);
tmp += ellipsis;
- if (line_width(with_tags ? tmp : del_tags(tmp), font_size) >
max_width) {
+ if (line_width(with_tags ? tmp : del_tags(tmp), font_size,
style) > max_width) {
return current_substring + ellipsis;
}
Modified: trunk/src/font.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/font.hpp?rev=32635&r1=32634&r2=32635&view=diff
==============================================================================
--- trunk/src/font.hpp (original)
+++ trunk/src/font.hpp Sat Feb 7 14:00:40 2009
@@ -112,8 +112,11 @@
///
/// If the text excedes the specified max width, end it with an ellipsis (...)
/// The with_tags can probably always be set to false
+/// If parse_for_style is true we look for the style of the text (bold, etc.)
+/// before deleting its tags.
///
-std::string make_text_ellipsis(const std::string& text, int font_size, int
max_width, bool with_tags = true);
+std::string make_text_ellipsis(const std::string& text, int font_size, int
max_width,
+ bool with_tags = true, bool parse_for_style = false);
/// structure which will hide all current floating labels, and cause floating
labels
Modified: trunk/src/widgets/menu.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/widgets/menu.cpp?rev=32635&r1=32634&r2=32635&view=diff
==============================================================================
--- trunk/src/widgets/menu.cpp (original)
+++ trunk/src/widgets/menu.cpp Sat Feb 7 14:00:40 2009
@@ -913,7 +913,7 @@
const std::string to_show =
(use_ellipsis_ && !has_wrap) ?
font::make_text_ellipsis(str,
style_->get_font_size(),
- loc.w - (xpos - rect.x)
- 2*style_->get_thickness(), false)
+ loc.w - (xpos - rect.x)
- 2*style_->get_thickness(), false, true)
: str;
const SDL_Rect& text_size =
font::text_area(str,style_->get_font_size());
const size_t y = rect.y + (rect.h -
text_size.h)/2;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits