Sha256: 2b18fee853b39e73d5762d166302ca26f46b329c98f84c0738b3b6c5139c4926
Contents?: true
Size: 1.28 KB
Versions: 6
Compression:
Stored size: 1.28 KB
Contents
=begin Example: # fonts :system.nsfont => NSFont.systemFontOfSize(NSFont.systemFontSize) :label.nsfont => NSFont.systemFontOfSize(NSFont.labelFontSize) You can extend the defaults by adding entries: Symbol.nsfontsize[:big] = 40 :big.nsfont => NSFont =end class Symbol def nsfont(size=nil) size ||= NSFont.systemFontSize # system fonts if Symbol.nsfont.has_key? self font = SugarCube.look_in(self, Symbol.nsfont) if size.is_a?(Symbol) size = size.nsfontsize end if font.is_a?(Symbol) return NSFont.send(font, size) else return font.nsfont(size) end else if size.is_a?(Symbol) size = size.nsfontsize end return NSFont.systemFontOfSize(size) end end def nsfontsize size = SugarCube.look_in(self, Symbol.nsfontsize) if size.is_a?(Symbol) return NSFont.send(size) end return size.to_f end class << self attr :nsfont attr :nsfontsize end @nsfont = { system: :"systemFontOfSize:", bold: :"boldSystemFontOfSize:", italic: 'Helvetica-Italic', monospace: 'Courier New', } @nsfontsize = { label: :labelFontSize, button: :buttonFontSize, small: :smallSystemFontSize, system: :systemFontSize, } end
Version data entries
6 entries across 6 versions & 1 rubygems