From adb8bbab4d3d24dfd9502ca719e98d0ea2e01c63 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 12 May 2022 16:31:40 +0100 Subject: [PATCH] Sort font names in the dialog showing them in the font sample This makes the list of the fonts much more readable, compared to listing them in essentially random order. Incidentally stop using manual memory allocation to avoid giving a bad example. --- samples/font/font.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/samples/font/font.cpp b/samples/font/font.cpp index e0f169b8c4..cbe28f8051 100644 --- a/samples/font/font.cpp +++ b/samples/font/font.cpp @@ -648,24 +648,22 @@ bool MyFrame::DoEnumerateFamilies(bool fixedWidthOnly, else { // let the user choose - wxString *facenames = new wxString[nFacenames]; + wxSortedArrayString facenames; + facenames.Alloc(nFacenames); int n; for ( n = 0; n < nFacenames; n++ ) - facenames[n] = fontEnumerator.GetFacenames().Item(n); + facenames.Add(fontEnumerator.GetFacenames().Item(n)); n = wxGetSingleChoiceIndex ( "Choose a facename", GetSampleTitle(), - nFacenames, facenames, this ); if ( n != -1 ) facename = facenames[n]; - - delete [] facenames; } if ( !facename.empty() )