[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][TOP]

eel patch


あかがきです。

eel-font-manager でかっこわるく 日本語 ttf を選択させるパッチ
(eel-1.0-font.patch)
eel で随所で mb string の途中でおりかえしてくれるのを直したつもりのパッチ
(eel-1.0-wc.patch)
eel-smooth-text-layout で同じく mb string をぶちきられないようにするパッチ
(eel-1.0-wordwrap.patch)
です。

とくに3番目のもののデキの悪さはすばらしいものがあるのですが、
もんでください...
diff -uNr eel-1.0.orig/eel/Makefile.in eel-1.0/eel/Makefile.in
--- eel-1.0.orig/eel/Makefile.in	Tue May  8 08:13:34 2001
+++ eel-1.0/eel/Makefile.in	Wed May  9 18:38:30 2001
@@ -209,7 +209,7 @@
 DEFS = @DEFS@ -I. -I$(srcdir) -I..
 CPPFLAGS = @CPPFLAGS@
 LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
+LIBS = @LIBS@ -lesd
 libeel_la_LIBADD = 
 libeel_la_OBJECTS =  eel-art-extensions.lo eel-art-gtk-extensions.lo \
 eel-background-canvas-group.lo eel-background.lo eel-canvas-rect.lo \
diff -uNr eel-1.0.orig/eel/eel-font-manager.c eel-1.0/eel/eel-font-manager.c
--- eel-1.0.orig/eel/eel-font-manager.c	Sat Apr 21 00:03:29 2001
+++ eel-1.0/eel/eel-font-manager.c	Wed May  9 18:51:30 2001
@@ -33,6 +33,7 @@
 #include <libgnome/gnome-util.h>
 #include <ctype.h>
 #include <stdio.h>
+#include <unistd.h>
 #include <sys/stat.h>
 #include <libgnomevfs/gnome-vfs.h>
 
@@ -77,8 +78,8 @@
 	"Symbol",
 	"Standard Symbols L"
 	"cursor",
-	"mincho",
-	"gothic",
+//	"mincho",
+//	"gothic",
 	"MS Reference 2",
 	"MS Reference 1",
 	"Marlett",
@@ -97,7 +98,7 @@
 };
 
 static const char *ignored_font_dir_suffices[] = {
-	"unscaled",
+//	"unscaled",
 	"100dpi",
 	"75dpi",
 	"misc",
@@ -1141,6 +1142,16 @@
 	}
 	g_free (user_font_dir);
 
+	if (g_file_test ("/usr/X11R6/lib/X11/fonts/truetype-ja", G_FILE_TEST_ISDIR)) {
+		font_manager_collect_font_tables ("/usr/X11R6/lib/X11/fonts/truetype-ja", &global_font_table);
+	}
+	if (g_file_test ("/usr/X11R6/lib/X11/fonts/DynaLab-Kondara", G_FILE_TEST_ISDIR)) {
+		font_manager_collect_font_tables ("/usr/X11R6/lib/X11/fonts/DynaLab-Kondara", &global_font_table);
+	}
+	if (g_file_test ("/usr/X11R6/lib/X11/fonts/truetype-ko", G_FILE_TEST_ISDIR)) {
+		font_manager_collect_font_tables ("/usr/X11R6/lib/X11/fonts/truetype-ko", &global_font_table);
+	}
+
 	/* Populate the system font table if needed - using the font server's configuration */
 	if (!try_using_font_server (global_font_table)) {
 		/* If that didnt work, then fallback to the directories known at configure time. */
@@ -1210,12 +1221,27 @@
 eel_font_manager_get_default_font (void)
 {
 	guint i;
+	char* lang=getenv("LANG");
+
 
 	static const char *default_fonts[] = {
 		DEFAULT_FONT_DIRECTORY "/" DEFAULT_FONT,
 		SOURCE_FONT_DIRECTORY "/" DEFAULT_FONT
 	};
 
+	if(lang&&strlen(lang)>=2){
+		if(!strncmp(lang,"ja",2)){
+			if (g_file_exists ("/usr/X11R6/lib/X11/fonts/truetype-ja/kochi-mincho.ttf"))
+				return g_strdup ("/usr/X11R6/lib/X11/fonts/truetype-ja/kochi-mincho.ttf");
+			if (g_file_exists ("/usr/X11R6/lib/X11/fonts/DynaLab-Kondara/DFGotP3.ttc"))
+				return g_strdup ("/usr/X11R6/lib/X11/fonts/DynaLab-Kondara/DFGotP3.ttc");
+		}
+		else if(!strncmp(lang,"ko",2)){
+			if (g_file_exists ("/usr/X11R6/lib/X11/fonts/truetype-ko/batabg.ttf"))
+				return g_strdup ("/usr/X11R6/lib/X11/fonts/truetype-ko/batabg.ttf");
+		}
+	}
+
 	for (i = 0; i < EEL_N_ELEMENTS (default_fonts); i++) {
 		if (g_file_exists (default_fonts[i])) {
 			return g_strdup (default_fonts[i]);
@@ -1233,12 +1259,17 @@
 eel_font_manager_get_default_bold_font (void)
 {
 	guint i;
+	char* lang=getenv("LANG");
 
 	static const char *default_bold_fonts[] = {
 		DEFAULT_FONT_DIRECTORY "/" DEFAULT_BOLD_FONT,
 		SOURCE_FONT_DIRECTORY "/" DEFAULT_BOLD_FONT
 	};
 
+	if(lang&&strlen(lang)>=2)
+		if(!strncmp(lang,"ja",2)||!strncmp(lang,"ko",2))
+			return eel_font_manager_get_default_font();
+
 	for (i = 0; i < EEL_N_ELEMENTS (default_bold_fonts); i++) {
 		if (g_file_exists (default_bold_fonts[i])) {
 			return g_strdup (default_bold_fonts[i]);
@@ -1252,15 +1283,34 @@
 eel_font_manager_file_is_scalable_font (const char *file_name)
 {
 	gboolean is_scalable_font = FALSE;
-	char *uri;
+	char *uri,*buf;
 	GnomeVFSFileInfo *info;
 	GnomeVFSResult result;
+	struct stat stat_buf;
 	
 	g_return_val_if_fail (eel_strlen (file_name) > 0, FALSE);
 
 	gnome_vfs_init_if_needed ();
 
-	uri = g_strconcat ("file://", file_name, NULL);
+	if(file_name[0]!='/')
+		buf=g_strconcat("/",file_name);
+	else
+		buf=g_strdup(file_name);
+
+	lstat(buf,&stat_buf);
+	if(S_ISLNK(stat_buf.st_mode)){
+		char lnb[1024];
+		int lnl;
+		lnl=readlink(buf,lnb,1024);
+		g_free(buf);
+		if(lnl>1023)
+			return FALSE;
+		lnb[lnl]=0;
+		buf=g_strdup(lnb);
+	}
+
+	uri = g_strconcat ("file://", buf, NULL);
+	g_free(buf);
 
 	info = gnome_vfs_file_info_new ();
 	result = gnome_vfs_get_file_info (uri, info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE);
diff -uNr eel-1.0.orig/eel/eel-gdk-font-extensions.c eel-1.0/eel/eel-gdk-font-extensions.c
--- eel-1.0.orig/eel/eel-gdk-font-extensions.c	Wed Apr 18 05:05:12 2001
+++ eel-1.0/eel/eel-gdk-font-extensions.c	Fri May 11 14:26:57 2001
@@ -645,6 +645,9 @@
 {
 	int truncate_offset;
 	int resulting_width;
+	GdkWChar* wc_str;
+	int original_length;
+	gchar* mb,*result;
 
 	resulting_width = gdk_string_width (font, string);
 	if (resulting_width <= width) {
@@ -661,25 +664,32 @@
 		return g_strdup ("");
 	}
 	
-	g_assert (strlen (string) > 0);
+	wc_str=g_new0(GdkWChar,strlen(string)+1);
+	original_length = gdk_mbstowcs(wc_str,string,(strlen(string)+1)*sizeof(GdkWChar));
+
+	g_assert (original_length > 0);
 
 	/* We rely on the fact that GdkFont does not use kerning and that
 	 * gdk_string_width ("foo") + gdk_string_width ("bar") ==
 	 * gdk_string_width ("foobar")
 	 */
         for (truncate_offset = 1; ; truncate_offset++) {
-        	if (string[truncate_offset] == '\0') {
+        	if (wc_str[truncate_offset] == 0) {
 			break;
         	}
 
-        	resulting_width -= gdk_char_width (font, string[truncate_offset - 1]);
+        	resulting_width -= gdk_char_width_wc (font, wc_str[truncate_offset - 1]);
 
         	if (resulting_width <= width) {
 			break;
         	}
         }
 
-	return g_strconcat (ELLIPSIS, string + truncate_offset, NULL);
+	mb=gdk_wcstombs(wc_str+truncate_offset);
+	result= g_strconcat (ELLIPSIS, mb, NULL);
+	g_free(wc_str);
+	g_free(mb);
+	return result;
 }
 
 static char *
@@ -688,6 +698,9 @@
 	int truncated_length;
 	char *result;
 	int resulting_width;
+	GdkWChar* wc_str;
+	int original_length;
+	gchar* mb;
 
 	resulting_width = gdk_string_width (font, string);
 	if (resulting_width <= width) {
@@ -704,16 +717,22 @@
 		return g_strdup ("");
 	}
 	
-        for (truncated_length = strlen (string) - 1; truncated_length > 0; truncated_length--) {
-        	resulting_width -= gdk_char_width (font, string[truncated_length]);
+	wc_str=g_new0(GdkWChar,strlen(string)+1);
+	original_length = gdk_mbstowcs(wc_str,string,(strlen(string)+1)*sizeof(GdkWChar));
+
+        for (truncated_length = original_length - 1; truncated_length > 0; truncated_length--) {
+        	resulting_width -= gdk_char_width_wc (font, wc_str[truncated_length]);
         	if (resulting_width <= width) {
 			break;
         	}
         }
-	
-	result = g_malloc (truncated_length + strlen (ELLIPSIS) + 1);
-	memcpy (result, string, truncated_length);
-	strcpy (result + truncated_length, ELLIPSIS);
+
+	wc_str[truncated_length]=0;
+	mb=gdk_wcstombs(wc_str);
+
+	result = g_strconcat(mb,ELLIPSIS,NULL);	
+	g_free(wc_str);
+	g_free(mb);
 
 	return result;
 }
@@ -726,6 +745,8 @@
 	int ending_fragment_offset;
 	int resulting_width;
 	char *result;
+	GdkWChar* wc_str;
+	gchar* mb1,*mb2;
 
 	resulting_width = gdk_string_width (font, string);
 	if (resulting_width <= width) {
@@ -735,16 +756,15 @@
 	
 	/* Account for the width of the ellipsis. */
 	width -= gdk_string_width (font, ELLIPSIS);
-	
 
 	if (width < 0) {
 		/* No room even for a an ellipsis. */
 		return g_strdup ("");
 	}
 
-	/* Split the original string into two halves */
-	original_length = strlen (string);
-	
+	wc_str=g_new0(GdkWChar,strlen(string)+1);
+	original_length = gdk_mbstowcs(wc_str,string,(strlen(string)+1)*sizeof(GdkWChar));
+
 	g_assert (original_length > 0);
 	
 	starting_fragment_length = original_length / 2;
@@ -753,7 +773,7 @@
 	/* Shave off a character at a time from the first and the second half
 	 * until we can fit
 	 */
-	resulting_width -= gdk_char_width (font, string[ending_fragment_offset - 1]);
+	resulting_width -= gdk_char_width_wc (font, wc_str[ending_fragment_offset - 1]);
 	
 	/* depending on whether the original string length is odd or even, start by
 	 * shaving off the characters from the starting or ending fragment
@@ -768,7 +788,7 @@
 			if (starting_fragment_length > 0) {
 				starting_fragment_length--;
 			}
-			resulting_width -= gdk_char_width (font, string[starting_fragment_length]);
+			resulting_width -= gdk_char_width_wc (font, wc_str[starting_fragment_length]);
 	case 1:
 			if (resulting_width <= width) {
 				break;
@@ -777,16 +797,19 @@
 			if (ending_fragment_offset < original_length) {
 				ending_fragment_offset++;
 			}
-			resulting_width -= gdk_char_width (font, string[ending_fragment_offset - 1]);
+			resulting_width -= gdk_char_width_wc (font, wc_str[ending_fragment_offset - 1]);
 	        }
 	}
-	
-	/* patch the two fragments together with an ellipsis */
-	result = g_malloc (starting_fragment_length + (original_length - ending_fragment_offset)
-		+ strlen (ELLIPSIS) + 1);
-	memcpy (result, string, starting_fragment_length);
-	strcpy (result + starting_fragment_length, ELLIPSIS);
-	strcpy (result + starting_fragment_length + strlen (ELLIPSIS), string + ending_fragment_offset);
+
+	wc_str[starting_fragment_length]=0;
+	mb1=gdk_wcstombs(wc_str);
+	mb2=gdk_wcstombs(wc_str+ending_fragment_offset);
+
+	result=g_strconcat(mb1,ELLIPSIS,mb2,NULL);
+
+	g_free(wc_str);
+	g_free(mb1);
+	g_free(mb2);
 
 	return result;
 }
diff -uNr eel-1.0.orig/eel/eel-list-column-title.c eel-1.0/eel/eel-list-column-title.c
--- eel-1.0.orig/eel/eel-list-column-title.c	Tue Apr 10 05:42:27 2001
+++ eel-1.0/eel/eel-list-column-title.c	Fri May 11 14:44:42 2001
@@ -376,6 +376,9 @@
 	int length;
 	int trimmed_length;
 	char *result;
+	GdkWChar* wc_str;
+	int wc_len;
+	gchar* mb;
 
 	length = strlen (string);
 	current_width = gdk_text_width (font, string, length);
@@ -398,14 +401,22 @@
 
 	width -= ellipsis_width;
 
-	for (trimmed_length = length - 1; trimmed_length >= 0; trimmed_length--) {
-		current_width = gdk_text_width (font, string, trimmed_length);
+	wc_str=g_new0(GdkWChar,length+1);
+	wc_len=gdk_mbstowcs(wc_str,string,length);
+
+	for (trimmed_length = wc_len - 1; trimmed_length >= 0; trimmed_length--) {
+		current_width = gdk_text_width_wc (font, wc_str, trimmed_length);
 		if (current_width <= width)
 			break;
 	}
-	result = (char *) g_malloc (trimmed_length + 3 + 1);
-	strncpy (result, string, trimmed_length);
-	strcpy (result + trimmed_length, "...");
+
+	wc_str[trimmed_length]=0;
+	mb=gdk_wcstombs(wc_str);
+
+	result=g_strconcat(mb,"...",NULL);
+
+	g_free(wc_str);
+	g_free(mb);
 
 	if (final_width  != NULL) {
 		*final_width = current_width + ellipsis_width;
--- eel-1.0.orig/eel/eel-smooth-text-layout.c	Tue May  1 22:20:38 2001
+++ eel-1.0/eel/eel-smooth-text-layout.c	Fri May 11 16:26:00 2001
@@ -392,6 +392,7 @@
  	}
 }
 
+//TAG
 static GList *
 smooth_text_layout_line_list_new_wrapped (const char *text,
 					  int text_length,
@@ -1144,18 +1145,36 @@
 			if (eel_scalable_font_text_width (font, font_size, text_iter, word_end - text_iter) > max_width) {
 				if (word_start == text_iter) {
 					if (confine) {
+						GdkWChar* wc_str;
+						int wc_len;
+						gchar* tmp_word;
 						/* We must force-split the word.  Look for a proper
                                                  * place to do it.
 						 */
 
 						w_len = word_end - word_start;
-						
-						for (i = 1; i < w_len; i++) {
-							w = eel_scalable_font_text_width (font, font_size, word_start, i);
-							if (w > max_width) {
-								if (i == 1)
-									/* Shit, not even a single character fits */
-									max_width = w;
+						tmp_word=g_strndup(word_start,w_len);
+						wc_str=g_new0(GdkWChar,w_len+1);
+						wc_len=gdk_mbstowcs(wc_str,tmp_word,w_len);
+						if(!wc_len){
+							int i;
+							for(i=0;i<w_len;i++)
+								wc_str[i]=tmp_word[i];
+							wc_len=w_len;
+						}
+						g_free(tmp_word);
+
+						for(i=1;i<wc_len;i++){
+							gchar* mb_str;
+							GdkWChar swap=wc_str[i];
+							wc_str[i]=0;
+							mb_str=gdk_wcstombs(wc_str);
+							wc_str[i]=swap;
+							w=eel_scalable_font_text_width(font,font_size,mb_str,strlen(mb_str));
+							g_free(mb_str);
+							if(w>max_width){
+								if(i==1)
+									max_width=w;
 								else
 									break;
 							}
@@ -1163,11 +1182,13 @@
 
 						/* Create sub-row with the chars that fit */
 
-						sub_text = g_strndup (word_start, i - 1);
+						wc_str[i]=0;
+						sub_text = gdk_wcstombs(wc_str);
+						g_free(wc_str);
 						
 						row = g_new0 (EelTextLayoutRow, 1);
 						row->text = sub_text;
-						row->text_length = i - 1;
+						row->text_length = strlen(sub_text);
 						row->width = eel_scalable_font_text_width (font, font_size, 
 											   sub_text, 
 											   strlen (sub_text));
@@ -1181,7 +1202,7 @@
 
 						/* Bump the text pointer */
 
-						text_iter += i - 1;
+						text_iter += strlen(sub_text);
 						s = text_iter;
 
 						continue;