Forum Xamarin.Forms

san francisco font

I'm relatively new to mobile app development and right now I'm trying to change the current font for a label in my xaml to iOS's relatively new San Francisco font. I've tried using FontFamily="SF" and FontFamily="San Francisco" on my labels to see if it would work but no so far nothing has changed. If someone could post a quick example of using the font it would be greatly appreciated.


Best Answer


  • WindermereWindermere CAMember

    I was under the impression that it was a font that was already built-in. I didn't realize that I should've been treating it as a custom font.

    Thank you!

  • JohnMillerJohnMiller USForum Administrator, Xamarin Team Xamurai

    @Windermere It is the default system font on iOS 9+. Which version of iOS are you testing with?

  • StermsSterms Member
    edited February 2018

    If anyone stumbles upon this, I was able to get San Francisco to work via Xaml like so:

    <OnPlatform x:TypeArguments="x:String" x:Key="BoldFontFamily" Android="sans-serif" iOS=".SFUIText-Bold"/>
    <OnPlatform x:TypeArguments="x:String" x:Key="ThinFontFamily" Android="sans-serif-thin" iOS=".SFUIText-Light"/>
    <OnPlatform x:TypeArguments="x:String" x:Key="DefaultFontFamily" Android="sans-serif" iOS=".SFUIText"/>

    I looked at the meta-data returned by UIFont.SystemFontOfSize() for what the application refers to SF as.

  • mjromkamjromka Member ✭✭

    .SFUIText-* (also tested with .SFUI-*) do not work on iOS 13 anymore. I updated Xamarin to the latest version.
    Any suggestions?

  • rcoconnorrcoconnor Member ✭✭

    @mjromka said:
    .SFUIText-* (also tested with .SFUI-*) do not work on iOS 13 anymore. I updated Xamarin to the latest version.
    Any suggestions?

    @mjromka I'm running into the same issue.. have you found a solution or a resource you could point me towards?

  • rcoconnorrcoconnor Member ✭✭

    UIStringAttributes fontName = new UIStringAttributes(); //Grabbing correct font after iOS 13 update fontName.Font = UIKit.UIFont.PreferredBody; var fontSize = Element.FontSize; string tableStyle = "table{color:white}"; string aStyle = "a{color:grey}"; string htmlContents = $"<span style=\"font-family:'{fontName.Font.FamilyName}'; color:{textColor}; font-size:{fontSize}\"><style>{tableStyle}</style><style>{aStyle}</style>{Element.Text}</span>";

    Using UIStringAttributes then grabbing the FamilyName gave me the sans serif font I was after.

Sign In or Register to comment.