mono / libgdiplus

C-based implementation of the GDI+ API
http://www.mono-project.com/
MIT License
329 stars 171 forks source link

GdipGetFontCollectionFamilyList does not correctly identify font families #692

Open trungnt2910 opened 3 years ago

trungnt2910 commented 3 years ago

I am embedding the Open Sans font family (downloaded on Google Fonts) in my Windows Forms application.

To use these fonts, I've added each .ttf file to a PrivateFontCollection. After adding these fonts, I display all the font families by showing string.Join("\n", fontCollection.Families.Select(f => f.Name)).

On Windows, using .NET Framework 4.8, it correctly displays 4 Font families:

Open Sans
Open Sans ExtraBold
Open Sans Light
Open Sans SemiBold

(None of the Windows applications seem to recognize ExtraBold, Light, SemiBold as the same font family).

However, using the latest version of Mono, with the latest build of libgdiplus fetched from master, on Ubuntu 20.04, it shows:

Open Sans
Open Sans
Open Sans
Open Sans
Open Sans
Open Sans
Open Sans
Open Sans
Open Sans
Open Sans

(One different family for each font, although the library correctly recognize them all as Open Sans).

This makes my app unable to distinguish between Open Sans variants on Linux. Also, creating a Font with one of these families, and applying FontStyle.Bold has no effects.