4

By a coincidence I now have two Python 3.5 environments on my Ubuntu 16.10 Linux PC. One environment came with the Ubuntu install and I started using it until I found that Spyder was broken by the 16.10 upgrade. I installed Python 3.5 from Anaconda so that I had Spyder back. I am currently working on a program that uses box drawing characters to display data in tables which requires a mono-spaced font. It was immediately apparent that the two environments had different default fonts for a ScrolledText control. Under the Ubuntu environment the default font is: 'family': 'DejaVu Sans Mono' which works well with box drawing characters. Under Anaconda the default is: family': 'nimbus mono l' which doesn't work with box characters. I changed the font to 'lucidiatypewriter' and the box character spacing is correct but the font doesn't look very good.

I used the following script to display the available font families for the two environments.

import tkinter as tk  
import tkinter.font as tkf

root = tk.Tk()
print(tkf.families())

By comparing the list of font families to the /usr/share/fonts directory I have found that the two environments are using different paths to font files. The original Ubuntu environment is using /usr/share/fonts/truetype/... and the Anaconda environment is using /usr/share/fonts/x11/...

The Ubuntu environment presents many more choices than the Anaconda environment and the display looks much better using the truetype fonts. There has to be a configuration file somewhere that tells Python where to find fonts but I haven't been able to locate it. Does anyone know how to set Python's path to fonts?

  • 1
    I've asked [a similar question](https://stackoverflow.com/q/47769187/2749397) and an user pointed me to yours... investigating my own question I stumbled on a _very partial_ solution to the problem, that I have documented in an edit to the question itself. Maybe you are interested... – gboffi Dec 12 '17 at 12:30
  • FYI i have found a hackish solution, sort of, that I've published as a [self answer](https://stackoverflow.com/a/47787749/2749397). – gboffi Dec 13 '17 at 07:41

0 Answers0