Skip to content

Commit

Permalink
font-patcher: Improve 'Mono' compatibility with Windows
Browse files Browse the repository at this point in the history
[why]
Some of the patched Mono fonts do not turn up in the font chooser
of Windows CMD and PowerShell (and probably more).

[how]
For some reasons Windows does not identify the fonts as being strictly
monospaced, so they are hidden in that font choosers.

For the monospaced fonts we set now the Panose proportion 'monospaced'.
Windows seems to honor the Panose properties.

It is not clear why we need to set the old Panose props, especially as
Cascadia Code does not (!) set them and is still detected as monospaced.

Anyhow, the way Windows detects if a font is monospaced is a mystery (at
least for me), and this works, so ;-)

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
  • Loading branch information
Finii committed Nov 29, 2021
1 parent ab6fa3c commit 8da5a32
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions font-patcher
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ class font_patcher:
# Force width to be equal on all glyphs to ensure the font is considered monospaced on Windows.
# This needs to be done on all characters, as some information seems to be lost from the original font file.
self.set_sourcefont_glyph_widths()
# For some Windows applications (e.g. 'cmd') that is not enough. But they seem to honour the Panose table
# https://forum.high-logic.com/postedfiles/Panose.pdf
panose = list(self.sourceFont.os2_panose)
if panose[0] == 0 or panose[0] == 2: # 0 (1st value) = family kind; 0 = any (default); 2 = latin text and display
panose[0] = 2: # Assert kind
panose[3] = 9 # 3 (4th value) = propotion; 9 = monospaced
self.sourceFont.os2_panose = tuple(panose)

# Prevent opening and closing the fontforge font. Makes things faster when patching
# multiple ranges using the same symbol font.
Expand Down

0 comments on commit 8da5a32

Please sign in to comment.