Refactor common glyph drawing code