__init__.py 1.3 KB

123456789101112131415161718192021222324
  1. import os
  2. import sys
  3. from .ctk_font import CTkFont
  4. from .font_manager import FontManager
  5. # import DrawEngine to set preferred_drawing_method if loading shapes font fails
  6. from ..core_rendering import DrawEngine
  7. FontManager.init_font_manager()
  8. # load Roboto fonts (used on Windows/Linux)
  9. customtkinter_directory = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
  10. FontManager.load_font(os.path.join(customtkinter_directory, "assets", "fonts", "Roboto", "Roboto-Regular.ttf"))
  11. FontManager.load_font(os.path.join(customtkinter_directory, "assets", "fonts", "Roboto", "Roboto-Medium.ttf"))
  12. # load font necessary for rendering the widgets (used on Windows/Linux)
  13. if FontManager.load_font(os.path.join(customtkinter_directory, "assets", "fonts", "CustomTkinter_shapes_font.otf")) is False:
  14. # change draw method if font loading failed
  15. if DrawEngine.preferred_drawing_method == "font_shapes":
  16. sys.stderr.write("customtkinter.windows.widgets.font warning: " +
  17. "Preferred drawing method 'font_shapes' can not be used because the font file could not be loaded.\n" +
  18. "Using 'circle_shapes' instead. The rendering quality will be bad!\n")
  19. DrawEngine.preferred_drawing_method = "circle_shapes"