當前位置: 首頁>>代碼示例>>Python>>正文


Python NSFont.fontWithName_size_方法代碼示例

本文整理匯總了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
開發者ID:Mondego,項目名稱:pyreco,代碼行數:34,代碼來源:allPythonContent.py

示例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)
開發者ID:typemytype,項目名稱:drawbot,代碼行數:9,代碼來源:preferencesController.py

示例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()
開發者ID:donbro,項目名稱:openworld,代碼行數:46,代碼來源:fontWithName_size_.py

示例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)
開發者ID:typemytype,項目名稱:drawbot,代碼行數:14,代碼來源:preferencesController.py

示例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)
開發者ID:typemytype,項目名稱:defconAppKit,代碼行數:47,代碼來源:featureTextEditor.py

示例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)
開發者ID:pobivan,項目名稱:GlyphsSDK,代碼行數:5,代碼來源:drawingTools.py

示例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)
開發者ID:pobivan,項目名稱:GlyphsSDK,代碼行數:8,代碼來源:drawingTools.py

示例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)
開發者ID:ajinkyakulkarni,項目名稱:nodebox-pyobjc,代碼行數:33,代碼來源:polymagic_test.py

示例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()
開發者ID:pepsipepsi,項目名稱:nodebox_opengl_python3,代碼行數:4,代碼來源:glyph.py

示例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))
開發者ID:schriftgestalt,項目名稱:Autopsy-Plugin,代碼行數:6,代碼來源:AutopsyLib.py

示例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)
開發者ID:xoconusco,項目名稱:verano16,代碼行數:4,代碼來源:osx_panel.py

示例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()
開發者ID:typemytype,項目名稱:defconAppKit,代碼行數:33,代碼來源:pillListCell.py


注:本文中的AppKit.NSFont.fontWithName_size_方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。