Skip to content

[BUG] On Android, SKTypeface.FromFamilyName returns either serif or sans serif for installed font. #3283

Open
@DanTravison

Description

@DanTravison

Description

I'm hitting this issue on Android.

  • I'm calling SKFontManager.Default.GetFontFamilies() to enumerate the available fonts.
  • Later, I'm calling SKTypeface.FromFamilyName(name, SKFontStyle) with a name returned from GetFontFamilies
  • The returned SKTypeface.FamilyName does not match the requested font.
  • I call a second time using SKTypeface.FromFamilyName(string name) and get the same result.

For example, on the Android simulator, 'georgia' is returned from GetFontFamilies yet both calls to SKTypeface.FromFamilyName return an SKTypeface with FamilyName = 'serif'.

The only fonts that return the expected FontFamily are the various sans serif/serif fonts. All the others either return sans-serif, sans, or monospace.

I don't see this issue on Windows and have not tested yet tested on IOS or MacCatalyst.

Code

The best way to share code for larger projects is a link to a GitHub repository: https://github.com/user/repo/tree/bug-123

But, you can also share a short block of code here:

// some C# code here

You can also share some XAML:

<!-- xaml code here -->

Expected Behavior

SKTypeface.FromFontFamily should return the expected font when using a named returned FontManager.GetFontFamilies

Actual Behavior

Other than the family of serif fonts, calling SKTypeface.FromFontFamily appears to fallback to sans, sans-serif or monospaced.

Version of SkiaSharp

3.116.0 (Current)

Last Known Good Version of SkiaSharp

2.88.9 (Previous)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Android

Platform / Operating System Version

Android 13
.Net 9.0
Maui 9.0.50
SkiaSharp 3.116.1

Devices

Android Emulator

Relevant Screenshots

Image

Relevant Log Output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions