<div dir="ltr">Hi <br clear="all"><div>I use the latest version of HarfBuzz as a static library in VisualStudio,</div><div>The Mongolian string can't be rendered as I expected in my program but rendered correctly in sh-view.exe. Could anyone tell me where is wrong in my program. </div><div><br></div><div><img src="cid:ii_i316mxl01_149f522725c1d302" width="339" height="132" style="margin-right: 0px;"></div><div>I found that the vaule -- glyph_info[i].codepoint is less than real glyph index, the difference is always 87 in my case.What is the correct way to get glyph index?</div><div><br>​void HBDrawText(HDC dc, int x, int y)<br></div><div>{</div><div><span class="" style="white-space:pre">  </span>const char<span class="" style="white-space:pre">                </span>*<span class="" style="white-space:pre"> </span>fontFilePath <span style="white-space:pre">       </span>= "./MongolianWhite.ttf";</div><div><span class="" style="white-space:pre">        </span>const wchar_t<span class="" style="white-space:pre">     </span>*<span class="" style="white-space:pre"> </span>text <span style="white-space:pre">       </span><span style="white-space:pre">     </span><span style="white-space:pre">     </span>= L"ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ";//Mongolian string for render</div><div><br></div><div><br></div><div><span class="" style="white-space:pre">   </span>FT_Library<span class="" style="white-space:pre">                        </span>ft_library;</div><div><span class="" style="white-space:pre">        </span>FT_Face<span class="" style="white-space:pre">                   </span>ft_face;</div><div><br></div><div><span class="" style="white-space:pre">  </span>FT_Init_FreeType(&ft_library); /* initialize library */</div><div><span class="" style="white-space:pre">        </span>FT_New_Face(ft_library, fontFilePath, 0, &ft_face); /* create face object */</div><div><span class="" style="white-space:pre">   </span>FT_Set_Pixel_Sizes(ft_face, 0, 40); /* set character size */</div><div><br></div><div><span class="" style="white-space:pre">      </span>hb_font_t<span class="" style="white-space:pre">         </span>*<span class="" style="white-space:pre"> </span>font<span class="" style="white-space:pre">      </span>= hb_ft_font_create(ft_face, NULL);</div><div><span class="" style="white-space:pre">        </span>hb_buffer_t<span class="" style="white-space:pre">       </span>*<span class="" style="white-space:pre"> </span>buffer= hb_buffer_create();;</div><div><br></div><div><span class="" style="white-space:pre">      </span>//</div><div><span class="" style="white-space:pre"> </span>//set buffer</div><div><span class="" style="white-space:pre">       </span>//</div><div><span class="" style="white-space:pre"> </span>hb_buffer_add_utf16(buffer, (uint16_t *)text, lstrlen(text), 0, -1);</div><div><span class="" style="white-space:pre">       </span>hb_buffer_set_direction(buffer, HB_DIRECTION_TTB); /* or LTR */</div><div><span class="" style="white-space:pre">    </span>hb_buffer_set_script(buffer, HB_SCRIPT_MONGOLIAN); /* see hb-unicode.h */</div><div><span class="" style="white-space:pre">  </span>hb_buffer_guess_segment_properties(buffer);</div><div><span class="" style="white-space:pre">        </span>//</div><div><span class="" style="white-space:pre"> </span>//</div><div><span class="" style="white-space:pre"> </span>//</div><div><span class="" style="white-space:pre"> </span>hb_shape(font, buffer, NULL, 0);</div><div><br></div><div><span class="" style="white-space:pre">  </span>int<span class="" style="white-space:pre">               </span><span style="white-space:pre">     </span><span style="white-space:pre">     </span><span style="white-space:pre">     </span>glyph_count<span style="white-space:pre">  </span>= hb_buffer_get_length(buffer);</div><div><span class="" style="white-space:pre">    </span>hb_glyph_info_t *<span class="" style="white-space:pre"> </span><span style="white-space:pre">     </span>glyph_info<span style="white-space:pre">   </span><span style="white-space:pre">     </span>= hb_buffer_get_glyph_infos(buffer, 0);</div><div><br></div><div><span class="" style="white-space:pre">   </span>WCHAR<span class="" style="white-space:pre">                             </span>dbg_info[6];</div><div><span class="" style="white-space:pre">       </span>int<span class="" style="white-space:pre">                                       </span>pen_x<span class="" style="white-space:pre">             </span>= x;</div><div><span class="" style="white-space:pre">       </span>int<span class="" style="white-space:pre">                                       </span>yBaseLine<span class="" style="white-space:pre"> </span><span style="white-space:pre">     </span>= y;</div><div><span class="" style="white-space:pre">       </span>int<span class="" style="white-space:pre">                                       </span>glyphPosX<span class="" style="white-space:pre"> </span><span style="white-space:pre">     </span>= 0;</div><div><span class="" style="white-space:pre">       </span>int<span class="" style="white-space:pre">                                       </span>glyphPosY<span class="" style="white-space:pre"> </span><span style="white-space:pre">     </span>= 0;</div><div><br></div><div><span class="" style="white-space:pre">      </span>for (int i = 0; i < glyph_count; ++i) </div><div><span class="" style="white-space:pre"> </span>{</div><div><span class="" style="white-space:pre">          </span>FT_UInt glyph_index <span style="white-space:pre">        </span>= glyph_info[i].codepoint;</div><div><span class="" style="white-space:pre">         </span>FT_Load_Glyph(ft_face, glyph_index, FT_LOAD_DEFAULT);</div><div><span class="" style="white-space:pre">              </span></div><div><span class="" style="white-space:pre">           </span>wsprintf(dbg_info, L"%d,", glyph_index + 87);//<b>why + 87?</b></div><div><span class="" style="white-space:pre">              </span>OutputDebugString(dbg_info);</div><div><br></div><div><span class="" style="white-space:pre">              </span>/* convert to an anti-aliased bitmap */</div><div><span class="" style="white-space:pre">            </span>FT_Render_Glyph(ft_face->glyph, FT_RENDER_MODE_NORMAL);</div><div><br></div><div><span class="" style="white-space:pre">                </span>FreeTypeDrawBitmap(dc, &ft_face->glyph->bitmap, pen_x + ft_face->glyph->bitmap_left,</div><div><span class="" style="white-space:pre">                               </span>yBaseLine - ft_face->glyph->bitmap_top);</div><div><span class="" style="white-space:pre">             </span>pen_x += ft_face->glyph->advance.x >> 6;</div><div><span class="" style="white-space:pre">       </span>}</div><div><span class="" style="white-space:pre">  </span>hb_buffer_destroy(buffer);</div><div><span class="" style="white-space:pre"> </span>hb_font_destroy(font);</div><div><span class="" style="white-space:pre">     </span>FT_Done_Face(ft_face);</div><div><span class="" style="white-space:pre">     </span>FT_Done_FreeType(ft_library);</div><div>}</div><div><br></div><div>this is the glyph index list generated by this program(incorrect).</div><div>769,660,566,487,675,490,705<br></div><div>hb-shape' s output(correct) is:</div><div> [769|660|566|484|678|492|705]</div><div><br></div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Aron<br></div></div>
</div>