Issue with some letters not joining in arabic script #4177
-
I am trying to implement arabic text rendering with opengl using freetyp2 and harfbuzz. I used this code to get me started : https://github.com/harfbuzz/harfbuzz-tutorial So far, I am getting this result: As you can see, there are 2 letters that are detached but should be attached to the left. I printed the name, position (pos + offset), advance and texture width of each glyph after shaping:
I noticed, for the last meem, the advance value is bigger than the texture width, which could explain the issue, but why ? Here is the code that creates the vertices; as I mentioned, I based my code on the harfbuzz-tutorial code, and the loop is similar: double current_x = 100;
double current_y = 300;
for (unsigned int i = 0; i < len; i++)
{
hb_codepoint_t gid = info[i].codepoint;
auto& this_pos = pos[i];
char glyph_name[32];
hb_font_get_glyph_name(hb_font, gid, glyph_name, 32);
auto& glyph = font.getGlyph(gid, FONT_SIZE); // this comes from my code that creates the font texture
double pos_x = current_x + this_pos.x_offset / 64.;
double pos_y = current_y - this_pos.y_offset / 64. - glyph.base; // glyph.base is horiBearingY from freetype metrics
double adv_x = this_pos.x_advance / 64.;
double adv_y = this_pos.y_advance / 64.;
double tex_x = glyph.tex_pos.x;
double tex_y = glyph.tex_pos.y;
double tex_w = glyph.tex_size.x;
double tex_h = glyph.tex_size.y;
text_va.pushQuad({{
{{pos_x, pos_y},
{tex_x, tex_y}},
{{pos_x + tex_w, pos_y},
{tex_x + tex_w, tex_y}},
{{pos_x + tex_w, pos_y + tex_h},
{tex_x + tex_w, tex_y + tex_h}},
{{pos_x, pos_y + tex_h},
{tex_x, tex_y + tex_h}}
}});
auto off = this_pos.x_offset / 64.;
printf("%8s @ %4.2f (%4.2f %c %2.f), %+3.2f (w=%3.f)\n", glyph_name, pos_x, current_x, off < 0 ? '-' : '+', abs(off), adv_x, tex_w);
current_x += adv_x;
current_y += adv_y;
} Here is the font texture generated and used to render the text, it looks fine: Any help is welcome :). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
What is the font you are using? Can you reproduce the issue with |
Beta Was this translation helpful? Give feedback.
What is the font you are using? Can you reproduce the issue with
hb-view
orhb-shape
?