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

Re: Debian for ARM710的中文化問題



On Fri, Jan 26, 2001 at 12:44:33PM +0800, hashao@chinese.com wrote:
> On Thu, Jan 25, 2001 at 11:34:37PM +0800, shuyong@public.nn.gx.cn wrote:
> > 應該是:(這也是X內部代碼使用的技巧)
> > 
> > char *chinese = "這是中文字符串";
> > XChar2b *ch_str;
> > XFontStruct *font = XLoadQueryFont (display,
> > "-isas-*-medium-r-normal--16-160-72-72-c-160-gb2312.1980-0");
> > 
> >  length = strlen (chinese);
> >  ch_str = (XChar2b *)malloc (length + sizeof (XChar2b));
> >  memset (ch_str, 0, length + sizeof (XChar2b));
> >  for (i = 0; i < length / sizeof (XChar2b); i++) {
> >   ch_str[i].byte1 = chinese[i * 2] & 0x7F;
> >   ch_str[i].byte2 = chinese[i * 2 + 1] & 0x7F;
> >  }
> >  length /= sizeof (XChar2b);
> >  XDrawString16 (display, window, gc, x, y, (_Xconst XChar2b *)ch_str, length + 1);
> > 
> > 可能是因為效率問題,XDrawString16假設每個字是緊密排列進行顯示的。你可以想象
> > 當sizeof(XChar2b) == 4時的情況。所以我要尋找gcc關于結構對齊的選項。看看我的想法
> > 是否正確。
> > 
> 
> 你肯定 ARM 上 sizeof(XChart2b) == 4 ? 如果肯定,那上面這種hack完全
> 錯了。XmbDrawString... 都不對了。XDrawString16 沒問題,
> (_Xconst XChar2b *)ch_str 這種cast 就肯定亂套了。相應的Xmb 函數全完了。
> 

In omText.c, you can find that the cast is from (char *) to (_Xconst XChar2b *).
Which is totally wrong with XChar2b != char * 2.
In your example, simply replace i < length /sizeof(XChar2b) with 
i < (length>>1) will do the job. I think the DrawStringWidthFontSet should
changed to your example, Of course if we sure sizeof(XChar2b) could be 4.

-- 
Best regard
hashao

-- 
| This message was re-posted from debian-chinese-gb@lists.debian.org
| and converted from gb2312 to big5 by an automatic gateway.



Reply to: