def set_font(self, font: str): """ Sets the font to the specified font in the cache :param font: the font """ self.font = get_font(font) self.reload_text()
def __init__(self, screen: pygame.Surface, args: dict, parent: 'Room'): ObjectBase.__init__(self, screen, args, parent) self.font = get_font(self.get_mandatory_arguement( "font", str)) # type: pygame.font.Font self.text = self.get_mandatory_arguement("text", str) self.antialiasing = bool( self.get_optional_arguement("antialiasing", 1, int, blank_means_unset=True)) self.color = utils.convert_color( self.get_optional_arguement("color", "White", str, blank_means_unset=True)) self.text_object = None self.rebuild_text_object()
def __init__(self, screen: pygame.Surface, font: str, text: str, color, antialiasing=True): """ This class is to be used for all objects which are represented on the screen by text :param screen: The main pygame surface to draw the text to :param font: The reference to the font in the cache to use :param text: The text to render in the font :param color: The color to draw the text :param antialiasing: If antialiasing should be used """ DisplayBase.__init__(self) self.color = convert_color(color) self.screen = screen self.font = get_font(font) self.text = text self.antialiasing = antialiasing self.text_object = None self.reload_text()
def __init__(self, screen: pygame.Surface, args: dict, parent): ObjectBase.__init__(self, screen, args, parent) self.color = (0, 255, 0) self.font_name = self.get_mandatory_arguement("font", str) self.font = get_font(self.font_name) self.value = self.get_mandatory_arguement("text", str) self.text = self.font.render(self.value, True, self.color) self.set_width( self.get_optional_arguement("w", self.text.get_width(), int)) self.set_height( self.get_optional_arguement("h", self.text.get_height(), int)) self.sup = self.get_mandatory_arguement("supplementary", str) self.outline = pygame.Rect(self.rect) self.visible = bool(self.get_optional_arguement("visible", 1, int)) self.text_x = self.x + ((self.w / 2) - (self.text.get_width() / 2)) self.text_y = self.y + ((self.h / 2) - (self.text.get_height() / 2))
def set_font(self, font: str): self.font = get_font(font) self.rebuild_text_object()