Sha256: e10a375ef226c9a568a5bbd445bdb5a54526caab64297a7159e63148cab28dc6
Contents?: true
Size: 1.16 KB
Versions: 5
Compression:
Stored size: 1.16 KB
Contents
#!/usr/bin/env ruby # Original script was contributed by ageldama (Yun, Jonghyouk) require 'encoding/character/utf-8' require 'rubygame' # Initialize Rubygame Rubygame.init screen = Rubygame::Screen.open([320,200]) queue = Rubygame::EventQueue.new # Initialize fonts fontname = 'FreeSans.ttf' str = u'abc123하이~' if ARGV[0] if File.exist?(File.expand_path(ARGV[0])) fontname = File.expand_path(ARGV[0]) str = ARGV[1..-1].join(" ") else str = ARGV[0..-1].join(" ") end else puts <<EOF This script demonstrates UTF8 (8-bit Unicode Transformation Format) text rendered with TTF fonts. This allows you to display international symbols in your games. If you like, you can give some arguments to this script to try it out: 1) A path to a different TTF font to use. (optional) *) A custom string to display. EOF end Rubygame::TTF.setup fnt = Rubygame::TTF.new(fontname, 20) loop do queue.each do |event| case event when Rubygame::KeyDownEvent Rubygame::TTF.quit Rubygame.quit exit end end screen.fill([0, 0, 0]) surf_str = fnt.render_utf8(str, true, [0xff, 0xff, 0xff]) surf_str.blit(screen, [10, 10]) screen.update end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
rubygame-2.6.4 | samples/demo_utf8.rb |
rubygame-2.6.3 | samples/demo_utf8.rb |
rubygame-2.6.2 | samples/demo_utf8.rb |
rubygame-2.6.1 | samples/demo_utf8.rb |
rubygame-2.6.0 | samples/demo_utf8.rb |