'Python 3.10.2 anti-aliased fonts not smoothing in Tkinter under SUSI Linux
I have a problem with font smoothing AKA anti-aliasing not working. I have provided a small Tkinter test code snippet that shows a grid of Tkinter labels that steps through all of the installed fonts using that font's type face below. When run the code under our current build of Python 3.10.2 Tkinter 8.6 running under SUSI Linux. I get a grid of font names but they are clearly not using anti-aliasing. Very jagged.
When I run the same code on my Mac the fonts are smooth as expected. I now believe that this is due to an installation problem for either Python itself and/or Tkinter. I have spent a lot of time searching the Net for any information regarding installation settings/flags for Python 3.10.2 installation that would turn on anti-aliasing because it is clearly not operating under our Linux build. Unfortunately I have to figure out the problem and guide my IT group on how to fix the build because I do not control the installations.
Any ideas/trick and/or where to look for answers for this problem would be greatly appreciated. FWIW anti-aliasing works for our Python 3.6.0 build under the same Linux environment so there is something specifically wrong with the 3.10.2 build and/or the Tkinter installation for same.
Note all of the existing Stack Overflow postings that come up on this topic address using anti-aliased fonts not how to get the feature to fundamentally work. Even though I don't think my code snippet is needed I've included below just in case.
import tkinter
from tkinter import font
root = tkinter.Tk()
root.geometry('1500x1500')
root.columnconfigure(0, minsize=25)
root.columnconfigure(1, minsize=70)
tkinter.Label(root, text='Lists:', anchor=tkinter.W).grid(row=0, column=0, sticky=tkinter.W)
fams = font.families(root)
for i in range(39):
root.rowconfigure(i, minsize=14)
col = 0
row = 1
for i, fam in enumerate(fams):
label_id = tkinter.Label(root, anchor=tkinter.W, text=f'Sector {i}')
print(f'({i}: {row}, {col})')
label_id.grid(row=row, column=col )
label_name = tkinter.Label(root, anchor=tkinter.W, font=(fam, 14), text=fam)
c2 = col + 1
print(f'({i}: {row}, {c2}) FAM: {fam}')
label_name.grid(row=row, column=c2)
row += 1
if row % 40 == 0:
row = 1
col += 2
root.mainloop()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
