6

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.

12

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).

  • 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 May 10 '19 at 17:26
  • 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 May 10 '19 at 18:31
  • @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 May 10 '19 at 18:46
  • 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 May 11 '19 at 17:12
  • 1
    Ok I believe in this community, and it took quite some time to go through and check the edit. Thanks @jpaugh . – not2qubit May 11 '19 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.