Sha256: 9d8d32a6b332c1e4f1ae6304c3259167b00cc090427c5fbe9409a86ba2aac366

Contents?: true

Size: 869 Bytes

Versions: 4

Compression:

Stored size: 869 Bytes

Contents

# -*- coding: utf-8 -*-

module DXRubySDL
  class Font
    attr_reader :size
    attr_reader :_ttf

    def initialize(size, fontname = '', hash = {})
      @size = size

      if !SDL::TTF.init?
        SDL::TTF.init
      end
      if !(path = FONTS[fontname.downcase])
        path = FONTS.first.last
      end
      @_ttf = SDL::TTF.open(path, size)
    end

    private

    # :nocov:
    if /darwin/ =~ RUBY_PLATFORM
      FONTS = {
        'osaka' => '/Library/Fonts/osaka.ttf',
        'IPA ゴシック' => '/Library/Fonts/ipag.ttf',
        'IPA Pゴシック' => '/Library/Fonts/ipagp.ttf',
      }
    elsif /linux/ =~ RUBY_PLATFORM
      FONTS = {
        'IPA ゴシック' => '/usr/share/fonts/opentype/ipafont-gothic/ipag.ttf',
        'IPA Pゴシック' => '/usr/share/fonts/opentype/ipafont-gothic/ipagp.ttf',
      }
    end
    # :nocov:
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dxruby_sdl-0.0.4 lib/dxruby_sdl/font.rb
dxruby_sdl-0.0.3 lib/dxruby_sdl/font.rb
dxruby_sdl-0.0.2 lib/dxruby_sdl/font.rb
dxruby_sdl-0.0.1 lib/dxruby_sdl/font.rb