<div dir="ltr">Thank you for your helping.<div>I didn't compile with UCDN. <span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:14px">If I did that, </span>Do I have to make any changes in the <span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:14px">HBDrawText function?</span></div><div>Best regards.</div><div><br></div><div><br></div><div class="gmail_extra"><div class="gmail_quote">2014-11-29 6:58 GMT+09:00 Behdad Esfahbod <span dir="ltr"><<a href="mailto:behdad@behdad.org" target="_blank">behdad@behdad.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Humm. Re the shaping issue, you most probably don't have any Unicode callbacks<br>
set up.  Did you compile with UCDN?  You should.<br>
<span class=""><br>
On 14-11-28 12:28 AM, aron wrote:<br>
</span><span class="">> Hi<br>
> I use the latest version of HarfBuzz as a static library in VisualStudio,<br>
> The Mongolian string can't be rendered as I expected in my program<br>
> but rendered correctly in sh-view.exe. Could anyone tell me where is wrong in<br>
> my program.<br>
><br>
</span><span class="">> I found that the vaule -- glyph_info[i].codepoint is less than real glyph<br>
> index, the difference is always 87 in my case.What is the correct way to get<br>
> glyph index?<br>
><br>
> ​void HBDrawText(HDC dc, int x, int y)<br>
> {<br>
</span>> const char*fontFilePath = "./MongolianWhite.ttf";<br>
> const wchar_t*text = L"ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ";//Mongolian string for render<br>
<span class="">><br>
><br>
> FT_Libraryft_library;<br>
> FT_Faceft_face;<br>
><br>
> FT_Init_FreeType(&ft_library); /* initialize library */<br>
> FT_New_Face(ft_library, fontFilePath, 0, &ft_face); /* create face object */<br>
> FT_Set_Pixel_Sizes(ft_face, 0, 40); /* set character size */<br>
><br>
> hb_font_t*font= hb_ft_font_create(ft_face, NULL);<br>
</span>> hb_buffer_t*buffer= hb_buffer_create();;<br>
<span class="">><br>
> //<br>
> //set buffer<br>
> //<br>
> hb_buffer_add_utf16(buffer, (uint16_t *)text, lstrlen(text), 0, -1);<br>
> hb_buffer_set_direction(buffer, HB_DIRECTION_TTB); /* or LTR */<br>
> hb_buffer_set_script(buffer, HB_SCRIPT_MONGOLIAN); /* see hb-unicode.h */<br>
> hb_buffer_guess_segment_properties(buffer);<br>
> //<br>
> //<br>
> //<br>
> hb_shape(font, buffer, NULL, 0);<br>
><br>
</span><span class="">> intglyph_count= hb_buffer_get_length(buffer);<br>
> hb_glyph_info_t *glyph_info= hb_buffer_get_glyph_infos(buffer, 0);<br>
><br>
> WCHARdbg_info[6];<br>
> intpen_x= x;<br>
> intyBaseLine= y;<br>
> intglyphPosX= 0;<br>
</span>> intglyphPosY= 0;<br>
<span class="">><br>
> for (int i = 0; i < glyph_count; ++i)<br>
> {<br>
> FT_UInt glyph_index = glyph_info[i].codepoint;<br>
> FT_Load_Glyph(ft_face, glyph_index, FT_LOAD_DEFAULT);<br>
</span>> wsprintf(dbg_info, L"%d,", glyph_index + 87);//*why + 87?*<br>
<span class="im">> OutputDebugString(dbg_info);<br>
><br>
> /* convert to an anti-aliased bitmap */<br>
> FT_Render_Glyph(ft_face->glyph, FT_RENDER_MODE_NORMAL);<br>
><br>
> FreeTypeDrawBitmap(dc, &ft_face->glyph->bitmap, pen_x +<br>
> ft_face->glyph->bitmap_left,<br>
> yBaseLine - ft_face->glyph->bitmap_top);<br>
> pen_x += ft_face->glyph->advance.x >> 6;<br>
> }<br>
> hb_buffer_destroy(buffer);<br>
> hb_font_destroy(font);<br>
> FT_Done_Face(ft_face);<br>
> FT_Done_FreeType(ft_library);<br>
> }<br>
><br>
> this is the glyph index list generated by this program(incorrect).<br>
> 769,660,566,487,675,490,705<br>
> hb-shape' s output(correct) is:<br>
>  [769|660|566|484|678|492|705]<br>
><br>
><br>
> --<br>
> Aron<br>
><br>
><br>
</span><div class=""><div class="h5">> _______________________________________________<br>
> HarfBuzz mailing list<br>
> <a href="mailto:HarfBuzz@lists.freedesktop.org">HarfBuzz@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/harfbuzz" target="_blank">http://lists.freedesktop.org/mailman/listinfo/harfbuzz</a><br>
><br>
<br>
--<br>
behdad<br>
<a href="http://behdad.org/" target="_blank">http://behdad.org/</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Aron<br></div></div>
</div></div>