<!--
{
  "availability" : [
    "macOS: 10.11.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSStringDrawingContext",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSStringDrawingContext"
  },
  "title" : "NSStringDrawingContext"
}
-->

# NSStringDrawingContext

An object that manages metrics for drawing attributed strings.

```
class NSStringDrawingContext
```

## Overview

Prior to drawing, you can create an instance of this class and use it to specify the minimum scale factor and tracking adjustments for a string. After drawing, you can retrieve the actual values that were used during drawing.

To use this class, allocate and initialize a new instance, set the minimum values, and pass your object to one of the corresponding <doc://com.apple.documentation/documentation/Foundation/NSAttributedString> methods that take the context object as a parameter. Upon completion of drawing, you can use the actual drawing values to make adjustments or record where the string was actually drawn.

## Topics

### Accessing the scale factors

[`minimumScaleFactor`](/documentation/AppKit/NSStringDrawingContext/minimumScaleFactor)

The scale factor that determines the smallest font size to use during drawing.

[`actualScaleFactor`](/documentation/AppKit/NSStringDrawingContext/actualScaleFactor)

The actual scale factor that the system applied to the font during drawing.

### Getting the drawing bounds

[`totalBounds`](/documentation/AppKit/NSStringDrawingContext/totalBounds)

The most recent bounding rectangle that the system used to draw the string.

## Relationships

### Conforms To

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Equatable`](/documentation/Swift/Equatable)

[`CVarArg`](/documentation/Swift/CVarArg)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)