fixed bug in getTextDir