widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #07404
[Merge] lp:~widelands-dev/widelands/bug-1535732-testfix into lp:widelands
Miroslav Remák has proposed merging lp:~widelands-dev/widelands/bug-1535732-testfix into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1535732 in widelands: "Texts not displayed correctly with the new font renderer"
https://bugs.launchpad.net/widelands/+bug/1535732
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1535732-testfix/+merge/292734
Do NOT review/merge. This request exists solely to create an AppVeyor build.
This is just a wild guess, but let's see if removing text shadows helps.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1535732-testfix into lp:widelands.
=== modified file 'src/graphic/text/sdl_ttf_font.cc'
--- src/graphic/text/sdl_ttf_font.cc 2016-03-18 11:34:40 +0000
+++ src/graphic/text/sdl_ttf_font.cc 2016-04-24 16:47:10 +0000
@@ -66,53 +66,8 @@
set_style(style);
- SDL_Surface * text_surface = nullptr;
-
SDL_Color sdlclr = {clr.r, clr.g, clr.b, SDL_ALPHA_OPAQUE};
- if (style & SHADOW) {
- SDL_Surface * tsurf = TTF_RenderUTF8_Blended(font_, txt.c_str(), sdlclr);
- SDL_Surface * shadow = TTF_RenderUTF8_Blended(font_, txt.c_str(), SHADOW_CLR);
- text_surface = empty_sdl_surface(shadow->w + SHADOW_OFFSET, shadow->h + SHADOW_OFFSET);
- SDL_FillRect(text_surface,
- NULL,
- SDL_MapRGBA(text_surface->format, 255, 255, 255, SDL_ALPHA_TRANSPARENT));
-
- if (text_surface->format->BitsPerPixel != 32)
- throw RenderError("SDL_TTF did not return a 32 bit surface for shadow text. Giving up!");
-
- SDL_Rect dstrct1 = {0, 0, 0, 0};
- SDL_SetSurfaceAlphaMod(shadow, SDL_ALPHA_OPAQUE);
- SDL_SetSurfaceBlendMode(shadow, SDL_BLENDMODE_NONE);
- SDL_BlitSurface(shadow, nullptr, text_surface, &dstrct1);
-
- uint32_t* spix = static_cast<uint32_t*>(tsurf->pixels);
- uint32_t* dpix = static_cast<uint32_t*>(text_surface->pixels);
-
- // Alpha Blend the Text onto the Shadow. This is really slow, but it is
- // the only compatible way to do it using SDL 1.2. SDL 2.0 offers more
- // functionality but is not yet released.
- uint8_t sr, sg, sb, sa, dr, dg, db, da, outa, outr = 0, outg = 0, outb = 0;
- for (int y = 0; y < tsurf->h; ++y) {
- for (int x = 0; x < tsurf->w; ++x) {
- size_t sidx = (y * tsurf->pitch + 4 * x) / 4;
- size_t didx = ((y + SHADOW_OFFSET) * text_surface->pitch + (x + SHADOW_OFFSET) * 4) / 4;
-
- SDL_GetRGBA(spix[sidx], tsurf->format, &sr, &sg, &sb, &sa);
- SDL_GetRGBA(dpix[didx], text_surface->format, &dr, &dg, &db, &da);
-
- outa = (255 * sa + da * (255 - sa)) / 255;
- if (outa) {
- outr = (255 * sa * sr + da * dr * (255 - sa)) / outa / 255;
- outg = (255 * sa * sg + da * dg * (255 - sa)) / outa / 255;
- outb = (255 * sa * sb + da * db * (255 - sa)) / outa / 255;
- }
- dpix[didx] = SDL_MapRGBA(text_surface->format, outr, outg, outb, outa);
- }
- }
- SDL_FreeSurface(tsurf);
- SDL_FreeSurface(shadow);
- } else
- text_surface = TTF_RenderUTF8_Blended(font_, txt.c_str(), sdlclr);
+ SDL_Surface * text_surface = TTF_RenderUTF8_Blended(font_, txt.c_str(), sdlclr);
if (!text_surface)
throw RenderError((boost::format("Rendering '%s' gave the error: %s") % txt % TTF_GetError()).str());
Follow ups