Ejemplo n.º 1
0
 def __init__(self, font, size):
     self._max_size = NSMakeSize(sys.float_info.max, sys.float_info.max)
     self._options = 1 << 3 # NSStringDrawingOptions.NSStringDrawingUsesDeiceMetrics
         # https://developer.apple.com/documentation/uikit/nsstringdrawingoptions?language=objc
     if font == "<System>":
         nsfont = NSFont.systemFontOfSize_(size)
     else:
         nsfont = NSFont.fontWithName_size_(font, size)
     self._attributes = NSMutableDictionary.dictionary()
     self._attributes.setObject_forKey_(nsfont, NSFontAttributeName)
     
     self._terminator = '1'
     self._terminator_width = self._measure(self._terminator)
Ejemplo n.º 2
0
 def _wrapFontForList(self, font):
     changed = False
     if font in self._wrappedListItems:
         d = self._wrappedListItems[font]
     else:
         d = NSMutableDictionary.dictionary()
         self._subscribeToFont(font)
     for key, attribute in self._keyToAttribute.items():
         if attribute == defaultFontIDAttribute:
             value = makeDefaultIDString(font)
         else:
             value = getattr(font, attribute)
         if not key in d or d.get(key) != value:
             d[key] = value
             changed = True
     d["_font"] = font
     if changed:
         self._wrappedListItems[font] = d
     return d
Ejemplo n.º 3
0
 def _wrapFontForList(self, font):
     changed = False
     if font in self._wrappedListItems:
         d = self._wrappedListItems[font]
     else:
         d = NSMutableDictionary.dictionary()
         self._subscribeToFont(font)
     for key, attribute in self._keyToAttribute.items():
         if attribute == defaultFontIDAttribute:
             value = makeDefaultIDString(font)
         else:
             value = getattr(font, attribute)
         if not key in d or d.get(key) != value:
             d[key] = value
             changed = True
     d["_font"] = font
     if changed:
         self._wrappedListItems[font] = d
     return d