Fix bug in text position computation