After a italic to non-italic style change the space between the glyphs
is sometimes wrongly calculated, especially if the font doesn't have
an italic version and FreeType falls back to oblique glyphs.
In such cases, add additional space to the glyph's advance to make up
for the slant of the glyph; the amount is calculated from the glyph's
bbox.
get_outline_glyph(render_priv, code,
text_info->glyphs + text_info->length, drawing);
+ // Add additional space after italic to nonitalic style changes
+ if (text_info->length &&
+ text_info->glyphs[text_info->length - 1].hash_key.italic &&
+ !render_priv->state.italic) {
+ GlyphInfo *og = &text_info->glyphs[text_info->length - 1];
+ int advmax = FFMAX(0, og->bbox.xMax - og->advance.x);
+ pen.x += advmax;
+ }
+
text_info->glyphs[text_info->length].pos.x = pen.x;
text_info->glyphs[text_info->length].pos.y = pen.y;