<commit_before>// Copyright 2002-2012, University of Colorado

/**
 * Font handling for text drawing
 *
 * Examples:
 * new scenery.Font().font                      // "10px sans-serif" (the default)
 * new scenery.Font( { family: 'serif' } ).font // "10px serif"
 * new scenery.Font( { weight: 'bold' } ).font  // "bold 10px sans-serif"
 * new scenery.Font( { size: 16 } ).font        // "16px sans-serif"
 * var font = new scenery.Font( {
 *   family: '"Times New Roman", serif'
 * } );
 * font.style = 'italic';
 * font.lineHeight = 10;
 * font.font;                                   // "italic 10px/10 'Times New Roman', serif"
 * font.family;                                 // "'Times New Roman', serif"
 * font.weight;                                 // 400 (the default)
 *
 * Useful specs:
 * http://www.w3.org/TR/css3-fonts/
 *
 * @author <NAME> <<EMAIL>>
 */

define( function( require ) {
  "use strict";
  
  var assert = require( 'ASSERT/assert' )( 'scenery' );
  
  var scenery = require( 'SCENERY/scenery' );
  
  // options from http://www.w3.org/TR/css3-fonts/
  // font-family      v ---
  // font-weight      v normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
  // font-stretch     v normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded
  // font-style       v normal | italic | oblique
  // font-size        v <absolute-size> | <relative-size> | <length> | <percentage>
  // font-size-adjust v none | auto | <number>
  // font             v [ [ <‘font-style’> || <font-variant-css21> || <‘font-weight’> || <‘font-stretch’> ]? <‘font-size’> [ / <‘line-height’> ]? <‘font-family’> ] | caption | icon | menu | message-box | small-caption | status-bar
  //                    <font-variant-css21> = [normal | small-caps]
  // font-synthesis   v none | [ weight || style ]
  
  scenery.Font = function( options ) {
    // internal string representation
    this._font = '10px sans-serif';
    
    // span for using the browser to compute font styles
    this.$span = $( document.createElement( 'span' ) );
    this.$span.css( 'font', this._font ); // set up the initial CSS, since it isn't called in getProperty anymore
    
    var type = typeof options;
    if ( type === 'string' ) {
      this._font = options;
    } else if ( type === 'object' ) {
      this.mutate( options );<commit_msg>Further improvements on Font's handling<commit_after>// Copyright 2002-2012, University of Colorado

/**
 * Font handling for text drawing
 *
 * Examples:
 * new scenery.Font().font                      // "10px sans-serif" (the default)
 * new scenery.Font( { family: 'serif' } ).font // "10px serif"
 * new scenery.Font( { weight: 'bold' } ).font  // "bold 10px sans-serif"
 * new scenery.Font( { size: 16 } ).font        // "16px sans-serif"
 * var font = new scenery.Font( {
 *   family: '"Times New Roman", serif'
 * } );
 * font.style = 'italic';
 * font.lineHeight = 10;
 * font.font;                                   // "italic 10px/10 'Times New Roman', serif"
 * font.family;                                 // "'Times New Roman', serif"
 * font.weight;                                 // 400 (the default)
 *
 * Useful specs:
 * http://www.w3.org/TR/css3-fonts/
 *
 * @author <NAME> <<EMAIL>>
 */

define( function( require ) {
  "use strict";
  
  var assert = require( 'ASSERT/assert' )( 'scenery' );
  
  var scenery = require( 'SCENERY/scenery' );
  
  // options from http://www.w3.org/TR/css3-fonts/
  // font-family      v ---
  // font-weight      v normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
  // font-stretch     v normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded
  // font-style       v normal | italic | oblique
  // font-size        v <absolute-size> | <relative-size> | <length> | <percentage>
  // font-size-adjust v none | auto | <number>
  // font             v [ [ <‘font-style’> || <font-variant-css21> || <‘font-weight’> || <‘font-stretch’> ]? <‘font-size’> [ / <‘line-height’> ]? <‘font-family’> ] | caption | icon | menu | message-box | small-caption | status-bar
  //                    <font-variant-css21> = [normal | small-caps]
  // font-synthesis   v none | [ weight || style ]
  
  scenery.Font = function( options ) {
    // internal string representation
    this._font = '10px sans-serif';
    
    // span for using the browser to compute font styles
    this.$span = $( document.createElement( 'span' ) );
    
    var type = typeof options;
    if ( type === 'string' ) {
      this._font = options;
      this.$span.css( 'font', this._font ); // properly initialize the font instance
    } else if ( type === 'object' ) {
      this.$span.css( 'font', this._font ); // properly initialize the font instance
      this.mutate( options );
    } else {
      this.$span.css( 'font', this._font ); // properly initialize the font instance
{'fraction_non_alphanumeric': 0.16170634920634921, 'fraction_numerical': 0.025396825396825397, 'mean_word_length': 2.1644695543000627, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1149285', 'n_tokens_mistral': 1729, 'n_tokens_neox': 1566, 'n_words': 434}