title: Measuring the text width
body: <p>I am trying to draw some text with CoreGraphics. Unfortunately there is no method which returns the width of the text. I tried getting the width using this method:</p>
  
  <pre><code>private float GetTextWidth(CGContext context, string text)
      {
          float   startWidth, 
                  endWidth,
                  textWidth;
          startWidth = context.TextPosition.X;
          context.SetTextDrawingMode(CGTextDrawingMode.Invisible);
          context.ShowText(text);
          endWidth = context.TextPosition.X;
          textWidth = endWidth - startWidth;
          return textWidth;
      }
  </code></pre>
  
  <p>but if I want a multiline text I also need to take the font into consideration. 
  So I thought about using a UILable and get the values from it doing the following: </p>
  
  <pre><code>RectangleF lableRect = new RectangleF((float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height);
              UILabel lable = new UILabel(lableRect){
                  Font = UIFont.FromName(font.Family.ToString(), (float)font.Size),
                  Text = text,
              };
  SizeF uiSize = lable.StringSize(lable.Text, lable.Font);
  </code></pre>
  
  <p>Although the height seems to be ok, the width is not correct. Any idea why?</p>