[HarfBuzz] Some experiments with harfbuzz/OpenGL
Behdad Esfahbod
behdad at behdad.org
Fri Apr 12 14:29:07 PDT 2013
On 13-04-12 01:44 PM, Nicolas Rougier wrote:
>
>
> Hi,
>
> Thanks to the great example available at https://github.com/lxnt/ex-sdl-freetype-harfbuzz, I did some experiments to render
> some Arabic text using OpenGL/Freetype/Harfbuzz.
>
> You can find a screenshot here: http://freetype-gl.googlecode.com/svn/wiki/images/arabic.png
>
> Sources are available in http://code.google.com/p/freetype-gl/source/browse/trunk/harfbuzz.
> It's quite experimental though...
>
> I hope the text is ok since I don't read Arabic (google helped me on this).
First, you were ignoring the glyph offsets:
Index: demo-harfbuzz.c
===================================================================
--- demo-harfbuzz.c (revision 216)
+++ demo-harfbuzz.c (working copy)
@@ -182,14 +182,16 @@
int codepoint = glyph_info[j].codepoint;
float x_advance = glyph_pos[j].x_advance/(64.*64.); // because of
vhinting trick
float y_advance = glyph_pos[j].y_advance/(64.);
+ float x_offset = glyph_pos[j].x_offset/(64.*64.); // because of
vhinting trick
+ float y_offset = glyph_pos[j].y_offset/(64.);
texture_glyph_t *glyph = texture_font_get_glyph(fonts[i], codepoint);
float r = 0.0;
float g = 0.0;
float b = 0.0;
float a = 1.0;
- float x0 = x + glyph->offset_x;
- float y0 = y + glyph->offset_y;
+ float x0 = x + x_offset + glyph->offset_x;
+ float y0 = y + y_offset + glyph->offset_y;
float x1 = x0 + glyph->width;
float y1 = y0 - glyph->height;
float s0 = glyph->s0;
Next, you should create the hb-ft font after setting size on the FT face:
Index: texture-font.c
===================================================================
--- texture-font.c (revision 216)
+++ texture-font.c (working copy)
@@ -170,7 +170,6 @@
}
}
}
- self->hb_ft_font = hb_ft_font_create( self->ft_face, NULL );
/* Set char size */
error = FT_Set_Char_Size( self->ft_face, (int)(size*64), 0, hdpi*hres,
vdpi );
@@ -184,6 +183,8 @@
/* Set transform matrix */
FT_Set_Transform( self->ft_face, &matrix, NULL );
+ self->hb_ft_font = hb_ft_font_create( self->ft_face, NULL );
+
return self;
}
Looks correct after adding these. Though, I was under the impression that
Amiri has much better mark positioning. Khaled, am I missing anything here?
b
--
behdad
http://behdad.org/
More information about the HarfBuzz
mailing list