def set_font(self, font, fixed_font=None): font = QFontInfo(font) settings = self.page().settings() for fontfamily in (settings.StandardFont, settings.SerifFont, settings.SansSerifFont, settings.CursiveFont, settings.FantasyFont): settings.setFontFamily(fontfamily, font.family()) if fixed_font is not None: settings.setFontFamily(settings.FixedFont, fixed_font.family()) size = font.pixelSize() settings.setFontSize(settings.DefaultFontSize, size) settings.setFontSize(settings.DefaultFixedFontSize, size)
def set_font(self, font, fixed_font=None): font = QFontInfo(font) settings = self.page().settings() for fontfamily in (settings.StandardFont, settings.SerifFont, settings.SansSerifFont, settings.CursiveFont, settings.FantasyFont): settings.setFontFamily(fontfamily, font.family()) if fixed_font is not None: settings.setFontFamily(settings.FixedFont, fixed_font.family()) size = font.pixelSize() settings.setFontSize(settings.DefaultFontSize, size) settings.setFontSize(settings.DefaultFixedFontSize, size)
def qwtUnscaleFont(painter): if painter.font().pixelSize() >= 0: return dpix, dpiy = get_screen_resolution() pd = painter.device() if pd.logicalDpiX() != dpix or pd.logicalDpiY() != dpiy: pixelFont = QFont(painter.font(), QApplication.desktop()) pixelFont.setPixelSize(QFontInfo(pixelFont).pixelSize()) painter.setFont(pixelFont)
def qwtUnscaleFont(painter): if painter.font().pixelSize() >= 0: return screenResolution = qwtScreenResolution() pd = painter.device() if (pd.logicalDpiX() != screenResolution.width() or pd.logicalDpiY() != screenResolution.height()): pixelFont = QFont(painter.font(), QApplication.desktop()) pixelFont.setPixelSize(QFontInfo(pixelFont).pixelSize()) painter.setFont(pixelFont)