From e893f6bd9db696a1d647b796138233152ca290fa Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 22 Aug 2014 15:22:02 -0700 Subject: Use the Windows default font on Windows 7 and 8/8.1 It contains the characters we need and will make the application look more "native". See #712 Signed-off-by: Dirk Hohndel --- linux.c | 8 +++++++- macos.c | 8 +++++++- pref.h | 3 ++- subsurfacestartup.c | 1 + subsurfacesysinfo.cpp | 8 ++++++++ windows.c | 14 ++++++++++++-- 6 files changed, 37 insertions(+), 5 deletions(-) diff --git a/linux.c b/linux.c index ed063b28c..2e37054a9 100644 --- a/linux.c +++ b/linux.c @@ -12,9 +12,15 @@ #include #include -const char system_divelist_default_font[] = "Sans"; +const char linux_system_divelist_default_font[] = "Sans"; +const char *system_divelist_default_font = linux_system_divelist_default_font; const int system_divelist_default_font_size = 8; +void subsurface_OS_pref_setup(void) +{ + // nothing +} + void subsurface_user_info(struct user_info *user) { struct passwd *pwd = getpwuid(getuid()); diff --git a/macos.c b/macos.c index b75ddbf6f..c51ef9f7b 100644 --- a/macos.c +++ b/macos.c @@ -28,9 +28,15 @@ void subsurface_user_info(struct user_info *info) #define ICON_NAME "Subsurface.icns" #define UI_FONT "Arial 12" -const char system_divelist_default_font[] = "Arial"; +const char mac_system_divelist_default_font[] = "Arial"; +const char *system_divelist_default_font = mac_system_divelist_default_font; const int system_divelist_default_font_size = 10; +void subsurface_OS_pref_setup(void) +{ + // nothing +} + const char *system_default_filename(void) { const char *home, *user; diff --git a/pref.h b/pref.h index 8bde0da80..9076eff99 100644 --- a/pref.h +++ b/pref.h @@ -79,9 +79,10 @@ extern struct preferences prefs, default_prefs; #define PP_GRAPHS_ENABLED (prefs.pp_graphs.po2 || prefs.pp_graphs.pn2 || prefs.pp_graphs.phe) -extern const char system_divelist_default_font[]; +extern const char *system_divelist_default_font; extern const int system_divelist_default_font_size; extern const char *system_default_filename(); +extern void subsurface_OS_pref_setup(); #ifdef __cplusplus } diff --git a/subsurfacestartup.c b/subsurfacestartup.c index 8edc409be..10dacfcba 100644 --- a/subsurfacestartup.c +++ b/subsurfacestartup.c @@ -195,6 +195,7 @@ void setup_system_prefs(void) { const char *env; + subsurface_OS_pref_setup(); default_prefs.divelist_font = strdup(system_divelist_default_font); default_prefs.font_size = system_divelist_default_font_size; default_prefs.default_filename = system_default_filename(); diff --git a/subsurfacesysinfo.cpp b/subsurfacesysinfo.cpp index caa9db8a5..4093654ee 100644 --- a/subsurfacesysinfo.cpp +++ b/subsurfacesysinfo.cpp @@ -479,3 +479,11 @@ QString SubsurfaceSysInfo::osArch() #endif return res; } + +extern "C" { +bool isWin7Or8() +{ + QString os = SubsurfaceSysInfo::prettyOsName(); + return os == "Windows 7" || os.startsWith("Windows 8"); +} +} diff --git a/windows.c b/windows.c index 099ad502e..a4fe1e2c2 100644 --- a/windows.c +++ b/windows.c @@ -12,12 +12,22 @@ #include #include -const char system_divelist_default_font[] = "Calibri"; -const int system_divelist_default_font_size = 8; +const char non_standard_system_divelist_default_font[] = "Calibri"; +const char current_system_divelist_default_font[] = "Segoe UI"; +const char *system_divelist_default_font = non_standard_system_divelist_default_font; +const int system_divelist_default_font_size = 9; void subsurface_user(struct user_info *user) { /* Encourage use of at least libgit2-0.20 */ } +extern bool isWin7Or8(); + +void subsurface_OS_pref_setup(void) +{ + if (isWin7Or8()) + system_divelist_default_font = current_system_divelist_default_font; +} + const char *system_default_filename(void) { char datapath[MAX_PATH]; -- cgit v1.2.3-70-g09d2