FTCharToGlyphIndex.h implements a sparse array of glyph indicies.
There are two problems with it: first, it doesn't check the character value passed to it, so any character over 0xFFFF will segfault. Second, it is using "div" to generate the bucket indices... which since this isn't a hash table, there is no reason to do this.
The max defined unicode character point is 0x10FFFF (according to wikipedia) so thats 21 bits. Rather than extending the buckets, I decided to convert from a 2-level array to 3-level, with each level having 7 bits.
The slight loss of speed from the extra lookup should be more than made up for by avoiding the div instruction; I used bitshifts instead.
Also, I added 'if' statements that ignore any character request >= 0x11000. This is the most important part, because before, data external to the program would have been able to cause a buffer overrun of up to 0xFFFF00 beyond the end of the 256-element array, which could be quite dangerous.
I also was about to implement a static "sentinel" index, so that instead of pointing to NULL, the empty buckets would point to Sentinel and this would get rid of the 'if' statements in 'find()'. However, its something of a mess to get static vars initialized in a library and I decided it was a bit overkill. (but if you like that idea, I'll go ahead and write it)