Rebol Talk Forum  |  REBOL Discussions  |  REBOL View  |  Topic: font + string --> text bounding box size?
Pages: [1] Print
Author Topic: font + string --> text bounding box size?  (Read 457 times)
HakimBey
Newbie
*
Offline Offline

Posts: 1


View Profile WWW
font + string --> text bounding box size?
« on: December 31, 2005, 09:49:21 AM »

As a part of a bigger application I want to draw a graph
with labeled nodes and lines connecting the labels.
The node positions will be in the "db" and editable,
but the drawing I want generic, so that there should
be a way to calculate the size of the label,
"obj.BoundingBox()" so to say.

An example:
Code:
test: func [spec] [
   view layout [box 400x800 black effect [draw spec]]
]
bold20: make face/font [style: 'bold size: 20]
test [
   pen yellow
   line 30x30 60x260

   fill-pen yellow
   pen navy
   box 18x18 220x42
   font bold20 text anti-aliased "Some labeled graph" 20x20

   box 50x250 110x280
   text "Hello!" 52x252
]

How that can be done? I can restrict the app to
have only one font size and only one font, and
it is OK if there is only an approximative estimation
for the bounding box (yellow box in the code).
And the font can be fixed to be Arial or something with
regular spacing. But if there is an even more generic
way, the better...

(I have used Rebol many years, but have not
done many visual apps with it).

Any help appreciated, and Happy New year too!
« Last Edit: December 31, 2005, 09:51:08 AM by HakimBey » Logged
CarlRead
Full Member
***
Offline Offline

Posts: 105


View Profile
font + string --> text bounding box size?
« Reply #1 on: December 31, 2005, 03:29:01 PM »

You can find the area used by text with SIZE-TEXT.  ie...

>> layout [t: text "abc"]
>> size-text t
== 22x15
>> layout [t: text "abcdef"]
>> size-text t
== 39x15

Note that this is different than the size of the face the text is within...

>> layout [t: text "abcdef"]
>> size-text t
== 39x15
>> t/size
== 43x19

Hope that's of some use.
 
Logged

- Carl Read
Guest
Guest


Email
font + string --> text bounding box size?
« Reply #2 on: January 01, 2006, 06:46:08 AM »

Thx a lot, that is OK, I can afford that when new
label gets added, it is once processed by
"layout" and the tex-size recorded with it
for the future...  
Logged
Pages: [1] Print 
Rebol Talk Forum  |  REBOL Discussions  |  REBOL View  |  Topic: font + string --> text bounding box size?
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 03, 2008, 11:49:06 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2315 Posts in 597 Topics by 4206 Members
Latest Member: amoutbroodo

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc