mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-04 16:01:17 +00:00
Ensured surfaces returned by Pango are not bigger than expected.
This commit is contained in:
parent
bdaee5da15
commit
15549e8c5c
@ -2161,7 +2161,7 @@ void display::refresh_report(reports::TYPE report_num, reports::report report,
|
||||
}
|
||||
|
||||
// Loop through and display each report element.
|
||||
size_t tallest = 0;
|
||||
int tallest = 0;
|
||||
int image_count = 0;
|
||||
bool used_ellipsis = false;
|
||||
std::ostringstream ellipsis_tooltip;
|
||||
@ -2170,6 +2170,7 @@ void display::refresh_report(reports::TYPE report_num, reports::report report,
|
||||
foreach (const reports::element &e, report)
|
||||
{
|
||||
SDL_Rect area = { x, y, rect.w + rect.x - x, rect.h + rect.y - y };
|
||||
if (area.h <= 0) break;
|
||||
|
||||
if (!e.text.empty())
|
||||
{
|
||||
@ -2189,21 +2190,18 @@ void display::refresh_report(reports::TYPE report_num, reports::report report,
|
||||
text.set_font_size(item->font_size());
|
||||
text.set_text(t, true);
|
||||
text.set_maximum_width(area.w);
|
||||
// This will force the use of ellipsis
|
||||
text.set_maximum_height(0);
|
||||
text.set_maximum_height(area.h);
|
||||
surface s = text.render();
|
||||
screen_.blit_surface(x, y, s);
|
||||
area.w = s->w;
|
||||
area.h = s->h;
|
||||
if (area.h > tallest) {
|
||||
tallest = area.h;
|
||||
if (s->h > tallest) {
|
||||
tallest = s->h;
|
||||
}
|
||||
if (eol) {
|
||||
x = rect.x;
|
||||
y += tallest;
|
||||
tallest = 0;
|
||||
} else {
|
||||
x += area.w;
|
||||
x += s->w;
|
||||
}
|
||||
}
|
||||
else if (!e.image.get_filename().empty())
|
||||
|
12
src/text.cpp
12
src/text.cpp
@ -473,8 +473,10 @@ void ttext::rerender(const bool force) const
|
||||
recalculate(force);
|
||||
surface_dirty_ = false;
|
||||
|
||||
const unsigned width = rect_.x + rect_.width;
|
||||
const unsigned height = rect_.y + rect_.height;
|
||||
int width = rect_.x + rect_.width;
|
||||
int height = rect_.y + rect_.height;
|
||||
if (maximum_width_ > 0 && width > maximum_width_ ) width = maximum_width_;
|
||||
if (maximum_height_ > 0 && height > maximum_height_) height = maximum_height_;
|
||||
const unsigned stride = width * 4;
|
||||
create_surface_buffer(stride * height);
|
||||
|
||||
@ -497,9 +499,9 @@ void ttext::rerender(const bool force) const
|
||||
// The cairo surface is in CAIRO_FORMAT_ARGB32 which uses
|
||||
// pre-multiplied alpha. SDL doesn't use that so the pixels need to be
|
||||
// decoded again.
|
||||
for(size_t y = 0; y < height; ++y) {
|
||||
for(size_t x = 0; x < width; ++x) {
|
||||
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for (int x = 0; x < width; ++x)
|
||||
{
|
||||
unsigned char *pixel = &surface_buffer_[(y * width + x) * 4];
|
||||
|
||||
// Assume everything not compiled with gcc to be on a little endian platform.
|
||||
|
Loading…
x
Reference in New Issue
Block a user