我想用UNICODE编码通过GetCharacterPlacement函数转换成某个字库中相应的索引号。
WCHAR glyphs[12];
memset(glyphs,0,sizeof(WCHAR)*12); gcp.lStructSize = sizeof(GCP_RESULTSW);
gcp.lpOutString = NULL;
gcp.lpDx = NULL;
gcp.lpCaretPos = NULL;
gcp.lpOrder = NULL;
gcp.lpGlyphs = glyphs;
gcp.nGlyphs = i;
//GetGlyphIndicesW(pDC->GetSafeHdc(),str,i,glyphs,0);
GetCharacterPlacementW(pDC->GetSafeHdc(),str , i, 0,
&gcp,GetFontLanguageInfo(pDC->GetSafeHdc()));
::ExtTextOutW(pDC->GetSafeHdc(),0,0,0x16,&ret,glyphs,i,NULL);
str:UNICODE字串,glyphs是返回的索引値。
我想转换的是泰语。
现在有一个很奇怪的问题,安装和不安装泰语(就是在控制面版->区域选项中->系统的语言设置中有那几个语言打上勾了)glyphs的结果是不一样的,但用ExtTextOutW显示结果却是一样的,注意只有很少的字符会有这种情况。谁能解释这种情况呢?答对了我另开帖给1000分。

解决方案 »

  1.   

    The reason may be font linking.ExtTextOut is finally implemented by kernel mode. When certain glyph is missing, GDI will use font linking to find the right glyph in other linked fonts.GetCharacterPlacement may not going through the same code path.
      

  2.   

    ExtOutOut is able to map a single string into multiple sub-strings, each with a possible different physical font. You can see the mapping at DDI interfaceGetCharacterPlacmentW can only handle a single font.
      

  3.   

    ExtOutOut is able to map a single string into multiple sub-strings, each with a possible different physical font. You can see the mapping at DDI interfaceGetCharacterPlacmentW can only handle a single font.我是非常同意FengYuanMSFT(袁峰 www.fengyuan.com)这种说法的。
    glyphs的结果虽然不一样的,但用ExtTextOutW显示结果却是一样的,
    这里我还有一个很重要的问题没有说,虽然ExtTextOutW显示结果是一样,但位置是稍有一点不同的。
    但如果我想用GetCharacterPlacementW在不安装泰语的环境中得到与安装泰语的环境中结果一样,能做到吗?
    我会去好好看一下DDI interface,FengYuanMSFT能不能告诉我在DDI interface的那部份能找到呢?非常感谢
      

  4.   

    To see what is happening at DDI interface, write a printer driver. May be you can build a minidriver based on Microsoft's UniDriver. Download and install DDK first.I'm not really font/text expert. If you want to know more, post your problem in English to microsoft.public.win32.programming.gdi newsgroup. If you do not get answer within a few days, I will forward it to the font/text team within Microsoft.
      

  5.   

    非常感谢 FengYuanMSFT(袁峰 www.fengyuan.com)
    但我的英语不是很好,看来得靠 FengYuanMSFT(袁峰 www.fengyuan.com)大侠的帮忙了,先行谢过了.我晚上一再去下裁DDK来看看.
      

  6.   

    Not every problem has a simple answer. For this kind of advanced problems, get your hands dirty, explore on your own.