Sha256: 71c514ad7b1c05fed9ccf4c46ef8c0de1e2704f5cf8ffd54187392c33c7158f9

Contents?: true

Size: 612 Bytes

Versions: 1

Compression:

Stored size: 612 Bytes

Contents

class Shoes
  module Swt
    class TextFontFactory
      def initialize
        @fonts = []
      end

      def create_font(font_style)
        name = font_style[:name]
        size = font_style[:size]
        styles = font_style[:styles].reduce { |result, s| result | s }

        font = ::Swt::Graphics::Font.new Shoes.display, name, size, styles

        # Hold a reference to the font so we can dispose it when the time comes
        @fonts << font

        font
      end

      def dispose
        @fonts.each { |font| font.dispose unless font.disposed? }
        @fonts.clear
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoes-4.0.0.pre1 lib/shoes/swt/text_font_factory.rb