本文整理汇总了Python中AppKit.NSFont.systemFontOfSize_方法的典型用法代码示例。如果您正苦于以下问题:Python NSFont.systemFontOfSize_方法的具体用法?Python NSFont.systemFontOfSize_怎么用?Python NSFont.systemFontOfSize_使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppKit.NSFont
的用法示例。
在下文中一共展示了NSFont.systemFontOfSize_方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import systemFontOfSize_ [as 别名]
def init(self, wizard):
self = super(SetupWizardWindow, self).initWithContentRect_styleMask_backing_defer_(NSRect((0, 0), (580, 500)), NSTitledWindowMask | NSClosableWindowMask, NSBackingStoreBuffered, NO)
if self is not None:
self._wizard = wizard
self._dropbox_app = wizard.dropbox_app
self.setReleasedWhenClosed_(NO)
self.center()
self.setLevel_(NSFloatingWindowLevel)
self._system_font = NSFont.systemFontOfSize_(NSFont.systemFontSizeForControlSize_(NSRegularControlSize))
self._small_system_font = NSFont.systemFontOfSize_(NSFont.systemFontSizeForControlSize_(NSSmallControlSize))
self.setTitle_(SetupWizardStrings.window_title)
self._renderers = {Button: self._create_button,
CenteredMultiControlLine: self._create_centered_multi_control_line,
Checkbox: self._create_checkbox,
Choice: self._create_choice,
CreditCardType: self._create_credit_card_type,
Date: self._create_date,
ExampleText: self._create_example_text,
FancyRadioGroup: self._create_fancy_radio_group,
FlagChoice: self._create_flag_choice,
HelpButton: self._create_help_button,
Image: self._create_image,
LocationChanger: self._create_location_changer,
MultiControlLine: self._create_multi_control_line,
MultiControlLineSimple: self._create_multi_control_line,
TextBlock: self._create_text_block,
TextInput: self._create_text_input,
PlanChoices: self._create_plan_choices,
RadioGroup: self._create_radio_group,
SelectiveSync: self._create_selective_sync,
Spacer: self._create_spacer}
self._buttons = {}
return self
示例2: drawFontVerticalMetrics
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import systemFontOfSize_ [as 别名]
def drawFontVerticalMetrics(glyph, scale, rect, drawLines=True, drawText=True, color=None, backgroundColor=None, flipped=False):
font = glyph.font
if font is None:
return
if color is None:
color = getDefaultColor("fontVerticalMetrics")
if backgroundColor is None:
backgroundColor = getDefaultColor("background")
color.set()
# gather y positions
toDraw = (
("Descender", "descender"),
("X Height", "xHeight"),
("Cap Height", "capHeight"),
("Ascender", "ascender")
)
toDraw = [(name, getattr(font.info, attr)) for name, attr in toDraw if getattr(font.info, attr) is not None]
toDraw.append(("Baseline", 0))
positions = {}
for name, position in toDraw:
if position not in positions:
positions[position] = []
positions[position].append(name)
# create lines
xMin = rect[0][0]
xMax = xMin + rect[1][0]
lines = []
for y, names in sorted(positions.items()):
names = ", ".join(names)
lines.append(((xMin, y), (xMax, y), names))
# draw lines
if drawLines:
lineWidth = 1.0 * scale
for pt1, pt2, names in lines:
drawLine(pt1, pt2, lineWidth=lineWidth)
# draw text
if drawText:
fontSize = 9
shadow = NSShadow.shadow()
shadow.setShadowColor_(backgroundColor)
shadow.setShadowBlurRadius_(5)
shadow.setShadowOffset_((0, 0))
attributes = {
NSFontAttributeName: NSFont.systemFontOfSize_(fontSize),
NSForegroundColorAttributeName: color
}
glowAttributes = {
NSFontAttributeName: NSFont.systemFontOfSize_(fontSize),
NSForegroundColorAttributeName: color,
NSStrokeColorAttributeName: backgroundColor,
NSStrokeWidthAttributeName: 25,
NSShadowAttributeName: shadow
}
for pt1, pt2, names in lines:
x, y = pt1
x += 5 * scale
y -= (fontSize / 2.0) * scale
drawTextAtPoint(names, (x, y), scale, glowAttributes, flipped=flipped)
drawTextAtPoint(names, (x, y), scale, attributes, flipped=flipped)
示例3: __init__
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import systemFontOfSize_ [as 别名]
def __init__(self, posSize, titles, isVertical=True, callback=None, sizeStyle="regular"):
self._setupView(self.nsMatrixClass, posSize, callback=callback)
self._isVertical = isVertical
matrix = self._nsObject
matrix.setMode_(NSRadioModeMatrix)
matrix.setCellClass_(self.nsCellClass)
# XXX! this does not work for vertical radio groups!
matrix.setAutosizesCells_(True)
# we handle the control size setting here
# since the actual NS object is a NSMatrix
cellSizeStyle = _sizeStyleMap[sizeStyle]
font = NSFont.systemFontOfSize_(NSFont.systemFontSizeForControlSize_(cellSizeStyle))
# intercell spacing and cell spacing are based on the sizeStyle
if sizeStyle == "regular":
matrix.setIntercellSpacing_((4.0, 2.0))
matrix.setCellSize_((posSize[2], 18))
elif sizeStyle == "small":
matrix.setIntercellSpacing_((3.5, 2.0))
matrix.setCellSize_((posSize[2], 15))
elif sizeStyle == "mini":
matrix.setIntercellSpacing_((3.0, 2.0))
matrix.setCellSize_((posSize[2], 12))
else:
raise ValueError("sizeStyle must be 'regular', 'small' or 'mini'")
for _ in range(len(titles)):
if isVertical:
matrix.addRow()
else:
matrix.addColumn()
for title, cell in zip(titles, matrix.cells()):
cell.setButtonType_(NSRadioButton)
cell.setTitle_(title)
cell.setControlSize_(cellSizeStyle)
cell.setFont_(font)
示例4: SmallTextListCell
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import systemFontOfSize_ [as 别名]
def SmallTextListCell(editable=False):
cell = NSTextFieldCell.alloc().init()
size = NSSmallControlSize
cell.setControlSize_(size)
font = NSFont.systemFontOfSize_(NSFont.systemFontSizeForControlSize_(size))
cell.setFont_(font)
cell.setEditable_(editable)
return cell
示例5: __init__
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import systemFontOfSize_ [as 别名]
def __init__(self, posSize, title=None):
self._setupView(self.nsBoxClass, posSize)
if title:
self._nsObject.setTitle_(title)
if osVersionCurrent < osVersion10_10:
self._nsObject.titleCell().setTextColor_(NSColor.blackColor())
font = NSFont.systemFontOfSize_(NSFont.systemFontSizeForControlSize_(NSSmallControlSize))
self._nsObject.setTitleFont_(font)
else:
self._nsObject.setTitlePosition_(NSNoTitle)
示例6: __init__
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import systemFontOfSize_ [as 别名]
def __init__(self, dimensions, font):
font_name = font.info.familyName
attribution = "{} by {}".format(font_name, font.info.designer)
attribution_attributes = {
NSFontAttributeName: NSFont.systemFontOfSize_(NSFont.systemFontSize()),
NSForegroundColorAttributeName: NSColor.whiteColor()
}
formatted_attribution = NSMutableAttributedString.alloc().initWithString_attributes_(attribution, attribution_attributes)
formatted_attribution.addAttribute_value_range_(NSFontAttributeName, NSFont.boldSystemFontOfSize_(NSFont.systemFontSize()), [0, len(font_name)])
super(AttributionText, self).__init__(dimensions, formatted_attribution)
示例7: drawCellHeaderText
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import systemFontOfSize_ [as 别名]
def drawCellHeaderText(self, rect):
paragraph = NSMutableParagraphStyle.alloc().init()
paragraph.setAlignment_(NSCenterTextAlignment)
paragraph.setLineBreakMode_(NSLineBreakByTruncatingMiddle)
attributes = {
NSFontAttributeName: NSFont.systemFontOfSize_(10.0),
NSForegroundColorAttributeName: NSColor.colorWithCalibratedRed_green_blue_alpha_(.22, .22, .27, 1.0),
NSParagraphStyleAttributeName: paragraph,
}
text = NSAttributedString.alloc().initWithString_attributes_(self.glyph.name, attributes)
text.drawInRect_(rect)
示例8: initWithFrame_imageDir_
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import systemFontOfSize_ [as 别名]
def initWithFrame_imageDir_(self, frame, imageDir):
self = super(IntroView, self).initWithFrame_(frame)
if not self:
return None
dropboxImage = NSImage.alloc().initWithContentsOfFile_(os.path.join(imageDir, u'box_stroked_150.png'))
iW, iH = dropboxImage.size()
newHeight = iH * 300.0 / iW
self.dropboxViewFinalPosition = NSRect((25, frame.size[1] - 43 - newHeight), (300, newHeight))
self.dropboxView = ShadowedImage.alloc().initWithFrame_(self.dropboxViewFinalPosition)
self.dropboxView.setImageScaling_(NSScaleToFit)
self.dropboxView.setImage_(dropboxImage)
self.dropboxView.setShadowColor_(NSColor.colorWithCalibratedRed_green_blue_alpha_(0, 0, 0, 0.5))
self.dropboxView.setShadowOffset_((0.0, -2.0))
self.dropboxView.setShadowBlurRadius_(5.0)
logoImage = NSImage.alloc().initWithContentsOfFile_(os.path.join(imageDir, u'dropboxlogo.png'))
iW, iH = logoImage.size()
newHeight = iH * 300.0 / iW
self.logoViewFinalPosition = NSRect((25, frame.size[1] - 334 - newHeight), (300, newHeight))
self.logoView = NSImageView.alloc().initWithFrame_(self.logoViewFinalPosition)
self.logoView.setImage_(logoImage)
self.versionView = NSTextView.alloc().initWithFrame_(NSRect((0, 0), frame.size))
self.versionView.setDrawsBackground_(NO)
self.versionView.setEditable_(NO)
self.versionView.setSelectable_(NO)
self.versionView.textStorage().mutableString().setString_(u'Version %s' % build_number.VERSION)
self.versionView.textStorage().setFont_(NSFont.labelFontOfSize_(14))
self.versionView.layoutManager().glyphRangeForTextContainer_(self.versionView.textContainer())
textSize1 = self.versionView.layoutManager().usedRectForTextContainer_(self.versionView.textContainer()).size
textAnchor1 = 5
self.versionView2 = NSTextView.alloc().initWithFrame_(NSRect((0, 0), frame.size))
self.versionView2.setDrawsBackground_(NO)
self.versionView2.setEditable_(NO)
self.versionView2.setSelectable_(NO)
self.versionView2.textStorage().mutableString().setString_(u'Copyright \xa9 2007-2010 Dropbox Inc.')
self.versionView2.setFont_(NSFont.systemFontOfSize_(NSFont.systemFontSizeForControlSize_(NSSmallControlSize)))
self.versionView2.layoutManager().glyphRangeForTextContainer_(self.versionView2.textContainer())
textSize2 = self.versionView2.layoutManager().usedRectForTextContainer_(self.versionView2.textContainer()).size
textAnchor2 = 4
bottomToLogoViewBaseline = self.logoView.frame().origin[1] + 17
textSeparation = 10
combinedHeight = textSize1[1] + textSize2[1] + textSeparation
self.versionView2FinalPosition = NSRect(((frame.size[0] - textSize2[0]) / 2.0, (bottomToLogoViewBaseline - combinedHeight) / 2.0), (textSize2[0], textSize2[1] + textAnchor2))
self.versionView2.setFrame_(self.versionView2FinalPosition)
self.versionViewFinalPosition = NSRect(((frame.size[0] - textSize1[0]) / 2.0, self.versionView2.frame().origin[1] + textSeparation + self.versionView2.frame().size[1]), (textSize1[0], textSize1[1] + textAnchor1))
self.versionView.setFrame_(self.versionViewFinalPosition)
for _view in (self.dropboxView,
self.logoView,
self.versionView,
self.versionView2):
self.addSubview_(_view)
return self
示例9: checkSampleSize
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import systemFontOfSize_ [as 别名]
def checkSampleSize(self):
text = self.w.selectionUnicodeText.get()
minFontSize = 20
maxFontSize = 50
charsForLarge = 35
charsForSmall = 50
if len(text) < charsForLarge:
fontSize = maxFontSize
elif len(text) > charsForSmall:
fontSize = minFontSize
else:
fs = (len(text)-charsForLarge)/(charsForSmall-charsForLarge)
fontSize = maxFontSize + fs * (minFontSize-maxFontSize)
tf = self.w.selectionUnicodeText.getNSTextField()
nsBig = NSFont.systemFontOfSize_(fontSize)
tf.setFont_(nsBig)
示例10: initWithDropboxApp_initialIgnoreList_takeAction_callback_remote_
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import systemFontOfSize_ [as 别名]
def initWithDropboxApp_initialIgnoreList_takeAction_callback_remote_(self, dropbox_app, initial_ignore_list, take_action, callback, remote):
self = super(SelectiveSyncView, self).initWithFrame_(NSZeroRect)
if self is None:
return
self._initial_ignore_list = initial_ignore_list
self._callback = callback
self._take_action = take_action
self._remote = remote
self.setAutoresizingMask_(NSViewWidthSizable | NSViewHeightSizable)
self._dropbox_app = dropbox_app
self.initBrowser(self._remote)
self.initButtons()
f = NSFont.systemFontOfSize_(NSFont.smallSystemFontSize())
self.infoLabel = NSTextField.createLabelWithText_font_(selsync_strings.info, f)
self.addSubview_(self.infoLabel)
self.reloadInvalidState()
self.layoutForWidth_(DEFAULT_ADVANCED_WIDTH if self.forest.advanced_view else DEFAULT_SIMPLE_WIDTH)
return self
示例11: _drawTextLabel
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import systemFontOfSize_ [as 别名]
def _drawTextLabel(self, transform, text, size, vector):
if vector is None:
vector = (-1, 1)
angle = atan2(vector[0], -vector[1])
text_size = 0.5 * size
#para_style = NSMutableParagraphStyle.alloc().init()
#para_style.setAlignment_(NSCenterTextAlignment)
attrs = {
NSFontAttributeName: NSFont.systemFontOfSize_(text_size),
NSForegroundColorAttributeName: NSColor.colorWithCalibratedRed_green_blue_alpha_( 0.4, 0.4, 0.6, 0.7 ),
#NSParagraphStyleAttributeName: para_style,
}
myString = NSString.string().stringByAppendingString_(text)
bbox = myString.sizeWithAttributes_(attrs)
bw = bbox.width
bh = bbox.height
text_pt = NSPoint()
text_pt.y = 0
if -0.5 * pi < angle <= 0.5 * pi:
text_pt.x = -1.3 * size - bw / 2 * cos(angle) - bh / 2 * sin(angle)
else:
text_pt.x = -1.3 * size + bw / 2 * cos(angle) + bh / 2 * sin(angle)
text_pt = transform.transformPoint_(text_pt)
rr = NSRect(
origin = (text_pt.x - bw / 2, text_pt.y - bh / 2),
size = (bw, bh)
)
if DEBUG:
NSColor.colorWithCalibratedRed_green_blue_alpha_( 0, 0, 0, 0.15 ).set()
myRect = NSBezierPath.bezierPathWithRect_(rr)
myRect.setLineWidth_(0.05 * size)
myRect.stroke()
myString.drawInRect_withAttributes_(
rr,
attrs
)
示例12: drawGlyphAnchors
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import systemFontOfSize_ [as 别名]
def drawGlyphAnchors(glyph, scale, rect, drawAnchor=True, drawText=True, color=None, backgroundColor=None, flipped=False):
if not glyph.anchors:
return
if color is None:
color = getDefaultColor("glyphAnchor")
fallbackColor = color
if backgroundColor is None:
backgroundColor = getDefaultColor("background")
anchorSize = 5 * scale
anchorHalfSize = anchorSize / 2
for anchor in glyph.anchors:
if anchor.color is not None:
color = colorToNSColor(anchor.color)
else:
color = fallbackColor
x = anchor.x
y = anchor.y
name = anchor.name
context = NSGraphicsContext.currentContext()
context.saveGraphicsState()
shadow = NSShadow.alloc().init()
shadow.setShadowColor_(backgroundColor)
shadow.setShadowOffset_((0, 0))
shadow.setShadowBlurRadius_(3)
shadow.set()
if drawAnchor:
r = ((x - anchorHalfSize, y - anchorHalfSize), (anchorSize, anchorSize))
color.set()
drawFilledOval(r)
if drawText and name:
attributes = {
NSFontAttributeName: NSFont.systemFontOfSize_(9),
NSForegroundColorAttributeName: color,
}
y -= 2 * scale
drawTextAtPoint(name, (x, y), scale, attributes, xAlign="center", yAlign="top", flipped=flipped)
context.restoreGraphicsState()
示例13: drawPath
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import systemFontOfSize_ [as 别名]
path = glyph._layer.bezierPath
drawPath(path)
def save():
# save the current graphic state
NSGraphicsContext.currentContext().saveGraphicsState()
def restore():
# restore the current graphic state
NSGraphicsContext.currentContext().restoreGraphicsState()
currentPath = None
currentFillColor = NSColor.blackColor()
currentStrokeColor = None
currentGradient = None
currentFont = NSFont.systemFontOfSize_(NSFont.systemFontSize())
def rect(x, y, width, height):
# draws a rectangle
drawPath(NSBezierPath.bezierPathWithRect_(NSMakeRect(x, y, width, height)))
def oval(x, y, width, height):
# draws an oval
drawPath(NSBezierPath.bezierPathWithOvalInRect_(NSMakeRect(x, y, width, height)))
def line(x1, y1, x2=None, y2=None):
# draws a line
if x2 is None and y2 is None and isinstance(x1, tuple) and isinstance(y1, tuple):
(x1, y1), (x2, y2) = x1, y1
p = NSBezierPath.bezierPath()
p.moveToPoint_(NSMakePoint(x1, y1))
示例14: _setSizeStyle
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import systemFontOfSize_ [as 别名]
def _setSizeStyle(self, value):
value = _sizeStyleMap[value]
self._nsObject.cell().setControlSize_(value)
font = NSFont.systemFontOfSize_(NSFont.systemFontSizeForControlSize_(value))
self._nsObject.setFont_(font)
示例15: regular
# 需要导入模块: from AppKit import NSFont [as 别名]
# 或者: from AppKit.NSFont import systemFontOfSize_ [as 别名]
def regular(size):
return {NSFontAttributeName: NSFont.systemFontOfSize_(size)}