wxPython demo showing block symbols in Demo Code tab

When I ran the wxPython Demo today for the first time in a couple of weeks, I noticed that the Demo Code tab is showing block symbols containing numbers instead of regular characters. It also happens in the demo’s STC examples, but the rest of the demo appears OK.

Screenshot at 2020-12-19 11-22-31

I assume this is a font problem. I ran the demo again from the command line and none of the messages output there refer to fonts. If I copy/paste the blocks into a text editor program, the code appears correctly there. The problem is not occurring in any other apps on this PC, including several of my own projects that use the STC.

I am using Python 3.8.5 and wxPython 4.1.1 on Linux Mint 20. The wxPython Demo app is the 4.1.1 version downloaded from extras.

How can I get the demo to display the code correctly?

It’s been a while since I dealt with font issues on Linux so this is just a shot in the dark, but one possible cause of the issue that comes to mind is that the demo uses generic typeface names on Linux, defined in demo/StyledTextCtrl_2.py like this:

    faces = { 'times': 'Times',
              'mono' : 'Courier',
              'helv' : 'Helvetica',
              'other': 'new century schoolbook',
              'size' : 12,
              'size2': 10,
             }

If your system doesn’t have those names mapped to real fonts then it could be choosing another default that doesn’t have unicode glyphs available. (Or maybe they are mapped to a real font that doesn’t have unicode support.)

Thanks, Robin.

I’ve just installed version 4.1.1 of wxPython and the demo on my laptop which has an almost stock Mint 20 installation and the contents of the Demo Code tab are being displayed correctly there.

Therefore it seems that I have disrupted the stock fonts on my desktop PC somehow, so I’m now looking to see if there is a way to re-install them without having to re-install the whole OS.

I have solved the problem.

I noticed in the demo’s Main.py, in the definition of DemoCodeEditor.SetUpEditor(), the section that specifies the global default style specifies “Courier” for linux systems.

On the PC that has the problem, when I run fc-list, it shows 2 sets of Courier fonts.

richardt@Pavilion ~ $ fc-list | sort | grep -i courier
/usr/share/fonts/type1/texlive-fonts-recommended/pcrb8a.pfb: Courier:style=Bold
/usr/share/fonts/type1/texlive-fonts-recommended/pcrbo8a.pfb: Courier:style=Bold Italic
/usr/share/fonts/type1/texlive-fonts-recommended/pcrr8a.pfb: Courier:style=Regular
/usr/share/fonts/type1/texlive-fonts-recommended/pcrro8a.pfb: Courier:style=Italic
/usr/share/fonts/X11/Type1/c0419bt_.pfb: Courier 10 Pitch:style=Regular
/usr/share/fonts/X11/Type1/c0582bt_.pfb: Courier 10 Pitch:style=Italic
/usr/share/fonts/X11/Type1/c0583bt_.pfb: Courier 10 Pitch:style=Bold
/usr/share/fonts/X11/Type1/c0611bt_.pfb: Courier 10 Pitch:style=Bold Italic

However, the PC that doesn’t show the problem only lists the 4 ‘X11’ Courier fonts. Not long ago I had installed the "Texlive-fonts-extra’ package on the problem PC (I can’t remember why!). After removing it and the dependent packages it had dragged in, the font problem in the wxPython demo was fixed.

I assume that when an application requested a Courier font it was given a texlive one instead of one of the X11 Courier fonts, and as you suggested Robin, the texlive one couldn’t display the characters correctly.