fix crash in texttools.cpp