Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#15410 closed defect (fixed)

wxFontList doesn't correctly match existing fonts

Reported by: eco Owned by:
Priority: normal Milestone:
Component: base Version:
Keywords: Cc:
Blocked By: Blocking:
Patch: yes


On WXGTK there is a specialization in wxFontList::FindOrCreateFont to match when the font family is wxFONTFAMILY_DEFAULT and the font from the existing list is wxFONTFAMILY_SWISS but all other platforms just compare font family directly (with a note by VZ wondering why the other platforms don't use the same logic as GTK). On Windows the exact same issue happens where SWISS is the default font family.

This led to fonts often not matching and identical fonts being added over and over to the font list. On Windows this can exhaust GDI resources and cause some nasty program drawing corruptions and crashes.

Attached is a patch in which I've simply made all platforms follow the same logic as the WXGTK specialization. My software no longer slows down and eventually crashes as GDI resources get exhausted.

Attachments (1)

fix_non-gtk_font_list.patch download (1.1 KB) - added by eco 2 years ago.
Treat SWISS as the default font family

Download all attachments as: .zip

Change History (4)

Changed 2 years ago by eco

Treat SWISS as the default font family

comment:1 Changed 2 years ago by vadz

Unfortunately wxFONTFAMILY_SWISS doesn't seem to be the default under OS X where it's mapped to "Helvetica" while wxFONTFAMILY_DEFAULT is "Lucida Grande" (interestingly enough, in the old Cocoa port they were mapped to "Lucida Grande" and "Times", respectively). So at best we can do this for non-OSX ports and I'll commit this for now...

comment:2 Changed 2 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [74660]) Replace wxFONTFAMILY_DEFAULT with wxFONTFAMILY_SWISS when comparing fonts.

Otherwise comparison always failed as no existing fonts had
wxFONTFAMILY_DEFAULT as their family in all ports except wxOSX, which does

Closes #15410.

comment:3 Changed 2 years ago by eco


Note: See TracTickets for help on using tickets.