If you want to use installed/system font, you can use this example:
(you can replace this method with foreground method in plugin reporter template to see what it does)
@objc.python_method
def foreground(self, layer):
currentZoom = self.getScale()
text_to_display = 'my awesome Menlo font test'
fontName = "Menlo"
position = (0,0)
color = NSColor.redColor() # good default is NSColor.textColor(), here I used red to make it more visible
# here I'm createing NSFont object, with given font name and size
font = AppKit.NSFont.fontWithName_size_(fontName, 30 / currentZoom)
# abourt if font was not found
if font is None:
return
# draw text at given position, with specified color and font
fontAttributes = {
AppKit.NSForegroundColorAttributeName: color,
AppKit.NSFontAttributeName: font
}
txt = AppKit.NSAttributedString.alloc().initWithString_attributes_(
text_to_display,
fontAttributes)
txt.drawAtPoint_alignment_(AppKit.NSPoint(*position), 0)
I hope it helps a bit,
cheers