I have managed to get the correct glyphs (glyph shaping) using libraqm, and now I need to do glyph joining to make the glyphs join up properly.
I have managed to get the correct horizontal advance, using:
advance = (glyphs[i].x_advance / glyphs[i].ftface->units_per_EM) * fontsize;
However, the offset doesn't seem to be correct because all of the glyphs x and y offsets are being set to 0 by libraqm.
Originally, I was setting the position of the glyphs using:
const float left = (float)(origin_x + glyphs[i].x_offset);
const float top = (float)(origin_y + font->leading + (font->ascent - glyphs[i].y_offset));
But that caused all of the glyphs to be aligned to the top of the the text line, like so: (Random text example)
So I altered the code to align the glyphs to the bottom of the line of text, like so:
const float left = (float)(origin_x + glyphs[i].x_offset);
const float top = (float)(origin_y + font->leading + (font->ascent - glyphs[i].y_offset)) - glyphs[i].ftface->glyph->bitmap.rows;
but although it looks better, it still isn't quite right...
Does anyone know how I am supposed to get the correct offsets for each glyph using libraqm?
rather than using glyphs[i].ftface->glyph->bitmap.rows
to get the glyph height, use glyphs[i].ftface->glyph->bitmap_top
, so your vertical alignment looks like:
const float top = (float)(origin_y + font->leading + (font->ascent - glyphs[i].y_offset)) - glyphs[i].ftface->glyph->bitmap_top;