[Python] ImageFont.truetype() Fonts in tkinter - do I need to know the file extension? (e.g....

Discussão em 'Python' iniciado por Stack, Dezembro 7, 2024.

  1. Stack

    Stack Membro Participativo

    I pulled a list of available fonts from the tkinter 'font' module.

    from tkinter import font ... font.families())


    However, when trying to select a font through the ImageFont class, I'm really struggling to match the font names (from above) with the font .ttf file.

    my_font = ImageFont.truetype(f"{some_font_from_above}.ttf")


    Is it an upper/lowercase issue? Or font names differing from .ttf file names?

    Thanks,

    Getting the same error:

    self.font = core.getfont(
    ^^^^^^^^^^^^^
    OSError: cannot open resource

    Continue reading...

Compartilhe esta Página