[kaffe] CVS kaffe (dalibor): AWT I18N patches

Kaffe CVS cvs-commits at kaffe.org
Fri Mar 5 09:28:02 PST 2004


PatchSet 4479 
Date: 2004/03/05 17:12:34
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
AWT I18N patches

2004-03-05  Jim Huang <jimchyun at ccns.ncku.edu.tw>
        * libraries/clib/awt/X/tlk.c
        * libraries/clib/awt/X/toolkit.h:
        Support XOM (X Output Method) for i18n context drawing.

        * libraries/clib/awt/X/fnt.c:
        Add switch to Replace X11 fonts declared in XFontStruct * with
        struct XOC, and modify the font-related functions accordingly.
        With the i18n patch, Xlib AWT backend would render i18n message.

Members: 
	ChangeLog:1.2059->1.2060 
	libraries/clib/awt/X/fnt.c:1.11->1.12 
	libraries/clib/awt/X/gra.c:1.21->1.22 
	libraries/clib/awt/X/tlk.c:1.20->1.21 
	libraries/clib/awt/X/toolkit.h:1.26->1.27 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2059 kaffe/ChangeLog:1.2060
--- kaffe/ChangeLog:1.2059	Fri Mar  5 13:45:29 2004
+++ kaffe/ChangeLog	Fri Mar  5 17:12:34 2004
@@ -1,3 +1,13 @@
+2004-03-05  Jim Huang <jimchyun at ccns.ncku.edu.tw>
+	* libraries/clib/awt/X/tlk.c
+	* libraries/clib/awt/X/toolkit.h:
+	Support XOM (X Output Method) for i18n context drawing.
+
+	* libraries/clib/awt/X/fnt.c:
+	Add switch to Replace X11 fonts declared in XFontStruct * with 
+	struct XOC, and modify the font-related functions accordingly.
+	With the i18n patch, Xlib AWT backend would render i18n message.
+
 2004-03-05  Dalibor Topic <robilad at kaffe.org>
 
         kaffe/kaffevm/verify-type.c,
Index: kaffe/libraries/clib/awt/X/fnt.c
diff -u kaffe/libraries/clib/awt/X/fnt.c:1.11 kaffe/libraries/clib/awt/X/fnt.c:1.12
--- kaffe/libraries/clib/awt/X/fnt.c:1.11	Thu Sep 25 17:26:16 2003
+++ kaffe/libraries/clib/awt/X/fnt.c	Fri Mar  5 17:12:35 2004
@@ -64,6 +64,37 @@
  * adapts the AWT to your X installation/preferences. Don't lament, modify it!
  */
 
+#ifdef KAFFE_I18N
+XOC create_xoc(Toolkit *X,char *font_name)
+{
+  XOC xoc;
+  int i;
+  char **missing_list;
+  int missing_count;
+  char *def_string;
+
+  xoc = XCreateOC(X->xom,
+		XNBaseFontName, font_name,
+		NULL);
+  if (xoc) {
+    XGetOCValues(xoc,
+		XNMissingCharSet, &missing_count,
+		XNRequiredCharSet, &missing_list,
+		XNDefaultString, &def_string,
+		NULL);
+    if( missing_count!=0 ){
+      DBG( AWT, fprintf(stderr, "missing list exists at %s.\n" ,font_name) );
+      for (i = 0; i < missing_count; i++) {
+        DBG( AWT, fprintf(stderr, "missing list[%d]: %s\n", i, missing_list[i]) );
+      }
+    }
+  } else {
+    DBG( AWT, fprintf(stderr, "XCreateOC error at %s.\n" ,font_name) );
+  }
+  return xoc;		    
+}
+#endif
+
 void*
 Java_java_awt_Toolkit_fntInitFont ( JNIEnv* env, jclass clazz, jstring jSpec,
                                     jint style, jint size )
@@ -71,7 +102,11 @@
   int  i, j, k, i0, i1, j0, j1, di, dj;
   char buf[160];
   char *spec = java2CString( env, X, jSpec);
+#ifdef KAFFE_I18N
+  XOC xoc = NULL;
+#else  
   XFontStruct* fs = 0;
+#endif  
 
 	size *= 10;  /* convert into X pointsizes */
 
@@ -89,16 +124,38 @@
     j0 = 0; j1 = NSLANT; dj = 1;
   }
 
