<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreText",
  "identifier" : "/documentation/CoreText/CTLine",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Text"
    ],
    "preciseIdentifier" : "c:@T@CTLineRef"
  },
  "title" : "CTLine"
}
-->

# CTLine

A line of text.

```
class CTLine
```

## Overview

A `CTLine` object contains an array of glyph runs. Line objects are created by the typesetter during a framesetting operation and can draw themselves directly into a graphics context.

## Topics

### Creating Lines

[`CTLineCreateWithAttributedString(_:)`](/documentation/CoreText/CTLineCreateWithAttributedString(_:))

Creates a single immutable line object from an attributed string.

[`CTLineCreateTruncatedLine(_:_:_:_:)`](/documentation/CoreText/CTLineCreateTruncatedLine(_:_:_:_:))

Creates a truncated line from an existing line.

[`CTLineCreateJustifiedLine(_:_:_:)`](/documentation/CoreText/CTLineCreateJustifiedLine(_:_:_:))

Creates a justified line from an existing line.

### Drawing the Line

[`CTLineDraw(_:_:)`](/documentation/CoreText/CTLineDraw(_:_:))

Draws a complete line.

### Getting Line Data

[`CTLineGetGlyphCount(_:)`](/documentation/CoreText/CTLineGetGlyphCount(_:))

Returns the total glyph count for the line object.

[`CTLineGetGlyphRuns(_:)`](/documentation/CoreText/CTLineGetGlyphRuns(_:))

Returns the array of glyph runs that make up the line object.

[`CTLineGetStringRange(_:)`](/documentation/CoreText/CTLineGetStringRange(_:))

Gets the range of characters that originally spawned the glyphs in the line.

[`CTLineGetPenOffsetForFlush(_:_:_:)`](/documentation/CoreText/CTLineGetPenOffsetForFlush(_:_:_:))

Gets the pen offset required to draw flush text.

### Measuring Lines

[`CTLineGetImageBounds(_:_:)`](/documentation/CoreText/CTLineGetImageBounds(_:_:))

Calculates the image bounds for a line.

[`CTLineGetTypographicBounds(_:_:_:_:)`](/documentation/CoreText/CTLineGetTypographicBounds(_:_:_:_:))

Calculates the typographic bounds of a line.

[`CTLineGetTrailingWhitespaceWidth(_:)`](/documentation/CoreText/CTLineGetTrailingWhitespaceWidth(_:))

Returns the trailing whitespace width for a line.

### Getting Line Positioning

[`CTLineGetStringIndexForPosition(_:_:)`](/documentation/CoreText/CTLineGetStringIndexForPosition(_:_:))

Performs hit testing.

[`CTLineGetOffsetForStringIndex(_:_:_:)`](/documentation/CoreText/CTLineGetOffsetForStringIndex(_:_:_:))

Determines the graphical offset or offsets for a string index.

[`CTLineEnumerateCaretOffsets(_:_:)`](/documentation/CoreText/CTLineEnumerateCaretOffsets(_:_:))

Enumerates caret offsets for characters in a line.

### Getting the Type Identifier

[`CTLineGetTypeID()`](/documentation/CoreText/CTLineGetTypeID())

Returns the Core Foundation type identifier of the line object.

### Constants

[`CTLineTruncationType`](/documentation/CoreText/CTLineTruncationType)

Truncation types required by the [`CTLineCreateTruncatedLine(_:_:_:_:)`](/documentation/CoreText/CTLineCreateTruncatedLine(_:_:_:_:)) function to tell the truncation engine which type of truncation is being requested.



---

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)