How to fix PowerShell 7 fonts not showing correctly | oh-my-posh

Viewed 1479

I've already installed Windows Terminal, set it up with "oh my posh" and everything working as intended. Though whenever I launch PowerShell 7 (without the terminal), the font is messy as you can see at the image below

enter image description here

I have already tried to change the font, to the same one I used in terminal's .json but there are still some parts that are not rendering correctly and I cannot use it that way with VSCode

enter image description here

1 Answers

The problem is because the Windows Console doesn't fully support UTF-8:

Windows Console was created way back in the early days of Windows, back before Unicode itself existed! Back then, a decision was made to represent each text character as a fixed-length 16-bit value (UCS-2). Thus, the Console’s text buffer contains 2-byte wchar_t values per grid cell, x columns by y rows in size. ... One problem, for example, is that because UCS-2 is a fixed-width 16-bit encoding, it is unable to represent all Unicode codepoints.

This means you have "partial" support for Unicode characters in the Windows Console (i.e. as long as the character can be represented in UCS-2), but won't support all potential (32-bit) Unicode regions.

When you see boxes, that means that the character that is being used is using a region outside of the UCS-2 range. You also tell this because you get 2 boxes (i.e. 2 x 16 bit values). That is why you can't have happy faces in your Windows Console (which makes me sad ☹️).

In order for it to work in all locations, you will have to modify your oh-my-posh themes to use a different character that can be represented with a UCS-2 character.

For Version 2 of Oh My Posh, to make the font changes you have to edit the $ThemeSettings variable. Follow the instructions on the GitHub on configuring Theme Settings. e.g.:

$ThemeSettings.GitSymbols.BranchSymbol = [char]::ConvertFromUtf32(0x2514) 

For Version 3+ of Oh My Posh, you have to edit the JSON configuration file to make the changes, e.g.:

...
{
    "type": "git",
    "style": "powerline",
    "powerline_symbol": "\u2514",
....
Related