NS(Attributed)String+Geometrics

I like to measure strings so that I can precisely size their fields.  Although Apple explains how to do this, there are some subtle issues that cause it to sometimes give inaccurate results.  NS(Attributed)String+Geometrics is a pair or reuseable categories (on NSString and NSAttributedString) which you can add to your projects, providing simple methods to get the width and height required for text drawing.  A commentary in the header explains some of the issues you may run into.  It comes packaged in a demo project.  The demo only shows measuring height, but measuring width works too. 

REPOSITORY

This project is contained as a subfolder within our CategoriesObjC GitHub repository.


StringGeometricsDemo


Thanks very much to Steve Nygard for taking the project one night, recognizing the importance of the line fragment padding and hyphenation factor, and the idea of generalizing to support NSAttributedString.