public float adjustWidth ( float width ) { // Canvas.measureText does not account for the extra width consumed by italic characters, so we // fudge in a fraction of an em and hope the font isn't too slanted switch ( font . style ) { case ITALIC : return width + emwidth / 8 ; case BOLD_ITALIC : return width + emwidth / 6 ; default : return width ; // nada } }
Adjusts a measured width to account for italic and bold italic text . We have to handle this hackily because there s no way to measure exact text extent in HTML5 .