Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 395621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:28:20+00:00 2026-05-12T16:28:20+00:00

I’m trying to draw in the currently selected system font using the ATSU api

  • 0

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:


(source: memecode.com)

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:28:20+00:00Added an answer on May 12, 2026 at 4:28 pm

    I’ve converted the cocoa ATSU example code to carbon and ran that alongside my own code. It looked correct so I refined that code and worked out what I was doing differently. Turns out that it’s that initial stage of turning a font face name into an ATSUFontID. Obviously I’m using ATSUFindFontFromName which appears to be totally reasonable, however it looks different to the rest of the operating system. The correct drop in replacement code is:

    CFStringRef fontName = CFStringCreateWithBytes( kCFAllocatorDefault,
                                                    (UInt8*)Face(),
                                                    strlen(Face()),
                                                    kCFStringEncodingUTF8,
                                                    false);
    ATSFontRef atsFont = ATSFontFindFromName(fontName, kATSOptionFlagsDefault);
    CFRelease(fontName);
    ATSUFontID font = FMGetFontFromATSFontRef(atsFont);
    

    So now my apps are looking great 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 231k
  • Answers 231k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Do you want age as people typically understand it, or… May 13, 2026 at 2:07 am
  • Editorial Team
    Editorial Team added an answer Would placing it in an iframe work? May 13, 2026 at 2:07 am
  • Editorial Team
    Editorial Team added an answer A simple foreach loop should suffice: foreach ($array as $key… May 13, 2026 at 2:06 am

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want use html5's new tag to play a wav file (currently only supported
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,
I have a French site that I want to parse, but am running into

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.