[HarfBuzz] question about Mongolian text render
Behdad Esfahbod
behdad at behdad.org
Fri Nov 28 23:09:18 PST 2014
On 14-11-28 08:57 PM, aron wrote:
> Thank you for your helping.
> I didn't compile with UCDN. If I did that, Do I have to make any changes in
> the HBDrawText function?
Nope. No changes needed.
I should fix HB to either terminate compilation with an error if no Unicode
callbacks are configured, or automatically include UCDN.
>
>
> 2014-11-29 6:58 GMT+09:00 Behdad Esfahbod <behdad at behdad.org
> <mailto:behdad at behdad.org>>:
>
> Humm. Re the shaping issue, you most probably don't have any Unicode callbacks
> set up. Did you compile with UCDN? You should.
>
> 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 <mailto:HarfBuzz at lists.freedesktop.org>
> > http://lists.freedesktop.org/mailman/listinfo/harfbuzz
> >
>
> --
> behdad
> http://behdad.org/
>
>
>
>
> --
> 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