無限に大きな四角形に配置されるときに、それらの境界四角形を計算したい一意の文字列が大量にあります。現在、単一の NSTextStorage/NSLayoutManager を使用し、すべての文字列をループして、四角形を収集します。
// setup NSTextStorage and its NSLayoutManager, NSTextContainer
...
forall (NSAttributedString *astring in ...)
{
// put string into textstorage
[textStorage setAttributedString:astring];
// trigger glyph generation and layout
[textContainer setContainerSize: NSMakeSize (CGFLOAT_MAX, CGFLOAT_MAX)];
[layoutManager ensureLayoutForTextContainer: textContainer];
// finally get the bounding box
NSRect boundingBox = [layoutManager usedRectForTextContainer: textContainer];
...
}
問題は、文字列を描画する必要がないことを考慮して、計算を高速化できるかどうかです。長方形の幅と高さにのみ興味があります。