Using San Francisco Font Weights

Maybe this is incredibly easy and I’m just completely missing it, but does anyone have any tips on how to use the various weights of the San Francisco font? I have a need to use San Francisco Display Black in an UI element and I cannot for the life of me figure out how to get it.

I’d appreciate any pointers!

Maybe like this:
control.FontName = "SFProDisplay-Black"

Thanks for the suggestion! Unfortunately, that’s not it. It just gives me standard San Francisco.

I have a method as part of the Ohanaware App Kit which takes the font weight and returns a font name that works with Xojo.

Thanks Sam! I looked in the latest App Kit release and think I found to what you were referring. Unfortunately, I still don’t know how to refer to San Francisco specifically. However, I’m now thinking maybe that was the wrong approach. One thing I did find in App Kit was a reference to .AppleSystemUIFontHeavy. When I use that as the font name, I get exactly what I was looking for. It seems to work fine, at least in initial tests.

Thanks for pointing me in the right direction!

1 Like

I am sorry for not being clear Scott, I am gald that my rather vague directions got you there.

This is what I use to get a heavier font weight in the UI.
me.textFont = NSFontSystemFontName( NSFontWeightMedium, 13, false )

It is weird, but I think it’s done that way so you’ll get whatever the system font is.

That methodology does make complete sense. Apple’s changed system fonts a number of times over the years. Hard-coding the font doesn’t make sense. Obviously, why Xojo provides “System” as a font. Just doesn’t have the various weights. Your method does.

1 Like

For completeness: If people are displaying HTML content and want to use the same system font. The following CSS will help.

font-family: -apple-system;