Hi,<br>I am glad to inform that I could use HarfBuzz-ng and FreeType to render Indic text on Android Canvas.<br><br>Thank you for creating such an elegant  lightweight library.<br><br>I referred <a href="https://github.com/anoek/ex-sdl-cairo-freetype-harfbuzz">https://github.com/anoek/ex-sdl-cairo-freetype-harfbuzz</a> to come up with my sample program, the essence of which looks as below:<br>
<br>---- start of indic-text-rendering code snippet -----<br>

<br>#include <hb-ft.h><br>...<br>void drawIndicText(unsigned short* text, int textLength, int xStart, int yBaseLine, int charHeight) {<br>    FT_Library ft_library;<br>    FT_Init_FreeType(&ft_library); /* initialize library */<br>
<br>    char* fontFilePath = "/sdcard/Android/data/org.iisc.mile.indictext.android/Lohit-Kannada.ttf";<br>    FT_Face ft_face;<br>    FT_New_Face(ft_library, fontFilePath, 0, &ft_face); /* create face object */<br>
<br>    hb_font_t *font = hb_ft_font_create(ft_face, NULL);<br><br>    FT_Set_Pixel_Sizes(ft_face, 0, charHeight); /* set character size */<br><br>    /* Create a buffer for harfbuzz to use */<br>    hb_buffer_t *buffer = hb_buffer_create();<br>
<br>    //hb_buffer_set_direction(buffer, HB_DIRECTION_LTR); /* or LTR */<br>    hb_buffer_set_script(buffer, HB_SCRIPT_KANNADA); /* see hb-unicode.h */<br>    //hb_buffer_set_language(buffer, hb_language_from_string("ka"));<br>
<br>    /* Layout the text */<br>    hb_buffer_add_utf16(buffer, text, textLength, 0, textLength);<br>    hb_ot_shape(font, buffer, NULL, 0, 0);<br><br>    int glyph_count = hb_buffer_get_length(buffer);<br>    hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos(buffer, 0);<br>
    hb_glyph_position_t *glyph_pos = hb_buffer_get_glyph_positions(buffer, 0);<br><br>    for (int i = 0; i < glyph_count; i++) {<br>        FT_UInt glyph_index = glyph_info[i].codepoint;<br>        FT_Error error = FT_Load_Glyph(ft_face, glyph_index, FT_LOAD_DEFAULT);<br>
        if (error) {<br>            continue; /* ignore errors */<br>        }<br>        /* convert to an anti-aliased bitmap */<br>        error = FT_Render_Glyph(ft_face->glyph, FT_RENDER_MODE_NORMAL);<br>        if (error) {<br>
            continue;<br>        }<br><br>        /* now, draw to our target surface (convert position) */<br>        FT_GlyphSlot slot = ft_face->glyph;<br>        draw_bitmap(&slot->bitmap, xStart + slot->bitmap_left, yBaseLine - slot->bitmap_top);<br>
        int glyphPosX = xStart + glyph_pos[i].x_offset;<br>        int glyphPosY = yBaseLine - glyph_pos[i].y_offset;<br>        //draw_bitmap(&slot->bitmap, glyphPosX, glyphPosY, env, thiz, lock);<br><br>        /* increment pen position */<br>
        xStart += slot->advance.x >> 6;<br>        //xStart += glyph_pos[i].x_advance / 64;<br>    }<br><br>    hb_buffer_destroy(buffer);<br><br>    hb_font_destroy(font);<br>    FT_Done_Face(ft_face);<br>    FT_Done_FreeType(ft_library);<br>
<br>    return;<br>}<br>...<br>---- end of indic-text-rendering code snippet -----<br>

