<!--
{
  "availability" : [
    "iOS: 3.2.0 -",
    "iPadOS: 3.2.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreText",
  "identifier" : "/documentation/CoreText/kCTForegroundColorFromContextAttributeName",
  "metadataVersion" : "0.1.0",
  "role" : "Global Variable",
  "symbol" : {
    "kind" : "Global Variable",
    "modules" : [
      "Core Text"
    ],
    "preciseIdentifier" : "c:@kCTForegroundColorFromContextAttributeName"
  },
  "title" : "kCTForegroundColorFromContextAttributeName"
}
-->

# kCTForegroundColorFromContextAttributeName

Sets a foreground color using the context’s fill color.

```
let kCTForegroundColorFromContextAttributeName: CFString
```

## Discussion

Value must be a <doc://com.apple.documentation/documentation/CoreFoundation/CFBoolean> object. Default is <doc://com.apple.documentation/documentation/CoreFoundation/kCFBooleanFalse>. The reason this exists is because an <doc://com.apple.documentation/documentation/Foundation/NSAttributedString> object defaults to a black color if no color attribute is set. This forces Core Text to set the color in the context. This attribute allows developers to sidestep this, making Core Text set nothing but font information in the <doc://com.apple.documentation/documentation/CoreGraphics/CGContext>. If set, this attribute also determines the color used by [`kCTUnderlineStyleAttributeName`](/documentation/CoreText/kCTUnderlineStyleAttributeName), in which case it overrides the foreground color.

---

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)