SkFontMgr can't match "Arial Narrow"

658 views
Skip to first unread message

Jim Shi

unread,
Jun 20, 2018, 4:02:44 AM6/20/18
to skia-discuss
Hi all,

today i had a strange problem, I use following code to create typeface from font name:

        sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
        sk_sp<SkTypeface> typeface( fm->matchFamilyStyle(font.GetFamily(), SkFontStyle(SkFontStyle::kNormal_Weight, SkFontStyle::kNormal_Width, SkFontStyle::kUpright_Slant)) );

then i found when font.family is "Arial Narrow", typeface would be nullptr. actually, all other variations in "Arial" (like "Arial black" etc) can't be matched by matchFamilyStyle(), except for the "Arial" itself.

Could you help shed some light on it please? and how should I render text using "Arial Narrow" properly?

Cheers,
Jim

Jim Shi

unread,
Jun 20, 2018, 4:06:12 AM6/20/18
to skia-discuss
Sorry, forgot to mention that i was working on Windows 10.

Hal Canary

unread,
Jun 20, 2018, 2:21:10 PM6/20/18
to skia-discuss
If you take a look at this fiddle:
it will show you how to enumerate all the typefaces accessible to the font mugger.  I suspect you want regular Arial with SkFontStyle::kCondensed_Width or something like that.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

Jim Shi

unread,
Jun 26, 2018, 5:42:54 PM6/26/18
to skia-discuss
Many thanks for your reply Hal.

I tried your suggestion to list all fonts on my Windows 10, and found there's another issue:

First, here is pic shows part of fonts i have on my machine:

Please note, there're fonts named like "Arvo", "Arial Rounded MT" etc, but here is what i've got from Skia's font manager:

As you can see, Skia only reads in "Arial" and then "Bahnschrift", and just ignores many other fonts in system. Could you advise what's the problem could be, and how should i fix it?

Cheers,
Jim
Auto Generated Inline Image 1
Auto Generated Inline Image 2

Hal Canary

unread,
Jun 27, 2018, 9:59:16 AM6/27/18
to skia-discuss
Windows has two different font engines, gdi and directwrite.  According to our local font expert, they have different notions of what a "family" is.

You must be using Skia's directwrite font manager, while Window's file explorer still uses the deprecated gdi API.

I guess that some of those 14 "Arial" typefaces are actually the same as "Arial Rounded MT Bold".

Jim Shi

unread,
Jun 27, 2018, 7:03:08 PM6/27/18
to skia-discuss
thanks Hal.

I ended with implementing of my own font manager reading in font files and use "createFamilyNameIterator" to get alternative font names. so far so good.

another question if i may, i found that when i load font file using "SkTypeface::MakeFromFile", sometime i got "Microsoft C++ exception: CacheOverflowException", for example, when i load "C:\\Windows\\Fonts\\OpenSans-Bold.ttf".  Is this something that your team has been aware of? what could be the solution?

Cheers,
Jim
Reply all
Reply to author
Forward
0 new messages