Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Powerline Glyph for Git Branch #351

Closed
krish-r opened this issue Jun 13, 2020 · 18 comments
Closed

Powerline Glyph for Git Branch #351

krish-r opened this issue Jun 13, 2020 · 18 comments
Labels
enhancement – planned New feature or request

Comments

@krish-r
Copy link

krish-r commented Jun 13, 2020

Hi,
Could you please consider adding the powerline glyph for git branch if possible?

OS: Windows 10
Terminal: VS Code Integrated terminal
Recursive Version: v1.051

Cascadia Code:
image

Recursive Mono:
image

Thanks

@arrowtype
Copy link
Owner

This is a good idea, thanks!

It looks like the Windows Terminal doesn’t yet support fallback fonts, but maybe it would be helpful to upvote/add a reaction to it at microsoft/terminal#1790 to encourage that effort. :)

@arrowtype arrowtype added the enhancement – planned New feature or request label Jun 13, 2020
@arrowtype
Copy link
Owner

Note for later: seems like https://github.com/ryanoasis/nerd-fonts might be a way to do this

@arrowtype
Copy link
Owner

arrowtype commented Sep 16, 2020

Notes:

There are fewer powerline glyphs that I realized – I thought they might include a lot of box-drawing glyphs, but it is basically 8 useful glyphs, then a bunch of glyphs that seem to be purely for ... style?

From nerd fonts powerline fonts, here is the basic set:

image

...and the "extras":

image

A screenshot from the powerline website shows some of these in context, as elements that are seemingly just for decoration (rather than system status, etc):

image

From Cascadia Code, here is the glyph set, adapted to fit within single-width units:

image

If/when I add these to Recursive, I would have a few goals:

  • Add them just at the Regular weight
  • Possibly adapt the style of the core glyphs slightly to match Recursive, and maaaaaybe even give them a Casual axis
  • Match their overall sizing to work well with Recursive
  • Probably, have them added in a post-process to the Rec Mono Code fonts, rather than being included in the main fonts

It might be helpful to use the Cascadia Code merging approach:

def step_merge_glyphs_from_ufo(path):
    def _merge(instance):
        ufo = ufoLib2.Font.open(path)
        print(f"[{instance.info.familyName} {instance.info.styleName}] Merging {path}")
        for glyph in ufo.glyphOrder:
            if glyph not in instance.glyphOrder:
                instance.addGlyph(ufo[glyph])

    return _merge

...though, I also want to look at merging TTFs with FontTools. Which, actually might be super easy with the FontTools merge tool!

@arrowtype
Copy link
Owner

arrowtype commented Sep 16, 2020

Design steps: Make a branch powerline, then...

  1. Start with the Cascadia Code powerline glyphs
  2. Adjust this to a 1000 UPM, and glyphs to 600 units wide
  3. Use scaling transforms to bring the glyphs to the correct height (probably, figure our the percentage transform needed, then transform all glyphs). What is the correct height? Hard to know ... possibly, it would help to ask Aaron Bell, and possibly, it would just require merging into Rec Mono & testing. But, this maybe goes beyond "design steps."
  4. Break into three fonts: powerline-extras.ufo, powerline-base-casual.ufo, and powerline-base-linear.ufo. Place these into a new folder at src/ufo/powerline
  5. Adjust "Casual" and "Linear" versions of the main glyphs:
  • Make the "branch" glyph have a Recursive-ish arrow, but keep it connected because it’s too small for much detail
  • The LN and CN glyphs can get adjusted Recursive caps. Probably, the "C" should be more like the lowercase shape, to keep an open shape (but not be the rectangular thing typically in PL glyphs)
  • Make the "lock" glyph not ugly, if possible (hard to say what should change, though ... probably, it should just get Recursive-style corners and outlines)
  1. In the powerline-extras, make an even amount of space in contour lines – e.g. the legos should have even thicknesses in their negative spaces, rather than looking squished (they currently look squished in Cascadia, as shown below)

image

  1. Make a Pull Request with that branch into main

@arrowtype
Copy link
Owner

We’ve made some good progress here with the PR #407.

