MeasureString bug or feature
-
I've tried to use MeasureString function and noticed that it almost always returns size that is noticeably wider then the actual string. So, I was wondering if any one can comment on this behavior. Is it a bug or a feature ;) Also, does anybody else thinks that support for text output in .NET SDK is totally inadequate? How is one can change kerning or get character glyph?…
-
I've tried to use MeasureString function and noticed that it almost always returns size that is noticeably wider then the actual string. So, I was wondering if any one can comment on this behavior. Is it a bug or a feature ;) Also, does anybody else thinks that support for text output in .NET SDK is totally inadequate? How is one can change kerning or get character glyph?…
Well, MeasureString have been broken in Beta 1 (it returned invalid result for some fonts). They fixed this problem in Beta 2. Still this function might be inadequate for precise measurement. I agree that .NET does not have enough power as far as text output goes (fonts, measurements). E.g. writing fully managed text editor with support for variety of fonts is an uphill battle (I would even say it is impossible). The only solution is to use P-Invoke to call into Windows SDK functions. I suspect that due to the fact that .NET is supposed to be appealing for cross-platform development they couldn't include any "Windows specific" functionality. Regards, Andrei Zenkovitch
-
Well, MeasureString have been broken in Beta 1 (it returned invalid result for some fonts). They fixed this problem in Beta 2. Still this function might be inadequate for precise measurement. I agree that .NET does not have enough power as far as text output goes (fonts, measurements). E.g. writing fully managed text editor with support for variety of fonts is an uphill battle (I would even say it is impossible). The only solution is to use P-Invoke to call into Windows SDK functions. I suspect that due to the fact that .NET is supposed to be appealing for cross-platform development they couldn't include any "Windows specific" functionality. Regards, Andrei Zenkovitch
Thanks for the info Andrei! I did figure as much myself. Unfortunately I was trying to create text editor with extra features not found in RichEdit and for now I had to abandon it. I hope Microsoft reconsiders their decision about text output support (or lack of it) in .NET. As for Windows SDK, if I have to use it I'd rather use it from C++. Cheers. P.S. I am using Beta2 VS.NET