Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>simple. set up a test string and frame and compare origin of two lines of the font you want. Then if you want to calculate leading just use line height accent descent to do the calculation.</p> <pre><code> - (float)getLineHeight { CFMutableAttributedStringRef testAttrString; testAttrString = CFAttributedStringCreateMutable(kCFAllocatorDefault, 0); NSString *testString = @"testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest"; CFAttributedStringReplaceString (testAttrString, CFRangeMake(0, 0), (CFStringRef)testString); CTFontRef myFont1 = CTFontCreateWithName((CFStringRef)@"Helvetica", 30, NULL); CFRange range = CFRangeMake(0,testString.length); CFAttributedStringSetAttribute(testAttrString, range, kCTFontAttributeName, myFont1); CGMutablePathRef path = CGPathCreateMutable(); CGRect bounds; if ([model isLandscape]) { bounds = CGRectMake(0, 10, 1024-20, 768); } else { bounds = CGRectMake(0, 10, 768-20, 1024); } CGPathAddRect(path, NULL, bounds); CTFramesetterRef testFramesetter = CTFramesetterCreateWithAttributedString(testAttrString); CTFrameRef testFrameRef = CTFramesetterCreateFrame(testFramesetter,CFRangeMake(0, 0), path, NULL); CGPoint origins1,origins2; CTFrameGetLineOrigins(testFrameRef, CFRangeMake(0, 1), &amp;origins1); CTFrameGetLineOrigins(testFrameRef, CFRangeMake(1, 1), &amp;origins2); return origins1.y-origins2.y; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload