<commit_before>fontTester = require "../core/font/tester.coffee"

module.exports = (words, style, opts) ->

  opts   = {} unless opts
  tester = opts.parent or fontTester("svg").append("g")
  style  = style or {}
  sizes  = []
  words  = [ words ] unless words instanceof Array
  tspans = tester.selectAll("text").data(words)
  attr   =
    x: 0
    y: 0

  tspans.enter().append("text")
    .text String
    .attr "position", "absolute"
    .attr "top", "0px"
    .attr "left", "0px"
    .style style
    .attr attr
    .each (d) ->
      opts.mod this if typeof opts.mod is "function"
    .each (d) ->

      children = d3.select(this).selectAll("tspan")
      if children.size()
        width  = []
        children.each -> width.push getWidth(this)
        width = d3.max width
      else
        width = getWidth(this)
      height = getHeight(this)

      sizes.push<commit_msg>font.sizes needs to use tspans<commit_after>fontTester = require "../core/font/tester.coffee"

module.exports = (words, style, opts) ->

  opts   = {} unless opts
  tester = opts.parent or fontTester("svg").append("text")
  style  = style or {}
  sizes  = []
  words  = [ words ] unless words instanceof Array
  tspans = tester.selectAll("tspan").data(words)
  attr   =
    left: "0px"
    position: "absolute"
    top: "0px"
    x: 0
    y: 0

  tspans.enter().append("tspan")
    .text String
    .style style
    .attr attr
    .each (d) -> opts.mod this if typeof opts.mod is "function"
    .each (d) ->

      children = d3.select(this).selectAll("tspan")
      if children.size()
        width  = []
        children.each -> width.push getWidth(this)
        width = d3.max width
      else
        width = getWidth(this)
      height = getHeight(this)

      sizes.push
{'fraction_non_alphanumeric': 0.1409090909090909, 'fraction_numerical': 0.006818181818181818, 'mean_word_length': 2.3101503759398496, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4401624', 'n_tokens_mistral': 601, 'n_tokens_neox': 587, 'n_words': 150}