Normally I would have just used whatever map type was provided by the programming language (which for C would be a simple binary search, if I were to use C, which I wouldn’t), and my painful hands are punishing me for straying from that relatively low-labor technique. :)
There is a C source file for the table lookup. There is also C for converting multicomponent glyph names to Unicode strings (actually UTF-16BE), the writing of which reminded me not to use C. There’s also the Python code that converts the AGL to the packed trie and a copy of the Adobe Glyph List. Don’t be surprised if any of these programs look vaguely ML- or Lisp-like, with recursive calls where one usually sees loops.
All the stuff but the AGL is placed by me into the public domain. Bugs are left as an exercise for the reader.
I had considered patching Cairo to use this code but decided it wasn’t worth my labor, and also I was afraid of screwing things up. In my practice I’m always using pure glyph indices with left-to-right text, and don’t know how to avoid screwing up other schemes. You still ought to be able to use this code with Cairo, though, and thus avoid having to keep track of the source text—use the code to convert glyph indices to Unicode which you then feed to Cairo.