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

Re: 如何找出一個漢字所對應的字體



我是為了在OpenGL中顯示漢字, 才要處理字體的.
如果你對OpenGL感興趣, 我不妨說得具體一點.

OpenGL是這樣處理字體的, 例如要顯示ASCII字符,
先用glXUseXFont從字體font中取出前127個字符的字形,
放到以listBase開始的地方:
glXUseXFont(font, 0, 127, listBase);

然後如果我要顯示字符'A', 就用glCallList顯示'A'所在
位置的字形. 因為'A'=65, 'A'所在位置為listBase + 65,
所以用:
glCallList(listBase + 65);

顯示漢字也是類似的, 只不過glXUseXFont要把所有的漢字
裝載進去.

以上這種顯示漢字的方法是我目前正在做的, 缺點是我要
自己處理漢字. 還有一種方法就是利用XmbDrawString把
一個mb_string做成bitmap, 再通過glBitmap顯示出來,
這樣一來所有處理漢字的工作都由XmbDrawString完成了.
不過我沒有試過, 因為我不知道如何把mb_string生成
bitmap. 有誰可以告訴我嗎?

--
Chen sheng

--- ha shao <hashao@hashao.hypermart.net> wrote:
> On Tue, Apr 09, 2002 at 03:16:24AM -0700, Chen sheng
> wrote:
> > 比如說, 我用的字體是hanzigb16fs, 它的全名為:
> > -isas-fangsong-...-gb2312.1980-0
> > 我想找出"陳"字在hanzigb16fs中所對應的位置.
> >
> > 我用xfd查看hanzigb16fs字體,
> > xfd -fn hanzigb16fs
> > 發現"陳"字在hanzigb16fs中對應的一個16位字符:
> 0x3342.
> > 請問有沒有一個現成的函數實現它, 即
> > function("陳") 返回 0x3342
> >
>
> 沒有,對字體的函數應該直接交給xlib
> 的wc或者mb處理。他們會
> 根據xlocale
> 找出相應的字符。這是正統的i18n在X上的使用。
> man XmbDrawString ....
>
>
你要是非自己處理,X的國標字型使用iso-2022-cn排列。對應
> euc 碼,需要每一個byte 作 &0x80.
>
> --
> hashao|
>
千古江山,英雄無覓,孫仲謀處。舞榭歌台,風流總被,雨打風吹去。
> hashao|
>
斜陽草樹,尋常巷陌,人道寄奴曾住。想當年、金戈鐵馬,氣吞萬裡如虎。
>
>
> --
> To UNSUBSCRIBE, email to
> debian-chinese-gb-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact
> listmaster@lists.debian.org
>

__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

-- 
To UNSUBSCRIBE, email to debian-chinese-gb-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

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


-- 
To UNSUBSCRIBE, email to debian-chinese-big5-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: