I think you may be in a similar situation to librsvg, which uses Pango to draw text that comes from SVG documents. It uses Cairo but not GTK; the caller of the library passes a Cairo context to it, and the library draws everything to that
cairo_t, including text with Pango.
You create a
PangoLayout from a
PangoContext; in the case of librsvg this is a context created from a
PangoCairoFontMap. The basic codes goes like this:
PangoLayout does the hard work of running the Unicode bidi algorithm on your string, itemizing it, figuring out the direction of items, shaping each glyph string, etc. If you want to access the low-level stages, you can use PangoLayoutIter and
pango_layout_iter_next_cluster, for example, and then draw items individually with
PangoLayout is complex because it doesn’t just do the job of dissecting a string for drawing; it can also answer questions like, “given an (x, y) point, what glyph is under the mouse cursor”, or “point me to the next cluster as if the user had hit the Right arrow key”. If your typesetting system doesn’t need that, it’s possible to not use Pango, but the lower-level libraries directly (Harfbuzz to do shaping, maybe Fontconfig to enumerate fonts if your platform is happy with it, etc.). Librsvg may in fact have to do that eventually to get fine typographical control of each glyph, which is something SVG wants but Pango can’t really do directly.