Re: TextWidth() Alternative?
- From: "Mike Williams" <Mike@xxxxxxxxxxxxxxxxx>
- Date: Mon, 17 Jul 2006 22:16:49 +0100
"Dan Barclay" <Dan@xxxxxxxx> wrote in message news:ulHJm%23dqGHA.3820@xxxxxxxxxxxxxxxxxxxxxxx
I think you might want to restrict that to cases where you *really*
needed the exact width for some reason (that escapes me<g>).
How about if you want to send some fully justified text to the printer and you want the right edge as neat as possible. In that case the best method would be to use GetTextExtentPoint32A in order to get the exact width of the line of text so that you could calculate the correct value to pass to the SetTextJustification API.
Doing it this way requires that it look up width of each character.
Doing it what way? I suggested getting the width of an entire string (or substring if you're checking for word wrap) in one go using the GetTextExtentPoint32 API. I specifically advised *against* getting individual character by character (or word by word) widths and adding them up. (Unless of course you mean that the API routine itself will need to check every character in the string, in which case I'd love to know what method you are suggesting that doesn't need to do that!)
I don't know if that API supports fonts with kerning or not
Yes it does.
. . . but if it does then you'll *really* chew up some CPU.
No you wouldn't.
Agreed. Every time I have to handle text in any detail the
circumstances are different. So, you really need to look for
that issue when you're doing it.
I'm pleased to note that we do at least agree on something ;-)
Actually, the OP still hasn't told us what he is doing and, often more importantly, why he is doing it. Perhaps when he does we will be able to give him some more specific advice.
Mike
.
- Follow-Ups:
- Re: TextWidth() Alternative?
- From: Jim Carlock
- Re: TextWidth() Alternative?
- References:
- TextWidth() Alternative?
- From: Jim Carlock
- Re: TextWidth() Alternative?
- From: Karl E. Peterson
- Re: TextWidth() Alternative?
- From: Dan Barclay
- Re: TextWidth() Alternative?
- From: Mike Williams
- Re: TextWidth() Alternative?
- From: Dan Barclay
- TextWidth() Alternative?
- Prev by Date: Re: NO postings
- Next by Date: Re: Can I make a single-file exe to share?
- Previous by thread: Re: TextWidth() Alternative?
- Next by thread: Re: TextWidth() Alternative?
- Index(es):
Relevant Pages
|