//设置字体样式和大小
NSFont *font =[NSFont fontWithName:@"Helvetica" size:fontsize];
NSString*strTemp = @"TEST";
NSDictionary*attributes = [NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName,[NSColor yellowColor], NSForegroundColorAttributeName,nil];
NSAttributedString* currentText=[[NSAttributedString alloc] initWithString:strTemp attributes:attributes];
NSSizeattrSize = [currentText size];
int pixelsWith= attrSize.width;
intpixelsHight = attrSize.height;