My intent is to draw a text along a path using Pango and Cairo libraries in Rust. For this I need to get x position of glyph center on the line and its width. It must take into account properties like kerning, font spacing... So far I have something like this but I am not sure if my approach is correct:
let layout = pangocairo::functions::create_layout(context);
layout.set_text(text);
let font_desc = pango::FontDescription::from_string("Sans Bold 12");
layout.set_font_description(Some(&font_desc));
let line = layout.line_readonly(0).unwrap();
for run in line.runs() {
let glyph_string = run.glyph_string();
for glyph_info in glyph_string.glyph_info() {
let geom = glyph_info.geometry();
// TODO
}
}
I appreciate any hint or code example (in Rust, C or maybe Pyhon).