by Brent Rose » Tue Apr 03, 2012 10:11 pm
Sure. In a nut shell, access to TEXTMETRICS allows precise positioning of text by FONT rather than LINE. Granted, in some cases you can to achieve a similar result by reasonable guess-work, but it is much easier with the text metrics. Some instances where I use the metrics are:
1. I want to align text adjacent to a logo image, a top line even with the top of the image, a bottom line even with the bottom of the image. Roughly:
XXXXXXXX TOP LINE
XXXXXXXX
XXXXXXXX BOTTOM LINE
I need FONT-TOP to correctly align the top line, and FONT-BASELINE to correctly align the bottom line.
2. With natural line spacing in something like:
LARGE TEXT
SMALL TEXT
the normal gap between the lines is too large (in my given case). Instead, I want to accurately position the SMALL TEXT 0.5mm below the LARGE TEXT. Easiest way is to take FONT-BASELINE of LARGE TEXT plus 0.5mm equals FONT-TOP of SMALL TEXT.
3. I want to centre a line or arrow or bullet point on a caption or line of text. eg Roughly:
------> MY CAPTION
I would position the line on FONT-MIDDLE, or position the text by FONT-MIDDLE on the line.
4. I have a multi page report in which I always want text to visually start at exactly the same point below the page header (where I have some images starting too) regardless of the font used at the time. I would simply set by FONT-TOP to this vertical position.
5. With text of varying fonts on the same line like:
TEXT TEXT TEXT TEXT TEXT
you typically want to align the FONT-BASELINE, but you may also want to align the FONT-TOP or FONT-MIDDLE instead.
6. If you wanted to nicely centre some TEXT between two horizontal lines on a form, best way is relative to FONT-MIDDLE.
7. I want to label dimension lines on a simply diagramme - I need to centre my dimension numbers exactly on the line (ie by FONT-MIDDLE)
8. Plus other cases where text positioning is sensitive...
VPE Rendering allows calculation of LINE-HEIGHT, so LINE-TOP, LINE-MIDDLE, and LINE-BOTTOM can be derived.
However, within that vertical line space, you need font ascent and descent heights to determine FONT-TOP, FONT-MIDDLE (middle-of-ascent), FONT-BASELINE. FONT-BOTTOM would be the same as LINE-BOTTOM. With VPE as it stands, and access to the metrics, one would be able to calculate the correct "Top" value to use for the existing Write() and Print() procedures etc. In this context one might create simple utility functions to return an appropriate "Top" for these procedures - eg TopByFontTop(MyDesiredFontTop), TopByFontBaseLine(MyDesiredFontBaseLine) etc etc. You would still want access to ascent/descent values, though.
Hiding low-level details like this from the user makes perfect sense (afterall, you generally do not need them) - but, IMHO, still having it available exposes some extremely useful raw power.