[HarfBuzz] Arabic decoder

Nicolas Lacombe n.lacombe at gmail.com
Wed Dec 2 10:16:38 PST 2009


Hi,

I'm using HarfBuzz with freetype to render arabic text. I must say that this
library was exactly what I was looking for, great job!

Anyway I spotted something strange, I don't know if it's a bug or if it's me
that didn't understand correctly the spirit behind Harfbuzz.

When rendering arabic letter equivalent of la , it should give me only one
glyph (لا).

However, Harfbuzz render me correctly the glyph, but do not get rid of the
a. See screenshot here:

http://img522.yfrog.com/i/21856341.png/


Here's my (simplified) render loop:

HB_ShaperItem shaper_item;

    shaper_item.string = (HB_UChar16 *) g_utf8_to_utf16((gchar*)txt, -1,
NULL, &numberOfWords, NULL);

   shaper_item.kerning_applied = 0;
    shaper_item.stringLength = 0;
    shaper_item.shaperFlags = 0;
    shaper_item.font = &hbFont;
    shaper_item.face = hbFace;
    shaper_item.glyphIndicesPresent = 0;
    shaper_item.initialGlyphCount = 0;

    shaper_item.item.bidiLevel = 0;

    out_glyphs = (HB_Glyph*)malloc(numberOfWords * sizeof(HB_Glyph));
    memset(out_glyphs, 0, numberOfWords * sizeof(HB_Glyph));
    out_attrs = (HB_GlyphAttributes*)malloc(numberOfWords *
sizeof(HB_GlyphAttributes));
    memset(out_attrs, 0, numberOfWords * sizeof(HB_GlyphAttributes));
    out_advs = (HB_Fixed*)malloc(numberOfWords * sizeof(HB_Fixed));
    memset(out_advs, 0, numberOfWords * sizeof(HB_Fixed));
    out_offsets = (HB_FixedPoint*)malloc(numberOfWords *
sizeof(HB_FixedPoint));
    memset(out_offsets, 0, numberOfWords * sizeof(HB_FixedPoint));
    out_logClusters = (unsigned short*)malloc(numberOfWords *
sizeof(unsigned short));
    memset(out_logClusters, 0, numberOfWords * sizeof(unsigned short));

    shaper_item.glyphs = out_glyphs;
    shaper_item.attributes = out_attrs;
    shaper_item.advances = out_advs;
    shaper_item.offsets = out_offsets;
    shaper_item.log_clusters = out_logClusters;
    shaper_item.num_glyphs = numberOfWords;
    shaper_item.stringLength = numberOfWords;

    int l = 0;
    while(1){

        shaper_item.num_glyphs = numberOfWords;
        if (!hb_utf16_script_run_next(NULL, &shaper_item.item,
shaper_item.string, numberOfWords , &iterator))
            break;

        memset(out_glyphs, 0, numberOfWords * sizeof(HB_Glyph));
        HB_ShapeItem(&shaper_item);
        for (unsigned int j = 0; j < shaper_item.item.length; j++)
        {
            ind[l++] = out_glyphs[j];
        }
    }

so at the end, ind contains all the index of the glyph I need to draw.

Is there a way harfbuzz can tell me to get rid of a glyph?

Thanks, Nico.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20091202/a5fbc2ca/attachment.html>


More information about the HarfBuzz mailing list