Author: mordante
Date: Thu Oct 22 22:14:27 2009
New Revision: 39417
URL: http://svn.gna.org/viewcvs/wesnoth?rev=39417&view=rev
Log:
Fix truncating the campaign description.
A better fix than the previous version, it makes sure that other items
aren't rendered too wide. Still feels like a bug in pango, but need to
ask upstream about that.
Modified:
trunk/changelog
trunk/src/text.cpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=39417&r1=39416&r2=39417&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Thu Oct 22 22:14:27 2009
@@ -3,6 +3,7 @@
* Updated translations:
* User interface:
* Instead of "crashing" upon invalid markup try to show the raw text
+ * Found a better fix for truncating the campaign description (bug #14328)
Version 1.7.7:
* AI:
Modified: trunk/src/text.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/text.cpp?rev=39417&r1=39416&r2=39417&view=diff
==============================================================================
--- trunk/src/text.cpp (original)
+++ trunk/src/text.cpp Thu Oct 22 22:14:27 2009
@@ -333,9 +333,9 @@
if(width != maximum_width_) {
assert(context_);
-
+#if 0
/**
- * @todo Adding 4 extra pixels feels a bit hacky.
+ * todo Adding 4 extra pixels feels a bit hacky.
*
* For some reason it's needed since the following scenario
fails:
* - pango_layout_set_width(value)
@@ -349,6 +349,7 @@
pango_layout_set_width(layout_, width == -1
? -1
: (width + 4) * PANGO_SCALE);
+#endif
maximum_width_ = width;
calculation_dirty_ = true;
surface_dirty_ = true;
@@ -467,7 +468,31 @@
tfont font(get_font_families(), font_size_, font_style_);
pango_layout_set_font_description(layout_, font.get());
- pango_layout_get_pixel_extents(layout_, NULL, &rect_);
+ /*
+ * See set_maximum_width for some more background info as well.
+ * In order to fix the problem first set a width which seems to
render
+ * correctly then lower it to fit. For the campaigns the 4 does
"the
+ * right thing" for the terrain labels it should use the value
0 to set
+ * the ellipse properly. Need to see whether this is a bug in
pango or
+ * a bug in my understanding of the pango api.
+ */
+ int hack = 4;
+ do {
+ pango_layout_set_width(layout_, maximum_width_ == -1
+ ? -1
+ : (maximum_width_ + hack) *
PANGO_SCALE);
+ pango_layout_get_pixel_extents(layout_, NULL, &rect_);
+
+ DBG_GUI_L << "ttext::" << __func__
+ << " text '" <<
gui2::debug_truncate(text_)
+ << "' maximum_width " << maximum_width_
+ << " hack " << hack
+ << " width " << rect_.width
+ << ".\n";
+
+ --hack;
+ } while(maximum_width_ != -1
+ && hack >= 0 && rect_.width > maximum_width_);
DBG_GUI_L << "ttext::" << __func__
<< " text '" << gui2::debug_truncate(text_)
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits