2022-11-29 21:06:33 +03:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from .ctk_font import CTkFont
|
|
|
|
from .font_manager import FontManager
|
|
|
|
|
|
|
|
# import DrawEngine to set preferred_drawing_method if loading shapes font fails
|
|
|
|
from ..core_rendering import DrawEngine
|
|
|
|
|
|
|
|
FontManager.init_font_manager()
|
|
|
|
|
|
|
|
# load Roboto fonts (used on Windows/Linux)
|
2022-11-30 23:51:36 +03:00
|
|
|
customtkinter_directory = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
|
|
|
|
FontManager.load_font(os.path.join(customtkinter_directory, "assets", "fonts", "Roboto", "Roboto-Regular.ttf"))
|
|
|
|
FontManager.load_font(os.path.join(customtkinter_directory, "assets", "fonts", "Roboto", "Roboto-Medium.ttf"))
|
2022-11-29 21:06:33 +03:00
|
|
|
|
|
|
|
# load font necessary for rendering the widgets (used on Windows/Linux)
|
2022-11-30 23:51:36 +03:00
|
|
|
if FontManager.load_font(os.path.join(customtkinter_directory, "assets", "fonts", "CustomTkinter_shapes_font.otf")) is False:
|
2022-11-29 21:06:33 +03:00
|
|
|
# change draw method if font loading failed
|
|
|
|
if DrawEngine.preferred_drawing_method == "font_shapes":
|
2022-11-30 23:51:36 +03:00
|
|
|
sys.stderr.write("customtkinter.windows.widgets.font warning: " +
|
2022-11-29 21:06:33 +03:00
|
|
|
"Preferred drawing method 'font_shapes' can not be used because the font file could not be loaded.\n" +
|
|
|
|
"Using 'circle_shapes' instead. The rendering quality will be bad!\n")
|
|
|
|
DrawEngine.preferred_drawing_method = "circle_shapes"
|