Skip to content

Commit

Permalink
Resolves wesnoth#6908 - text rendering on Windows excessively heavy
Browse files Browse the repository at this point in the history
The work-around is no longer required due to 06b0247 (wesnoth#6685).

Revert "font: Work around chromatic aberration issue with Windows ClearType"

This reverts commit a56497a.
  • Loading branch information
Wedge009 committed Jul 30, 2022
1 parent 6701542 commit 7f84549
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions src/font/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ pango_text::pango_text()
cairo_font_options_t *fo = cairo_font_options_create();
cairo_font_options_set_hint_style(fo, CAIRO_HINT_STYLE_FULL);
cairo_font_options_set_hint_metrics(fo, CAIRO_HINT_METRICS_ON);
// Always use grayscale AA, particularly on Windows where ClearType subpixel hinting
// will result in colour fringing otherwise. See from_cairo_format() further below.
cairo_font_options_set_antialias(fo, CAIRO_ANTIALIAS_GRAY);
cairo_font_options_set_antialias(fo, CAIRO_ANTIALIAS_DEFAULT);

pango_cairo_context_set_font_options(context_.get(), fo);
cairo_font_options_destroy(fo);
Expand Down Expand Up @@ -721,17 +719,6 @@ static void from_cairo_format(uint32_t & c)
unpremultiply(g, div);
unpremultiply(b, div);

#ifdef _WIN32
// Grayscale AA with ClearType results in wispy unreadable text because of gamma issues
// that would normally be solved by rendering directly onto the destination surface without
// alpha blending. However, since the current game engine design would never allow us to do
// that, we work around that by increasing alpha at the expense of AA accuracy (which is
// not particularly noticeable if you don't know what you're looking for anyway).
if(a < 255) {
a = std::clamp<unsigned>(unsigned(a) * 1.75, 0, 255);
}
#endif

c = (static_cast<uint32_t>(a) << 24) | (static_cast<uint32_t>(r) << 16) | (static_cast<uint32_t>(g) << 8) | static_cast<uint32_t>(b);
}

Expand Down

0 comments on commit 7f84549

Please sign in to comment.