These are very similar to the pango utilities, and are copying code from the textview accessible implementation in GTK 3.