title: Differences in Core-Text between ios 6 and ios 5.1?
body: <p>It appears there are some differences in the CoreText implementation between ios 5.1 and ios 6, as you can see from these two screenshots :</p>
  
  <p>ios 6:
  <img src="https://i.stack.imgur.com/vKPAu.png" alt="enter image description here"></p>
  
  <p>ios 5:
  <img src="https://i.stack.imgur.com/Kf19b.png" alt="enter image description here"></p>
  
  <p>Firstly the text color isn't applied correctly. It seems that on ios 5.1 the <code>kCTForegroundColorAttributeName</code> requires that you give it a <code>CGColor</code>, whereas on ios 6, passing it a UIColor will suffice. So I solved the issue by changing my code to:</p>
  
  <pre><code>[attributes setObject:(id)[color CGColor] 
                 forKey:(NSString*)kCTForegroundColorAttributeName];
  </code></pre>
  
  <p>Secondly, the paragraph spacing is a bit off. The distance between "sight" and "According" is 11px vs 25px (measured in the screenshot). In both cases paragraph spacing is set to 5:</p>
  
  <pre><code>NSMutableData *styleSettingsArray = [NSMutableData data];
  CGFloat spaceBefore,spaceAfter;
  ...
  CTParagraphStyleSetting styleSettingB = {kCTParagraphStyleSpecifierParagraphSpacingBefore   ,sizeof(CGFloat),&amp;spaceBefore};
  CTParagraphStyleSetting styleSettingA = {kCTParagraphStyleSpecifierParagraphSpacing         ,sizeof(CGFloat),&amp;spaceAfter};
  [styleSettingsArray appendBytes:&amp;styleSettingB length:sizeof(styleSettingB)];
  [styleSettingsArray appendBytes:&amp;styleSettingA length:sizeof(styleSettingA)];
  ...
  if(styleSettingsArray.length &gt; 0)
  {
      CTParagraphStyleRef paragraphStyleRef = CTParagraphStyleCreate([styleSettingsArray bytes], [styleSettingsArray length] / sizeof(CTParagraphStyleSetting));
      [dictionary setObject:(__bridge id)(paragraphStyleRef) forKey:(NSString*)kCTParagraphStyleAttributeName];
      CFRelease(paragraphStyleRef);
  }
  </code></pre>
  
  <p>Description of <code>paragraphStyleRef</code> in console:</p>
  
  <pre><code>iOS 6:
  CTParagraphStyle:
  base writing direction = -1, alignment = 3, line break mode = 0, default tab interval = 0
  first line head indent = 0, head indent = 0, tail indent = 0
  line height multiple = 0, maximum line height = 0, minimum line height = 0
  line spacing adjustment = 0, paragraph spacing = 5, paragraph spacing before = 5
  
  
  iOS 5:
  
  CTParagraphStyle:
  writing direction = -1, alignment = 3, line break mode = 0, default tab interval = 0
  first line head indent = 0, head indent = 0, tail indent = 0
  line height multiple = 0, maximum line height = 0, minimum line height = 0
  line spacing adjustment = 0, paragraph spacing = 5, paragraph spacing before = 5
  </code></pre>
  
  <p>which seem the same to me, so I don't know what the problem is. Other than the spacing between the paragraphs, they're identical.</p>
  
  <p>So how can I fix this? Also are there any other things I should be aware of that might cause the text to display differently?</p>
  
  <p><strong>EDIT:</strong>
  After some investigation, it turnes out that the difference in paragraph styling was actually caused by my line breaks which printed "\r\n". Changing that to "\n" solved the spacing problem.</p>