refactoring code for font selection