Rightpoint / BonMot

Beautiful, easy attributed strings in Swift
MIT License
3.56k stars 197 forks source link

Transform 'kerning(forFont: )' method to public #324

Closed acacuce closed 6 years ago

acacuce commented 6 years ago

Currently kerning(forFont: ) method in Tracking enum has an internal attribute. It would be good if it will be public

ZevEisenberg commented 6 years ago

@acacuce thanks for your pull request! Just curious - what's your use case for making this method public?

acacuce commented 6 years ago

I use StringStyles to describe the text styles in our application. Our designers use custom Tracking. This text is used in a chat where the sizes of chat bubble are calculated in with the help of NSTextContainer. For the correct calculation, I need to transfer the value of the tracking value.

acacuce commented 6 years ago

As an example, I need to count the hashValue from the value of Tacking

ZevEisenberg commented 6 years ago

Ah, yep, that makes sense. Would you mind adding a unit test that confirms that this method stays public? It would be a simple test case that does import BonMot instead of @testable import BonMot, and then it just needs to call kerning(forFont:), so if the method ever loses public, the test won't compile.

Also, as a current workaround, you can get the kerning if you query yourStringStyle.attributes[.kerning] as? NSNumber (I think as? CGFloat would work too).

ZevEisenberg commented 6 years ago

I merged this, but then I realized it should really be spelled kerning(for:), so the call site looks like kerning(for: font). I'm going to push a change for this. Just a heads up in case you're depending on this method name.

ZevEisenberg commented 6 years ago

This has been released as part of BonMot 5.1. Thanks for your contribution, @acacuce! 🚀