export function getFontWidth ( font ) { let width = Private . fontWidthCache [ font ] ; if ( width !== undefined ) { return width ; } Private . fontMeasurementGC . font = font ; let normFont = Private . fontMeasurementGC . font ; Private . fontMeasurementNode . style . font = normFont ; document . body . appendChild ( Private . fontMeasurementNode ) ; width = Private . fontMeasurementNode . offsetWidth ; document . body . removeChild ( Private . fontMeasurementNode ) ; Private . fontWidthCache [ font ] = width ; Private . fontWidthCache [ normFont ] = width ; return width ; } /**
 * The namespace for the module implementation details.
 */ namespace Private { /**
     * A cache of measured font heights.
     */ export const fontWidthCache = Object . create ( null ) ; /**
     * The DOM node used for font height measurement.
     */ export const fontMeasurementNode = ( ( ) => { let node = document . createElement ( 'div' ) ; node . style . position = 'absolute' ; node . style . top = '-99999px' ; node . style . left = '-99999px' ; node . style . visibility = 'hidden' ; node . textContent = 'M' ; return node ; } ) ( ) ; /**
     * The GC used for font measurement.
     */ export const fontMeasurementGC = ( ( ) => { let canvas = document . createElement ( 'canvas' ) ; canvas . width = 0 ; canvas . height = 0 ; return canvas . getContext ( '2d' ) ! ; } ) ( ) ; }