免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2895 | 回复: 1
打印 上一主题 下一主题

求助:tinyx下使用fcitx问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-07-17 18:27 |只看该作者 |倒序浏览
我编译了一个tinyx,想在上面使用fcitx,我交叉编译好fcitx,configure时enable了xft选项,但是在tinyx中运行时有些问题。

输入法的bug如图显示,主窗口的最右边的当前是什么输入发没有画出来,输入窗口的中文也没有显示出来,在最新的3.6版本中,connect_id倒是对的。

刚开始觉得是XIM没有正常初始化照成的,后来发现代码中setlocale()函数的返回是NULL,这个不知道是不是导致XIM没有初始化的原因。或者是为什么setlocale()函数会返回NULL??
我在调用setlocale()函数后跟着调用XSupportsLocale,这个函数返回时非空的。

我想应该有朋友做个这方面的移植,求各位大虾指教,谢谢

15-07-09_1949.jpg (20.65 KB, 下载次数: 18)

15-07-09_1949.jpg

论坛徽章:
0
2 [报告]
发表于 2009-07-17 18:28 |只看该作者
不好意思,因为思绪比较乱,只好多个论坛求学了,请见谅


继续求学:


今天早上试着安装,把编译器里面的locale相关的全部铐过来了,
# locale -a
显示有zh_CN.gb2312了,setlocale()函数终于没有返回出错,但是程序运行起来还是和上面截图一样,还是没有能把中文字体画出来

找了个小程序来测试(在x86正常显示)在setlocale()也没有报错了,在板子上还是不能输出中文。晚上继续看看,先弄明白小程序的中文为什么也画不出来~

用于测试输出 "abc 你好“的小程序,网上找的:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iconv.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>
/*
#include <locale.h>
*/

#include <X11/Xlocale.h>

void DrawCenteredMbString ( Display *, Window, XFontSet, GC, char*, int, int,
int, int, int );

int
main (argc, argv)
int argc;
char *argv[];
{
Display *dpy;
Window w;
XFontSet fontset;
char **missing_charsets;
int num_missing_charsets;
char *default_string;
int i;
GC gc;
XEvent xe;
char *p;
char locale[100];

char *program_name = argv[0];

p = setlocale (LC_CTYPE,"");
if ( !p ) {
//if ( setlocale (LC_ALL,"") == NULL ) {

fprintf (stderr, "%s: setlocale fail.\n",
program_name );
//exit (1);

}
else
{
strcpy(locale, p);
fprintf(stderr, "%s: locale is (%s)\n", program_name, locale);
}

if ( !XSupportsLocale() ) {
fprintf (stderr,"%s: X does not support locale %s.\n",
program_name, setlocale( LC_ALL, NULL ) );
exit (1);
}

if ( XSetLocaleModifiers("") == NULL ) {
fprintf (stderr,
"%s: Warning: setlocalemodifiers fail.\n",
program_name);
}

dpy = XOpenDisplay ( NULL);
w = XCreateSimpleWindow ( dpy, RootWindow( dpy, 0 ), 50, 50,
100, 50, 5, BlackPixel( dpy, 0 ),
WhitePixel( dpy, 0 ) );
gc = XCreateGC ( dpy, w, 0L, ( XGCValues * ) NULL );

fontset = XCreateFontSet (dpy, "-*-*-*-*-*-*-16-*-*-*-*-*-*-*",
&missing_charsets, &num_missing_charsets,
&default_string);
if ( num_missing_charsets > 0 ) {
(void) fprintf (stderr,
"%s: The following charsets are missing:\n",
program_name);
for ( i=0; i < num_missing_charsets; i++ )
(void)fprintf (stderr, "%s: %s\n", program_name,
missing_charsets);
(void) fprintf (stderr, "%s: The string is %s\n", program_name,
default_string);
(void) fprintf (stderr,
"%s: of any characters from those sets\n",
program_name);
XFreeStringList (missing_charsets);
}

XSetLineAttributes ( dpy, gc, 5, LineSolid, CapRound, JoinRound );

XSelectInput ( dpy, w, ExposureMask | ButtonPressMask
| EnterWindowMask | LeaveWindowMask );

XMapWindow ( dpy, w );

XFlush ( dpy );

while ( True )
{
XNextEvent ( dpy, &xe );

switch ( xe.type ) {

case Expose:
printf ("Expose 出现.\n");
XSetForeground ( dpy, gc, BlackPixel( dpy, 0 ) );
DrawCenteredMbString ( dpy, w, fontset, gc,
"abc 你好",
10, 0, 0, 100, 50 );
break;
case ButtonPress:
printf ("按下!\n");
exit (1);
break;
case EnterNotify:
printf ("进入.\n");
XSetForeground ( dpy, gc, BlackPixel( dpy, 0 ) );
XDrawRectangle ( dpy, w, gc, 0, 0, 100, 50 );
break;
case LeaveNotify:
printf ("离开.\n");
XSetForeground ( dpy, gc, WhitePixel( dpy, 0 ) );
XDrawRectangle ( dpy, w, gc, 0, 0, 100, 50 );
break;
default:
printf ("默认.\n");
break;
}
}
return 0;
}

void
DrawCenteredMbString (dpy, w, fontset, gc, str, num_bytes, x, y, width, height )
Display *dpy;
Window w;
XFontSet fontset;
GC gc;
char *str;
int num_bytes;
int x,y, width, height;
{
XRectangle boundingbox;
XRectangle dummy;
int originx, originy;

(void) XmbTextExtents (fontset, str, num_bytes, &dummy, &boundingbox);

originx = x + ( width - boundingbox.width )/2 - boundingbox.x;
originy = y + ( height - boundingbox.height)/2 - boundingbox.y;

XmbDrawString (dpy, w, fontset, gc, originx, originy, str, num_bytes);
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP