I am working with a code base that is largely CoreFoundation in C++. I prefer not to introduce Foundation objects in source files that do not already use them.
I would like to create a CFAttributedString using the NSStrikethroughStyleAttribute without first creating an NSAttributedString. I know they are toll-free bridged, but I would prefer to keep this source file free of obj-c if possible.
So, is there a way to create a CFAttributedString with the strikethrough attribute without going through Foundation, and if so, how?
I’m assuming here that this
CFAttributedStringis going to end up being rendered by AppKit eventually. If you’re rendering using CoreText, then you’re going to have to implement strikethrough yourself, as CoreText doesn’t have an attribute for it (there’s a Cocoanetics post with some sample code).So, assuming the string is rendered with AppKit by a portion of your app that does use obj-c, then what you really want is to somehow expose just the constant
NSStrikethroughStyleAttributeNameto your C code.The simplest way to do this is probably just to add this to the top of your file: