Use Pango and Harfbuzz for the task, getting the default language, then its scripts, then their directions. We pick the first valid horizontal direction, resorting to LTR as a fallback. Related: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5385 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2780>