[Mono-list] MeasureString

Sebastien Pouliot sebastien.pouliot at gmail.com
Thu Sep 20 17:23:44 EDT 2007


Hello Dan,

On Thu, 2007-09-20 at 17:02 -0400, Maser, Dan wrote:
>  
>   It might be a real issue, but my app has the need to measure strings
> too and I've found that MeasureString is often quite wrong.  The MSDN
> docs indicate that it often is too, and recommends using
> Graphics.MeasureCharacterRanges instead.   You might consider trying
> that approach as a work-around.   I know that I've removed all
> references to MeasureString in my app in favor of
> MeasureCharacterRanges which is far more reliable for me.

Older libgdiplus versions had very similar, yet subtly different, code
for both functions. Recent versions share the exact same code - so
reliability should be identical between the two of them. 

A lot of bugs around both calls has been fixed (most of them should be
in 1.2.5 iirc) but the current custom renderer in libgdiplus has some
design flaws that makes it impossible to handle all kind of options that
the API provides.

Someday we'll probably switch to the pango renderer(*). It should
produce far more precise results and handle i18n-fu correctly. However
there's no date planned for this feature - nor anyone working on it at
the moment(**).

(*) it's possible to play with a experimental version of this using SVN
(see my blog) but today it doesn't deal with a lot of options and is
also a lot slower (all fixable).

(**) Contributions are welcome :)
> 
> ______________________________________________________________________
> From: mono-list-bounces at lists.ximian.com
> [mailto:mono-list-bounces at lists.ximian.com] On Behalf Of Jansen Bart
> Sent: Thursday, September 20, 2007 3:28 PM
> To: mono-list at lists.ximian.com
> Subject: [Mono-list] MeasureString
> 
> 
> 
> Hi all,
> 
>  
> 
> I’m trying to ensure that a string fits in a rectangle shown on
> screen, so whenever the string is too long, some characters are
> stripped.  I’m using MeasureString to accomplish this.  With mono
> under windows this is working fine, under linux the resulting string
> is always way too long.  Is this a known issue? Is there a workaround?
> 
>  
> 
> Thanks a lot for your help,
> 
>  
> 
> B.
> 
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
-- 
Sebastien Pouliot  <sebastien at ximian.com>
Blog: http://pages.infinit.net/ctech/



More information about the Mono-list mailing list