I'm trying to draw in the currently selected system font using the ATSU api in a Carbon app. And the fonts are coming out bolder than all the other native apps. Here is a screenshot example of what I'm talking about:
The top line is XCode, and the middle is my app using a non-bold font and the bottom is my app using a bold font. I used the same text to make it easy to see the difference in weight between them. The code I'm using to create the styles I draw with is:
if (Face() AND !(e = ATSUCreateStyle(&d->hFont)))
{
// Lookup ID
ATSUFontID atsuFont = 0;
e = ATSUFindFontFromName(Face(),
strlen(Face()),
kFontFamilyName,
(FontPlatformCode)kFontNoPlatform,
(FontScriptCode)kFontNoScript,
(FontLanguageCode)kFontNoLanguage,
&atsuFont);
if (!e)
{
Fixed Size;
Size = PointSize() << 16;
Boolean IsBold = Bold();
Boolean IsItalic = Italic();
Boolean IsUnder = Underline();
// Set style attr
ATSUAttributeTag Tags[] = {kATSUFontTag, kATSUSizeTag, kATSUQDItalicTag, kATSUQDUnderlineTag, kATSUQDBoldfaceTag};
ATSUAttributeValuePtr Values[] = {&atsuFont, &Size, &IsItalic, &IsUnder, &IsBold};
ByteCount Lengths[] = {sizeof(atsuFont), sizeof(Size), sizeof(IsItalic), sizeof(IsUnder), sizeof(IsBold)};
if (!(e = ATSUSetAttributes(d->hFont,
CountOf(Tags),
Tags,
Lengths,
Values)))
{
GDisplayString ds(this, "A");
d->Height = ds.Y();
return true;
}
}
}
Where "Face()" returns a C string containing the font name, "PointSize()" returns an integer containing the point size I want etc etc. I'm retreiving this values with this code:
Str255 Name;
SInt16 Size;
Style St;
OSStatus e = GetThemeFont( kThemeSmallSystemFont,
smSystemScript,
Name,
&Size,
&St);
if (e) printf("%s:%i - GetThemeFont failed with %i\n", __FILE__, __LINE__, e);
else
{
Info.Face(p2c(Name));
Info.PointSize(Size);
Status = true;
}
And it returns valid looking face/pointsize info, and in fact the font looks correct apart from it looking bolder than other apps. It might not look like a big difference but when your entire app is full of text it gets to be obvious. And my flagship product is an email client... hence lots of text.
The drawing code that creates the layouts and eventually calls ATSUDrawText is quite long, and I'm not sure it's causing the issue.. I think it's more style related... but if need by I'll post a link to that source later.
Can anyone help getting my fonts looking less bold?