@@ -515,6 +515,9 @@ class DOMTextMeasure {
515515 }
516516 ++ i ;
517517 }
518+
519+ const localStyle = { ...morph . defaultTextStyle , ...styleOpts } ;
520+
518521 for ( let i = 0 ; i < codePoints . length ; i ++ ) {
519522 const code = codePoints [ i ] ;
520523 if ( code === 32 && measuringState . currentWord . length > 0 ) {
@@ -528,7 +531,7 @@ class DOMTextMeasure {
528531 if ( isMonospace && Array . isArray ( code ) ) {
529532 hit = fontMetric . defaultCharExtent ( morph ) . width * 2 ; // for emojis
530533 } else {
531- const metrics = Array . isArray ( code ) ? fontMetric . measure ( morph , code . map ( c => String . fromCharCode ( c ) ) . join ( '' ) ) : ctx . measureText ( String . fromCharCode ( code ) ) ;
534+ const metrics = Array . isArray ( code ) ? fontMetric . measure ( localStyle , code . map ( c => String . fromCharCode ( c ) ) . join ( '' ) ) : ctx . measureText ( String . fromCharCode ( code ) ) ;
532535 const writeToCache = document . fonts . status === 'loaded' && morph . allFontsLoaded ( ) ;
533536 hit = metrics . width ;
534537 if ( writeToCache ) cache [ Array . isArray ( code ) ? code . join ( ',' ) : code ] = hit ;
@@ -812,8 +815,9 @@ export function charBoundsOfLineViaCanvas (line, textMorph, fontMetric, measure)
812815 }
813816 const style = { ...textMorph . defaultTextStyle , ...attrs } ;
814817 style . fontSize = Math . max ( style . fontSize , textMorph . fontSize ) ;
818+ const charHeight = attrs . fontFamily ? fontMetric . sizeFor ( textMorph . defaultTextStyle , [ '.' , attrs ] , true ) . height : fontMetric . defaultLineHeight ( style ) ;
815819 measure . measureCharWidthsInCanvas ( textMorph , textOrMorph , attrs , measuringState ) . forEach ( ( res ) => {
816- characterBounds . push ( [ fontMetric . defaultLineHeight ( style ) , res ] ) ;
820+ characterBounds . push ( [ charHeight , res ] ) ;
817821 } ) ;
818822 } else {
819823 console . warn ( 'Can not measure' , textOrMorph ) ; // eslint-disable-line no-console
0 commit comments