drawbot icon indicating copy to clipboard operation
drawbot copied to clipboard

FormattedString tracking value – what does it refer to?

Open frankrolf opened this issue 5 years ago • 4 comments

It seems to be neither

  • an absolute value based on the em square (InDesign) Screen Shot 2020-03-30 at 01 29 59

  • a percentage (of what?) (Pages) Screen Shot 2020-03-30 at 01 33 27

  • instead: Screen Shot 2020-03-30 at 01 37 05

newPage(200, 100)
fs = FormattedString(
    'TESTING',
    font='Base900SansOT-Heavy',
    fontSize=12,
    tracking=10)
    
textBox(fs, (10, 10, 200, 50))

frankrolf avatar Mar 29 '20 23:03 frankrolf

That's setting NSKernAttributeName which is about kerning. There are subtle but important differences between this and tracking.

folengo avatar Mar 30 '20 01:03 folengo

It's an absolute number of points to be added in-between the letters.

If you want Adobe-style 1/1000 tracking, calculate based on your point size:

pointSize = 20

trackingUnits = 100

newPage(200, 100)
fs = FormattedString(
    'TESTING',
    font='Helvetica',
    fontSize=pointSize,
    tracking=pointSize*trackingUnits/1000)
    
textBox(fs, (10, 10, 200, 50))

justvanrossum avatar Mar 30 '20 05:03 justvanrossum

@folengo: kCTTrackingAttributeName has only been available since 10.12. We still support 10.10. It was not us who confused tracking and kerning, but Apple :)

That said, we could have made our public API a bit more sensible.

justvanrossum avatar Mar 30 '20 05:03 justvanrossum

Thanks @justvanrossum !

frankrolf avatar Mar 30 '20 09:03 frankrolf