TextRenderer measuring characters

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

With .Net 1.1 I developed a text editing control using:

Graphics.MeasureCharacterRanges;
Graphics.MeasureString

It worked but was not perfect as the text "walked" as new characters were
added and finding the exact position of a character (especially spaces at the
end of a line) was not always precise.

I understood that TextRenderer that is available in .Net 2.0 would alleviate
these problems as it used GDI rather than GDI+, providing a more precise
method MeasureText. My question is, how can I find a character's exact
position using TextRenderer? It doesn't appear to have the equivalent of
Graphics.MeasureCharacterRanges.

Thank you in advance.

Piers
 
If you're wiling to do lots of work, only the Uniscribe C API would always
provide you the right answer no matter what.
 
Hi Piers,

I will do a little more research in this issue, I will reply to you ASAP.
Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
OK, seems TextRenderer provide answer to some question.
But what about international text, when it's bidirectional, or there are
cluster which are not OK to break, etc...
Do I have to use Uniscribe?
Or is there a managed way to do that?

I get the feeling that I really want to write display international text, I
could use TextRenderer instead of ScriptShape & ScriptPlace, but I still
have to use ScriptItemize, ScriptLayout & ScriptBreak to know how to layout
the text and valid cursor position.
I also still have to use ScriptXToCP & ScriptCPToX (hence ScriptShape &
ScriptPlace) to do hit testing.

Am I right or is there some managed way to do that?
 
Sorry for letting you wait.
After doing some research, I do not think there is a
Graphics.MeasureCharacterRanges equivalent in TextRenderer class.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
So, does Microsoft have any suggestions on how to find the exact position a
character will be rendered to when using TextRenderer?

Or must I either:

* Stick with the Graphics.XXX methods (and put up with their problems)

* Wrap the Uniscribe API (no small feat I understand)

Thanks

Piers
 
Hi Piers,

Sorry for letting you wait for so long.

Yes, I have contacted our product team for the suggestion. Because of the
complexity of Uniscribe API, they still suggest go with the first option.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top