Example #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)
Example #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
Example #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
#!/usr/bin/python

# takes the sparkle system name plist and prints it out as a string that can be used in an NSDictionary initializer

from AppKit import NSMutableDictionary, NSURL
    
models = NSMutableDictionary.dictionaryWithContentsOfURL_(NSURL.URLWithString_("https://raw.github.com/andymatuschak/Sparkle/4d00e8c569933dc7576a7b501f3caea0f4d30737/SUModelTranslation.plist"))

for model in models:
    print "@\"%s\", @\"%s\"," % (models[model], model)
Example #5
0
    'Kxpn': 0x4B78706E, # include slide numbers
    'Kxpd': 0x4B787064, # include date
    'Kxkf': 0x4B786B66, # export in raw KPF
    'KxPW': 0x4B785057, # password
    'KxPH': 0x4B785048, # password hint
}

if len(sys.argv) < 2:
    print "usage: %s <keynote-file>" % sys.argv[0]
    sys.exit(-1)

# Export options
keynote_file = sys.argv[1]
to_file = NSURL.fileURLWithPath_(keynote_file.split('.key')[0] + '.pdf')
as_format = EXPORT_FORMAT['Kpdf']
with_properties = NSMutableDictionary.dictionaryWithDictionary_({
})

if DEBUG:
    print("   KEYNOTE_FILE: %s" % keynote_file)
    print("        TO_FILE: %s" % to_file)
    print("      AS_FORMAT: %s" % as_format)
    print("WITH_PROPERTIES: %s" % with_properties)

# Open Keynote file
keynote = SBApplication.applicationWithBundleIdentifier_(BUNDLE)
doc = keynote.open_(keynote_file)

# Export to format
doc.exportTo_as_withProperties_(to_file, as_format, with_properties)

# Close keynote