mirror of
https://github.com/wez/wezterm.git
synced 2024-11-23 23:21:08 +03:00
wezterm: fixup dark edges on text
9892b16d40
adjusted how the text
colors are produced; it resulted in some ugly dark edges, especially
on lighter backgrounds.
This commit routes that tint via an alpha compositing helper which
produces smoother edges.
refs: #320
This commit is contained in:
parent
9892b16d40
commit
720a6fd9b6
@ -150,7 +150,7 @@ impl FreeTypeRasterizer {
|
||||
let red = data[src_offset + (x * 3)];
|
||||
let green = data[src_offset + (x * 3) + 1];
|
||||
let blue = data[src_offset + (x * 3) + 2];
|
||||
let alpha = red | green | blue;
|
||||
let alpha = red.min(green).min(blue);
|
||||
rgba[dest_offset + (x * 4)] = red;
|
||||
rgba[dest_offset + (x * 4) + 1] = green;
|
||||
rgba[dest_offset + (x * 4) + 2] = blue;
|
||||
|
@ -24,16 +24,14 @@ float multiply_one(float src, float dst, float inv_dst_alpha, float inv_src_alph
|
||||
}
|
||||
|
||||
// Alpha-regulated multiply to colorize the glyph bitmap.
|
||||
// The texture data is pre-multiplied by the alpha, so we need to divide
|
||||
// by the alpha after multiplying to avoid having the colors be too dark.
|
||||
vec4 multiply(vec4 src, vec4 dst) {
|
||||
float inv_src_alpha = 1.0 - src.a;
|
||||
float inv_dst_alpha = 1.0 - dst.a;
|
||||
|
||||
return vec4(
|
||||
multiply_one(src.r, dst.r, inv_dst_alpha, inv_src_alpha) / dst.a,
|
||||
multiply_one(src.g, dst.g, inv_dst_alpha, inv_src_alpha) / dst.a,
|
||||
multiply_one(src.b, dst.b, inv_dst_alpha, inv_src_alpha) / dst.a,
|
||||
multiply_one(src.r, dst.r, inv_dst_alpha, inv_src_alpha),
|
||||
multiply_one(src.g, dst.g, inv_dst_alpha, inv_src_alpha),
|
||||
multiply_one(src.b, dst.b, inv_dst_alpha, inv_src_alpha),
|
||||
dst.a);
|
||||
}
|
||||
|
||||
@ -114,7 +112,7 @@ void main() {
|
||||
if (o_has_color == 0.0) {
|
||||
// if it's not a color emoji it will be grayscale
|
||||
// and we need to tint with the fg_color
|
||||
color.rgb *= o_fg_color.rgb;
|
||||
color = multiply(o_fg_color, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user