A couple times now I've run into a layout issue where I really need to know the height of a font. After poking around I found the CompartmentPattern in the examples. It has the same problem, since it's doing the same thing I want to do. It has to make layout decisions based on the size of a font. CompartmentPattern solves the problem by hard coding a pixel height.
That approach might be reasonable for some cases, but if the user has control of the typeface or the size of the font, then knowing the height when the code is compiled is tricky. Also, I imagine that font sizes (at least in physical pixels) might vary across platforms.
Is there a better solution?
Also, having seen CompartmentPattern, I'm now curious about Patterns. :)
Thanks for your help. I noticed, after I'd asked the question, that the font sizes did seem to correspond to pixel height. So, if it's a vector font and it's being scaled, that's good for height.
I do have a portion of my graphical object whose width is dominated by the maximum width of a set of text labels. Ideally, I'd like to be able to set the default width for that rectangle so that, by default, all of the text labels are visible. Is there a way to get the "preferred width" of a text label?