[HarfBuzz] question about Mongolian text render
Behdad Esfahbod
behdad at behdad.org
Fri Nov 28 13:57:20 PST 2014
Hi,
In general, you should use LTR direction for Mongolian. The top-to-bottom
rendering is simply geometric rotation.
The 87 doesn't make any sense to me. I have no idea what might be wrong, but
I'm extremely curious to know when you figure out!
Cheers,
behdad
On 14-11-28 12:28 AM, aron wrote:
> Hi
> I use the latest version of HarfBuzz as a static library in VisualStudio,
> 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.
>
> 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?
>
> void HBDrawText(HDC dc, int x, int y)
> {
> const char*fontFilePath = "./MongolianWhite.ttf";
> const wchar_t*text = L"ᠺᠣᠮᠫᠢᠦ᠋ᠲ᠋ᠧᠷ";//Mongolian string for render
>
>
> FT_Libraryft_library;
> FT_Faceft_face;
>
> FT_Init_FreeType(&ft_library); /* initialize library */
> FT_New_Face(ft_library, fontFilePath, 0, &ft_face); /* create face object */
> FT_Set_Pixel_Sizes(ft_face, 0, 40); /* set character size */
>
> hb_font_t*font= hb_ft_font_create(ft_face, NULL);
> hb_buffer_t*buffer= hb_buffer_create();;
>
> //
> //set buffer
> //
> hb_buffer_add_utf16(buffer, (uint16_t *)text, lstrlen(text), 0, -1);
> hb_buffer_set_direction(buffer, HB_DIRECTION_TTB); /* or LTR */
> hb_buffer_set_script(buffer, HB_SCRIPT_MONGOLIAN); /* see hb-unicode.h */
> hb_buffer_guess_segment_properties(buffer);
> //
> //
> //
> hb_shape(font, buffer, NULL, 0);
>
> intglyph_count= hb_buffer_get_length(buffer);
> hb_glyph_info_t *glyph_info= hb_buffer_get_glyph_infos(buffer, 0);
>
> WCHARdbg_info[6];
> intpen_x= x;
> intyBaseLine= y;
> intglyphPosX= 0;
> intglyphPosY= 0;
>
> for (int i = 0; i < glyph_count; ++i)
> {
> FT_UInt glyph_index = glyph_info[i].codepoint;
> FT_Load_Glyph(ft_face, glyph_index, FT_LOAD_DEFAULT);
> wsprintf(dbg_info, L"%d,", glyph_index + 87);//*why + 87?*
> OutputDebugString(dbg_info);
>
> /* convert to an anti-aliased bitmap */
> FT_Render_Glyph(ft_face->glyph, FT_RENDER_MODE_NORMAL);
>
> FreeTypeDrawBitmap(dc, &ft_face->glyph->bitmap, pen_x +
> ft_face->glyph->bitmap_left,
> yBaseLine - ft_face->glyph->bitmap_top);
> pen_x += ft_face->glyph->advance.x >> 6;
> }
> hb_buffer_destroy(buffer);
> hb_font_destroy(font);
> FT_Done_Face(ft_face);
> FT_Done_FreeType(ft_library);
> }
>
> this is the glyph index list generated by this program(incorrect).
> 769,660,566,487,675,490,705
> hb-shape' s output(correct) is:
> [769|660|566|484|678|492|705]
>
>
> --
> Aron
>
>
> _______________________________________________
> HarfBuzz mailing list
> HarfBuzz at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/harfbuzz
>
--
behdad
http://behdad.org/
More information about the HarfBuzz
mailing list