Added a general function for measuring text