Sha256: 368abb863654e9beae356dae251cd6dcca8515d330e23e4113bb9f71ac5288c7

Contents?: true

Size: 1.91 KB

Versions: 9

Compression:

Stored size: 1.91 KB

Contents

require_relative '../../helper'

Tk.init

describe Tk::Font do
  it 'lists names of all named fonts' do
    Tk::Font.names.sort.should ==  [
      "TkCaptionFont", "TkDefaultFont", "TkFixedFont", "TkHeadingFont",
      "TkIconFont", "TkMenuFont", "TkSmallCaptionFont", "TkTextFont",
      "TkTooltipFont"
    ]
  end

  it 'measures a character' do
    Tk::Font.measure('TkDefaultFont', '0').should >= 4
  end

  it 'shows metrics of a font' do
    Tk::Font.metrics('TkDefaultFont', :ascent).should == 12
    Tk::Font.metrics('TkDefaultFont', :descent).should == 3
    Tk::Font.metrics('TkDefaultFont', :linespace).should == 15
    Tk::Font.metrics('TkDefaultFont', :fixed).should == 0
  end

  it 'lists all font families on the system' do
    Tk::Font.families.size.should > 0
  end

  it 'creates a font' do
    Tk::Font.create('Awesome Font').should == "Awesome Font"
    Tk::Font.names.sort.should.include('Awesome Font')

    lambda{
      Tk::Font.create('Awesome Font')
    }.should.raise.message =~ /^named font "Awesome Font" already exists/
  end

  it 'show configuration for our font' do
    conf = Tk::Font.configure('Awesome Font')
    conf[:family].should == ''
    conf[:size].should == 0
    conf[:weight].should == :normal
    conf[:slant].should == :roman
    conf[:underline].should == false
    conf[:overstrike].should == false
  end

  it 'manipulates configuration of our font' do
    Tk::Font.configure('Awesome Font', size: 10)
    Tk::Font.configure('Awesome Font')[:size].should == 10
  end

  it 'shows actual information about the font' do
    conf = Tk::Font.actual('Awesome Font')
    conf[:family].should.not == ''
    conf[:size].should == 10
    conf[:weight].should == :normal
    conf[:slant].should == :roman
    conf[:underline].should == false
    conf[:overstrike].should == false
  end

  it 'deletes the font' do
    Tk::Font.delete('Awesome Font')
    Tk::Font.names.should.not.include('Awesome Font')
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ffi-tk-2010.08.23 spec/ffi-tk/command/font.rb
ffi-tk-2010.08 spec/ffi-tk/command/font.rb
ffi-tk-2010.06 spec/ffi-tk/command/font.rb
ffi-tk-2010.03 spec/ffi-tk/command/font.rb
ffi-tk-2010.02 spec/ffi-tk/command/font.rb
ffi-tk-2010.01 spec/ffi-tk/command/font.rb
ffi-tk-2010.01.02 spec/ffi-tk/command/font.rb
ffi-tk-2009.12.14 spec/ffi-tk/command/font.rb
ffi-tk-2009.11.29 spec/ffi-tk/command/font.rb