mirror of
https://github.com/wez/wezterm.git
synced 2024-11-23 23:21:08 +03:00
refine dual source blending / subpixel aa and RGBA color interaction
Previously, we'd unconditionally enable dual source blending for the text foreground layer when rendering. That meant that if the user had configured the fg color to include an alpha value it would get "stamped through" the draw all the way to the background, making that whole pixel take on that alpha value rather than allowing it to blend through the way you might expect. In prior releases that didn't matter, but since we now allow configuring the fg color with alpha, and allow using escape sequences to set the fg for a span to something with alpha, there is now a much higher chance of something looking weird. Dual source blending is only really needed for subpixel-aa and that isn't enabled by default. This commit changes the behavior to use regular alpha blending if the main config (rather than a per-font override) hasn't set the freetype load/render target to one that enables subpixel-aa. That means that alpha channel values work as expected for fg color by default. If you want to enable subpixel-aa you need to enable it globally and be aware that it will cause weirdness when trying to use alpha channels for the fg text color. The docs now also indicate this behavior. This limitation could be removed by making text rendering significantly more complex and I don't fancy doing that at this time.
This commit is contained in:
parent
4c1fd693b4
commit
28d803e3f4
@ -18,4 +18,10 @@ See also [freetype_render_target](freetype_render_target.md) and
|
||||
[freetype_load_flags](freetype_load_flags.md) for more advanced flags that can
|
||||
be primarily used to influence font hinting.
|
||||
|
||||
Note: when using subpixel-rendering, it comes at the cost of the ability to
|
||||
explicitly set the alpha channel for the text foreground color. You will need
|
||||
to choose between using the alpha channel or using subpixel-rendering, and you
|
||||
must select subpixel-rendering in your main configuration in order for the
|
||||
correct render mode to activate: setting it only in a
|
||||
[wezterm.font](../wezterm/font.md) override is not sufficient.
|
||||
|
||||
|
@ -20,8 +20,8 @@ use ::window::glium::{uniform, BlendingFunction, LinearBlendingFactor, Surface};
|
||||
use ::window::{glium, DeadKeyStatus, PointF, RectF, SizeF, WindowOps};
|
||||
use anyhow::anyhow;
|
||||
use config::{
|
||||
ConfigHandle, Dimension, DimensionContext, HsbTransform, TabBarColors, TextStyle,
|
||||
VisualBellTarget,
|
||||
ConfigHandle, Dimension, DimensionContext, FreeTypeLoadTarget, HsbTransform, TabBarColors,
|
||||
TextStyle, VisualBellTarget,
|
||||
};
|
||||
use euclid::num::Zero;
|
||||
use mux::pane::Pane;
|
||||
@ -1440,6 +1440,15 @@ impl super::TermWindow {
|
||||
)
|
||||
.to_arrays_transposed();
|
||||
|
||||
let use_subpixel = match self
|
||||
.config
|
||||
.freetype_render_target
|
||||
.unwrap_or(self.config.freetype_load_target)
|
||||
{
|
||||
FreeTypeLoadTarget::HorizontalLcd | FreeTypeLoadTarget::VerticalLcd => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
let dual_source_blending = glium::DrawParameters {
|
||||
blend: glium::Blend {
|
||||
color: BlendingFunction::Addition {
|
||||
@ -1497,7 +1506,7 @@ impl super::TermWindow {
|
||||
let (vertex_count, index_count) = vb.vertex_index_count();
|
||||
if vertex_count > 0 {
|
||||
let vertices = vb.current_vb();
|
||||
let subpixel_aa = idx == 1;
|
||||
let subpixel_aa = use_subpixel && idx == 1;
|
||||
|
||||
frame.draw(
|
||||
vertices.slice(0..vertex_count).unwrap(),
|
||||
|
Loading…
Reference in New Issue
Block a user