2010-07-14 09:47:17 +00:00
|
|
|
/*
|
|
|
|
* QuartzTextStyle.h
|
|
|
|
*
|
|
|
|
* Created by Evan Jones on Wed Oct 02 2002.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _QUARTZ_TEXT_STYLE_H
|
|
|
|
#define _QUARTZ_TEXT_STYLE_H
|
|
|
|
|
|
|
|
#include "QuartzTextStyleAttribute.h"
|
|
|
|
|
|
|
|
class QuartzTextStyle
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QuartzTextStyle()
|
|
|
|
{
|
2011-07-17 22:30:49 +00:00
|
|
|
styleDict = CFDictionaryCreateMutable(NULL, 1, NULL, NULL);
|
2010-07-14 09:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~QuartzTextStyle()
|
|
|
|
{
|
2011-07-17 22:30:49 +00:00
|
|
|
if (styleDict != NULL)
|
|
|
|
{
|
|
|
|
CFRelease(styleDict);
|
|
|
|
styleDict = NULL;
|
|
|
|
}
|
2010-07-14 09:47:17 +00:00
|
|
|
}
|
2011-07-17 22:30:49 +00:00
|
|
|
|
|
|
|
CFMutableDictionaryRef getCTStyle() const
|
|
|
|
{
|
|
|
|
return styleDict;
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
fontRef = inRef;
|
|
|
|
|
|
|
|
if (styleDict != NULL)
|
|
|
|
CFRelease(styleDict);
|
|
|
|
|
|
|
|
styleDict = CFDictionaryCreateMutable(NULL, 1, NULL, NULL);
|
|
|
|
|
|
|
|
CFDictionaryAddValue(styleDict, kCTFontAttributeName, fontRef);
|
|
|
|
}
|
|
|
|
|
|
|
|
CTFontRef getFontRef()
|
|
|
|
{
|
|
|
|
return fontRef;
|
|
|
|
}
|
|
|
|
|
2010-07-14 09:47:17 +00:00
|
|
|
private:
|
2011-07-17 22:30:49 +00:00
|
|
|
CFMutableDictionaryRef styleDict;
|
|
|
|
CTFontRef fontRef;
|
2010-07-14 09:47:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|