本文整理汇总了Python中AppKit.NSFont.fontWithName_size_方法的典型用法代码示例。如果您正苦于以下问题:Python NSFont.fontWithName_size_方法的具体用法?Python NSFont.fontWithName_size_怎么用?Python NSFont.fontWithName_size_使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppKit.NSFont
的用法示例。
在下文中一共展示了NSFont.fontWithName_size_方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: awakeFromNib
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import fontWithName_size_ [as 别名]
def awakeFromNib(self):
NSLog("Awake from nib.")
self.setPreviewMode(True)
self.bodyField.setDelegate_(self)
self.urlField.setDelegate_(self)
self.titleField.setDelegate_(self)
# Style the bodyField.
self.bodyField.setFont_(NSFont.fontWithName_size_("Monaco", 13))
self.bodyField.setRichText_(NO)
self.bodyField.setUsesFontPanel_(NO)
# Authenticate to twitter if we can.
if self.twitter.is_authenticated():
self.twitter.login()
self.twitterCheckbox.setState_(NSOnState)
self.ltp.syndicators.append(self.twitter)
# Authenticate to G+ if we can.
if self.gplus.is_authenticated():
self.gplus.login()
self.gplusCheckbox.setState_(NSOnState)
self.ltp.syndicators.append(self.gplus)
# Listen to the NSApplicationWillTerminateNotification.
center = NSNotificationCenter.defaultCenter()
center.addObserver_selector_name_object_(self, "applicationWillTerminateNotification:", NSApplicationWillTerminateNotification, None)
self.setupStatusBar()
self.didPublish = False
self.didPreview = False
示例2: _setFont
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import fontWithName_size_ [as 别名]
def _setFont(self, font):
self.font.getNSTextField().setFont_(NSFont.fontWithName_size_(font.fontName(), 10))
size = font.pointSize()
if size == int(size):
size = int(size)
s = u"%s %spt" % (font.displayName(), size)
self.font.set(s)
示例3: main
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import fontWithName_size_ [as 别名]
def main():
# "Skia-Regular 14.00 pt. P [] (0x7ff98cb0b410) fobj=0x7ff98cb0ad90, spc=3.50"
font = NSFont.fontWithName_size_("HelveticaNeue-Medium",14.0)
font = NSFont.fontWithName_size_("Avenir Next LT Pro Ultra Light Italic",14.0)
print "font is", font
print "font.displayName() is", font.displayName()
# attributes = NSDictionary.dictionaryWithObjectsAndKeys_(font, NSFontAttributeName, None )
# print "attributes is", attributes
s = "CGColorCreateGenericRGB(0.8, 0.8, 0.8, 0.4)"
# print dir(NSAttributedString)
# s2 = NSAttributedString.alloc().initWithString_attributes_(s, attributes)
#
# print "s2 is", s2
s3 = NSAttributedString.alloc().initWithString_attributes_(s, { "NSFont":font })
print "s3 is", s3 # , "s2 == s3", s2 == s3
print "s3.size() is", s3.size()
# s3.size() is <NSSize width=293.0 height=21.0>
cat = CATextLayer.alloc().init()
cat.setString_(s3)
# cat.setFont_(font)
# cat.setFontSize_(font.pointSize() ) # necessary after setFont?
s4 = cat.string()
print "s4 is", s4, "s3 == s4", s3 == s4
print "cat.bounds() is", cat.frame()
示例4: tokenString
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import fontWithName_size_ [as 别名]
def tokenString(self):
font = NSFont.fontWithName_size_(fallbackFont.fontName(), 10)
attr = _textAttributesForStyle(self._style, font)
attr[NSForegroundColorAttributeName] = self.color()
if NSUnderlineColorAttributeName in attr:
attr[NSUnderlineColorAttributeName] = self.color()
txt = self.token()
if txt == "Token":
txt = "Fallback"
else:
txt = txt.replace("Token.", "")
return NSMutableAttributedString.alloc().initWithString_attributes_(txt, attr)
示例5: __init__
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import fontWithName_size_ [as 别名]
def __init__(self, posSize, text, callback=None):
# there must be a callback as it triggers the creation of the delegate
if callback is None:
callback = self._fallbackCallback
super(FeatureTextEditor, self).__init__(posSize, "", callback=callback)
self._nsObject.setHasHorizontalScroller_(True)
font = NSFont.fontWithName_size_("Monaco", 10)
self._textView.setFont_(font)
self._textView.setUsesFindPanel_(True)
## line numbers
#ruler = DefconAppKitLineNumberView.alloc().init()
#ruler.setClientView_(self._textView)
#self._nsObject.setVerticalRulerView_(ruler)
#self._nsObject.setHasHorizontalRuler_(False)
#self._nsObject.setHasVerticalRuler_(True)
#self._nsObject.setRulersVisible_(True)
#notificationCenter = NSNotificationCenter.defaultCenter()
#notificationCenter.addObserver_selector_name_object_(
# ruler, "clientViewSelectionChanged:", NSTextViewDidChangeSelectionNotification, self._textView
#)
# colors
self._mainColor = NSColor.blackColor()
self._commentColor = NSColor.colorWithCalibratedWhite_alpha_(.6, 1)
self._keywordColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(.8, 0, 0, 1)
self._tokenColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(.8, .4, 0, 1)
self._classNameColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(0, 0, .8, 1)
self._includeColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(.8, 0, .8, 1)
self._stringColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(0, .6, 0, 1)
# build the placard
placardW = 65
placardH = 16
self._placardJumps = []
self._placard = vanilla.Group((0, 0, placardW, placardH))
self._placard.featureJumpButton = PlacardPopUpButton((0, 0, placardW, placardH),
[], callback=self._placardFeatureSelectionCallback, sizeStyle="mini")
self._nsObject.setPlacard_(self._placard.getNSView())
# registed for syntax coloring notifications
self._programmaticallySettingText = False
delegate = self._textViewDelegate
delegate.vanillaWrapper = weakref.ref(self)
notificationCenter = NSNotificationCenter.defaultCenter()
notificationCenter.addObserver_selector_name_object_(
self._textViewDelegate, "textStorageDidProcessEditing", NSTextStorageDidProcessEditingNotification, self._textView.textStorage())
# set the text
self.set(text)
示例6: fontSize
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import fontWithName_size_ [as 别名]
def fontSize(fontSize):
# Set the font size.
currentFont = NSFont.fontWithName_size_(currentFont.fontName(), fontSize)
示例7: font
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import fontWithName_size_ [as 别名]
def font(fontName, fontSize=None):
# Set the font by PostScript name.
# Optionally set the font size.
if fontSize is None:
fontSize = NSFont.systemFontSize()
NSFont.fontWithName_size_(fontName, fontSize)
示例8: intersects
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import fontWithName_size_ [as 别名]
p1 = NSBezierPath.bezierPathWithOvalInRect_(((0, 0), (100, 100)))
p2 = NSBezierPath.bezierPathWithOvalInRect_(((40, 40), (100, 100)))
# Outside of bounding box
p3 = NSBezierPath.bezierPathWithOvalInRect_(((110, 0), (100, 100)))
# In bounding box, doesn't intersect
p4 = NSBezierPath.bezierPathWithOvalInRect_(((72, 72), (100, 100)))
from cPolymagic import *
print intersects(p1, p4)
f = NSFont.fontWithName_size_("Helvetica", 72)
fp1 = NSBezierPath.bezierPath()
fp1.moveToPoint_((100, 100))
fp1.appendBezierPathWithGlyph_inFont_(68, f)
fp2 = NSBezierPath.bezierPath()
fp2.moveToPoint_((110, 100))
fp2.appendBezierPathWithGlyph_inFont_(68, f)
print intersects(fp1, fp2)
# Some other thing inside of the function perhaps?
print intersects(fp2, fp2)
p = union(fp1, fp2)
示例9: descent
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import fontWithName_size_ [as 别名]
def descent(fontname, fontsize=10):
return NSFont.fontWithName_size_(fontname, fontsize).descender()
示例10: DrawText
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import fontWithName_size_ [as 别名]
def DrawText(font, fontsize, fontcolour, x, y, text):
attributes = {NSFontAttributeName : NSFont.fontWithName_size_(font, fontsize), NSForegroundColorAttributeName: NSColor.colorWithDeviceCyan_magenta_yellow_black_alpha_(fontcolour[0], fontcolour[1], fontcolour[2], fontcolour[3], 1)}
String = NSAttributedString.alloc().initWithString_attributes_(text, attributes)
String.drawAtPoint_((x, y))
示例11: __init__
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import fontWithName_size_ [as 别名]
def __init__(self, name, size):
self.ns_font = NSFont.fontWithName_size_(name, size)
示例12: DefconAppKitPillCell
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import fontWithName_size_ [as 别名]
from AppKit import NSFontAttributeName, NSFont, NSForegroundColorAttributeName, NSColor, NSActionCell, \
NSBezierPath, NSAttributedString
pillTextAttributes = {
NSFontAttributeName: NSFont.fontWithName_size_("Helvetica Bold", 12.0),
NSForegroundColorAttributeName: NSColor.whiteColor()
}
pillColor = NSColor.colorWithCalibratedRed_green_blue_alpha_(.75, .75, .8, 1.0)
class DefconAppKitPillCell(NSActionCell):
def setColor_(self, color):
self._color = color
def drawWithFrame_inView_(self, frame, view):
row = view.selectedRow()
columnCount = len(view.tableColumns())
frames = [view.frameOfCellAtColumn_row_(i, row) for i in xrange(columnCount)]
selected = frame in frames
(x, y), (w, h) = frame
y += 1
h -= 2
if selected:
pillTextAttributes[NSForegroundColorAttributeName] = self._color
foregroundColor = NSColor.whiteColor()