[fxruby-users] fonts & rotated text redux

Daniel Rocco drocco at westga.edu
Wed Apr 1 14:33:13 EDT 2009

hi folks,

I'm a new FXRuby user using the library as part of an introductory CS 
course.  I'd like to offer a huge "thank you" to Lyle and the other 
contributors to the example programs, which make getting started 
surprisingly easy.  I have a few questions I was hoping someone would be 
able to shed some light on:
1.  Is there a repository of snippets, recipes, or links to programs 
using FXRuby?  In particular, I'd be interested in any FXRuby games, 
particularly simpler ones, since I like to smuggle practice with CS 
concepts into interesting projects but don't want to write everything 
from scratch if I don't have to.
2.  Is there a particular search path used for font files?  I'd like to 
distribute some custom fonts with one or two projects, but couldn't find 
any information about how fonts are located.  (We are on Windows, using 
the bundled FXRuby that comes with the one click installer for Ruby 1.8.x)

3.  Concerning rotating fonts, the information I've found suggests that 
not all fonts on Windows can be rotated, but that TrueType fonts can 
be.  Does this include OpenType fonts?  Is there any way to determine if 
a particular font can be rotated or not (aside from trying it!)?
4.  I can't seem to get rotated text to work.  I've attempted to follow 
Jeroen's steps from an earlier post (Feb. 2008), but the text stubbornly 
insists on appearing in its original orientation.  Here is what I've got 
at the moment:

class ParchmentMap < FXMainWindow
    # initialize the main map GUI and the instance variables for the map
    def initialize(app)

        # Invoke base class initialize method first
        super(app, "CS 1300 Parchment Map Environment", nil, nil, 
DECOR_ALL, 0, 0, 1024, 768)
        # Sunken border for map canvas
        frame = FXHorizontalFrame.new(self,
          :padLeft => 0, :padRight => 0, :padTop => 0, :padBottom => 0)

        # Make canvas
        @canvas = FXCanvas.new(frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y)
        # load parchment background
        background = load_image('./images/parchment.jpg')
        @canvas.connect(SEL_PAINT) do |sender, sel, event|
            FXDCWindow.new(@canvas, event) do |dc|
                dc.drawImage(background, 0, 0)
                dc.foreground = "black"   
                font = FXFont.new(app, 'Arial', 16)
                dc.font = font

                dc.drawText(10, 30, "CS 1300 programming DRY divide and 
conquer Ruby")


I've tried several different fonts including both TrueType and OpenType 
varieties, and while the fonts change appearance, the rotation does not 

Thanks in advance for any insight you can offer!

More information about the fxruby-users mailing list