---
title: kCTForegroundColorFromContextAttributeName
framework: coretext
role: symbol
role_heading: Global Variable
path: coretext/kctforegroundcolorfromcontextattributename
---

# kCTForegroundColorFromContextAttributeName

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

## Declaration

```swift
let kCTForegroundColorFromContextAttributeName: CFString
```

## Discussion

Discussion Value must be a CFBoolean object. Default is kCFBooleanFalse. The reason this exists is because an 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 CGContext. If set, this attribute also determines the color used by kCTUnderlineStyleAttributeName, in which case it overrides the foreground color.

## See Also

### Constants

- [kCTCharacterShapeAttributeName](coretext/kctcharactershapeattributename.md)
- [kCTFontAttributeName](coretext/kctfontattributename.md)
- [kCTKernAttributeName](coretext/kctkernattributename.md)
- [kCTLigatureAttributeName](coretext/kctligatureattributename.md)
- [kCTForegroundColorAttributeName](coretext/kctforegroundcolorattributename.md)
- [kCTParagraphStyleAttributeName](coretext/kctparagraphstyleattributename.md)
- [kCTStrokeWidthAttributeName](coretext/kctstrokewidthattributename.md)
- [kCTStrokeColorAttributeName](coretext/kctstrokecolorattributename.md)
- [kCTSuperscriptAttributeName](coretext/kctsuperscriptattributename.md)
- [kCTUnderlineColorAttributeName](coretext/kctunderlinecolorattributename.md)
- [kCTUnderlineStyleAttributeName](coretext/kctunderlinestyleattributename.md)
- [kCTVerticalFormsAttributeName](coretext/kctverticalformsattributename.md)
- [kCTGlyphInfoAttributeName](coretext/kctglyphinfoattributename.md)
- [kCTRunDelegateAttributeName](coretext/kctrundelegateattributename.md)
- [kCTBaselineOffsetAttributeName](coretext/kctbaselineoffsetattributename.md)