+#ifdef KAFFE_I18N
+  for ( j=j0; (xoc == NULL) && (j != j1); j += dj ) {
+    for ( i=i0; (xoc == NULL) && (i != i1); i += di ) {
+      for ( k=0;  (xoc == NULL) && (k < NDSIZE); k++ ) {
+#else	      
   for ( j=j0; !fs && (j != j1); j += dj ) {
     for ( i=i0; !fs && (i != i1); i += di ) {
       for ( k=0;  !fs && (k < NDSIZE); k++ ) {
+#endif	      
         sprintf( buf, spec, weight[i], slant[j], size + dsize[k]);
         DBG( AWT_FNT, printf("look up font: %s\n", buf));
+#ifdef KAFFE_I18N
+        xoc = create_xoc( X, buf);
+#else	
         fs = XLoadQueryFont( X->dsp, buf);
+#endif	
       }
     }
   }
 
+#ifdef KAFFE_I18N
+  if ( ! xoc ){
+    xoc = create_xoc( X, spec);
+  }
+  if ( ! xoc ){
+        if ( !(xoc = create_xoc( X, backupFont)) ) {
+	  fprintf( stderr, "font panic, no default font!\n");
+	}
+  }
+
+  return (void*) xoc;
+#else  
   if ( ! fs ){
     /* now we are getting desperate, try the spec directly (without vars) */
     fs = XLoadQueryFont( X->dsp, spec);
@@ -112,19 +169,100 @@
   }
 
   return (void*) fs;
+#endif  
 }
 
+#ifdef KAFFE_I18N
+void
+Java_java_awt_Toolkit_fntFreeFont ( JNIEnv* env, jclass clazz, XOC xoc )
+{
+  XDestroyOC(xoc);
+}
+#else
 void
 Java_java_awt_Toolkit_fntFreeFont ( JNIEnv* env, jclass clazz, XFontStruct* fs )
 {
   XFreeFont( X->dsp, fs);
 }
-
+#endif
 
 /*******************************************************************************
  * FontMetrics support
  */
 
+#ifdef KAFFE_I18N
+void *
+Java_java_awt_Toolkit_fntInitFontMetrics ( JNIEnv* env, jclass clazz, void* xoc )
+{
+  return xoc;
+}
+
+void
+Java_java_awt_Toolkit_fntFreeFontMetrics ( JNIEnv* env, jclass clazz, XOC xoc )
+{
+}
+
+jint
+Java_java_awt_Toolkit_fntGetAscent ( JNIEnv* env, jclass clazz, XOC xoc )
+{
+  return -XExtentsOfFontSet(xoc)->max_logical_extent.y;	
+}
+
+jint
+Java_java_awt_Toolkit_fntGetDescent ( JNIEnv* env, jclass clazz, XOC xoc )
+{
+  XFontSetExtents *xfse=XExtentsOfFontSet(xoc);
+  return xfse->max_logical_extent.height-(-xfse->max_logical_extent.y);
+}
+
+jint
+Java_java_awt_Toolkit_fntGetFixedWidth ( JNIEnv* env, jclass clazz, XOC xoc )
+{
+  XFontSetExtents *xfse=XExtentsOfFontSet(xoc);
+  return ( xfse->max_logical_extent.width == xfse->max_ink_extent.width ) ?
+	  xfse->max_logical_extent.width : 0;
+}
+
+jint
+Java_java_awt_Toolkit_fntGetHeight ( JNIEnv* env, jclass clazz, XOC xoc )
+{
+  return XExtentsOfFontSet(xoc)->max_logical_extent.height;
+}
+
+jint
+Java_java_awt_Toolkit_fntGetLeading ( JNIEnv* env, jclass clazz, XOC xoc )
+{
+  return 0;  /* no leading (interline spacing) for X fonts */
+}
+
+jint
+Java_java_awt_Toolkit_fntGetMaxAdvance ( JNIEnv* env, jclass clazz, XOC xoc )
+{
+  return XExtentsOfFontSet(xoc)->max_logical_extent.width;
+}
+
+jint
+Java_java_awt_Toolkit_fntGetMaxAscent ( JNIEnv* env, jclass clazz, XOC xoc )
+{
+  XFontSetExtents *xfse=XExtentsOfFontSet(xoc);
+  return -xfse->max_logical_extent.y;
+}
+
+jint
+Java_java_awt_Toolkit_fntGetMaxDescent ( JNIEnv* env, jclass clazz, XOC xoc )
+{
+  XFontSetExtents *xfse=XExtentsOfFontSet(xoc);
+  return xfse->max_logical_extent.height-(-xfse->max_logical_extent.y);
+}
+
+jboolean
+Java_java_awt_Toolkit_fntIsWideFont ( JNIEnv* env, jclass clazz, XOC xoc )
+{
+  return 2; /* We assume that wide font is double-wide. */
+}
+
+#else
+
 void*
 Java_java_awt_Toolkit_fntInitFontMetrics ( JNIEnv* env, jclass clazz, void* fs )
 {
@@ -191,18 +329,44 @@
   return (fs->min_byte1 | fs->max_byte1);
 }
 
+#endif
+
 jobject
+#ifdef KAFFE_I18N
+Java_java_awt_Toolkit_fntGetWidths ( JNIEnv* env, jclass clazz, XOC xoc )
+#else
 Java_java_awt_Toolkit_fntGetWidths ( JNIEnv* env, jclass clazz, XFontStruct* fs )
+#endif	
 {
   int       n = 256;
   jintArray widths;
   jint      *jw;
   jboolean isCopy;
+#ifdef KAFFE_I18N
+  register  int i;
+  XRectangle ink_array, logical_array;
+  XRectangle overall_ink, overall_logical;
+  wchar_t wch;
+  int num;
+#else  
   register  int i, j;
+#endif  
 
   widths = (*env)->NewIntArray( env, 256);
   jw = (*env)->GetIntArrayElements( env, widths, &isCopy);
 
+#ifdef KAFFE_I18N
+  for( i = 0; i < 256; i++ ) {
+    wch = i;
+    if (!XwcTextPerCharExtents(
+	 xoc ,&wch ,1 ,&ink_array, &logical_array, 1,
+         &num,&overall_ink, &overall_logical )){
+      DBG( AWT, fprintf(stderr, __FILE__ "(%d)"
+        "):" "XwcTextPerCharExtents Error\n",__LINE__ ));
+    }
+    jw[i] = overall_logical.width;
+  }
+#else  
   if ( fs->max_char_or_byte2 < n ) n = fs->max_char_or_byte2;
 
   if ( fs->min_bounds.width == fs->max_bounds.width ) {
@@ -213,7 +377,7 @@
 	for ( i=fs->min_char_or_byte2, j=0; i < n; i++, j++ )
 	  jw[i] = fs->per_char[j].width;
   }
-
+#endif
   (*env)->ReleaseIntArrayElements( env, widths, jw, 0);
 
   return widths;
@@ -221,44 +385,118 @@
 
 
 jint
+#ifdef KAFFE_I18N
+Java_java_awt_Toolkit_fntBytesWidth ( JNIEnv* env, jclass clazz,
+        XOC xoc, jbyteArray jBytes, jint off, jint len )
+#else
 Java_java_awt_Toolkit_fntBytesWidth ( JNIEnv* env, jclass clazz,
 	XFontStruct* fs, jbyteArray jBytes, jint off, jint len )
+#endif
 {
   jboolean  isCopy;
   jbyte    *jb = (*env)->GetByteArrayElements( env, jBytes, &isCopy);
   int       n = (*env)->GetArrayLength( env, jBytes);
   int       w;
+#ifdef KAFFE_I18N
+  wchar_t   *wch;
+  XRectangle *ink_array, *logical_array;
+  XRectangle overall_ink, overall_logical;
+  int num;
+#endif
 
   if ( off+len > n ) len = n - off;
 
+#ifdef KAFFE_I18N
+  wch = jbyte2wchar( jb + off, len );
+  ink_array = (XRectangle *)malloc(sizeof(XRectangle)*len);
+  logical_array = (XRectangle *)malloc(sizeof(XRectangle)*len);
+  if(!XwcTextPerCharExtents(xoc ,wch ,len ,ink_array,logical_array, len,
+      &num,&overall_ink ,&overall_logical)){
+    DBG( AWT, fprintf(stderr, __FILE__ "(%d)"
+         "):" "XwcTextPerCharExtents Error\n",__LINE__ ));
+  }
+  free( (void *)logical_array );
+  free( (void *)ink_array );
+  free( (void *)wch );
+#else  
   w = XTextWidth( fs, jb+off, len);
-
+#endif
+  
   (*env)->ReleaseByteArrayElements( env, jBytes, jb, JNI_ABORT);
+  
+#ifdef KAFFE_I18N
+  return overall_logical.width;
+#else  
   return w;
+#endif  
 }
 
 jint
+#ifdef KAFFE_I18N
+Java_java_awt_Toolkit_fntCharWidth ( JNIEnv* env, jclass clazz, 
+	XOC xoc, jchar jChar )
+#else	
 Java_java_awt_Toolkit_fntCharWidth ( JNIEnv* env, jclass clazz, XFontStruct* fs, jchar jChar )
+#endif	
 {
+#ifdef KAFFE_I18N
+  wchar_t wch;
+  XRectangle ink_array, logical_array;
+  XRectangle overall_ink, overall_logical;
+  int num;
+
+  wch = jChar;
+  if(!XwcTextPerCharExtents(xoc ,&wch ,1 ,&ink_array, &logical_array,
+	1, &num, &overall_ink, &overall_logical)){
+    DBG( AWT, fprintf(stderr, __FILE__ "(%d)"
+         "):" "XwcTextPerCharExtents Error\n",__LINE__ ));			
+  }
+  return overall_logical.width;     
+	
+#else /* !KAFFE_I18N */
+	
 #ifndef WORDS_BIGENDIAN
   jChar = (jChar << 8) | (jChar >> 8);
 #endif
 
   return XTextWidth16( fs, (XChar2b*)&jChar, 1);
+#endif  
 }
 
 jint
+#ifdef KAFFE_I18N
 Java_java_awt_Toolkit_fntCharsWidth ( JNIEnv* env, jclass clazz,
+	XOC xoc, jcharArray jChars, jint off, jint len )
+#else
+Java_java_awt_Toolkit_fntCharsWidth ( JNIEnv* env, jclass clazz,		
 	XFontStruct* fs, jcharArray jChars, jint off, jint len )
+#endif
 {
   jboolean  isCopy;
   jchar    *jc = (*env)->GetCharArrayElements( env, jChars, &isCopy);
   int      n = (*env)->GetArrayLength( env, jChars);
+#ifdef KAFFE_I18N
+  wchar_t  *wch;
+  XRectangle *ink_array, *logical_array;
+  XRectangle overall_ink, overall_logical;
+  int num;
+#else  
   XChar2b  *b;
   int      w;
+#endif
 
   if ( off+len > n ) len = n - off;
 
+#ifdef KAFFE_I18N
+  wch = jchar2wchar( jc + off, len );
+  ink_array = (XRectangle *)malloc(sizeof(XRectangle)*len);
+  logical_array = (XRectangle *)malloc(sizeof(XRectangle)*len);
+  if(!XwcTextPerCharExtents(xoc ,wch ,len ,ink_array,logical_array, len,
+	&num,&overall_ink ,&overall_logical)){
+    DBG( AWT, fprintf(stderr, __FILE__ "(%d)"
+         "):" "XwcTextPerCharExtents Error\n",__LINE__ ));			    }
+#else /* !KAFFE_I18N */
+  
 #ifndef WORDS_BIGENDIAN
   n = sizeof(XChar2b)*len;
   b = (XChar2b*) getBuffer( X, n);
@@ -267,18 +505,53 @@
   b = (XChar2b*) (jc + off);
 #endif
 
+#endif
+ 
+#ifdef KAFFE_I18N
+  free( (void *)logical_array );
+  free( (void *)ink_array );
+  free( (void *)wch );
+#else  
   w = XTextWidth16( fs, b, len);
-
+#endif
+  
   (*env)->ReleaseCharArrayElements( env, jChars, jc, JNI_ABORT);
+#ifdef KAFFE_I18N
+  return overall_logical.width;
+#else  
   return w;
+#endif  
 }
 
 jint
+#ifdef KAFFE_I18N
+Java_java_awt_Toolkit_fntStringWidth ( JNIEnv* env, jclass clazz, 
+	XOC xoc, jstring jStr )
+#else
 Java_java_awt_Toolkit_fntStringWidth ( JNIEnv* env, jclass clazz, XFontStruct* fs, jstring jStr )
+#endif	
 {
   jboolean isCopy;
   const jchar    *jc = (*env)->GetStringChars( env, jStr, &isCopy);
   int      len = (*env)->GetStringLength( env, jStr);
+#ifdef KAFFE_I18N
+  wchar_t  *wch;
+  XRectangle *ink_array, *logical_array;
+  XRectangle overall_ink, overall_logical;
+  int num=len;
+
+  wch = jchar2wchar( jc, len );
+  ink_array = (XRectangle *)malloc(sizeof(XRectangle)*len);
+  logical_array = (XRectangle *)malloc(sizeof(XRectangle)*len);
+  if(!XwcTextPerCharExtents(xoc ,wch ,len ,ink_array,logical_array, len,
+	&num,&overall_ink ,&overall_logical)){
+    DBG( AWT, fprintf(stderr, __FILE__ "(%d)"
+         "):" "XwcTextPerCharExtents Error\n",__LINE__ ));
+  }
+  free( (void *)logical_array );
+  free( (void *)ink_array );
+  free( (void *)wch );
+#else /* !KAFFE_I18N */  
   int      w;
 #ifndef WORDS_BIGENDIAN
   int      n;
@@ -294,7 +567,12 @@
 #endif
 
   w = XTextWidth16( fs, b, len);
+#endif /* !KAFFE_I18N */  
 
   (*env)->ReleaseStringChars( env, jStr, jc);
+#ifdef KAFFE_I18N
+  return overall_logical.width;  
+#else  
   return w;
+#endif  
 }
Index: kaffe/libraries/clib/awt/X/gra.c
diff -u kaffe/libraries/clib/awt/X/gra.c:1.21 kaffe/libraries/clib/awt/X/gra.c:1.22
--- kaffe/libraries/clib/awt/X/gra.c:1.21	Thu Sep 25 17:26:16 2003
+++ kaffe/libraries/clib/awt/X/gra.c	Fri Mar  5 17:12:35 2004
@@ -13,6 +13,9 @@
 typedef struct {
   GC        gc;
   Drawable  drw;
+#ifdef KAFFE_I18N
+  XOC       oc;
+#endif  
   int       fg;
   int       bg;
   char      xor;
@@ -40,7 +43,11 @@
   Drawable       drw;
   XGCValues      values;
   XRectangle     rect;
+#ifdef KAFFE_I18N
+  unsigned long  valueMask = GCForeground | GCBackground | GCFunction;
+#else  
   unsigned long  valueMask = GCForeground | GCBackground | GCFont | GCFunction;
+#endif  
 
   DBG( AWT_GRA, printf("initGraphics: %p (%p, %d) %d,%d  %d,%d - %d,%d  %p %x %x\n",
 				 gr, tgt,tgtType, xOff,yOff, xClip,yClip,wClip,hClip, fnt,fg,bg));
@@ -65,7 +72,9 @@
 
   values.foreground = fg;
   values.background = bg;
+#ifndef KAFFE_I18N /* !KAFFE_I18N */ 
   values.font       = ((XFontStruct*)fnt)->fid;
+#endif  
   values.function   = GXcopy;
   
   if ( gr ) {
@@ -90,6 +99,9 @@
   gr->x0   = xOff;
   gr->y0   = yOff;
   gr->xor  = 0;
+#ifdef KAFFE_I18N
+  gr->oc   = fnt;
+#endif  
 
   if ( blank ) {
 	XSetForeground( X->dsp, gr->gc, gr->bg);
@@ -148,6 +160,9 @@
   jboolean isCopy;
   int      n;
   jbyte    *jb, *jbo;
+#ifdef KAFFE_I18N
+  wchar_t *wch;
+#endif  
 
   if ( !jBytes ) return;
 
@@ -161,7 +176,13 @@
   if ( offset+len > n )
 	len = n - offset;
 
+#ifdef KAFFE_I18N
+  wch = jbyte2wchar( jbo, len );
+  XwcDrawString( X->dsp, gr->drw, gr->oc, gr->gc, x+gr->x0, y+gr->y0, wch,len);
+  free((void*) wch);  
+#else  
   XDrawString( X->dsp, gr->drw, gr->gc, x+gr->x0, y+gr->y0, jbo, len);
+#endif  
 
   (*env)->ReleaseByteArrayElements( env, jBytes, jb, JNI_ABORT);
   XFLUSH( X, False);
@@ -175,7 +196,11 @@
   jboolean isCopy;
   int      n;
   jchar    *jc, *jco;
+#ifdef KAFFE_I18N
+  wchar_t *wch;  
+#else  
   XChar2b  *b;
+#endif  
 
   if ( !jChars ) return;
 
@@ -189,6 +214,12 @@
   if ( offset+len > n )
 	len = n - offset;
 
+#ifdef KAFFE_I18N
+  wch = jchar2wchar( jco, len );  
+  XwcDrawString( X->dsp, gr->drw, gr->oc, gr->gc, x+gr->x0, y+gr->y0, wch,len);
+  free((void*) wch);
+#else /* !KAFFE_I18N */
+	 
 #ifndef WORDS_BIGENDIAN
   n = sizeof(XChar2b)*len;
   b = (XChar2b*) getBuffer( X, n);
@@ -197,7 +228,8 @@
   b = (XChar2b*) jco;
 #endif
 
-  XDrawString16( X->dsp, gr->drw, gr->gc, x+gr->x0, y+gr->y0, b, len);  
+  XDrawString16( X->dsp, gr->drw, gr->gc, x+gr->x0, y+gr->y0, b, len);
+#endif  
 
   (*env)->ReleaseCharArrayElements( env, jChars, jc, JNI_ABORT);
   XFLUSH( X, False);
@@ -210,11 +242,21 @@
 {
   jboolean     isCopy;
   int          len;
+
+#ifndef KAFFE_I18N
+  
 #ifndef WORDS_BIGENDIAN
   int n;
 #endif
+
+#endif
+  
   const jchar  *jc;
+#ifdef KAFFE_I18N
+  wchar_t *wch;  
+#else  
   XChar2b      *b;
+#endif  
 
   DBG( AWT_GRA, printf("drawString: %p  \"%s\"  %d,%d\n", gr, java2CString(env,X,str), x,y));
 
@@ -223,6 +265,12 @@
   len = (*env)->GetStringLength( env, str);
   jc = (*env)->GetStringChars( env, str, &isCopy);
 
+#ifdef KAFFE_I18N
+  wch = jchar2wchar( jc, len );
+  XwcDrawString( X->dsp, gr->drw, gr->oc, gr->gc, x+gr->x0, y+gr->y0, wch,len);
+  free( (void *)wch );  
+#else /* !KAFFE_I18N */
+  
 #ifndef WORDS_BIGENDIAN
   n = sizeof(XChar2b)*len;
   b = (XChar2b*) getBuffer( X, n);
@@ -232,7 +280,8 @@
 #endif
 
   XDrawString16( X->dsp, gr->drw, gr->gc, x+gr->x0, y+gr->y0, b, len);  
-
+#endif
+  
   (*env)->ReleaseStringChars( env, str, jc);
   XFLUSH( X, False);
 }
@@ -590,8 +639,11 @@
 Java_java_awt_Toolkit_graSetFont ( JNIEnv* env, jclass clazz, Graphics* gr, jobject fnt )
 {
   DBG( AWT_GRA, printf("setFont: %p, %p\n", gr, fnt));
-
+#ifdef KAFFE_I18N
+  gr->oc=(XOC)fnt;  
+#else
   XSetFont( X->dsp, gr->gc, ((XFontStruct*)fnt)->fid);
+#endif  
 }
 
 void
Index: kaffe/libraries/clib/awt/X/tlk.c
diff -u kaffe/libraries/clib/awt/X/tlk.c:1.20 kaffe/libraries/clib/awt/X/tlk.c:1.21
--- kaffe/libraries/clib/awt/X/tlk.c:1.20	Mon Jan  6 17:14:25 2003
+++ kaffe/libraries/clib/awt/X/tlk.c	Fri Mar  5 17:12:35 2004
@@ -14,6 +14,10 @@
 #include "toolkit.h"
 #include "tlkprops.h"
 
+#ifdef KAFFE_I18N
+#include "locale.h"
+#endif
+
 /********************************************************************************
  * auxiliary functions
  */
@@ -81,6 +85,15 @@
 {
   char    *dspName;
 
+#ifdef KAFFE_I18N
+  /* for X Output Method */
+  int i;
+  Bool direction;
+  Bool contextdrawing;
+  XOMCharSetList cslist;
+  XOMOrientation orientation;
+#endif
+  
   getBuffer(X, 128);
 
   JniEnv = env;
@@ -114,7 +127,8 @@
   X->root   = DefaultRootWindow( X->dsp);
   X->fwdIdx = -1;
 
-#if defined(USE_XSHM_EXTENSION)
+// #if defined(USE_XSHM_EXTENSION)
+#if defined(HAVE_LIBXEXT) && defined(KAFFE_I18N)  
   /*
    * We just can use XShm in case we don't run remote, and we better don't rely on
    * XShmQueryExtension to make this distinction
@@ -139,6 +153,28 @@
   RETRY_FOCUS      = XInternAtom( X->dsp, "RETRY_FOCUS", False);
   FORWARD_FOCUS    = XInternAtom( X->dsp, "FORWARD_FOCUS", False);
 
+#ifdef KAFFE_I18N
+  /* Open  X Output Method */
+  setlocale(LC_ALL ,"");
+  
+  X->xom = XOpenOM(X->dsp, NULL, NULL, NULL);
+  if (X->xom) {
+    DBG( AWT, printf("locale of XOM: %s\n", XLocaleOfOM(X->xom)));
+    XGetOMValues(X->xom,
+		XNRequiredCharSet, &cslist,
+		XNQueryOrientation, &orientation,
+	        XNDirectionalDependentDrawing, &direction,
+	        XNContextualDrawing, &contextdrawing,
+	        NULL);
+     /* We could create fontset list from these. */
+    for (i = 0; i < cslist.charset_count; i++) {
+      DBG( AWT, printf("needed charset[%d]: %s\n", i, cslist.charset_list[i]));
+    }
+  } else {
+    DBG( AWT, fprintf(stderr ,"XOpenOM error\n") );
+  }
+#endif
+    
   return JNI_TRUE;
 }
 
Index: kaffe/libraries/clib/awt/X/toolkit.h
diff -u kaffe/libraries/clib/awt/X/toolkit.h:1.26 kaffe/libraries/clib/awt/X/toolkit.h:1.27
--- kaffe/libraries/clib/awt/X/toolkit.h:1.26	Mon Jan 13 23:27:53 2003
+++ kaffe/libraries/clib/awt/X/toolkit.h	Fri Mar  5 17:12:35 2004
@@ -19,13 +19,14 @@
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 
-#if defined(HAVE_LIBXEXT) && defined(HAVE_SYS_IPC_H) && defined(HAVE_SYS_SHM_H) && defined(HAVE_X11_EXTENSIONS_XSHM_H)
-#define USE_XSHM_EXTENSION 1
+// #if defined(HAVE_LIBXEXT) && defined(HAVE_SYS_IPC_H) && defined(HAVE_SYS_SHM_H) && defined(HAVE_X11_EXTENSIONS_XSHM_H)
+// #define USE_XSHM_EXTENSION 1
 #include <sys/ipc.h>
 #include <sys/shm.h>
+#if defined(HAVE_LIBXEXT)
 #include <X11/extensions/XShm.h>
 #else
-#undef USE_XSHM_EXTENSION
+// #undef USE_XSHM_EXTENSION
 #define	XShmGetImage(A,B,C,D,E,F)		0
 #define	XShmPutImage(A,B,C,D,E,F,G,H,I,J,K)	0
 #define	XShmSegmentInfo				void
@@ -44,6 +45,8 @@
 #include <fcntl.h>
 #endif
 
+#define KAFFE_I18N	1 /* make Kaffe to be able to support i18n */
+
 /*******************************************************************************
  * color conversion structures
  */
@@ -191,6 +194,9 @@
   Window         focus;     /* this is the real focus, if it is in our process */
   Window         focusFwd;  /* this might be a (owned) window we forward the focus to */
   int            fwdIdx;    /* cached index of the focus forward window */
+#ifdef KAFFE_I18N
+  XOM            xom;       /* X Output Method */
+#endif  
 } Toolkit;
 
 
@@ -330,6 +336,21 @@
   return X->buf;
 }
 
+#ifdef KAFFE_I18N
+static inline wchar_t* jchar2wchar( const jchar *jc, int len ) {
+  int i;
+  wchar_t *wch = (wchar_t *)malloc(sizeof(wchar_t)*len);
+  for( i=0; i < len; i++ ) wch[i] = jc[i];
+  return wch;
+}
+
+static inline wchar_t* jbyte2wchar( jbyte *jc, int len ) {
+  int i;
+  wchar_t *wch = (wchar_t *)malloc(sizeof(wchar_t)*(len));
+  for( i=0; i < len; i++ ) wch[i] = jc[i];
+  return wch;
+}
+#endif
 
 /*****************************************************************************************
  * color functions & defines




More information about the kaffe mailing list