Arabic decoder
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.
<div><p>Hi,<br><br>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!<br><br>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.<br><br>When rendering arabic letter equivalent of la , it should give me only one glyph (لا).<br><br>However, Harfbuzz render me correctly the glyph, but do not get rid of the a. See screenshot here:<br><br><a href="http://img522.yfrog.com/i/21856341.png/">http://img522.yfrog.com/i/21856341.png/</a><br><br><br>Here's my (simplified) render loop:<br><br>HB_ShaperItem shaper_item;<br><br> shaper_item.string = (HB_UChar16 *) g_utf8_to_utf16((gchar*)txt, -1, NULL, &numberOfWords, NULL);<br><br> shaper_item.kerning_applied = 0;<br> shaper_item.stringLength = 0;<br> shaper_item.shaperFlags = 0;<br> shaper_item.font = &hbFont;<br> shaper_item.face = hbFace;<br> shaper_item.glyphIndicesPresent = 0;<br> shaper_item.initialGlyphCount = 0;<br><br> shaper_item.item.bidiLevel = 0;<br><br> out_glyphs = (HB_Glyph*)malloc(numberOfWords * sizeof(HB_Glyph));<br> memset(out_glyphs, 0, numberOfWords * sizeof(HB_Glyph));<br> out_attrs = (HB_GlyphAttributes*)malloc(numberOfWords * sizeof(HB_GlyphAttributes));<br> memset(out_attrs, 0, numberOfWords * sizeof(HB_GlyphAttributes));<br> out_advs = (HB_Fixed*)malloc(numberOfWords * sizeof(HB_Fixed));<br> memset(out_advs, 0, numberOfWords * sizeof(HB_Fixed));<br> out_offsets = (HB_FixedPoint*)malloc(numberOfWords * sizeof(HB_FixedPoint));<br> memset(out_offsets, 0, numberOfWords * sizeof(HB_FixedPoint));<br> out_logClusters = (unsigned short*)malloc(numberOfWords * sizeof(unsigned short));<br> memset(out_logClusters, 0, numberOfWords * sizeof(unsigned short));<br><br> shaper_item.glyphs = out_glyphs;<br> shaper_item.attributes = out_attrs;<br> shaper_item.advances = out_advs;<br> shaper_item.offsets = out_offsets;<br> shaper_item.log_clusters = out_logClusters;<br> shaper_item.num_glyphs = numberOfWords;<br> shaper_item.stringLength = numberOfWords;<br><br> int l = 0;<br> while(1){<br> <br> shaper_item.num_glyphs = numberOfWords;<br> if (!hb_utf16_script_run_next(NULL, &shaper_item.item, shaper_item.string, numberOfWords , &iterator))<br> break;<br><br> memset(out_glyphs, 0, numberOfWords * sizeof(HB_Glyph));<br> HB_ShapeItem(&shaper_item);<br> for (unsigned int j = 0; j < shaper_item.item.length; j++)<br> {<br> ind[l++] = out_glyphs[j];<br> }<br> }<br><br>so at the end, ind contains all the index of the glyph I need to draw.<br><br>Is there a way harfbuzz can tell me to get rid of a glyph?<br><br>Thanks, Nico.<br><br><br></p></div>
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:
> >
> >
RSS Feed