How can I add additional fonts to the Windows console?

4

2

I found a guide online stating that you need to edit the registry in order to add new fonts to the list of available fonts in Command Prompt: specifically, you have to edit the key:

  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont

by adding string values with keys 00, 000, 0000, and so on, with their values being the names of the fonts. I've already done this. I added the font names to the registry, as you can in the screenshot below, and restarted the computer:

regedit

However, the fonts which I've added aren't showing up in the list. More specifically, I added Inconsolata and Source Code Pro. But I don't see them in the list of available fonts:

console fonts

What am I missing? I am using Windows 10 version 1803, build 17134.165.

soapergem

Posted 2018-08-09T23:48:11.357

Reputation: 1 056

That method works fine on Windows 7 (which is what they use in the example). I've just tested it now. You might need to search for something specific for Windows 10. – Michael Frank – 2018-08-09T23:59:02.033

Microsoft has developed and released (open source, I believe) a theme tool for the console for the latest builds of Windows 10: https://blogs.msdn.microsoft.com/commandline/2017/08/11/introducing-the-windows-console-colortool/

– music2myear – 2018-08-10T00:04:59.770

1@music2myear I just tried out the tool you've linked to, and it only handles colors. It has nothing to do with fonts. – soapergem – 2018-08-10T21:02:46.970

Good to know. I installed it and was playing around with it today, but got sidetracked before I could test fonts with it. – music2myear – 2018-08-10T21:17:40.430

2If you want a customisable terminal then use mintty. – Biswapriyo – 2018-09-06T07:29:06.287

Try updating to 17134.228 :) – var firstName – 2018-09-07T20:35:29.230

Answers

9

How to add new fonts to your Powershell (Or CMD) Console settings?

First thing to know, is that, unfortunately (!):

Only fonts fulfilling certain criteria can be installed into the console!

(See: here, here and here.)


The Font Criteria + Explanation
(The current status of this is unknown.)

For Font to be supported in Console they have to:

  1. The font must be a fixed-pitch font.
  2. The font cannot be an italic font.
  3. If it is a TrueType font, it must be FF_MODERN.
  4. If it is not a TrueType font, it must contain the OEM_CHARSET.
  5. The font cannot have a negative A or C space.

What does all that mean? Most of these metrics are defined here, which outlines the following structure describing a font in C++:

typedef struct tagLOGFONTA {
  LONG lfHeight;
  LONG lfWidth;
  LONG lfEscapement;
  LONG lfOrientation;
  LONG lfWeight;
  BYTE lfItalic;
  BYTE lfUnderline;
  BYTE lfStrikeOut;
  BYTE lfCharSet;
  BYTE lfOutPrecision;
  BYTE lfClipPrecision;
  BYTE lfQuality;
  BYTE lfPitchAndFamily;
  CHAR lfFaceName[LF_FACESIZE];
} LOGFONTA, *PLOGFONTA, *NPLOGFONTA, *LPLOGFONTA;
  1. The font must be fixed-pitch. pitch and family of the font is described by the field lfPitchAndFamily. The two low-order bits specify the pitch of the font and can be one of the following values:

    • DEFAULT_PITCH
    • FIXED_PITCH
    • VARIABLE_PITCH
  2. The font cannot be italic. In other words, the lfItalic field must be set to false.

  3. If it is a TrueType font, the lfPitchAndFamily field must contain the code for the FF_MODERN family, in bits 4 through 7. FF_MODERN describes fonts with a constant stroke width (i.e. monospace fonts), with or without serifs. Monospace fonts are usually modern. Pica, Elite, and CourierNew are examples.

  4. If it is not a TrueType font, it's charset must include OEM_CHARSET, as defined by the lfCharSet field in the tagLOGFONTA structure. That is, the font needs to be more than merely monospace. It also needs to support all the characters in the OEM code page, the 437 "OEM" characters of the IBM437 (OEM United States) char set as described here.

  5. The font cannot have a negative A or C space. The width of a character is described by an ABC structure. The B spacing is the width of the character. The A spacing is how much space to leave on the left of the character, and the C spacing is how much margin to leave on the right.

    Any character with a negative margin on the left or right is oversized the designated grid/raster. For example, a font with an overloaded W needs more space than the designated X pixel character width to properly draw the character. Obviously, fonts with oversized characters are not fixed-width.


However, one known font to work and that has been suggested because it supports a lot of useful glyphs and math, is DejaVu. Unfortunately it is not part of the Windows standard font selection and need to be installed manually.

If the font you need doesn't already have a TrueType font file (*.ttf) or OpenType (*.otf), you will need to convert the SFD files into TTF (or OTF). To do so, you can use FontForge to import SFD and then generate the TTF.


Steps to install a TTF file using FontForge

  1. Install FontForge (hereafter "FF")
  2. Run FF as Administrator
  3. Download the SFD font file(s) (For example: DejaVuSansMono.sfd.)
  4. Open the file with: File > Open and hit OK.
  5. Generate a TTF with: File > Generate Fonts..., then
  6. Select True Type in the drop-down, then
  7. Un-Select the Validate Before Saving option and hit Generate.
  8. Drag the resulting *.ttf file into the Windows Control Panel for Fonts found at:
    (Control Panel\Appearance and Personalisation\Fonts) or by: WIN+R and type: %windir%\fonts.

Done. The new font is now immediately available in your registry.


Load the new font(s) into the Console registry

Open a Powershell console as Administrator to do this.

# All your available fonts are located here:
$T1key = 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Fonts'

# But your Console fonts are located here:
$T2key = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont'

# Check the correct name: 
Get-ItemProperty -Path $T1key | grep "DejaVu"
DejaVu Sans Mono (TrueType)     : DejaVuSansMono.ttf
# Note the correct spacing of the name and ignore the "(TrueType)" part

# Check what's already there:
Get-ItemProperty -Path $T2key

# To add more fonts, just add the new name like this: 
# - Add another 0 (zero) to the -Name parameter, for each new font
# So since there is already an item with two zeros, so we need 3 and 4 zeros...
#Set-ItemProperty -Path $key -Name '000' -Value 'Arial'     # Doesn't work!
#Set-ItemProperty -Path $key -Name '0000' -Value 'Calibri'  # Doesn't work!
Set-ItemProperty -Path $key -Name '00000' -Value 'DejaVu Sans Mono'

However, you will not see the new font items, until:

  1. the registry has been reloaded into memory, so the only way is to either:
    • reboot the computer or
    • restart Windows Explorer.
  2. Restart your Powershell Console
  3. File a bug report to Windows Powershell repo Console repo and ask them to:
    support proper Fonts with correct unicode glyphs.

Enjoy the many new and correct glyphs!

For example, try the 5/8th box:
[char]0x2585 # (U+2585)


Addendum:

stroke width

The Expand Stroke dialog gives you control over various aspects of the expansion process. First you can specify three types of pen nibs:

  • A round pen, which is circular by default but may be transformed into an ellipse
  • A rectangular pen, which is square by default but may be transformed into more traditional caligraphic nib shapes
  • A polygonal pen – you can draw almost any convex polygon.

For circular and caligraphic pens you can chose a stroke width, how the ends of an open path should be drawn, and how the path should look when two splines (or lines) join which do not have the same slope (ie. at a corner point).

not2qubit

Posted 2018-08-09T23:48:11.357

Reputation: 1 234

Hey, not2qubit! I appreciate all the research you did. It saved me a lot of time. I heavily modified your intro to save the next person even more time (currently in the edit review queue). I'm giving you a heads up in case you want to tweak my changes any. – jpaugh – 2019-05-10T17:26:43.933

Nice answer. Minor point for accuracy: What Does That Mean #3, constant stroke width is unrelated to monospace. Monospace refers to every character having the same character width, or at least being placed at a fixed interval; character positions will always be aligned regardless of which characters are used. Constant stroke width refers to the line used to draw the character. With calligraphy, there is extreme variation in the line width within the character, but some amount of variation is common for many fonts. In fonts with constant stroke width, the line thickness doesn't change at all. – fixer1234 – 2019-05-10T18:31:30.347

@fixer1234 Makes sense, but there must be some relationship between monospace fonts and constant-stroke-width fonts. FWIW, the source text makes the same mistake, and I didn't catch this while I was reading & editing this answer.

– jpaugh – 2019-05-10T18:46:26.703

@jpaugh, monospace fonts often have constant width strokes, probably because variable width strokes complicate scaling the character while accurately retaining the appearance. There's no real connection between the size of the characters, or the interval at which you place them, and uniform thickness of the line used to draw the characters. At small character sizes, it gets hard to accurately reproduce variable width strokes as defined for the font. There may not be enough pixels to make thin portions in the right proportion to thick portions, or to make smooth transition curves. – fixer1234 – 2019-05-10T19:16:50.780

@jpaugh Although I appreciate you trying o improve the answer, I do not see such a great need for "improvement" here, as people already have found my answer more than satisfactory. In addition you missed some of my original paragraph formatting, which is fine too. But I have been edit-stalked on the SE platform before, with people basically following me and editing every single answer I post. This is highly annoying, but is unfortunately very difficult to prevent or flag. So unless, there is something wrong or need to be added, these edits are not providing much more than point candy. – not2qubit – 2019-05-11T10:09:38.460

1@not2qubit, I was one of the reviewers who approved the edit. To be honest, I had to give it a lot of thought because it was so extensive (more change than we typically like to see in an edit). So I double checked it and verified that it was all from authoritative sources. I also concluded that it added value. Your answer was already very good (I upvoted it), but even the best answers can sometimes benefit from expansion with relevant points. jpaugh put substantial work into the edit, and the edit was substantive, so the points were well earned (not trivial polish for point candy). (cont'd) – fixer1234 – 2019-05-11T17:12:19.980

As far as people following you and editing all your posts, I don't know what kinds of edits the other posts received. Sure, there are users who like to add "polish" to as many posts as they can, it's not just your posts. But if your other posts were the same quality as this one, consider it an honor rather than an annoyance. People see exceptional posts and want them to be as perfect as possible because they are representative of what the site has to offer. This one is certainly in that league, and I think this edit was in that vein. – fixer1234 – 2019-05-11T17:12:26.893

1Ok I believe in this community, and it took quite some time to go through and check the edit. Thanks @jpaugh . – not2qubit – 2019-05-11T17:43:52.967