[HarfBuzz] Arabic decoder

Nicolas Lacombe n.lacombe at gmail.com
Fri Dec 4 09:26:02 PST 2009


Thanks for the answear.

I found that Freetype and Harfbuzz don't give the same advance for some
glyph. Since I guess it's only looking to the font setting, how is that
possible?

I guess Harfbuzz is doing more than just looking to the font, I should use
his advance then.



2009/12/4 Lars Knoll <lars.knoll at nokia.com>

> On Friday 04 December 2009 08:21:16 am Nicolas Lacombe wrote:
> > problem solved:
>
> [snip]
>
> > I'm still having problem rendering complexe sentances, but it looks like
> > working fine on small letter... I'm wondering if I have to take into
> >  account the advances given by the shaper... for now I'm just letting
> >  freetype taking care of it for me... need some test.
>
> There's a reason harfbuzz delivers you advances and positions for the
> glyphs
> ;-) You'll need to use them to get correct layout.
>
> > Are you aware of any problem in the arabic/syriac translation module, or
> is
> > it suppose to work fine?
>
> We're using the code directly in Qt and haven't gotten any bug reports
> about
> problems with arabic or syriac for quite some time.
>
> Cheers,
> Lars
>
> >
> > Behdad answear to this question with:
> >
> > "Supposed to work fine.  Though you need a bidi engine also.  Try setting
> > bidi level to 1 instead of 0..."
> >
> >
> > Wich does not appear to change a lot of things. However I resolved my
> > problem by changing font... they are very important, and I'm having
> trouble
> > to find good Persian and Syriac font.
> >
> >
> >
> > 2009/12/2 Nicolas Lacombe <n.lacombe at gmail.com>
> >
> > > 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.
> >
> _______________________________________________
> HarfBuzz mailing list
> HarfBuzz at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/harfbuzz
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20091204/e203cce3/attachment.html>


More information about the HarfBuzz mailing list