fix encode_glyphs