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-4.0.0 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.5.0 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.4.2 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.4.1 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.4.0 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.3.7 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.3.6 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.3.5 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.3.4 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.3.3 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.3.2 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.3.1 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.3.0 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.2.0 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.1.1 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.1.0 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.0.8 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.0.7 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.0.6 lib/ios/sugarcube-ui/symbol.rb
sugarcube-3.0.5 lib/ios/sugarcube-ui/symbol.rb