import os import pygame import sys def font(size, font = "Ubuntu-Regular"): if getattr(sys, 'frozen', False): return pygame.font.Font(sys._MEIPASS + "/fonts/" + font + ".ttf", size) else: path = os.path.dirname(os.path.realpath(__file__)) return pygame.font.Font(path + "/../fonts/" + font + ".ttf", size)