#! /usr/bin/env ruby # -*- mode: ruby; coding: utf-8 -*- # Last updated: <2019/04/22 19:59:53 +0900> # # Ruby/SDL birmap font (SFont) draw. # # usage: ruby sfont.rb # ESC key : exit # # * Windows10 x64 + Ruby 1.9.3 p661 mingw32 + rubysdl 2.1.1.1 # load png : FAIL , load bmp : PASS # # * Windows10 x64 + Ruby 1.8.7 p330 mswin32 + rubysdl 1.3.1 # * Ubuntu Linux 18.04 + ruby 2.5.1 p57 x86_64-linux-gnu + rubysdl 2.2.0 # load png : PASS , load bmp : PASS require "sdl" fontimg = "font/verabd_sfont01_32col.bmp" #fontimg = "font/verabd_sfont01.png" SDL.init( SDL::INIT_VIDEO ) screen = SDL::Screen.open(640, 480, 16, SDL::SWSURFACE) fontflag = SDL::BMFont::TRANSPARENT | SDL::BMFont::SFONT font = SDL::BMFont.open(fontimg, fontflag) while true while event = SDL::Event2.poll case event when SDL::Event2::Quit exit when SDL::Event2::KeyDown case event.sym when SDL::Key::ESCAPE exit end end end screen.fill_rect(0, 0, 640, 480, [128, 128, 128]) font.textout(screen, fontimg, 0, 0) x, y = 8, 64 font.textout(screen, "SFont (BitMapFont) Testing..", x, y) screen.updateRect(0,0,0,0) sleep 0.016 end