def test_get_font_from_data(fontdata, face, size): """Unit test for get_font_from_data""" font = get_font_from_data(fontdata) assert font.GetFaceName() == face assert font.GetPointSize() == size
def get_font(self, textfont, pointsize, fontweight, fontstyle, underline): """Returns font for given attribute strings Parameters ---------- textfont: String \tString that describes the type of font pointsize: Integer \tFont size in points fontweight: Integer in (wx.NORMAL, wx.BOLD) \tFontsize integer fontstyle: Integer in (wx.NORMAL, wx.ITALICS) \tString that describes the font style underlined: Bool \tFont is underlined if True """ # Get a real font from textfont string font = get_font_from_data(textfont) font.SetPointSize(self.get_zoomed_size(pointsize)) font.SetWeight(fontweight) font.SetStyle(fontstyle) font.SetUnderlined(underline) return font
def _zoom_labels(self, zoom): """Adjust grid label font to zoom factor""" labelfont = self.grid.GetLabelFont() default_fontsize = \ get_font_from_data(config["font"]).GetPointSize() - 2 labelfont.SetPointSize(max(1, int(round(default_fontsize * zoom)))) self.grid.SetLabelFont(labelfont)
def test_get_font_from_data(fontdata, face, size): """Unit test for get_font_from_data""" try: font = get_font_from_data(fontdata) except: # msttcorefonts is missing return assert font.GetFaceName() == face assert font.GetPointSize() == size
def test_get_font_from_data(fontdata, face, size): """Unit test for get_font_from_data""" try: font = get_font_from_data(fontdata) except: # msttcorefonts is missing return # This test seems to fail on many Linux systems because # font nemes are tweaked. # Since this has never been an issue, I comment out the face name test # assert font.GetFaceName() == face assert font.GetPointSize() == size
def get_font(self, textfont, pointsize, fontweight, fontstyle, underline): """Returns font for given attribute strings Parameters ---------- textfont: String \tString that describes the type of font pointsize: Integer \tFont size in points fontweight: Integer in (wx.NORMAL, wx.BOLD) \tFontsize integer fontstyle: Integer in (wx.NORMAL, wx.ITALICS) \tString that describes the font style underlined: Bool \tFont is underlined if True """ fontsize = self.get_zoomed_size(pointsize) font_key = textfont, fontsize, fontweight, fontstyle, underline if font_key in self.font_cache: return self.font_cache[font_key] # Get a real font from textfont string font = get_font_from_data(textfont) font.SetPointSize(fontsize) font.SetWeight(fontweight) font.SetStyle(fontstyle) font.SetUnderlined(underline) font.SetFaceName(textfont) # Windows hack self.font_cache[font_key] = font return font