wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
16.94k stars 763 forks source link

powerline semicircle custom glyphs are too pointy #1311

Closed nost17 closed 2 years ago

nost17 commented 2 years ago

sorry if the wording is strange, I'm using google translator. I have a problem with the zsh prompt with the theme of powerlevel10k, the semicircle shaped sides are "weird" more pointed than they appear in other terminals

left Tilix / right Wezterm both terminals with the same source

Screenshot_20211110_194038

Do you know of any solution? , beyond that I have not had another problem, I am liking the terminal a lot, it has everything I am looking for

wez commented 2 years ago

Those glyphs are computed based on the font metrics by this code: https://github.com/wez/wezterm/blob/main/wezterm-gui/src/customglyph.rs#L3491-L3540 it sounds like those quadratic bezier curves could do with some tweaking to improve the shape.

In the meantime, you could try setting https://wezfurlong.org/wezterm/config/lua/config/custom_block_glyphs.html to false to use glyphs from your available fonts instead, but note that you may be trading a slightly wonky shape for glyphs that don't properly line up due to a freetype hinting bug.

bew commented 2 years ago

(note for easy testing, semicircle chars are    ).

Hello!

I've managed to mostly fix them with with the following diff:

diff --git a/wezterm-gui/src/customglyph.rs b/wezterm-gui/src/customglyph.rs
index 168451b4..e6001e3b 100644
--- a/wezterm-gui/src/customglyph.rs
+++ b/wezterm-gui/src/customglyph.rs
@@ -3491,11 +3491,15 @@ impl BlockKey {
             // [] Powerline filled left semicircle
             0xe0b4 => Self::Poly(&[Poly {
                 path: &[
                     PolyCommand::MoveTo(BlockCoord::Zero, BlockCoord::Zero),
                     PolyCommand::QuadTo {
-                        control: (BlockCoord::Frac(6, 3), BlockCoord::Frac(1, 2)),
+                        control: (BlockCoord::One, BlockCoord::Zero),
+                        to: (BlockCoord::One, BlockCoord::Frac(1, 2)),
+                    },
+                    PolyCommand::QuadTo {
+                        control: (BlockCoord::One, BlockCoord::One),
                         to: (BlockCoord::Zero, BlockCoord::One),
                     },
                     PolyCommand::Close,
                 ],
                 intensity: BlockAlpha::Full,
@@ -3504,11 +3508,15 @@ impl BlockKey {
             // [] Powerline outline left semicircle
             0xe0b5 => Self::Poly(&[Poly {
                 path: &[
                     PolyCommand::MoveTo(BlockCoord::Zero, BlockCoord::Zero),
                     PolyCommand::QuadTo {
-                        control: (BlockCoord::Frac(6, 3), BlockCoord::Frac(1, 2)),
+                        control: (BlockCoord::One, BlockCoord::Zero),
+                        to: (BlockCoord::One, BlockCoord::Frac(1, 2)),
+                    },
+                    PolyCommand::QuadTo {
+                        control: (BlockCoord::One, BlockCoord::One),
                         to: (BlockCoord::Zero, BlockCoord::One),
                     },
                 ],
                 intensity: BlockAlpha::Full,
                 style: PolyStyle::Outline,
@@ -3516,11 +3524,15 @@ impl BlockKey {
             // [] Powerline filled right semicircle
             0xe0b6 => Self::Poly(&[Poly {
                 path: &[
                     PolyCommand::MoveTo(BlockCoord::One, BlockCoord::Zero),
                     PolyCommand::QuadTo {
-                        control: (BlockCoord::Frac(-3, 3), BlockCoord::Frac(1, 2)),
+                        control: (BlockCoord::Zero, BlockCoord::Zero),
+                        to: (BlockCoord::Zero, BlockCoord::Frac(1, 2)),
+                    },
+                    PolyCommand::QuadTo {
+                        control: (BlockCoord::Zero, BlockCoord::One),
                         to: (BlockCoord::One, BlockCoord::One),
                     },
                     PolyCommand::Close,
                 ],
                 intensity: BlockAlpha::Full,
@@ -3529,11 +3541,15 @@ impl BlockKey {
             // [] Powerline outline right semicircle
             0xe0b7 => Self::Poly(&[Poly {
                 path: &[
                     PolyCommand::MoveTo(BlockCoord::One, BlockCoord::Zero),
                     PolyCommand::QuadTo {
-                        control: (BlockCoord::Frac(-3, 3), BlockCoord::Frac(1, 2)),
+                        control: (BlockCoord::Zero, BlockCoord::Zero),
+                        to: (BlockCoord::Zero, BlockCoord::Frac(1, 2)),
+                    },
+                    PolyCommand::QuadTo {
+                        control: (BlockCoord::Zero, BlockCoord::One),
                         to: (BlockCoord::One, BlockCoord::One),
                     },
                 ],
                 intensity: BlockAlpha::Full,
                 style: PolyStyle::Outline,

Which gives a perfect :sparkles: result for the filled semicircles, but is not so great for the stroke ones: wezterm-better-semicircle-chars--small

Here zoomed to better show the problem: wezterm-better-semicircle-chars :point_right: The issue here is that the stroke is drawn at the limits of the cell

I'm still working on a possible fix, but at least wanted to share this :smiley:

wez commented 2 years ago

For the strokes, I think you want to try FracWithOffset:

https://github.com/wez/wezterm/blob/main/wezterm-gui/src/customglyph.rs#L91-L101

bew commented 2 years ago

Hmm I don't think I can represent BlockCoord::Zero with FracWithOffset ?

Maybe I can introduce a BlockCoord::WithOffset(LineScale, BlockCoord) (not sure for the order of args) as a generic replacement for FracWithOffset ?

Edit: except it won't allow me to embed a BlockCoord in a BlockCoord :confused: Any other idea? :point_right: I'm going for ZeroWithOffset & OneWithOffset for now

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.