diff options
author | Stephen McConnel <stephen_mcconnel@sil.org> | 2015-01-22 21:26:42 +0300 |
---|---|---|
committer | Stephen McConnel <stephen_mcconnel@sil.org> | 2015-01-22 21:26:42 +0300 |
commit | e62a37d332e3de970d26fc8ceedd6c3945da4687 (patch) | |
tree | 9685a8c473ea51e180174fda809cf86b8bfcecc5 /mcs/class/Managed.Windows.Forms/System.Windows.Forms | |
parent | a9af48a4a65dbb47bd480c7fcee6f72f8e133292 (diff) |
Fix occasional rendering problem in TextBoxes
See https://bugzilla.xamarin.com/show_bug.cgi?id=26258 for details.
Diffstat (limited to 'mcs/class/Managed.Windows.Forms/System.Windows.Forms')
-rw-r--r-- | mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxTextRenderer.cs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxTextRenderer.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxTextRenderer.cs index 9917a9ab902..04bb3a3d152 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxTextRenderer.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxTextRenderer.cs @@ -92,7 +92,19 @@ namespace System.Windows.Forms // used tends to be small, this is a good performance gain for
// not too much memory.
if (text.Length == 1) {
- string key = font.GetHashCode ().ToString () + "|" + text;
+ // If g.VisibleClipBounds is {X=0, Y=0, Width=1, Height=1}, then some characters
+ // (in some fonts for some point sizes) return a different width then when the
+ // VisibleClipBounds has a different (usually but not always more reasonable) value.
+ // This state of the Graphics object can occur during initialization of text boxes
+ // with preset Text values. See https://bugzilla.xamarin.com/show_bug.cgi?id=26258
+ // for more details.
+ string sep;
+ var bounds = g.VisibleClipBounds;
+ if (bounds.Width == 1 && bounds.Height == 1 && bounds.X == 0 && bounds.Y == 0)
+ sep = "-1x1|";
+ else
+ sep = "|";
+ string key = font.GetHashCode ().ToString () + sep + text;
if (measure_cache.ContainsKey (key)) {
return (SizeF)measure_cache[key];
|