Texts in pdf are shorter than they should be
On screenshot is detail of top-right corner where "TextTex-" should touch right edge of page (text here has underline attribute):
Problem is probably because glyph widths are saved in pdf as integer values in widths array which is used by pdf renderers but cairo internally works with floating point values when placing glyphs. So cairo intends to place glyph at certain position calculated by summation of floating point widths of preceding glyphs but in reality it will be rendered at position calculated by summation of rounded integral widths. I think it would not be very good to store widths into pdf in higher precision nor to limit maximum number of glyphs inside single text object because then pdf could be larger. The best would be to compensate for these rounding errors in individual glyph positioning.
Source to generate such pdf
#include <string>
// include pango and cairo
int main()
{
auto surface = cairo_pdf_surface_create("1_cairo.pdf", 2000, 800);
//auto surface = cairo_svg_surface_create("1_cairo.svg", 2000, 800);
auto ctx = cairo_create(surface);
auto layout = pango_cairo_create_layout(ctx);
auto desc = pango_font_description_new();
pango_font_description_set_family(desc, "LiberationSans");
pango_font_description_set_absolute_size(desc, pango_units_from_double(2));
pango_layout_set_font_description(layout, desc);
pango_layout_set_width(layout, pango_units_from_double(2000));
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
std::string text;
for(int i = 0; i < 600; i++)text += "Text";
pango_layout_set_text(layout, text.data(), text.size());
pango_cairo_show_layout(ctx, layout);
cairo_show_page(ctx);
cairo_destroy(ctx);
cairo_surface_destroy(surface);
}
More here: https://gitlab.gnome.org/GNOME/pango/-/issues/506