[Kazehakase-cvs] kazehakase-svn [3004] * module/embed/gtk-webcore/kz-gtk-webcore.cpp: Set font settings.

Zurück zum Archiv-Index

svnno****@sourc***** svnno****@sourc*****
Sun Mar 25 18:38:57 JST 2007


Revision: 3004
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3004
Author:   ikezoe
Date:     2007-03-25 18:38:56 +0900 (Sun, 25 Mar 2007)

Log Message:
-----------
* module/embed/gtk-webcore/kz-gtk-webcore.cpp: Set font settings.

Modified Paths:
--------------
    kazehakase/trunk/ChangeLog
    kazehakase/trunk/module/embed/gtk-webcore/kz-gtk-webcore.cpp

Modified: kazehakase/trunk/ChangeLog
===================================================================
--- kazehakase/trunk/ChangeLog	2007-03-25 05:56:56 UTC (rev 3003)
+++ kazehakase/trunk/ChangeLog	2007-03-25 09:38:56 UTC (rev 3004)
@@ -13,6 +13,7 @@
 	preferences. Handle (set|get)_javascript.
 	* module/embed/gtk-webcore/kz-gtk-webcore.cpp: Implement
 	(get|set)_allow_image.
+	* module/embed/gtk-webcore/kz-gtk-webcore.cpp: Set font settings.
 
 2007-03-24  Kouhei Sutou  <kou****@cozmi*****>
 

Modified: kazehakase/trunk/module/embed/gtk-webcore/kz-gtk-webcore.cpp
===================================================================
--- kazehakase/trunk/module/embed/gtk-webcore/kz-gtk-webcore.cpp	2007-03-25 05:56:56 UTC (rev 3003)
+++ kazehakase/trunk/module/embed/gtk-webcore/kz-gtk-webcore.cpp	2007-03-25 09:38:56 UTC (rev 3004)
@@ -372,6 +372,121 @@
 }
 
 static void
+set_font_preferences (KzProfile *profile, OSB::Preferences *preferences)
+{
+	/* font settings */
+	GList *list, *node;
+	gint i = 0;
+	gint size_variable = -1, size_fixed = -1;
+	gint min_size_variable = -1, min_size_fixed = -1;
+
+	/* wordaround */
+	gchar langs[1024], *lang = NULL;
+	if (kz_profile_get_value(profile, "Language", "accept_languages", 
+				&langs, G_N_ELEMENTS(langs),
+				KZ_PROFILE_VALUE_TYPE_STRING))
+	{
+		gchar **split_str;
+		split_str = g_strsplit(langs, ",", 1);
+
+		if (split_str[0])
+		{
+			lang = g_strdup(split_str[0]);
+			g_strfreev(split_str);
+		}
+	}
+	if (!lang)
+		lang = g_strdup("");
+
+	gchar *serif_font, *sans_font, *mono_font;
+	serif_font = g_strdup_printf("name_serif_%s", lang);
+	sans_font = g_strdup_printf("name_sans-serif_%s", lang);
+	mono_font = g_strdup_printf("name_monospace_%s", lang);
+
+	list = kz_profile_enum_key(profile, "Font", TRUE);
+	for (node = list; node; node = g_list_next(node))
+	{
+		const gchar *key = (const gchar*)node->data;
+
+		if (!key || !*key) continue;
+		if (g_str_has_prefix(key, "size_variable_"))
+		{
+			gint value;
+			kz_profile_get_value(profile, "Font", key,
+					&value, sizeof(value),
+					KZ_PROFILE_VALUE_TYPE_INT);
+			if (value > size_variable)
+				size_variable = value;
+		}
+		else if (g_str_has_prefix(key, "size_fixed_"))
+		{
+			gint value;
+			kz_profile_get_value(profile, "Font", key,
+					&value, sizeof(value),
+					KZ_PROFILE_VALUE_TYPE_INT);
+			if (value > size_fixed)
+				size_fixed = value;
+		}
+		else if (g_str_has_prefix(key, "min-size_variable_"))
+		{
+			gint value;
+			kz_profile_get_value(profile, "Font", key,
+					&value, sizeof(value),
+					KZ_PROFILE_VALUE_TYPE_INT);
+			if (value > min_size_variable)
+				min_size_variable = value;
+		}
+		else if (g_str_has_prefix(key, "min-size_fixed_"))
+		{
+			gint value;
+			kz_profile_get_value(profile, "Font", key,
+					&value, sizeof(value),
+					KZ_PROFILE_VALUE_TYPE_INT);
+			if (value > min_size_fixed)
+				min_size_fixed = value;
+		}
+		else if (!strcmp(key, serif_font))
+		{
+			gchar value[1024];
+			kz_profile_get_value(profile, "Font", key,
+					&value, strlen(value)+1,
+					KZ_PROFILE_VALUE_TYPE_STRING);
+			preferences->setSerifFontFamily(value);
+			preferences->setStandardFontFamily(value);
+		}
+		else if (!strcmp(key, sans_font))
+		{
+			gchar value[1024];
+			kz_profile_get_value(profile, "Font", key,
+					&value, strlen(value)+1,
+					KZ_PROFILE_VALUE_TYPE_STRING);
+			preferences->setSansSerifFontFamily(value);
+		}
+		else if (!strcmp(key, mono_font))
+		{
+			gchar value[1024];
+			kz_profile_get_value(profile, "Font", key,
+					&value, strlen(value)+1,
+					KZ_PROFILE_VALUE_TYPE_STRING);
+			preferences->setFixedFontFamily(value);
+		}
+	}
+	g_list_free(list);
+	g_free(serif_font);
+	g_free(sans_font);
+	g_free(mono_font);
+
+	if (size_variable >= 0)
+		preferences->setDefaultFontSize((float)size_variable);
+	if (size_fixed >= 0)
+		preferences->setDefaultFixedFontSize((float)size_fixed);
+	if (min_size_variable >= 0)
+		preferences->setMinimumLogicalFontSize((float)min_size_variable);
+	if (min_size_fixed >= 0)
+		preferences->setMinimumFontSize((float)min_size_fixed);
+}
+
+static void
 set_default_preferences (KzGtkWebcore *gtk_webcore)
 {
 	KzProfile *profile;
@@ -386,6 +501,8 @@
 	{
 		preferences->setDefaultTextEncoding(value);
 	}
+
+	set_font_preferences (profile, preferences);
 }
 
 static void




More information about the Kazehakase-cvs mailing list
Zurück zum Archiv-Index