Rewrite editing algorithm to support non-fix-width fonts