Add range check for glyph buffer.
Some custom fonts with unexpected sizes can cause the writes to the glyph buffer be out of bounds, which will cause heap corruption. Adding a range check fixes this. (Will still produce corrupted text, but at least heap corruption won't happen)