Reimplement text truncation so that it is aware of linebreaks in the source text