def position_letters_in_word(word, line_width)
      # Strip tags before measuring word.
      word.gsub(ENTITIES_AND_TAGS_PATTERN, '').each_char do |c|
        char_width = font.text_width(c)
        line_width += char_width
        @caret_positions.push [line_width, y_at_line(@lines.size)]
        @char_widths.push char_width
      end

      line_width
    end
def position_letters_in_word(word, line_width)
      # Strip tags before measuring word.
      word.gsub(ENTITIES_AND_TAGS_PATTERN, '').each_char do |c|
        char_width = font.text_width(c)
        line_width += char_width
        @caret_positions.push [line_width, y_at_line(@lines.size)]
        @char_widths.push char_width
      end

      line_width
    end
Helper for #recalc
 @return [Integer]