function string_height(text, font, size) {
        var i, x, y, box;
        x = size / 2;
        y = size + (size / 2);
        if (!SpamoMeasureBox) SpamoMeasureBox = document.createElement("canvas");
        SpamoMeasureBox.width = size * 2;
        SpamoMeasureBox.height = size * 2;
        ctx = SpamoMeasureBox.getContext('2d');
        ctx.font = font;
        for (i = 0; i < text.length; ++i) {
          ctx.fillText(text.charAt(i), x, y);
        }
        box = bbox(ctx, size * 2, size * 2, true);

        return {height: box.height, vcenteroffset: (box.height / 2)}
      }
/*
       * Measures the character heights in string
       * by painting them over the top of each other and finding the
       * bounding box. Returns the height of the total string
       * as well as calculating the vertical centering offset.
       */
Measures the character heights in string
by painting them over the top of each other and finding the
bounding box. Returns the height of the total string
as well as calculating the vertical centering offset.
Measures the character heights in string by painting them over the top of each other and finding the bounding box . Returns the height of the total string as well as calculating the vertical centering offset .
function string_height(text, font, size) {
        var i, x, y, box;
        x = size / 2;
        y = size + (size / 2);
        if (!SpamoMeasureBox) SpamoMeasureBox = document.createElement("canvas");
        SpamoMeasureBox.width = size * 2;
        SpamoMeasureBox.height = size * 2;
        ctx = SpamoMeasureBox.getContext('2d');
        ctx.font = font;
        for (i = 0; i < text.length; ++i) {
          ctx.fillText(text.charAt(i), x, y);
        }
        box = bbox(ctx, size * 2, size * 2, true);
        return {height: box.height, vcenteroffset: (box.height / 2)}
      }
function string_height ( text , font , size ) { var i , x , y , box ; x = size / 2 ; y = size + ( size / 2 ) ; if ( ! SpamoMeasureBox ) SpamoMeasureBox = document . createElement ( "canvas" ) ; SpamoMeasureBox . width = size * 2 ; SpamoMeasureBox . height = size * 2 ; ctx = SpamoMeasureBox . getContext ( '2d' ) ; ctx . font = font ; for ( i = 0 ; i < text . length ; ++ i ) { ctx . fillText ( text . charAt ( i ) , x , y ) ; } box = bbox ( ctx , size * 2 , size * 2 , true ) ; return { height : box . height , vcenteroffset : ( box . height / 2 ) } }
Measures the character heights in string
 by painting them over the top of each other and finding the
 bounding box.
Measures the character heights in string by painting them over the top of each other and finding the bounding box .