3

I'm trying to resolve a spacing issue while drawing to a PDF. In debugging, I am watching the method that constructs a rectangle for my string (see below). As I watch the values in the debugger, they go from nice float values (ie., 30.0) to what you see in the image below, before the method returns its values. What is going on? Why, for example, does x become 1.4013e - 45?

    CGRect renderingRect = CGRectMake(kBorderInset + kMarginInset + widthOfPrevious,    kBorderInset + kMarginInset + 50.0 + heightOfPrevious,stringSize.width, stringSize.height);

    return renderingRect;

Please see the value for renderingRect:

enter image description here

cmac
  • 906
  • 10
  • 19
  • what data types are the constants? are they floats? – mkral Dec 05 '12 at 22:21
  • are you sure that your computation of the arguments of CGRectMake does not return non-round numbers? – Gabriele Petronella Dec 05 '12 at 22:39
  • Yes, the constants are floats. @Gabro, this is what I am trying to figure out. Somewhere, in one of my string-rectangles, extra space is getting added and it is not character whitespace. – cmac Dec 06 '12 at 02:41

1 Answers1

2

You can use CGRectIntegral as shown below to round the floating point values to nearest smallest integers as shown below.

CGRect renderingRect = CGRectIntegral(CGRectMake(kBorderInset + kMarginInset + widthOfPrevious, kBorderInset + kMarginInset + 50.0 + heightOfPrevious,stringSize.width, stringSize.height));
iDev
  • 23,310
  • 7
  • 60
  • 85