module Unicode::DisplayWidth
def self.of(string, ambiguous = 1, overwrite = {}, options = {})
def self.of(string, ambiguous = 1, overwrite = {}, options = {}) res = string.codepoints.inject(0){ |total_width, codepoint| index_or_value = INDEX codepoint_depth_offset = codepoint DEPTHS.each{ |depth| index_or_value = index_or_value[codepoint_depth_offset / depth] codepoint_depth_offset = codepoint_depth_offset % depth break unless index_or_value.is_a? Array } width = index_or_value.is_a?(Array) ? index_or_value[codepoint_depth_offset] : index_or_value width = ambiguous if width == :A total_width + (overwrite[codepoint] || width || 1) } res -= emoji_extra_width_of(string) if options[:emoji] res < 0 ? 0 : res end