def checkGlyphIsEmpty(glyph, allowWhiteSpace=True):
whiteSpace = [  <NUM_LIT>,    <EOL><NUM_LIT>,    <EOL><NUM_LIT>,    <EOL><NUM_LIT>,    <EOL><NUM_LIT>,    <EOL><NUM_LIT>,   <EOL><NUM_LIT>,   <EOL><NUM_LIT>,   <EOL><NUM_LIT>, <EOL><NUM_LIT>, <EOL><NUM_LIT>, <EOL><NUM_LIT>, <EOL><NUM_LIT>, <EOL><NUM_LIT>, <EOL><NUM_LIT>, <EOL><NUM_LIT>, <EOL><NUM_LIT>, <EOL><NUM_LIT>, <EOL><NUM_LIT>, <EOL><NUM_LIT>, <EOL><NUM_LIT>, <EOL><NUM_LIT>, <EOL><NUM_LIT>, <EOL><NUM_LIT>, <EOL><NUM_LIT>, <EOL>]<EOL>emptyPen = EmptyPen()<EOL>glyph.drawPoints(emptyPen)<EOL>if emptyPen.isEmpty():<EOL><INDENT>if glyph.unicode in whiteSpace and allowWhiteSpace:<EOL><INDENT>return False<EOL><DEDENT>return True<EOL><DEDENT>return False<EOL>
This will establish if the glyph is completely empty by drawing the glyph with an EmptyPen.
Additionally, the unicode of the glyph is checked against a list of known unicode whitespace
characters. This makes it possible to filter out glyphs that have a valid reason to be empty
and those that can be ignored.