Hi all,
I want to write a function that gets the following parameters:
a string "s"
a font "f"
and returns the EXACT width and height of the font.
I tried first with MeasureString but it adds me extra space;
then I tried with MeasureCharacterRanges but I didn't manage
to get rid of an extra space.
I need to have a pair of values that could enable me to draw,
let's say, a bounding box that TOUCHES the string on every border,
no matter how the glyphs are shaped (f.ex. a string with only
a period, ".", should return a very small b.box instead of taking
account of the extra space OVER the dot).
Thanks for your help!
Chris Nahr - 29 Oct 2007 14:19 GMT
Text measurements always include spacing pixels all around, as
determined by the font. AFAIK the only reliable way to determine the
actual pixels occupied by a text string is to render it to a memory
device, then scan from each side until you see a non-white pixel.
--
http://www.kynosarges.de
MarPrag - 29 Oct 2007 15:21 GMT
Chris Nahr ha scritto:
> Text measurements always include spacing pixels all around, as
> determined by the font. AFAIK the only reliable way to determine the
> actual pixels occupied by a text string is to render it to a memory
> device, then scan from each side until you see a non-white pixel.
Yes, I had already figured out this technique, but I hoped
to avoid it as it seems so unelegant ... Thanks, anyway!
MarPrag aka EgregioSignore