<commit_before>class NauticalFlagsTypeset {
  constructor(){
    this.font = undefined;

    this.styleStack = [];
    this.printBlocks = [];

    this.mode = NauticalFlagsTypeset.MODE_TEXT;
  }
  static get MODE_SINGLE(){ return 0; }
  static get MODE_TEXT(){ return 1; }

  setFont(newFont) {
    this.font = newFont;
    this.supportedKeybuffers = Object.getOwnPropertyNames(nauticalFlags.__proto__)
                                     .filter(item => typeof nauticalFlags[item] === 'function')
                                     .filter(name => name.startsWith('drawSpecial') )
                                     .map(name => name.replace('drawSpecial', ''));
  }

  get fontWidth(){
    return this.font.flagWidth;
  }

  getProperties(){
    return {
      fontWidth: this.fontWidth
    };
  }

  textSize(newSize){
    this.font.flagWidth = newSize;
  }

  push(){
    this.styleStack.push(this.getProperties());
  }

  pop(){
    if (this.styleStack.length == 0){
      return;
    }
    this.applyStyle( this.styleStack.pop() );
  }

  applyStyle(style){
    this.font.flagWidth = style.fontWidth;
  }

  text(str, x, y, w, h){
    x = x || 0;
    y = y || 0;
    w = w || width;
    h = h || height - y;
    let textAlignment = textAlign();

    const letterSpacing = this.fontWidth * 0.1;


    const textWidth = str.length * this.fontWidth 
                        + (str.length - 1) * letterSpacing;
    let startX;
    if (textAlignment.horizontal == CENTER){
      startX = x + (w - textWidth) / 2;
    } else if (textAlignment.horizontal == RIGHT){
      startX = x + w - textWidth;
    } else {
      // ALIGN LEFT
      startX = x;
    }

    noStroke();<commit_msg>p5js/nautical-flags-02 - Fix bug related to setting a new font-size<commit_after>class NauticalFlagsTypeset {
  constructor(){
    this.font = undefined;

    this.styleStack = [];
    this.printBlocks = [];

    this.mode = NauticalFlagsTypeset.MODE_TEXT;
  }
  static get MODE_SINGLE(){ return 0; }
  static get MODE_TEXT(){ return 1; }

  setFont(newFont) {
    this.font = newFont;
    this.supportedKeybuffers = Object.getOwnPropertyNames(nauticalFlags.__proto__)
                                     .filter(item => typeof nauticalFlags[item] === 'function')
                                     .filter(name => name.startsWith('drawSpecial') )
                                     .map(name => name.replace('drawSpecial', ''));
  }

  get fontWidth(){
    return this.font.flagWidth;
  }

  getProperties(){
    return {
      fontWidth: this.fontWidth
    };
  }

  textSize(newSize){
    this.font.nWidth = newSize;
  }

  push(){
    this.styleStack.push(this.getProperties());
  }

  pop(){
    if (this.styleStack.length == 0){
      return;
    }
    this.applyStyle( this.styleStack.pop() );
  }

  applyStyle(style){
    this.font.nWidth = style.fontWidth;
  }

  text(str, x, y, w, h){
    x = x || 0;
    y = y || 0;
    w = w || width;
    h = h || height - y;
    let textAlignment = textAlign();

    const letterSpacing = this.fontWidth * 0.1;


    const textWidth = str.length * this.fontWidth 
                        + (str.length - 1) * letterSpacing;
    let startX;
    if (textAlignment.horizontal == CENTER){
      startX = x + (w - textWidth) / 2;
    } else if (textAlignment.horizontal == RIGHT){
      startX = x + w - textWidth;
    } else {
      // ALIGN LEFT
      startX = x;
    }

    noStroke();
{'fraction_non_alphanumeric': 0.13514302393461763, 'fraction_numerical': 0.006129597197898424, 'mean_word_length': 2.046222222222222, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1459024', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1083, 'n_words': 229}