dist/melonjs.js
function setFont(font, size) {
         // font name and type
         var font_names = font.split(",").map(function (value) {
           value = value.trim();
           return !/(^".*"$)|(^'.*'$)/.test(value) ? "\"" + value + "\"" : value;
         }); // font size

         if (typeof size === "number") {
           this._fontSize = size;
           size += "px";
         } else
           /* string */
           {
             // extract the units and convert if necessary
             var CSSval = size.match(/([-+]?[\d.]*)(.*)/);
             this._fontSize = parseFloat(CSSval[1]);

             if (CSSval[2]) {
               this._fontSize *= toPX[runits.indexOf(CSSval[2])];
             } else {
               // no unit define, assume px
               size += "px";
             }
           }

         this.height = this._fontSize;
         this.font = size + " " + font_names.join(",");
         this.isDirty = true;
         return this;
       }
function setFont(font, size) {
         // font name and type
         var font_names = font.split(",").map(function (value) {
           value = value.trim();
           return !/(^".*"$)|(^'.*'$)/.test(value) ? "\"" + value + "\"" : value;
         }); // font size

         if (typeof size === "number") {
           this._fontSize = size;
           size += "px";
         } else
           /* string */
           {
             // extract the units and convert if necessary
             var CSSval = size.match(/([-+]?[\d.]*)(.*)/);
             this._fontSize = parseFloat(CSSval[1]);

             if (CSSval[2]) {
               this._fontSize *= toPX[runits.indexOf(CSSval[2])];
             } else {
               // no unit define, assume px
               size += "px";
             }
           }

         this.height = this._fontSize;
         this.font = size + " " + font_names.join(",");
         this.isDirty = true;
         return this;
       }
function setFont ( font , size ) { // font name and type var font_names = font . split ( "," ) . map ( function ( value ) { value = value . trim ( ) ; return ! / (^".*"$)|(^'.*'$) / . test ( value ) ? "\"" + value + "\"" : value ; } ) ; // font size if ( typeof size === "number" ) { this . _fontSize = size ; size += "px" ; } else /* string */ { // extract the units and convert if necessary var CSSval = size . match ( / ([-+]?[\d.]*)(.*) / ) ; this . _fontSize = parseFloat ( CSSval [ 1 ] ) ; if ( CSSval [ 2 ] ) { this . _fontSize *= toPX [ runits . indexOf ( CSSval [ 2 ] ) ] ; } else { // no unit define, assume px size += "px" ; } } this . height = this . _fontSize ; this . font = size + " " + font_names . join ( "," ) ; this . isDirty = true ; return this ; }
set the font family and size
@name setFont
@memberOf me.Text.prototype
@function
@param {String} font a CSS font name
@param {Number|String} size size, or size + suffix (px, em, pt)
@return this object for chaining
@example
font.setFont("Arial", 20);
font.setFont("Arial", "1.5em");
set the font family and size