core/glyph: copy data when adding glyph to cache

fixes #1500
Merge pull request #1508 from bmiklautz/issue/1500

core/glyph: copy data when adding glyph to cache