Re: are there any methods of figuring out how "large" a piece of typeset textual data will be?
- To: mathgroup at smc.vnet.net
- Subject: [mg71268] Re: [mg70660] are there any methods of figuring out how "large" a piece of typeset textual data will be?
- From: "Chris Chiasson" <chris at chiasson.name>
- Date: Sun, 12 Nov 2006 06:48:20 -0500 (EST)
- References: <200610220520.BAA04787@smc.vnet.net> <453C2C63.70702@wolfram.com>
A short addendum for those who may search for this in the future: A Graphics object that just barely contains the box (or Cell) "form" of an expression may be created. Creating a Cell without a border is outside the scope of this post, but involves the options CellFrameMargins & CellMargins. anyway, assuming boxes is defined appropriately: {{width,yup,ydown}}=FrontEndExecute[GetBoundingBoxSizePacket[boxes]]; Graphics[Text[DisplayForm@boxes,{0,0}],ImageSize->({width,yup+ydown}/Magnification^2/.AbsoluteOptions[$FrontEnd,Magnification])]//Show On 10/22/06, Carl Woll <carlw at wolfram.com> wrote: > Chris Chiasson wrote: > > >... after the front end gets done formatting it? > > > >I was thinking about getting the front end to spit out an equivalent > >EPS for the text and extracting the size from that, but I don't know > >if I can do it properly. Is there an easy method? Perhaps via some > >kind of API? > > > >The context for this question is that I am trying to generate "labels" > >(expressions) for nodes in a graph. I am trying to diagram functions. > > > > > There is an undocumented function that you may use to obtain this > information, with the usual caveat that this functionality is subject to > change. Here is an example of finding the size of the expression > Expand[(1+x)^11]: > > In[6]:= > FrontEndExecute[GetBoundingBoxSizePacket[BoxData[ToBoxes[Expand[(1 + > x)^11]]]]] > Out[6]= > {{504., 13., 4.}} > > I believe the returned values are {{width, toptobaseline, > baselinetobottom}} in points. > > Carl Woll > Wolfram Research > -- http://chris.chiasson.name/