mirror of https://github.com/odrling/Aegisub
Get the UI font from CoreText on OS X
This commit is contained in:
parent
1935e77261
commit
85148002bc
|
@ -97,7 +97,7 @@ AudioKaraoke::AudioKaraoke(wxWindow *parent, agi::Context *c)
|
||||||
SetSizerAndFit(main_sizer);
|
SetSizerAndFit(main_sizer);
|
||||||
|
|
||||||
/// @todo subscribe
|
/// @todo subscribe
|
||||||
split_font.SetFaceName(to_wx(OPT_GET("Audio/Karaoke/Font Face")->GetString()));
|
split_font.SetFaceName(FontFace("Audio/Karaoke"));
|
||||||
split_font.SetPointSize(OPT_GET("Audio/Karaoke/Font Size")->GetInt());
|
split_font.SetPointSize(OPT_GET("Audio/Karaoke/Font Size")->GetInt());
|
||||||
|
|
||||||
split_area->Bind(wxEVT_SIZE, &AudioKaraoke::OnSize, this);
|
split_area->Bind(wxEVT_SIZE, &AudioKaraoke::OnSize, this);
|
||||||
|
|
|
@ -225,7 +225,7 @@ void BaseGrid::OnHighlightVisibleChange(agi::OptionValue const& opt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseGrid::UpdateStyle() {
|
void BaseGrid::UpdateStyle() {
|
||||||
wxString fontname = to_wx(OPT_GET("Subtitle/Grid/Font Face")->GetString());
|
wxString fontname = FontFace("Subtitle/Grid");
|
||||||
if (fontname.empty()) fontname = "Tahoma";
|
if (fontname.empty()) fontname = "Tahoma";
|
||||||
font.SetFaceName(fontname);
|
font.SetFaceName(fontname);
|
||||||
font.SetPointSize(OPT_GET("Subtitle/Grid/Font Size")->GetInt());
|
font.SetPointSize(OPT_GET("Subtitle/Grid/Font Size")->GetInt());
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
"Drag Timing" : true,
|
"Drag Timing" : true,
|
||||||
"Inactive Lines Display Mode" : 1,
|
"Inactive Lines Display Mode" : 1,
|
||||||
"Karaoke" : {
|
"Karaoke" : {
|
||||||
"Font Face" : "Lucida Grande",
|
"Font Face" : "",
|
||||||
"Font Size" : 9
|
"Font Size" : 9
|
||||||
},
|
},
|
||||||
"Lead" : {
|
"Lead" : {
|
||||||
|
@ -361,7 +361,7 @@
|
||||||
"Width" : 1280
|
"Width" : 1280
|
||||||
},
|
},
|
||||||
"Edit Box" : {
|
"Edit Box" : {
|
||||||
"Font Face" : "Lucida Grande",
|
"Font Face" : "",
|
||||||
"Font Size" : 13
|
"Font Size" : 13
|
||||||
},
|
},
|
||||||
"Grid" : {
|
"Grid" : {
|
||||||
|
@ -378,7 +378,7 @@
|
||||||
{"bool" : true}
|
{"bool" : true}
|
||||||
],
|
],
|
||||||
"Focus Allow" : true,
|
"Focus Allow" : true,
|
||||||
"Font Face" : "Lucida Grande",
|
"Font Face" : "",
|
||||||
"Font Size" : 12,
|
"Font Size" : 12,
|
||||||
"Hide Overrides" : 1,
|
"Hide Overrides" : 1,
|
||||||
"Hide Overrides Char" : "☀",
|
"Hide Overrides Char" : "☀",
|
||||||
|
|
|
@ -207,7 +207,7 @@ void SubsTextEditCtrl::SetSyntaxStyle(int id, wxFont &font, std::string const& n
|
||||||
void SubsTextEditCtrl::SetStyles() {
|
void SubsTextEditCtrl::SetStyles() {
|
||||||
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||||
font.SetEncoding(wxFONTENCODING_DEFAULT); // this solves problems with some fonts not working properly
|
font.SetEncoding(wxFONTENCODING_DEFAULT); // this solves problems with some fonts not working properly
|
||||||
wxString fontname = to_wx(OPT_GET("Subtitle/Edit Box/Font Face")->GetString());
|
wxString fontname = FontFace("Subtitle/Edit Box");
|
||||||
if (!fontname.empty()) font.SetFaceName(fontname);
|
if (!fontname.empty()) font.SetFaceName(fontname);
|
||||||
font.SetPointSize(OPT_GET("Subtitle/Edit Box/Font Size")->GetInt());
|
font.SetPointSize(OPT_GET("Subtitle/Edit Box/Font Size")->GetInt());
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <libaegisub/util_osx.h>
|
#include <libaegisub/util_osx.h>
|
||||||
|
#include <CoreText/CTFont.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// @brief There shall be no kiB, MiB stuff here Pretty reading of size
|
/// @brief There shall be no kiB, MiB stuff here Pretty reading of size
|
||||||
|
@ -272,6 +273,31 @@ void AddFullScreenButton(wxWindow *) { }
|
||||||
void SetFloatOnParent(wxWindow *) { }
|
void SetFloatOnParent(wxWindow *) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
wxString FontFace(std::string opt_prefix) {
|
||||||
|
opt_prefix += "/Font Face";
|
||||||
|
auto value = OPT_GET(opt_prefix)->GetString();
|
||||||
|
#ifdef __WXOSX_COCOA__
|
||||||
|
if (value.empty()) {
|
||||||
|
auto default_font = CTFontCreateUIFontForLanguage(kCTFontUserFontType, 0, nullptr);
|
||||||
|
auto default_font_name = CTFontCopyPostScriptName(default_font);
|
||||||
|
CFRelease(default_font);
|
||||||
|
|
||||||
|
auto utf8_str = CFStringGetCStringPtr(default_font_name, kCFStringEncodingUTF8);
|
||||||
|
if (utf8_str)
|
||||||
|
value = utf8_str;
|
||||||
|
else {
|
||||||
|
char buffer[1024];
|
||||||
|
CFStringGetCString(default_font_name, buffer, sizeof(buffer), kCFStringEncodingUTF8);
|
||||||
|
buffer[1023] = '\0';
|
||||||
|
value = buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
CFRelease(default_font_name);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return to_wx(value);
|
||||||
|
}
|
||||||
|
|
||||||
agi::fs::path FileSelector(wxString const& message, std::string const& option_name, std::string const& default_filename, std::string const& default_extension, wxString const& wildcard, int flags, wxWindow *parent) {
|
agi::fs::path FileSelector(wxString const& message, std::string const& option_name, std::string const& default_filename, std::string const& default_extension, wxString const& wildcard, int flags, wxWindow *parent) {
|
||||||
wxString path;
|
wxString path;
|
||||||
if (!option_name.empty())
|
if (!option_name.empty())
|
||||||
|
|
|
@ -127,5 +127,7 @@ struct cast {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxString FontFace(std::string opt_prefix);
|
||||||
|
|
||||||
agi::fs::path OpenFileSelector(wxString const& message, std::string const& option_name, std::string const& default_filename, std::string const& default_extension, wxString const& wildcard, wxWindow *parent);
|
agi::fs::path OpenFileSelector(wxString const& message, std::string const& option_name, std::string const& default_filename, std::string const& default_extension, wxString const& wildcard, wxWindow *parent);
|
||||||
agi::fs::path SaveFileSelector(wxString const& message, std::string const& option_name, std::string const& default_filename, std::string const& default_extension, wxString const& wildcard, wxWindow *parent);
|
agi::fs::path SaveFileSelector(wxString const& message, std::string const& option_name, std::string const& default_filename, std::string const& default_extension, wxString const& wildcard, wxWindow *parent);
|
||||||
|
|
Loading…
Reference in New Issue