1

The font on my Debian bullseye OS normally looks just fine. However, when I create an app using tkinter and place text on it, the text looks awful. I expect my tkinter apps in general to show nice font. A screenshot of how the font appears is posted at the bottom.

These are the steps I've taken to try and resolve this issue.

  1. I installed: ttf-mscorefonts-installer
  2. I created a fonts.conf file in the directory .config/fontconfig/fonts.conf with the code as follows:

fontconfig

While my fonts do looks much better on my OS after taking these steps, the text on my tkinter apps still look awful. For additional information, here is the code I used to my app on tkinter:

from tkinter import *
from quiz_brain import QuizBrain


THEME_COLOR = "#375362"


class QuizInterface:

    def __init__(self, quiz_brain: QuizBrain):
        self.quiz = quiz_brain
        self.window = Tk()
        self.window.title("Quizzler")
        self.window.config(padx=20, pady=20, bg=THEME_COLOR)

        self.score_label = Label(text="Score: 0", fg="white", bg=THEME_COLOR)
        self.score_label.grid(row=0, column=1)

        self.canvas = Canvas(width=300, height=250, bg="white")
        self.question_text = self.canvas.create_text(
            150,
            125,
            width=280,
            text="Some Question Text",
            fill=THEME_COLOR,
            font=("Courier", 20, "italic"))
        self.canvas.grid(row=1, column=0, columnspan=2, pady=50)

        true_img = PhotoImage(file="images/true.png")
        self.true_button = Button(
            image=true_img,
            command=self.true_pressed,
            highlightthickness=0
        )
        self.true_button.grid(row=2, column=0)

        false_img = PhotoImage(file="images/false.png")
        self.false_button = Button(
            image=false_img,
            command= self.false_pressed,
            highlightthickness=0
        )
        self.false_button.grid(row=2, column=1)

        self.get_next_question()

        self.window.mainloop()

  • 3
    avoid using images of code: please write out your code or copy/paste code so that those helping you don't have to retype it. Please add what you expect your code to do, what error you are getting. [ask] – Jacob Glik Mar 24 '22 at 21:44
  • avoid using images of code: please write out your code or copy/paste code so that those helping you don't have to retype it. Please add what you expect your code to do, what error you are getting. How to Ask – Abhyuday Vaish Mar 25 '22 at 05:53
  • the code used for configuring my font shows up on this posting as: rgb hintslight lcddefault. So I kept the image of the code so that it is displayed properly. – user13017933 Mar 25 '22 at 06:33

0 Answers0