Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

How to change the font of a button ?

 [1/7] from: patrick:philipot:laposte at: 29-Jun 12:02


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

 [2/7] from: antonr:iinet:au at: 30-Jun-2003 10:59


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.

 [3/7] from: patrick:philipot:laposte at: 30-Jun-2003 12:09


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 . Regards Patrick

 [4/7] 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
<<quoted lines omitted: 97>>
>>> Regards >>> Patrick
-- Carl Read

 [5/7] from: maximo::meteorstudios::com at: 30-Jun-2003 14:21


I usually create my fonts in advance and switch between the different versions dynamically, in order to reduce the amount of ram being used by each face. try this: gui: layout [ abutton: button "rebol est cool" 150x30 [face/font: either ((face/font) = font-a) [:font-b][:font-a] show face] ] font-a: make abutton/font [ size: 12 ] font-b: make font-a [ size: 18 ] abutton/font: font-a view gui by clicking on the button, you should toggle between each font each time you press on the button... The reason I built the layout before the font is that the vid button style adds the /colors attribute to the font object... by makin a font from the allocated button, the fonts created are sure to have any other custom attributes added by the style. -maxim

 [6/7] from: patrick:philipot:laposte at: 30-Jun 22:26


Thanks Carl, Just what I needed (and I was so close ...) Regards Patrick

 [7/7] from: patrick:philipot:laposte at: 30-Jun 22:31


Merci maxim C'était clair et préçis et parfaitement adapté ŕ mes besoins. Oui, Rebol est cool! Cordialement Patrick ----- Original Message ----- From: Maxim Olivier-Adlhoch <[maximo--meteorstudios--com]> To: <[rebol-list--rebol--com]> Sent: Monday, June 30, 2003 8:21 PM Subject: [REBOL] Re: How to change the font of a button ? I usually create my fonts in advance and switch between the different versions dynamically, in order to reduce the amount of ram being used by each face. try this: gui: layout [ abutton: button "rebol est cool" 150x30 [face/font: either ((face/font) font-a) [:font-b][:font-a] show face] ] font-a: make abutton/font [ size: 12 ] font-b: make font-a [ size: 18 ] abutton/font: font-a view gui by clicking on the button, you should toggle between each font each time you press on the button... The reason I built the layout before the font is that the vid button style adds the /colors attribute to the font object... by makin a font from the allocated button, the fonts created are sure to have any other custom attributes added by the style. -maxim

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted