- int const item = _fonts->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
- string const id = wx_to_std (_fonts->GetItemText (item, 0));
- shared_ptr<Font> font;
- BOOST_FOREACH (shared_ptr<Font> i, caption->fonts()) {
- if (i->id() == id) {
- font = i;
- }
+ /* The wxFD_CHANGE_DIR here prevents a `could not set working directory' error 123 on Windows when using
+ non-Latin filenames or paths.
+ */
+ wxString default_dir = "";
+#ifdef DCPOMATIC_LINUX
+ if (dcp::filesystem::exists("/usr/share/fonts/truetype")) {
+ default_dir = "/usr/share/fonts/truetype";
+ } else {
+ default_dir = "/usr/share/fonts";
+ }
+#endif
+#ifdef DCPOMATIC_OSX
+ default_dir = "/System/Library/Fonts";
+#endif
+
+ auto d = make_wx<wxFileDialog>(this, _("Choose a font file"), default_dir, wxT(""), wxT("*.ttf;*.otf;*.ttc"), wxFD_CHANGE_DIR);
+
+ if (d->ShowModal() != wxID_OK) {
+ return;