Esempio n. 1
0
 def test_names(self):
     names = font.names(self.root)
     self.assertIsInstance(names, tuple)
     self.assertTrue(names)
     for name in names:
         self.assertIsInstance(name, (str, unicode))
         self.assertTrue(name)
     self.assertIn(fontname, names)
 def test_names(self):
     names = font.names(self.root)
     self.assertIsInstance(names, tuple)
     self.assertTrue(names)
     for name in names:
         self.assertIsInstance(name, (str, unicode))
         self.assertTrue(name)
     self.assertIn(fontname, names)
Esempio n. 3
0
 def findfont(self, names):
     "Return name of first font family derived from names."
     for name in names:
         if name.lower() in (x.lower() for x in tkfont.names(root=self)):
             font = tkfont.Font(name=name, exists=True, root=self)
             return font.actual()['family']
         elif name.lower() in (x.lower()
                               for x in tkfont.families(root=self)):
             return name
Esempio n. 4
0
 def findfont(self, names):
     "Return name of first font family derived from names."
     for name in names:
         if name.lower() in (x.lower() for x in tkfont.names(root=self)):
             font = tkfont.Font(name=name, exists=True, root=self)
             return font.actual()['family']
         elif name.lower() in (x.lower()
                               for x in tkfont.families(root=self)):
             return name
Esempio n. 5
0
def fix_scaling(root):
    """Scale fonts on HiDPI displays."""
    import tkFont
    scaling = float(root.tk.call('tk', 'scaling'))
    if scaling > 1.4:
        for name in tkFont.names(root):
            font = tkFont.Font(root=root, name=name, exists=True)
            size = int(font['size'])
            if size < 0:
                font['size'] = int(round(-0.75*size))
Esempio n. 6
0
def setfonts():
    for fontname in tkFont.names():
        default_font = tkFont.nametofont(fontname)
        default_font.configure(size=14)