<br>Few things I noticed:<br>1) I had earlier used hb_shape() but that didn't work. It worked when I used hb_ot_shape(). Is this by design?<br><br>2) There are a few errors in the sequence of glyphs returned by HarfBuzz for certain Kannada language words. In the attached snapshot, words in second edit-box are not rendered properly. Where should I report these errors and in what format?<br>
<br>I see a test case in <a href="http://cgit.freedesktop.org/harfbuzz/tree/test/test-shape-complex.c">http://cgit.freedesktop.org/harfbuzz/tree/test/test-shape-complex.c</a> . But I couldn't figure out how to run this. Simply running test-shape-complex.exe didn't help. Are there some instructions that I can look at?<br>
<br>-- <br>Thanks & Regards,<br>Shiva Kumar H R<br><a href="http://people.apache.org/~shivahr/">http://people.apache.org/~shivahr/</a><br><br><div class="gmail_quote">On Fri, Sep 16, 2011 at 5:05 PM, Shiva Kumar H R <span dir="ltr"><<a href="mailto:shivahr@gmail.com">shivahr@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">I have used a simple Android.mk as below and got the HarfBuzz to build on Android NDK. I got below warnings though.<br>
<br>harfbuzz-ng/src/hb-object-private.hh:74:2: warning: #warning "Could not find any system to define atomic_int macros, library will NOT be thread-safe"<br>
<br>Android.mk:<br>------Begin of Android.mk-------<br>BASE_PATH := $(call my-dir)<br>LOCAL_PATH:= $(call my-dir)<br><br>#############################################################<br>#   build the harfbuzz library<br>
#<br>
<br>include $(CLEAR_VARS)<br><br>LOCAL_ARM_MODE := arm<br><br>LOCAL_MODULE_TAGS := optional<br><br>LOCAL_CPP_EXTENSION := .cc<br><br>LOCAL_SRC_FILES:= \<br>        src/hb-blob.cc \<br>        src/hb-buffer.cc \<br>        src/hb-common.cc \<br>

        src/hb-fallback-shape.cc \<br>        src/hb-font.cc \<br>        src/hb-ot-tag.cc \<br>        src/hb-shape.cc \<br>        src/hb-tt-font.cc \<br>        src/hb-unicode.cc \<br>        src/hb-ot-layout.cc \<br>
        src/hb-ot-map.cc \<br>
        src/hb-ot-shape.cc \<br>        src/hb-ot-shape-complex-arabic.cc \<br>        src/hb-ot-shape-complex-indic.cc \<br>        src/hb-ot-shape-complex-misc.cc \<br>        src/hb-ot-shape-normalize.cc \<br>        src/hb-ft.cc \<br>

<br>LOCAL_C_INCLUDES += \<br>    $(LOCAL_PATH)/src $(LOCAL_PATH)/../freetype/include<br><br>LOCAL_MODULE:= libharfbuzz<br><br>LOCAL_STATIC_LIBRARIES := ft2<br><br>include $(BUILD_SHARED_LIBRARY)<br><br>------End of Android.mk-------<br>

<br><br>Yet to write a sample program and see if it is actually working.<div class="im"><br><br clear="all">-- <br>Thanks & Regards,<br>Shiva Kumar H R<br><br><br></div><div><div></div><div class="h5"><div class="gmail_quote">
On Fri, Sep 16, 2011 at 3:26 PM, Shiva Kumar H R <span dir="ltr"><<a href="mailto:shivahr@gmail.com" target="_blank">shivahr@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi,<br>Is it possible to build harfbuzz-ng using Android-NDK. If yes, are there any instructions that I can look at?<br>

<br>I came across Android.mk in <a href="http://tools.impjq.net/android/external/harfbuzz/" target="_blank">http://tools.impjq.net/android/external/harfbuzz/</a> , but this seems to be the old Harfbuzz tree and has a dependency on ICU4C.<br>

<font color="#888888">
<br clear="all">-- <br>Thanks & Regards,<br>Shiva Kumar H R<br><a href="http://people.apache.org/%7Eshivahr/" target="_blank">http://people.apache.org/~shivahr/</a><br>
</font></blockquote></div><br>
</div></div></blockquote></div><br>