[fxruby-users] How can you bold the text in a label?
jkinsella at ancillaryservices.com
Thu Apr 15 15:25:06 EDT 2010
sorry, I missed that one line where you said you didn't want to specify the
font.. You could probably just use the code I posted and use self.font.font
instead of "Helvetica" ... This would use whatever FXMainWindow is using,
which is most likely the OS's default font... Good Luck!
On Thu, Apr 15, 2010 at 1:04 PM, Joey Kinsella <
jkinsella at ancillaryservices.com> wrote:
> There are definitely better ways of doing this, but here is a basic
> Begin code
> #! /usr/bin/env ruby
> require 'rubygems'
> require 'fox16'
> include Fox
> class SimpleWindow < FXMainWindow
> def initialize(app)
> super(app, "My Simple Window", :opts => DECOR_ALL,
> :width => 640, :height => 480)
> def draw_widgets()
> label = FXLabel.new(self, "This is my label that is normal.")
> label.font = FXFont.new(getApp(), select_font())
> label2 = FXLabel.new(self, "This is my label that is bold.")
> label2.font = FXFont.new(getApp(), select_font(FONTWEIGHT_BOLD))
> def select_font(weight = FONTWEIGHT_NORMAL)
> f = FXFontDesc.new()
> f.encoding = FONTENCODING_DEFAULT
> f.face = "Helvetica"
> f.flags = 0
> f.setwidth = FONTSETWIDTH_WIDE
> f.size = 100
> f.slant = FONTSLANT_REGULAR
> f.weight = weight
> return (f)
> def create()
> if(__FILE__ == $0)
> app = FXApp.new("Example", "Example")
> win = SimpleWindow.new(app)
> End Code...
> I Hope this helps!
> On Thu, Apr 15, 2010 at 12:30 PM, Paul Carvalho <tester.paul at gmail.com>wrote:
>> I'm not at my development computer right now so I can't tell you the exact
>> code I tried, but I can say that, yes, I did try to use a nil/empty string
>> font face and Ruby choked on it -- didn't like it.
>> I tried "system" as a font face and that *really* didn't do what I wanted
>> either! =)
>> I entered "arial" and then the one label font changed - I had forgotten
>> that the default system font is not Arial. So the one label really stands
>> out now because it's a totally different font.. which is not what I want.
>> I don't want to hard-code a font that is different from the system font,
>> especially if the app will run on different platforms and I don't know what
>> the default fonts will be.
>> I can try some other variations tonight. I've already spent over 4 hours
>> on this and haven't gotten it to work. Maybe I just needed a break to see
>> something that I've missed.
>> I thought it would be something that would have come up by now.. I've seen
>> lots of apps where a label is bolded to indicate a required field. I just
>> haven't found any FXRuby examples of this *without* also specifying the font
>> at the same time.
>> Cheers. P.
>> 2010/4/15 Bartosz Dziewoński :
>>> Have you tried to use nil/empty string font face and use font style
>>> hint "System"? Or try any font together with the hint?
>>> I haven't tried it myself, but according to docs it might work.
>> fxruby-users mailing list
>> fxruby-users at rubyforge.org
If you are not the intended recipient, you are hereby notified
that any dissemination, distribution, copying or other use of
this communication is strictly prohibited. If you have
received this communication in error, please notify us
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fxruby-users