module NSWTopo::Font
def glyph_length(*args)
def glyph_length(*args) self.extend Chrome glyph_length *args end
def in_two(string, attributes)
def in_two(string, attributes) words = string.split(string[?\n] || string[?/] || ?\s).map(&:strip) (1...words.size).map do |index| [words[0...index].join(?\s), words[index...words.size].join(?\s)] end.map do |lines| lines.map do |line| [line, glyph_length(line, attributes)] end end.min_by do |lines_widths| lines_widths.map(&:last).max end || [[words[0], glyph_length(words[0], attributes)]] end