Next, I will work on a way to add this into the build system for Rec Mono fonts (e.g. https://github.com/arrowtype/recursive-code-config).

@arrowtype
Copy link
Owner

Approach I’ll try here:

  • export from powerline-specific UFOs to basic TTFs
  • use the FontTools Merger to merge those with the code TTFs

@arrowtype
Copy link
Owner

arrowtype commented Oct 2, 2020

This is partly working! I have a starter script here: https://github.com/arrowtype/recursive-code-config/blob/5260e83be9669e6e6cce4ea1e89510af6d11462f/scripts/merge-powerline-ttfs.py

However, there is a funny (slightly stupid on my part) mistake preventing the "branch" glyph from display with Recursive: the glyph already exists in the fonts, but only as a blank glyph (basically like a word space). This is probably because I added the glyph earlier, with the intention of filling it with an Recursive-specific branch drawing.

However, this results in that icon showing up as a blank space, if Recursive is used with a PowerLine theme. 💀

image

The fix is simple but will take a bit of time to allow for a new build & release. I will:

  • remove the empty uniE0A0 in the Recursive sources, then build a new version of the variable font.
  • generate new RecMono Code fonts
  • match the font metrics of the powerline UFOs & rebuild the TTFs moved down
  • then improve the merger script in recursive-code-config to merge the powerline glyphs with all of the font styles, splitting linear vs casual. moved down

I think this might be all it takes! 🤞 Or, it might take more investigation.

@arrowtype
Copy link
Owner

arrowtype commented Oct 2, 2020

Got it working at a simple level!

image

I still need to:

  • adjust the branch glyph to be a bit thicker/bigger. I probably will always have wordspaces to either side, so it can overflow its bounds by a bit
  • try given arrow/triangle glyphs a small flat portion at top & bottom plus a bit of overflow to the left, to see if that avoids the slight misalignment here (which may be a result of "hinting" / antialiasing stuff from the system)
  • match the font metrics of the powerline UFOs & rebuild the TTFs
  • then improve the merger script in recursive-code-config to merge the powerline glyphs with all of the font styles, splitting linear vs casual.

@arrowtype
Copy link
Owner

arrowtype commented Oct 3, 2020

Design fixes still needed:

  • adjust left side of “branch” glyph to balance with visual weight of right side

image

  • fix interior lines of these blocks uniE0CC uniE0CD:

image

@arrowtype
Copy link
Owner

Technical notes on the .stypo suffixes in Cascadia Code: https://twitter.com/ArrowType/status/1313594838462484481

TLDR: In , the .stypo glyphs match the typo metrics, and they are activated with the rclt OpenType feature.

Me:

I see that the Cascadia Code PowerLine UFO has both normal & "stypo" versions of PL glyphs.

  1. The stypo versions are probably for settings like the VScode terminal with shorter line heights, yes?

  2. How do you make that work?

Thank you for any insights!

Aaron Bell:

Windows Terminal (and others) correctly implement the useTypoMetrics flag, so the idea of the sTypo versions is to adjust the heights so that they align with the sTypo metrics.

For other systems that don’t respect that flag, they’d see the normal versions.

Unfortunately, I’m not totally sure if it is actually working as intended (microsoft/cascadia-code#310). It is complicated by the fact that coding editors play havoc with glyph sizing in order to fit everything into a standardized box.

(I postulated that a system advanced enough to understand / respect the useTypoMetrics flag is also advanced enough to understand / implement the rclt feature (which should be turned on by default). And one that isn’t smart enough to implement sTypo wouldn’t implement rclt.)

If you have any ideas of how better to implement, I’d definitely be interested! Getting the PL characters to consistently line up when you have two different metric sets is a pain.

@otherjoel
Copy link

There are fewer powerline glyphs that I realized – I thought they might include a lot of box-drawing glyphs, but it is basically 8 useful glyphs, then a bunch of glyphs that seem to be purely for ... style?

It would be really nice to have the box-drawing glyphs, perhaps this could be useful? https://github.com/adobe-type-tools/box-drawing

@alerque
Copy link

alerque commented Oct 24, 2020

@otherjoel I agree, but that should probably be a new issue. Box drawing glpyhs are in a different category that Powerline stuff.

@krish-r
Copy link
Author

krish-r commented Oct 26, 2020

Hello @arrowtype, thanks for implementing this request,

Would you like to keep this issue open or do you think I can close this issue based on 1.066 release?

image

@arrowtype
Copy link
Owner

Thanks, @krish-r! I will keep this open for now, as I still want to implement different sizing of the power line glyphs likely to show up in certain terminals such as the integrated terminal in VS Code.

@arrowtype
Copy link
Owner

Digging into this further, it seems like this is a VS Code issue, which is also affecting fonts like Cascadia Code & Fira Code (and many others). In turn, this seems to maaaybe be a Chrome text rendering issue.

The alignment is very good in the macOS Terminal and in iTerm2, so I will close this issue, and make a new issue to investigate whether there is a reasonable fix I can do on my end for VS Code alignment.

macOS Terminal:

image

iTerm2:

image

@aaronbell
Copy link

BTW, per some of my investigations, it appears that Windows Terminal is not turning on the rclt feature in the command line, but does in any content printed in terminal:
microsoft/cascadia-code#310 (comment)

@aaronbell
Copy link

(Also you're inspiring me to go back and improve some of those ugly glyphs :) )

@weiweihuanghuang
Copy link

Thanks for documenting another obscure font issue Stephen! I was looking up what the deal was with Powerline symbols was and didn't understand the meaning of the 'extra' set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement – planned New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants