def __init__(self, scrolling = 'hv', **kwds):
     width = 100
     height = 100
     frame = ((0, 0), (width,  height))
     ns_outer = NSScrollView.alloc().initWithFrame_(frame)
     ns_outer.setHasHorizontalScroller_('h' in scrolling)
     ns_outer.setHasVerticalScroller_('v' in scrolling)
     if 'h' in scrolling:
         cwidth = 2000
     else:
         cwidth = ns_outer.contentSize()[0]
     frame = ((0, 0), (cwidth,  height))
     ns_inner = PyGUI_NSTextView.alloc().initWithFrame_(frame)
     ns_inner.pygui_component = self
     ps = NSMutableParagraphStyle.alloc().init()
     ps.setDefaultTabInterval_(ps.tabStops()[0].location())
     ps.setTabStops_([])
     ns_inner.setDefaultParagraphStyle_(ps)
     ns_inner.setAllowsUndo_(True)
     ns_outer.setDocumentView_(ns_inner)
     if 'h' not in scrolling:
         ns_inner.setAutoresizingMask_(NSViewWidthSizable)
     if 'font' not in kwds:
         kwds['font'] = StdFonts.application_font
     GTextEditor.__init__(self, ns_outer,
         _ns_inner_view = ns_inner, **kwds)
Exemple #2
0
 def __init__(self, scrolling='hv', **kwds):
     width = 100
     height = 100
     frame = ((0, 0), (width, height))
     ns_outer = NSScrollView.alloc().initWithFrame_(frame)
     ns_outer.setHasHorizontalScroller_('h' in scrolling)
     ns_outer.setHasVerticalScroller_('v' in scrolling)
     if 'h' in scrolling:
         cwidth = 2000
     else:
         cwidth = ns_outer.contentSize()[0]
     frame = ((0, 0), (cwidth, height))
     ns_inner = PyGUI_NSTextView.alloc().initWithFrame_(frame)
     ns_inner.pygui_component = self
     ps = NSMutableParagraphStyle.alloc().init()
     ps.setDefaultTabInterval_(ps.tabStops()[0].location())
     ps.setTabStops_([])
     ns_inner.setDefaultParagraphStyle_(ps)
     ns_inner.setAllowsUndo_(True)
     ns_outer.setDocumentView_(ns_inner)
     if 'h' not in scrolling:
         ns_inner.setAutoresizingMask_(NSViewWidthSizable)
     if 'font' not in kwds:
         kwds['font'] = StdFonts.application_font
     GTextEditor.__init__(self, ns_outer, _ns_inner_view=ns_inner, **kwds)
Exemple #3
0
 def attributedStringForObjectValue_withDefaultAttributes_(self, obj, attrs):
     if obj is None or isinstance(obj, NSNull):
         obj = ""
     paragraph = NSMutableParagraphStyle.alloc().init()
     paragraph.setLineBreakMode_(NSLineBreakByTruncatingHead)
     attrs = dict(attrs)
     attrs[NSParagraphStyleAttributeName] = paragraph
     return NSAttributedString.alloc().initWithString_attributes_(obj, attrs)
Exemple #4
0
 def drawText(self, text, textColour, x, y):
     paragraphStyle = NSMutableParagraphStyle.alloc().init()
     paragraphStyle.setAlignment_(1)  ## 0=L, 1=R, 2=C, 3=justified
     attributes = {}
     attributes[NSFontAttributeName] = NSFont.systemFontOfSize_(9)
     attributes[NSForegroundColorAttributeName] = textColour
     attributes[NSParagraphStyleAttributeName] = paragraphStyle
     String = NSAttributedString.alloc().initWithString_attributes_(
         text, attributes)
     String.drawAtPoint_((x, y))
Exemple #5
0
 def attributedStringForObjectValue_withDefaultAttributes_(
         self, obj, attrs):
     if obj is None or isinstance(obj, NSNull):
         obj = ""
     paragraph = NSMutableParagraphStyle.alloc().init()
     paragraph.setLineBreakMode_(NSLineBreakByTruncatingHead)
     attrs = dict(attrs)
     attrs[NSParagraphStyleAttributeName] = paragraph
     return NSAttributedString.alloc().initWithString_attributes_(
         obj, attrs)
 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)
 def _ns_update_attributed_title(self):
     if self._color:
         ns_button = self._ns_view
         ns_attrs = NSMutableDictionary.alloc().init()
         ns_attrs[NSFontAttributeName] = ns_button.font()
         ns_attrs[NSForegroundColorAttributeName] = self._color._ns_color
         ns_parstyle = NSMutableParagraphStyle.alloc().init()
         ns_parstyle.setAlignment_(ns_button.alignment())
         ns_attrs[NSParagraphStyleAttributeName] = ns_parstyle
         ns_attstr = NSAttributedString.alloc().initWithString_attributes_(
             ns_button.title(), ns_attrs)
         ns_button.setAttributedTitle_(ns_attstr)
 def _ns_update_attributed_title(self):
     if self._color:
         ns_button = self._ns_view
         ns_attrs = NSMutableDictionary.alloc().init()
         ns_attrs[NSFontAttributeName] = ns_button.font()
         ns_attrs[NSForegroundColorAttributeName] = self._color._ns_color
         ns_parstyle = NSMutableParagraphStyle.alloc().init()
         ns_parstyle.setAlignment_(ns_button.alignment())
         ns_attrs[NSParagraphStyleAttributeName] = ns_parstyle
         ns_attstr = NSAttributedString.alloc().initWithString_attributes_(
             ns_button.title(), ns_attrs)
         ns_button.setAttributedTitle_(ns_attstr)
Exemple #9
0
 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)
Exemple #10
0
 def set_tab_spacing(self, x):
     ps = NSMutableParagraphStyle.alloc().init()
     ps.setTabStops_([])
     ps.setDefaultTabInterval_(x)
     self._ns_inner_view.setDefaultParagraphStyle_(ps)
     self._ns_apply_style()
 def set_tab_spacing(self, x):
     ps = NSMutableParagraphStyle.alloc().init()
     ps.setTabStops_([])
     ps.setDefaultTabInterval_(x)
     self._ns_inner_view.setDefaultParagraphStyle_(ps)
     self._ns_apply_style()
Exemple #12
0
def addCountBadgeToIcon(count, iconImage=None):
    if iconImage is None:
        iconImage = NSImage.alloc().initWithSize_((40, 40))
        iconImage.lockFocus()
        NSColor.colorWithCalibratedRed_green_blue_alpha_(0, 0, 1, .5).set()
        path = NSBezierPath.bezierPath()
        path.appendBezierPathWithOvalInRect_(((0, 0), iconImage.size()))
        path.fill()
        iconImage.unlockFocus()

    # badge text
    textShadow = NSShadow.alloc().init()
    textShadow.setShadowOffset_((2, -2))
    textShadow.setShadowColor_(
        NSColor.colorWithCalibratedRed_green_blue_alpha_(0, 0, 0, 1.0))
    textShadow.setShadowBlurRadius_(2.0)

    paragraph = NSMutableParagraphStyle.alloc().init()
    paragraph.setAlignment_(NSCenterTextAlignment)
    paragraph.setLineBreakMode_(NSLineBreakByCharWrapping)
    attributes = {
        NSFontAttributeName: NSFont.boldSystemFontOfSize_(12.0),
        NSForegroundColorAttributeName: NSColor.whiteColor(),
        NSParagraphStyleAttributeName: paragraph,
        NSShadowAttributeName: textShadow
    }
    text = NSAttributedString.alloc().initWithString_attributes_(
        str(count), attributes)
    rectWidth, rectHeight = NSString.stringWithString_(
        str(count)).sizeWithAttributes_(attributes)
    rectWidth = int(round(rectWidth + 8))
    rectHeight = int(round(rectHeight + 4))
    rectLeft = 0
    rectBottom = 0

    # badge shadow
    badgeShadow = NSShadow.alloc().init()
    badgeShadow.setShadowOffset_((0, -2))
    badgeShadow.setShadowColor_(NSColor.blackColor())
    badgeShadow.setShadowBlurRadius_(4.0)

    # badge path
    badgePath = roundedRectBezierPath(
        ((rectLeft, rectBottom), (rectWidth, rectHeight)), 3)

    # badge image
    badgeWidth = rectWidth + 3
    badgeHeight = rectHeight + 3
    badgeImage = NSImage.alloc().initWithSize_((badgeWidth, badgeHeight))
    badgeImage.lockFocus()
    transform = NSAffineTransform.transform()
    transform.translateXBy_yBy_(1.5, 1.5)
    transform.concat()
    NSColor.colorWithCalibratedRed_green_blue_alpha_(.2, .2, .25, 1.0).set()
    badgePath.fill()
    NSColor.colorWithCalibratedRed_green_blue_alpha_(.8, .8, .9, 1.0).set()
    badgePath.setLineWidth_(1.0)
    badgePath.stroke()
    text.drawInRect_(((0, -1), (rectWidth, rectHeight)))
    badgeImage.unlockFocus()

    # make the composite image
    imageWidth, imageHeight = iconImage.size()
    imageWidth += (badgeWidth - 15)
    imageHeight += 10

    badgeLeft = imageWidth - badgeWidth - 3
    badgeBottom = 3

    image = NSImage.alloc().initWithSize_((imageWidth, imageHeight))
    image.lockFocus()
    context = NSGraphicsContext.currentContext()

    # icon
    iconImage.drawAtPoint_fromRect_operation_fraction_(
        (0, 10), ((0, 0), iconImage.size()), NSCompositeSourceOver, 1.0)

    # badge
    context.saveGraphicsState()
    badgeShadow.set()
    badgeImage.drawAtPoint_fromRect_operation_fraction_(
        (badgeLeft, badgeBottom), ((0, 0), badgeImage.size()),
        NSCompositeSourceOver, 1.0)
    context.restoreGraphicsState()

    # done
    image.unlockFocus()
    return image
def GlyphCellDetailFactory(glyph):
    font = glyph.font

    imageWidth = 200
    imageHeight = 280

    scale = 120 / font.info.unitsPerEm
    glyphLeftOffset = (imageWidth - (glyph.width * scale)) / 2

    basePath = roundedRectBezierPath(((.5, .5), (imageWidth - 1, imageHeight - 1)), 7)
    basePath.setLineWidth_(1.0)

    glyphPath = glyph.getRepresentation("defconAppKit.NSBezierPath")

    line1Path = NSBezierPath.bezierPath()
    line1Path.moveToPoint_((1, 120.5))
    line1Path.lineToPoint_((imageWidth - 1, 120.5))
    line1Path.setLineWidth_(1.0)

    line2Path = NSBezierPath.bezierPath()
    line2Path.moveToPoint_((1, 121.5))
    line2Path.lineToPoint_((imageWidth - 1, 121.5))
    line2Path.setLineWidth_(1.0)

    lineColor = NSColor.colorWithCalibratedWhite_alpha_(.5, 1.0)

    paragraph = NSMutableParagraphStyle.alloc().init()
    paragraph.setAlignment_(NSRightTextAlignment)
    paragraph.setLineBreakMode_(NSLineBreakByCharWrapping)
    leftAttributes = {
        NSFontAttributeName: NSFont.systemFontOfSize_(12.0),
        NSForegroundColorAttributeName: NSColor.whiteColor(),
        NSParagraphStyleAttributeName: paragraph
    }

    paragraph = NSMutableParagraphStyle.alloc().init()
    paragraph.setAlignment_(NSLeftTextAlignment)
    paragraph.setLineBreakMode_(NSLineBreakByTruncatingMiddle)
    rightAttributes = {
        NSFontAttributeName: NSFont.systemFontOfSize_(12.0),
        NSForegroundColorAttributeName: NSColor.whiteColor(),
        NSParagraphStyleAttributeName: paragraph
    }

    nameTitle = NSAttributedString.alloc().initWithString_attributes_("Name", leftAttributes)
    nameText = NSAttributedString.alloc().initWithString_attributes_(glyph.name, rightAttributes)

    uniTitle = NSAttributedString.alloc().initWithString_attributes_("Unicode", leftAttributes)
    uni = glyph.unicode
    if uni is None:
        uni = ""
    else:
        uni = hex(uni)[2:].upper()
        if len(uni) < 4:
            uni = uni.zfill(4)
    uniText = NSAttributedString.alloc().initWithString_attributes_(str(uni), rightAttributes)

    widthTitle = NSAttributedString.alloc().initWithString_attributes_("Width", leftAttributes)
    width = glyph.width
    if width is None:
        width = 0
    width = round(width, 3)
    if width == int(width):
        width = int(width)
    widthText = NSAttributedString.alloc().initWithString_attributes_(str(width), rightAttributes)

    leftTitle = NSAttributedString.alloc().initWithString_attributes_("Left Margin", leftAttributes)
    leftMargin = glyph.leftMargin
    if leftMargin is None:
        leftMargin = 0
    leftMargin = round(leftMargin, 3)
    if leftMargin == int(leftMargin):
        leftMargin = int(leftMargin)
    leftText = NSAttributedString.alloc().initWithString_attributes_(str(leftMargin), rightAttributes)

    rightTitle = NSAttributedString.alloc().initWithString_attributes_("Right Margin", leftAttributes)
    rightMargin = glyph.rightMargin
    if rightMargin is None:
        rightMargin = 0
    rightMargin = round(rightMargin, 3)
    if rightMargin == int(rightMargin):
        rightMargin = int(rightMargin)
    rightText = NSAttributedString.alloc().initWithString_attributes_(str(rightMargin), rightAttributes)

    image = NSImage.alloc().initWithSize_((imageWidth, imageHeight))
    image.setFlipped_(True)
    image.lockFocus()

    NSColor.colorWithCalibratedWhite_alpha_(0, .65).set()
    basePath.fill()
    lineColor.set()
    basePath.stroke()

    context = NSGraphicsContext.currentContext()
    context.saveGraphicsState()
    transform = NSAffineTransform.transform()
    transform.translateXBy_yBy_(glyphLeftOffset, 145)
    transform.scaleBy_(scale)
    transform.translateXBy_yBy_(0, -font.info.descender)
    transform.concat()

    NSColor.whiteColor().set()
    glyphPath.fill()
    context.restoreGraphicsState()

    lineColor.set()
    line1Path.stroke()
    NSColor.colorWithCalibratedWhite_alpha_(0, .5).set()
    line2Path.stroke()

    transform = NSAffineTransform.transform()
    transform.translateXBy_yBy_(0, 110)
    transform.scaleXBy_yBy_(1.0, -1.0)
    transform.concat()

    nameTitle.drawInRect_(((0, 0), (90, 17)))
    nameText.drawInRect_(((95, 0), (85, 17)))

    uniTitle.drawInRect_(((0, 20), (90, 17)))
    uniText.drawInRect_(((95, 20), (85, 17)))

    widthTitle.drawInRect_(((0, 40), (90, 17)))
    widthText.drawInRect_(((95, 40), (85, 17)))

    leftTitle.drawInRect_(((0, 60), (90, 17)))
    leftText.drawInRect_(((95, 60), (85, 17)))

    rightTitle.drawInRect_(((0, 80), (90, 17)))
    rightText.drawInRect_(((95, 80), (85, 17)))

    image.unlockFocus()
    return image
Exemple #14
0
	def drawRect_(self, rect): ## needs to be `drawRect_` -- nothing else

		bounds = self.bounds()

		# thisUPM = self._layer.parent.parent.upm
		scaleFactor = self._scaleFactor
		thisUPM = self._upm * scaleFactor
		rectX, rectY, rectWidth, rectHeight = 0, 0, thisUPM, thisUPM
		self.rect = rect

		# self._layer.drawInFrame_(bounds)  # used in Georgs GlyphView


		try:
			layerWidth = self._layer.width * scaleFactor
			descender = self._layer.glyphMetrics()[3] * scaleFactor
			
			## this order is important! Wont work the other way around
			try: # pre Glyphs 2.3
				bezierPathOnly = self._layer.copy().bezierPath()  # Path Only
				bezierPathWithComponents = self._layer.copyDecomposedLayer().bezierPath() # Path & Components				
			except: # Glyphs 2.3
				bezierPathOnly = self._layer.copy().bezierPath  # Path Only
				bezierPathWithComponents = self._layer.copyDecomposedLayer().bezierPath  # Path & Components			

				

			scale = NSAffineTransform.transform()
			scale.translateXBy_yBy_( rectWidth/2 - (layerWidth / 2.0) + self._margin/2, -descender + self._margin/2 )
			scale.scaleBy_( scaleFactor )

			if bezierPathWithComponents:
				bezierPathWithComponents.transformUsingAffineTransform_( scale )
			if bezierPathOnly:
				bezierPathOnly.transformUsingAffineTransform_( scale )

			## DRAW COMPONENTS IN GRAY
			NSColor.darkGrayColor().set() # lightGrayColor
			bezierPathWithComponents.fill()
			
			## CHANGE COLOR FOR NON-EXPORTED GLYPHS
			thisGlyph = self._layer.parent
			if thisGlyph.export:
				NSColor.blackColor().set()

				## DRAW ONLY PATH IN BLACK
				if bezierPathOnly:
					bezierPathOnly.fill()
			else:
				NSColor.orangeColor().set()
				bezierPathWithComponents.fill()
			
			# print self.bounds()

			## AUTO-WIDTH LABEL
			if self._layer.hasAlignedWidth():
				paragraphStyle = NSMutableParagraphStyle.alloc().init()
				paragraphStyle.setAlignment_(2) ## 0=L, 1=R, 2=C, 3=justified
				attributes = {}
				attributes[NSFontAttributeName] = NSFont.systemFontOfSize_(10)
				attributes[NSForegroundColorAttributeName] = NSColor.lightGrayColor()
				attributes[NSParagraphStyleAttributeName] = paragraphStyle
				String = NSAttributedString.alloc().initWithString_attributes_("Auto-Width", attributes)
				# String.drawAtPoint_((rectWidth, 0))
				NSColor.redColor().set()
				# NSRectFill(((0, 0), (self.rect.size.width, 15)))
				String.drawInRect_(((0, 0), (self.rect.size.width, 15)))
		except:
			# pass
			print traceback.format_exc()
Exemple #15
0
	def drawRect_(self, rect): ## must be `drawRect_` - nothing else

		bounds = self.bounds()
		scaleFactor = self._scaleFactor
		thisUPM = self._upm * scaleFactor # = self._layer.parent.parent.upm
		rectX, rectY, rectWidth, rectHeight = 0, 0, thisUPM, thisUPM
		self.rect = rect


		# self._layer.drawInFrame_(bounds)  # used in Georgs GlyphView

		try:
			thisGlyph = self._layer.parent
			layerWidth = self._layer.width * scaleFactor
			descender = self._layer.glyphMetrics()[3] * scaleFactor
			
			# ## This order is important! Wont work the other way around.
			# try: # pre Glyphs 2.3
			# 	bezierPathOnly = self._layer.copy().bezierPath()  # Path Only
			# 	bezierPathWithComponents = self._layer.copyDecomposedLayer().bezierPath() # Path & Components
			# except: # Glyphs 2.3
			# 	bezierPathOnly = self._layer.copy().bezierPath  # Path Only
			# 	bezierPathWithComponents = self._layer.copyDecomposedLayer().bezierPath  # Path & Components

			## This order is important! Wont work the other way around.
			try: # Glyphs 2.3
				bezierPathOnly = self._layer.copy().bezierPath  # Path Only
				bezierPathWithComponents = self._layer.copyDecomposedLayer().bezierPath  # Path & Components
			except: # Glyphs 2.4
				bezierPathOnly = self._layer.copy().bezierPath  # Path Only
				bezierPathWithComponents = self._layer.completeBezierPath  # Path & Components


			# Set the scale
			#--------------
			scale = NSAffineTransform.transform()
			scale.translateXBy_yBy_( rectWidth/2 - (layerWidth / 2.0) + self._margin/2, -descender + self._margin/2 )
			scale.scaleBy_( scaleFactor )

			if bezierPathWithComponents:
				bezierPathWithComponents.transformUsingAffineTransform_( scale )
			if bezierPathOnly:
				bezierPathOnly.transformUsingAffineTransform_( scale )

			# Draw components in gray
			#------------------------
			NSColor.darkGrayColor().set() # lightGrayColor
			bezierPathWithComponents.fill()
			
			
			# Draw only path in black
			#------------------------
			if thisGlyph.export:
				NSColor.blackColor().set()
				if bezierPathOnly:
					bezierPathOnly.fill()
			# Draw non-exported glyphs in orange
			#-----------------------------------
			else:
				NSColor.orangeColor().set()
				bezierPathWithComponents.fill()
			
			# AUTO-WIDTH LABEL
			#-----------------
			if self._layer.hasAlignedWidth():
				paragraphStyle = NSMutableParagraphStyle.alloc().init()
				paragraphStyle.setAlignment_(2) ## 0=L, 1=R, 2=C, 3=justified
				attributes = {}
				attributes[NSFontAttributeName] = NSFont.systemFontOfSize_(10)
				attributes[NSForegroundColorAttributeName] = NSColor.lightGrayColor()
				attributes[NSParagraphStyleAttributeName] = paragraphStyle
				String = NSAttributedString.alloc().initWithString_attributes_("Auto-Width", attributes)
				# String.drawAtPoint_((rectWidth, 0))
				NSColor.redColor().set()
				# NSRectFill(((0, 0), (self.rect.size.width, 15)))
				String.drawInRect_(((0, 0), (self.rect.size.width, 15)))
		except:
			pass # print traceback.format_exc()
