[HarfBuzz] HARFBUZZ - ARABIC SHAPING PROBLEM

Shiva Kumar H R shivahr at gmail.com
Wed Oct 12 05:15:59 PDT 2011


On Wed, Oct 12, 2011 at 4:21 PM, Sergey <asnarta at gmail.com> wrote:

> We are newers in HB and have problems with using HB on Windows in our
> project
> for rendering Arabic/Indic and etc. languages. MAIN our goal while using
> harfbuzz is to get appropriate ligatures/replacement glyph indexes and etc.
> We
> build HB on msvc9, use FT-2.4.2 and ICU-4c-4_8_1. Our  implementation of
>  buffer
> shaping example is next:
>
>
>
>        /* Get our harfbuzz font/face structs */
>
>        hb_font_t *hb_ft_font = hb_ft_font_create(Font_Mgr::Font_Face,
> NULL);
>
>    hb_face_t *hb_ft_face = hb_ft_face_create(Font_Mgr::Font_Face, NULL);
>
>
>
>        hb_ft_font_set_funcs (hb_ft_font); // IS IT AS A MUST or could be
> ommited??
>
>
>
>        wchar_t *w_cut_text = L"عر بي";     // x0639, 0x0631, 0x0020,
> 0x0628, 0x064a
>
>
>
>        // INPUT string is wchar_t - NOT SURE that further conversion works
> well!!
>
>
>
>        uint16_t *cur_text_16 = (uint16_t*)w_cut_text;
>
>
>
>        const char *cur_lang = "ar"; // OK
>
>
>
>        /* Create a buffer for harfbuzz to use */
>
>        hb_buffer_t *buffer = hb_buffer_create(); //OK
>
>
>
>        hb_buffer_set_unicode_funcs(buffer, hb_icu_get_unicode_funcs());
>
>        // WHAT IS THE PURPOSE OF USING hb_icu_get_unicode_funcs() or what
> own
> implemtation should provide??
>
>
>
>        hb_buffer_set_direction(buffer, HB_DIRECTION_RTL); //OK
>
>        hb_buffer_set_script(buffer, HB_SCRIPT_ARABIC); //OK
>
>        hb_buffer_set_language(buffer, hb_language_from_string(cur_lang));
> //OK
>
>
>
>        /* Layout the text */
>
>        hb_buffer_add_utf16 (buffer, cur_text_16, 5, 0, 5); // WHAT is the
> semantic
> usage of 3 last parameters??
>
>
>
>        hb_shape (hb_ft_font, buffer, NULL, 0);
>
>
> Try using hb_ot_shape() and see if it solves your problem. I too had used
hb_shape() earlier but that didn't work, and when I used hb_ot_shape() it
started working.


>
>        /* Hand the layout to render */
>
>        unsigned int glyph_count = hb_buffer_get_length (buffer);
>
>        hb_glyph_info_t *glyph_infos = hb_buffer_get_glyph_infos (buffer,
> NULL);
>
>        hb_glyph_position_t *glyph_positions = hb_buffer_get_glyph_positions
> (buffer,
> NULL);
>
>
>
>        for (unsigned int i = 0; i < glyph_count; i++)
>
>        {
>
>                hb_glyph_info_t *info = &glyph_infos[i];
>
>                hb_glyph_position_t *pos = &glyph_positions[i];
>
>
>
>                printf ("cluster %d     glyph 0x%x at   (%d,%d)+(%d,%d)\n",
>
>                        info->cluster,
>
>                        info->codepoint,
>
>                        pos->x_offset,
>
>                        pos->x_offset,
>
>                        pos->x_advance,
>
>                        pos->y_advance);
>
>
>
>        }
>
>
>
>        hb_buffer_destroy (buffer);
>
>        hb_font_destroy (hb_ft_font);
>
>        hb_face_destroy (hb_ft_face);
>
>
>
> AS AN OUTPUT we got array of glyphs indexes in info->codepoint, but this
> array
> is the same as array of glyphs indexes, that backs FT for text
>
>  {'ع','ر',' ','ب','ي'}.
>
>  - > BUT DID NOT GET EXPECTED ligatures/replaced glyphs and etc. So, only
> string
> revers is worked good.
>
> What are we donig wrong??
>
> Could you please give any ideas or provide a sample code for a such task!
>
> THANK YOU VERY MUCH IN ADVANCED!
>
> WE ARE LOOKING FORWARD RECEIVING FEEDBACK FROM YOU!
>
> REGARDS,
>
> Sergey.
>
> _______________________________________________
> HarfBuzz mailing list
> HarfBuzz at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/harfbuzz
>

-- 
Thanks & Regards,
Shiva Kumar H R
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20111012/0c742650/attachment.html>


More information about the HarfBuzz mailing list