aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-04-16 05:41:15 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-04-16 05:41:15 +0000
commit839719a70498485a26889ee86086e768ead87d1b (patch)
tree3cebaabeab426e1982639647da93b57438794499
parent16de7229895d8c8da1ed334a2b638d1795c51626 (diff)
win32: check for the loadability of the default font.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1637 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog8
-rw-r--r--ChangeLog.ja8
-rw-r--r--libsylph/prefs_common.c9
-rw-r--r--src/gtkutils.c30
-rw-r--r--src/gtkutils.h2
-rw-r--r--src/main.c28
6 files changed, 76 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index e4aa9c3e..9f393e22 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-04-16
+
+ * libsylph/prefs_common.c
+ src/gtkutils.[ch]
+ src/main.c: win32: check if the font "MS Gothic 12" is really
+ loadable. Also check for multi-byte font name for the new JIS2004
+ MS Gothic font.
+
2007-04-13
* libsylph/utils.c: copy_file(): optimized using read() / write().
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 26013f29..1ff4b7d7 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,3 +1,11 @@
+2007-04-16
+
+ * libsylph/prefs_common.c
+ src/gtkutils.[ch]
+ src/main.c: win32: フォント "MS Gothic 12" が実際に読み込めるか
+ どうかをチェックするようにした。また、新しい JIS2004 MS Gothic
+ フォントのためにマルチバイトフォント名もチェックするようにした。
+
2007-04-13
* libsylph/utils.c: copy_file(): read() / write() を使用して最適化。
diff --git a/libsylph/prefs_common.c b/libsylph/prefs_common.c
index 4088e5f3..390f80f2 100644
--- a/libsylph/prefs_common.c
+++ b/libsylph/prefs_common.c
@@ -426,15 +426,6 @@ void prefs_common_read_config(void)
prefs_read_config(param, "Common", path, NULL);
-#ifdef G_OS_WIN32
- if (!is_file_exist(path)) {
- if (conv_is_ja_locale()) {
- g_free(prefs_common.textfont);
- prefs_common.textfont = g_strdup("MS Gothic 12");
- }
- }
-#endif
-
g_free(path);
prefs_common.online_mode = TRUE;
diff --git a/src/gtkutils.c b/src/gtkutils.c
index 585e75d3..9294587b 100644
--- a/src/gtkutils.c
+++ b/src/gtkutils.c
@@ -42,6 +42,10 @@
#include <stdlib.h>
#include <stdarg.h>
+#ifdef G_OS_WIN32
+# include <pango/pangowin32.h>
+#endif
+
#include "gtkutils.h"
#include "utils.h"
#include "codeconv.h"
@@ -106,6 +110,32 @@ void gtkut_widget_set_small_font_size(GtkWidget *widget)
pango_font_description_free(font_desc);
}
+gboolean gtkut_font_can_load(const gchar *str)
+{
+#ifdef G_OS_WIN32
+ PangoFontDescription *desc;
+ PangoContext *context;
+ PangoFont *font;
+ gboolean can_load = FALSE;
+
+ desc = pango_font_description_from_string(str);
+ if (desc) {
+ context = pango_win32_get_context();
+ font = pango_context_load_font(context, desc);
+ if (font) {
+ can_load = TRUE;
+ g_object_unref(font);
+ }
+ g_object_unref(context);
+ pango_font_description_free(desc);
+ }
+
+ return can_load;
+#else
+ return FALSE;
+#endif
+}
+
void gtkut_convert_int_to_gdk_color(gint rgbvalue, GdkColor *color)
{
g_return_if_fail(color != NULL);
diff --git a/src/gtkutils.h b/src/gtkutils.h
index d7e18c5c..ea5ff429 100644
--- a/src/gtkutils.h
+++ b/src/gtkutils.h
@@ -93,6 +93,8 @@ PangoFontDescription *gtkut_get_default_font_desc
(void);
void gtkut_widget_set_small_font_size (GtkWidget *widget);
+gboolean gtkut_font_can_load (const gchar *str);
+
void gtkut_convert_int_to_gdk_color (gint rgbvalue,
GdkColor *color);
diff --git a/src/main.c b/src/main.c
index 129a17aa..95debba6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -225,6 +225,34 @@ int main(int argc, char *argv[])
prefs_actions_read_config();
prefs_display_header_read_config();
+#ifdef G_OS_WIN32
+ {
+ gchar *path;
+ path = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC,
+ NULL);
+ if (!is_file_exist(path) && conv_is_ja_locale()) {
+ const gchar *str;
+
+ debug_print("fixing prefs_common.textfont setting\n");
+ str = "MS Gothic 12";
+ if (!gtkut_font_can_load(str)) {
+ debug_print("font '%s' load failed\n", str);
+ str = "\xef\xbc\xad\xef\xbc\xb3 \xe3\x82\xb4\xe3\x82\xb7\xe3\x83\x83\xe3\x82\xaf 12";
+ if (!gtkut_font_can_load(str)) {
+ debug_print("font '%s' load failed\n", str);
+ str = NULL;
+ }
+ }
+ if (str) {
+ debug_print("font '%s' load ok\n", str);
+ g_free(prefs_common.textfont);
+ prefs_common.textfont = g_strdup(str);
+ }
+ }
+ g_free(path);
+ }
+#endif
+
gtkut_stock_button_set_set_reverse(!prefs_common.comply_gnome_hig);
check_gpg();