diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2020-11-17 17:49:05 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-17 17:49:05 +0300 |
commit | 9724418d350df881afe8453bde6eb88643e7211e (patch) | |
tree | e3f2cac36404430df1f5093226dcc9f944f66cc0 /alacritty/res | |
parent | 8b10e5e77840c0477a4b1575f91a4549d010af04 (diff) | |
download | r-alacritty-9724418d350df881afe8453bde6eb88643e7211e.tar.gz r-alacritty-9724418d350df881afe8453bde6eb88643e7211e.tar.bz2 r-alacritty-9724418d350df881afe8453bde6eb88643e7211e.zip |
Fix wide characters being cut off
Fixes #791.
Diffstat (limited to 'alacritty/res')
-rw-r--r-- | alacritty/res/text.f.glsl | 38 | ||||
-rw-r--r-- | alacritty/res/text.v.glsl | 31 |
2 files changed, 39 insertions, 30 deletions
diff --git a/alacritty/res/text.f.glsl b/alacritty/res/text.f.glsl index c0c1bd1b..d5e26881 100644 --- a/alacritty/res/text.f.glsl +++ b/alacritty/res/text.f.glsl @@ -9,31 +9,31 @@ layout(location = 0, index = 1) out vec4 alphaMask; uniform sampler2D mask; -void main() -{ +#define COLORED 2 + +void main() { if (backgroundPass != 0) { - if (bg.a == 0.0) + if (bg.a == 0.0) { discard; + } alphaMask = vec4(1.0); color = vec4(bg.rgb, 1.0); - } else { - if (fg.a != 0.0) { - // Color glyphs, like emojis. - vec4 glyphColor = texture(mask, TexCoords); - alphaMask = vec4(glyphColor.a); + } else if ((int(fg.a) & COLORED) != 0) { + // Color glyphs, like emojis. + vec4 glyphColor = texture(mask, TexCoords); + alphaMask = vec4(glyphColor.a); - // Revert alpha premultiplication. - if (glyphColor.a != 0) { - glyphColor.rgb = vec3(glyphColor.rgb / glyphColor.a); - } - - color = vec4(glyphColor.rgb, 1.0); - } else { - // Regular text glyphs. - vec3 textColor = texture(mask, TexCoords).rgb; - alphaMask = vec4(textColor, textColor.r); - color = vec4(fg.rgb, 1.0); + // Revert alpha premultiplication. + if (glyphColor.a != 0) { + glyphColor.rgb = vec3(glyphColor.rgb / glyphColor.a); } + + color = vec4(glyphColor.rgb, 1.0); + } else { + // Regular text glyphs. + vec3 textColor = texture(mask, TexCoords).rgb; + alphaMask = vec4(textColor, textColor.r); + color = vec4(fg.rgb, 1.0); } } diff --git a/alacritty/res/text.v.glsl b/alacritty/res/text.v.glsl index 0f5fd3f9..31e6f934 100644 --- a/alacritty/res/text.v.glsl +++ b/alacritty/res/text.v.glsl @@ -1,18 +1,20 @@ #version 330 core // Cell properties. -layout (location = 0) in vec2 gridCoords; +layout(location = 0) in vec2 gridCoords; // Glyph properties. -layout (location = 1) in vec4 glyph; +layout(location = 1) in vec4 glyph; // uv mapping. -layout (location = 2) in vec4 uv; +layout(location = 2) in vec4 uv; -// Text foreground rgb packed together with multicolor flag. -layout (location = 3) in vec4 textColor; +// Text foreground rgb packed together with cell flags. textColor.a +// are the bitflags; consult RenderingGlyphFlags in renderer/mod.rs +// for the possible values. +layout(location = 3) in vec4 textColor; // Background color. -layout (location = 4) in vec4 backgroundColor; +layout(location = 4) in vec4 backgroundColor; out vec2 TexCoords; flat out vec4 fg; @@ -24,9 +26,9 @@ uniform vec4 projection; uniform int backgroundPass; +#define WIDE_CHAR 1 -void main() -{ +void main() { vec2 projectionOffset = projection.xy; vec2 projectionScale = projection.zw; @@ -39,8 +41,14 @@ void main() vec2 cellPosition = cellDim * gridCoords; if (backgroundPass != 0) { - vec2 finalPosition = cellPosition + cellDim * position; - gl_Position = vec4(projectionOffset + projectionScale * finalPosition, 0.0, 1.0); + vec2 backgroundDim = cellDim; + if ((int(textColor.a) & WIDE_CHAR) != 0) { + // Update wide char x dimension so it'll cover the following spacer. + backgroundDim.x *= 2; + } + vec2 finalPosition = cellPosition + backgroundDim * position; + gl_Position = + vec4(projectionOffset + projectionScale * finalPosition, 0.0, 1.0); TexCoords = vec2(0, 0); } else { @@ -49,7 +57,8 @@ void main() glyphOffset.y = cellDim.y - glyphOffset.y; vec2 finalPosition = cellPosition + glyphSize * position + glyphOffset; - gl_Position = vec4(projectionOffset + projectionScale * finalPosition, 0.0, 1.0); + gl_Position = + vec4(projectionOffset + projectionScale * finalPosition, 0.0, 1.0); vec2 uvOffset = uv.xy; vec2 uvSize = uv.zw; |