Compiling Glyphs For A Text

I recently created a flash banner using haXe and swfmill. When embedding my font into a library, I wanted to include only used characters. The following code prints the set of glyphs for use in swfmill source file:

# We'll use string `s` as our starting point
s=u'Let\'s find out which chars make up this text!'

# This is a set of chars in `s`, sorted and re-assembled as a string
chars = ''.join(sorted(set(s)))

# We need to escape non-ascii chars
encoded_chars = chars.encode('ascii', 'xmlcharrefreplace')

# Result
print encoded_chars

Hope it helps someone.

Bookmark and Share

No related posts.

Tags: , ,

Comments are closed.