def GlyphCellDetailFactory(glyph):
    font = glyph.font

    imageWidth = 200
    imageHeight = 280

    scale = 120 / font.info.unitsPerEm
    glyphLeftOffset = (imageWidth - (glyph.width * scale)) / 2

    basePath = roundedRectBezierPath(
        ((.5, .5), (imageWidth - 1, imageHeight - 1)), 7)
    basePath.setLineWidth_(1.0)

    glyphPath = glyph.getRepresentation("defconAppKit.NSBezierPath")

    line1Path = NSBezierPath.bezierPath()
    line1Path.moveToPoint_((1, 120.5))
    line1Path.lineToPoint_((imageWidth - 1, 120.5))
    line1Path.setLineWidth_(1.0)

    line2Path = NSBezierPath.bezierPath()
    line2Path.moveToPoint_((1, 121.5))
    line2Path.lineToPoint_((imageWidth - 1, 121.5))
    line2Path.setLineWidth_(1.0)

    lineColor = NSColor.colorWithCalibratedWhite_alpha_(.5, 1.0)

    paragraph = NSMutableParagraphStyle.alloc().init()
    paragraph.setAlignment_(NSRightTextAlignment)
    paragraph.setLineBreakMode_(NSLineBreakByCharWrapping)
    leftAttributes = {
        NSFontAttributeName: NSFont.systemFontOfSize_(12.0),
        NSForegroundColorAttributeName: NSColor.whiteColor(),
        NSParagraphStyleAttributeName: paragraph
    }

    paragraph = NSMutableParagraphStyle.alloc().init()
    paragraph.setAlignment_(NSLeftTextAlignment)
    paragraph.setLineBreakMode_(NSLineBreakByTruncatingMiddle)
    rightAttributes = {
        NSFontAttributeName: NSFont.systemFontOfSize_(12.0),
        NSForegroundColorAttributeName: NSColor.whiteColor(),
        NSParagraphStyleAttributeName: paragraph
    }

    nameTitle = NSAttributedString.alloc().initWithString_attributes_(
        "Name", leftAttributes)
    nameText = NSAttributedString.alloc().initWithString_attributes_(
        glyph.name, rightAttributes)

    uniTitle = NSAttributedString.alloc().initWithString_attributes_(
        "Unicode", leftAttributes)
    uni = glyph.unicode
    if uni is None:
        uni = ""
    else:
        uni = hex(uni)[2:].upper()
        if len(uni) < 4:
            uni = uni.zfill(4)
    uniText = NSAttributedString.alloc().initWithString_attributes_(
        str(uni), rightAttributes)

    widthTitle = NSAttributedString.alloc().initWithString_attributes_(
        "Width", leftAttributes)
    width = glyph.width
    if width is None:
        width = 0
    width = round(width, 3)
    if width == int(width):
        width = int(width)
    widthText = NSAttributedString.alloc().initWithString_attributes_(
        str(width), rightAttributes)

    leftTitle = NSAttributedString.alloc().initWithString_attributes_(
        "Left Margin", leftAttributes)
    leftMargin = glyph.leftMargin
    if leftMargin is None:
        leftMargin = 0
    leftMargin = round(leftMargin, 3)
    if leftMargin == int(leftMargin):
        leftMargin = int(leftMargin)
    leftText = NSAttributedString.alloc().initWithString_attributes_(
        str(leftMargin), rightAttributes)

    rightTitle = NSAttributedString.alloc().initWithString_attributes_(
        "Right Margin", leftAttributes)
    rightMargin = glyph.rightMargin
    if rightMargin is None:
        rightMargin = 0
    rightMargin = round(rightMargin, 3)
    if rightMargin == int(rightMargin):
        rightMargin = int(rightMargin)
    rightText = NSAttributedString.alloc().initWithString_attributes_(
        str(rightMargin), rightAttributes)

    image = NSImage.alloc().initWithSize_((imageWidth, imageHeight))
    image.setFlipped_(True)
    image.lockFocus()

    NSColor.colorWithCalibratedWhite_alpha_(0, .65).set()
    basePath.fill()
    lineColor.set()
    basePath.stroke()

    context = NSGraphicsContext.currentContext()
    context.saveGraphicsState()
    transform = NSAffineTransform.transform()
    transform.translateXBy_yBy_(glyphLeftOffset, 145)
    transform.scaleBy_(scale)
    transform.translateXBy_yBy_(0, -font.info.descender)
    transform.concat()

    NSColor.whiteColor().set()
    glyphPath.fill()
    context.restoreGraphicsState()

    lineColor.set()
    line1Path.stroke()
    NSColor.colorWithCalibratedWhite_alpha_(0, .5).set()
    line2Path.stroke()

    transform = NSAffineTransform.transform()
    transform.translateXBy_yBy_(0, 110)
    transform.scaleXBy_yBy_(1.0, -1.0)
    transform.concat()

    nameTitle.drawInRect_(((0, 0), (90, 17)))
    nameText.drawInRect_(((95, 0), (85, 17)))

    uniTitle.drawInRect_(((0, 20), (90, 17)))
    uniText.drawInRect_(((95, 20), (85, 17)))

    widthTitle.drawInRect_(((0, 40), (90, 17)))
    widthText.drawInRect_(((95, 40), (85, 17)))

    leftTitle.drawInRect_(((0, 60), (90, 17)))
    leftText.drawInRect_(((95, 60), (85, 17)))

    rightTitle.drawInRect_(((0, 80), (90, 17)))
    rightText.drawInRect_(((95, 80), (85, 17)))

    image.unlockFocus()
    return image