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

[ALLY] Determining Pixel size of font

 [1/4] from: rebol::techscribe::com at: 16-Aug-2000 2:42


Hi, how do I determine how much space (horizontally) a string will take up on the screen, given a specified font name and size? I.e. if I have the string "0123456789" and I'm using font size 12 and font name "courier", and I position the face that contains the text at offset 0x0, how do I determine programmatically how large I must make the face so that the complete string will be displayed? If I then want to add some other element behind this string, how do I - again programmatically - determine at which x offset I have to position that next element? TIA, ;- Elan [ : - ) ] author of REBOL: THE OFFICIAL GUIDE REBOL Press: The Official Source for REBOL Books http://www.REBOLpress.com visit me at http://www.TechScribe.com

 [2/4] from: rebol:techscribe at: 16-Aug-2000 10:42


Thanks. That's what I was looking for. At 12:38 PM 8/16/00 +0100, you wrote:
>On 16-Aug-00, [rebol--techscribe--com] wrote: >> how do I determine how much space (horizontally) a string will take
<<quoted lines omitted: 12>>
>-- >Johan Forsberg
;- Elan [ : - ) ] author of REBOL: THE OFFICIAL GUIDE REBOL Press: The Official Source for REBOL Books http://www.REBOLpress.com visit me at http://www.TechScribe.com

 [3/4] from: johan:forsberg:6117:student:uu:se at: 16-Aug-2000 12:38


On 16-Aug-00, [rebol--techscribe--com] wrote:
> how do I determine how much space (horizontally) a string will take > up on the screen, given a specified font name and size?
<<quoted lines omitted: 5>>
> again programmatically - determine at which x offset I have to > position that next element?
You might use 'size-text on the appropriate face after you've added the text and then re-size it accordingly. It's behaving a bit strange for me sometimes, but I think it has to do with whether the text has word-wrap turned on. -- Johan Forsberg

 [4/4] from: agem:crosswinds at: 16-Aug-2000 16:31


Not so used with faces, but - make a separate wide layout with your stuff and vid and look at its offsets? normaly lots of auto-space, but padding can be changed? Hey, now i have questions :) (ah. one tool is 'size-text i read :) and - how can i embed an already layout face like measure-this in another layout? can't remember. THE DEMO [rebol[title:"text sizes"] as short as measure-this: layout [ across label "a" a: label "short" label "string" label "for you" ] probe size-text a or a bit longer: measure-this: layout ;demonstrate label uses text size, not like fixed-button [ across label "a" a: label "short" label "string" label "for you" return label "a" b: label "and another very long" label "string" label "for you" ] view/new measure-this view/new layout [ across label a/text label to string! size-text a return label b/text label to string! size-text b ] do-events ] Volker

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