<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from traits . api import Trait , TraitHandler , TraitError <EOL> font_families = [ <EOL> '<STR_LIT:default>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> font_styles = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> font_weights = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> font_noise = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> class TraitFont ( TraitHandler ) : <EOL> """<STR_LIT>""" <EOL> def validate ( self , object , name , value ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> point_size = family = style = weight = underline = '<STR_LIT>' <EOL> facename = [ '<STR_LIT>' ] <EOL> for word in value . split ( ) : <EOL> lword = word . lower ( ) <EOL> if lword in font_families : <EOL> family = '<STR_LIT:U+0020>' + lword <EOL> elif lword in font_styles : <EOL> style = '<STR_LIT:U+0020>' + lword <EOL> elif lword in font_weights : <EOL> weight = '<STR_LIT:U+0020>' + lword <EOL> elif lword == '<STR_LIT>' : <EOL> underline = '<STR_LIT:U+0020>' + lword <EOL> elif lword not in font_noise : <EOL> try : <EOL> int ( lword ) <EOL> point_size = lword + '<STR_LIT>' <EOL> except : <EOL> facename . append ( word ) <EOL> fontstr = ( '<STR_LIT>' % ( point_size , family , style , weight , <EOL> underline , '<STR_LIT:U+0020>' . join ( facename ) ) ) . strip ( ) <EOL> return fontstr <EOL> except Exception : <EOL> pass <EOL> raise TraitError ( object , name , '<STR_LIT>' , <EOL> repr ( value ) ) <EOL> def info ( self ) : <EOL> return ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def get_font_editor ( * args , ** traits ) : <EOL> from . . api import FontEditor <EOL> return FontEditor ( * args , ** traits ) <EOL> fh = TraitFont ( ) <EOL> NullFont = Trait ( fh . validate ( None , None , '<STR_LIT>' ) , fh , <EOL> editor = get_font_editor ) </s>
