Sha256: f6eb6079bb83ce41f71aebd2b3a281b54376bb013815d5ecc82f2dedbc117b14

Contents?: true

Size: 1.29 KB

Versions: 97

Compression:

Stored size: 1.29 KB

Contents

=begin
Example:

    # fonts
    :system.uifont => UIFont.systemFontOfSize(UIFont.systemFontSize)
    :label.uifont => UIFont.systemFontOfSize(UIFont.labelFontSize)

You can extend the defaults by adding entries:

    Symbol.uifontsize[:big] = 40

    :big.uifont => UIFont

=end
class Symbol

  def uifont(size=nil)
    size ||= UIFont.systemFontSize
    # system fonts
    if Symbol.uifont.has_key? self
      font = SugarCube.look_in(self, Symbol.uifont)
      if size.is_a?(Symbol)
        size = size.uifontsize
      end

      if font.is_a?(Symbol)
        return UIFont.send(font, size)
      else
        return font.uifont(size)
      end
    else
      if size.is_a?(Symbol)
          size = size.uifontsize
      end
      return UIFont.systemFontOfSize(size)
    end
  end

  def uifontsize
    size = SugarCube.look_in(self, Symbol.uifontsize)
    if size.is_a?(Symbol)
      return UIFont.send(size)
    end
    return size.to_f
  end

  class << self
    attr :uifont
    attr :uifontsize
  end

  @uifont = {
    system: :"systemFontOfSize:",
    bold:   :"boldSystemFontOfSize:",
    italic: :"italicSystemFontOfSize:",
    monospace: 'Courier New',
  }

  @uifontsize = {
    label:  :labelFontSize,
    button: :buttonFontSize,
    small:  :smallSystemFontSize,
    system: :systemFontSize,
  }


end

Version data entries

97 entries across 97 versions & 1 rubygems

Version Path
sugarcube-1.5.8 lib/sugarcube-uikit/symbol.rb
sugarcube-1.5.7 lib/sugarcube-uikit/symbol.rb
sugarcube-1.5.6 lib/sugarcube-uikit/symbol.rb
sugarcube-1.5.5 lib/sugarcube-uikit/symbol.rb
sugarcube-1.5.4 lib/sugarcube-uikit/symbol.rb
sugarcube-1.5.3 lib/sugarcube-uikit/symbol.rb
sugarcube-1.5.2 lib/sugarcube-uikit/symbol.rb
sugarcube-1.5.1 lib/sugarcube-uikit/symbol.rb
sugarcube-1.5.0 lib/sugarcube-uikit/symbol.rb
sugarcube-1.4.6 lib/sugarcube-uikit/symbol.rb
sugarcube-1.4.5 lib/sugarcube-uikit/symbol.rb
sugarcube-1.4.4 lib/sugarcube-uikit/symbol.rb
sugarcube-1.4.3 lib/sugarcube-uikit/symbol.rb
sugarcube-1.4.2 lib/sugarcube-uikit/symbol.rb
sugarcube-1.4.1 lib/sugarcube-uikit/symbol.rb
sugarcube-1.4.0 lib/sugarcube-uikit/symbol.rb
sugarcube-1.3.11 lib/sugarcube-uikit/symbol.rb
sugarcube-1.3.10 lib/sugarcube-uikit/symbol.rb
sugarcube-1.3.9 lib/sugarcube-uikit/symbol.rb
sugarcube-1.3.8 lib/sugarcube-uikit/symbol.rb