larskanis / fxruby

FXRuby is an extension module for Ruby that provides an interface to the FOX GUI toolkit.
http://rubydoc.info/gems/fxruby/frames
265 stars 20 forks source link

Having trouble rotating fonts with FXFont #37

Closed flajann2 closed 7 years ago

flajann2 commented 7 years ago

Question: the angle property of the instantiated FXFont is said to be [RW], but fails on trying to actually set it, e.g.

FXFont.new(...).angle = 90 * 60

which results in an "angle= not found" error.

And so I tried using setAngle() thusly in this code snippet:

      def load_font font, angle=0
        f = FXFont.new ref(:app), font
        f.setAngle (angle * 64).to_i
        f.create
        return f
      end

Yet no rotation takes place in the rendered text. Tried 90*64, since I need to render vertical text. Any ideas? Am I missing something?

Ruby 2.4.0, FXRuby 1.6.35, Ubuntu 16.04

Thanks.

flajann2 commented 7 years ago

Nevermind. I had to look at the fox source code to figure out how to do it. It is not documented anywhere as far as I can tell. I had to pass in the following string to make it work:

"helvetica,90,bold,italic,normal,iso8859-1,2048"

That last parameter is the Rotatable bit. Ugly, but so C++. Please consider making a not of it in the FXFont documentation. Thanks a million.

Snippet from FXFont.h:

/// Font style hints enum { Decorative = 4, /// Fancy fonts Modern = 8, /// Monospace typewriter font Roman = 16, /// Variable width times-like font, serif Script = 32, /// Script or cursive Swiss = 64, /// Helvetica/swiss type font, sans-serif System = 128, /// System font X11 = 256, /// Raw X11 font string Scalable = 512, /// Scalable fonts Polymorphic = 1024, /// Polymorphic fonts, e.g. parametric weight, slant, etc. Rotatable = 2048 /// Rotatable fonts };

larskanis commented 7 years ago

Thank you for following up! I wasn't aware about this fox "feature". Which method did you call with this string?

flajann2 commented 7 years ago

FXFont.new app, "helvetica,90,bold,italic,normal,iso8859-1,2048"

FYI, I have created, and am still working on, a wrapper for your wrapper to create a more Ruby way to interact with your FXRuby.

https://github.com/flajann2/fxruby-enhancement

My aim is to simplify using FOX in Ruby so that more use FOX -- and your wrapper.