Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't load Arial Black as SKTypeface on Windows 10 machine #682

Open
washamdev opened this issue Nov 12, 2018 · 7 comments

Comments

@washamdev
Copy link

commented Nov 12, 2018

Description

When specifying the font family name of "Arial Black" on a Windows 10 machine (or Windows Server 2016), SkiaSharp selects "Segoe UI" instead.

Code

SKTypeface tf = SKTypeface.FromFamilyName("Arial Black", SKFontStyleWeight.Bold, SKFontStyleWidth.Normal, SKFontStyleSlant.Upright);

The resulting SKTypeface has these properties:

image

When loading "Arial Black" as a System.Drawing.FontFamily like this:

FontFamily fontFamily = new FontFamily("Arial Black");

It correctly finds the font:

image

Expected Behavior

SkiaSharp should be able to find the "Arial Black" font family.

Actual Behavior

SkiaSharp selects the default "Segoe UI" font family.

Basic Information

  • Version with issue: 1.60.3
  • IDE: Visual Studio
  • Platform Target Frameworks:
    • Windows Classic: .NET Framework 4.7.2

Additional Information

While browsing the Fonts folder in Windows, I noticed that the only font that appears in the main list is "Arial":

image

But when you double-click on "Arial," it then displays "Arial Black" in that list:

image

Does that have something to do with why SkiaSharp can't find that font? But why can System.Drawing.FontFamily find the font, but SkiaSharp can't?

VS bug #735691

@washamdev

This comment has been minimized.

Copy link
Author

commented Nov 12, 2018

For anyone else experiencing the same problem, I realized that the SKFontStyleWeight enum has a Black value. I ended up having to detect if the incoming font family name is "Arial Black", and if so, I change the font family name to "Arial" and set the weight to SKFontStyleWeight.Black. That made the resulting font appear like it was set to Arial Black.

SKFontStyleWeight weight = fontFamilyName == "Arial Black" ? SKFontStyleWeight.Black : SKFontStyleWeight.Normal);
string skiaFontFamilyName = fontFamilyName == "Arial Black" ? "Arial" : fontFamilyName;
SKTypeface tf = SKTypeface.FromFamilyName(skiaFontFamilyName, weight, SKFontStyleWidth.Normal, SKFontStyleSlant.Upright);

The question still remains for me: why can't SkiaSharp handle "Arial Black" but System.Drawing.FontFamily can?

@neodynamic

This comment has been minimized.

Copy link

commented Nov 13, 2018

Have you tried specifying the font name as "Arial-Black"?

@washamdev

This comment has been minimized.

Copy link
Author

commented Nov 13, 2018

@neodynamic, I just tried your suggestion, but it still returned Segoe UI. Thanks for the idea.

@mattleibow

This comment has been minimized.

Copy link
Contributor

commented Nov 13, 2018

This sounds very interesting... I will see what I can find out.
I asked on the forums and we can see what the developers say: https://groups.google.com/forum/#!topic/skia-discuss/56foxa1fCoQ

@mattleibow mattleibow added this to New in Triage Nov 15, 2018
@mattleibow mattleibow moved this from New to Low Priority in Triage Nov 23, 2018
@Gillibald

This comment has been minimized.

Copy link
Contributor

commented Nov 25, 2018

GDI+ handles font families differently it uses different families for styles like narrow or black. DirectWrite or other frameworks just have one FontFamily Arial and uses styles for all different combinations of narrow, black, etc. So Skia`s behavior looks right to me. Browsing the font with the explorer just showed how the font family is organized correctly.

@mattleibow

This comment has been minimized.

Copy link
Contributor

commented Nov 25, 2018

That really the issue here. TECHNICALLY skia is right. But, we are in the old world and it is unexpected. Google mentions that they have an extra layer over the font to read the prefix/suffix to read the weight and spacing: eg "Arial BLACK EXPANDED"

I will have to investigate this further to see if we want to do this in the API or leave it up to the developer. Leave comments and we can discuss.

@sansjunk

This comment has been minimized.

Copy link

commented Dec 11, 2018

I ran into the same issue. My vote is to handle this in SkiaSharp so that the correct family and weight are chosen. Perhaps an additional API SKTypeface.FromName which can do this.

@Redth Redth moved this from Low Priority to Needs Triage in Triage Dec 12, 2018
@mattleibow mattleibow moved this from Needs Triage to Low Priority in Triage Dec 15, 2018
@Redth Redth moved this from Low Priority to Needs Triage in Triage Dec 15, 2018
@mattleibow mattleibow moved this from Needs Triage to High Priority in Triage Dec 18, 2018
@mattleibow mattleibow moved this from High Priority to Low Priority in Triage Dec 18, 2018
@Redth Redth moved this from Low Priority to Needs Triage in Triage Dec 19, 2018
@Redth Redth removed azdo-sync labels Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.