mono / libgdiplus

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

Font families (with multiple names) have unexpected names and render using incorrect font #733

Open handerss-spotfire opened 2 years ago

handerss-spotfire commented 2 years ago

(This is using libgdiplus built from main with Pango as backend)

GdipGetFamilyName is different between libgdiplus and GDI+ for fonts which define multiple family names. One such example is the Roboto font family (available here: https://fonts.google.com/specimen/Roboto) where all Roboto fonts use "Roboto" as the first family value. So the font "Roboto-Black.ttf" shows up as "Roboto Black" on GDI+, and as "Roboto" on libgdiplus.

A possible solution may be to always pick the final FC_FAMILY value?

Another related issue is that while GdipCreateFontFamilyFromName("Roboto Black", nil, &ff) does find the correct font, however it is later passed to the pango backend via pango_font_description_set_family (font->pango, (char *)font->face);, which results in the incorrect font being used since font->face is "Roboto". If Pango is 1.4 or above pango_fc_font_description_from_pattern could be used instead ensure that the same font is used. However, I'm guessing that fixing the issue with the incorrect font name alleviates this second issue.