diff options
| -rw-r--r-- | cocoa/QuartzTextStyle.h | 69 | 
1 files changed, 34 insertions, 35 deletions
| diff --git a/cocoa/QuartzTextStyle.h b/cocoa/QuartzTextStyle.h index faffe7616..df5add75c 100644 --- a/cocoa/QuartzTextStyle.h +++ b/cocoa/QuartzTextStyle.h @@ -13,30 +13,29 @@  class QuartzTextStyle  {  public: -    QuartzTextStyle() -    { +	QuartzTextStyle() +	{  		fontRef = NULL;  		styleDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 2, -						   &kCFTypeDictionaryKeyCallBacks,  -						   &kCFTypeDictionaryValueCallBacks); +		        &kCFTypeDictionaryKeyCallBacks, +		        &kCFTypeDictionaryValueCallBacks);  		characterSet = 0; -    } - -    QuartzTextStyle(const QuartzTextStyle &other) -    { -	    // Does not copy font colour attribute -	    fontRef = static_cast<CTFontRef>(CFRetain(other.fontRef)); -	    styleDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 2, -						  &kCFTypeDictionaryKeyCallBacks,  -						  &kCFTypeDictionaryValueCallBacks); -	    CFDictionaryAddValue(styleDict, kCTFontAttributeName, fontRef); -	    characterSet = other.characterSet; -    } -	 - -    ~QuartzTextStyle() -    { +	} + +	QuartzTextStyle(const QuartzTextStyle &other) +	{ +		// Does not copy font colour attribute +		fontRef = static_cast<CTFontRef>(CFRetain(other.fontRef)); +		styleDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 2, +		        &kCFTypeDictionaryKeyCallBacks, +		        &kCFTypeDictionaryValueCallBacks); +		CFDictionaryAddValue(styleDict, kCTFontAttributeName, fontRef); +		characterSet = other.characterSet; +	} + +	~QuartzTextStyle() +	{  		if (styleDict != NULL)  		{  			CFRelease(styleDict); @@ -48,58 +47,58 @@ public:  			CFRelease(fontRef);  			fontRef = NULL;  		} -    } -	 +	} +  	CFMutableDictionaryRef getCTStyle() const  	{  		return styleDict;  	} -	  -	void setCTStyleColor(CGColor* inColor ) + +	void setCTStyleColor(CGColor *inColor)  	{  		CFDictionarySetValue(styleDict, kCTForegroundColorAttributeName, inColor);  	} -	 +  	float getAscent() const  	{  		return ::CTFontGetAscent(fontRef);  	} -	 +  	float getDescent() const  	{  		return ::CTFontGetDescent(fontRef);  	} -	 +  	float getLeading() const  	{  		return ::CTFontGetLeading(fontRef);  	} -	 +  	void setFontRef(CTFontRef inRef, int characterSet_)  	{  		fontRef = inRef;  		characterSet = characterSet_; -		 +  		if (styleDict != NULL)  			CFRelease(styleDict);  		styleDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 2, -						      &kCFTypeDictionaryKeyCallBacks,  -						      &kCFTypeDictionaryValueCallBacks); -		 +		        &kCFTypeDictionaryKeyCallBacks, +		        &kCFTypeDictionaryValueCallBacks); +  		CFDictionaryAddValue(styleDict, kCTFontAttributeName, fontRef);  	} -	 +  	CTFontRef getFontRef()  	{  		return fontRef;  	} -	 +  	int getCharacterSet()  	{  		return characterSet;  	} -	 +  private:  	CFMutableDictionaryRef styleDict;  	CTFontRef fontRef; | 
