[REBOL] Re: How to change the font of a button ?
From: carl:cybercraft at: 24-Dec-2003 22:22
On 30-Jun-03, [patrick--philipot--laposte--net] wrote:
> Hi Anton,
> Thanks for your examples, however this is not what I am looking for.
> I want to change the font dynamically, for example in the action
> code of the button.
> A button is first designed with "Arial, 12" and I want to change its
> font to "Times, 18".
Hi Patrick,
Try this...
view layout [
b: button "Font Test" font [name: "Arial" size: 12]
button "Change" [
b/font/name: "Times"
b/font/size: 18
show b
]
]
You can see the font object by using probe like so...
>> probe b/font
make object! [
name: "Times"
style: 'bold
size: 18
color: 255.255.255
offset: 2x2
space: 0x0
align: 'center
valign: 'middle
shadow: 1x1
colors: [255.255.255 255.180.55]
]
Carl.
> Regards
> Patrick
> ----- Original Message -----
> From: "Anton" <[antonr--iinet--net--au]>
> To: <[rebol-list--rebol--com]>
> Sent: Monday, June 30, 2003 2:59 AM
> Subject: [REBOL] Re: How to change the font of a button ?
>> A few quick answers:
>> view layout [button "bonjour" font [size: 18]]
>> view layout [button "bonjour" with [font: make font [size: 18]]]
>> my-font: make get in get-style 'button 'font [size: 18]
>> view layout [button "bonjour" font my-font]
>> These are all equivalent.
>> Anton.
>>> How to change the font of a button ?
>>>
>>> Inspired by Denis-Jo's "change text of button", I have tried to
>> change
> the
>>> font of a button with very poor results.
>>> To start simple, I have only tried to change the font/size.
>> > === My first attempt was ...
>> > f: layout [button "A" [face/font/size: 18] button "B"]
>> > view center-face f
>> > Unfortunately, not only "A" got the new size of 18, but "B", and
>> > all the
>> > buttons created since. I guess I have changed the system font
>> > used for
> all
>>> the buttons.
>> > === I thought "I need to create a new font"...
>> > +++ "make font" failed me !
>> >>> my-font: make font [size: 18]
>> > ** Script Error: font has no value
>> > ** Near: my-font: make font [size: 18]
>> > I was puzzled because I read something like that in an old VID
>> > documentation
>> > "REBOL/View User's Guide, Version 0.9.9 (Beta 4.1), 1-June-2000"
>> > :
>> > view make face
>> > size: 100x50
>> > edge: make edge [size: none]
>> > pane: make face
>> > size: 100x50
>> > text: "Hello World!"
>> > font: make font
>> > color: 255.255.255
>> > shadow: 1x1
>> > ]
>> > edge: make edge [size: none]
>> > ]
>> > ]
>> > +++ "system/standard/face/font" failed me too
>> > I figured I needed some system font for model. After wandering a
>> > little bit
>> > in the available documentation, I found
>> > system/standard/face/font which
>> > seemed perfect for the job.
>> >>> help system/standard/face/font
>> > SYSTEM/STANDARD/FACE/FONT is an object of value:
>> > name string! "arial"
>> > style none! none
>> > size integer! 12
>> > color tuple! 0.0.0
>> > offset pair! 2x2
>> > space pair! 0x0
>> > align word! center
>> > valign word! center
>> > shadow none! none
>> > I though I was going to be a VID guru ...
>> > my-font: make system/standard/face/font [size: 18]
>> > f: layout [button "A" [face/font: my-font] button "B"]
>> > view center-face f
>> > ... but testing proves me wrong.
>> > ** Script Error: Invalid path value: colors
>> > ** Where: wake-event
>> > ** Near: if all [face/font face/font/colors] [
>> > face/font/color: pick face/font/colors not action
>> > show face
>> > face/font/color: first face/font/colors
>> > ]
>> > My analyse of this is that this particular font miss something
>> > needed by the
>> > feel of the button. I have tried to add a colors block.
>> > my-font: make system/standard/face/font [size: 18 colors: [0.0.0
>> > 255.255.255]]
>> > It seems better till ... the next crash?
>> > ===However it was quite fun
>> > "I have lost two hours" would be a negative judgment. In fact it
>> > was quite a
>> > fun. Almost like a chess match. Each time I think I'm gonna win,
>> > Rebol
> is
>>> smarter than be. I will be a newbie forever, so be it!
>>>
>>> However, to move forward, I would like to have some remarks and
>>> explanations
>>> from THE list.
>>>
>>> Regards
>>> Patrick
--
Carl Read