@@ -216,7 +216,7 @@ export default class FontMetric {
216216 return this . isProportionalCache [ fontFamily ] = w_width !== i_width ;
217217 }
218218
219- sizeFor ( style , string = '' , forceCache = false ) {
219+ sizeFor ( style , stringOrTextAndAttr = '' , forceCache = false ) {
220220 // Select style properties relevant to individual character size
221221 const {
222222 fontFamily, fontSize, lineHeight,
@@ -232,12 +232,17 @@ export default class FontMetric {
232232 textStyleClasses
233233 } ;
234234
235- if ( ! forceCache && string . length > 1 ) return this . measure ( relevantStyle , string ) ;
235+ if ( Array . isArray ( stringOrTextAndAttr ) && stringOrTextAndAttr [ 1 ] ?. fontFamily ) {
236+ relevantStyle . nestedFontFamily = stringOrTextAndAttr [ 1 ] ?. fontFamily ;
237+ }
238+
239+ if ( ! forceCache && stringOrTextAndAttr . length > 1 ) return this . measure ( relevantStyle , stringOrTextAndAttr ) ;
236240
237241 const styleKey = this . _domMeasure . generateStyleKey ( relevantStyle ) ;
242+ const string = typeof stringOrTextAndAttr === 'string' ? stringOrTextAndAttr : stringOrTextAndAttr [ 0 ] ;
238243
239244 if ( ! this . charMap [ styleKey ] ) { this . charMap [ styleKey ] = { } ; }
240- if ( ! this . charMap [ styleKey ] [ string ] ) { this . charMap [ styleKey ] [ string ] = this . measure ( relevantStyle , string ) ; }
245+ if ( ! this . charMap [ styleKey ] [ string ] ) { this . charMap [ styleKey ] [ string ] = this . measure ( relevantStyle , stringOrTextAndAttr ) ; }
241246
242247 return this . charMap [ styleKey ] [ string ] ;
243248 }
@@ -398,6 +403,7 @@ class DOMTextMeasure {
398403 const {
399404
400405 fontFamily,
406+ nestedFontFamily,
401407 fontSize,
402408 fontWeight,
403409 fontStyle,
@@ -409,7 +415,7 @@ class DOMTextMeasure {
409415 width, height, clipMode, lineWrapping, textAlign
410416 } = styleOpts ;
411417 return [
412- fontFamily ,
418+ fontFamily + ( nestedFontFamily ? `@ ${ nestedFontFamily } ` : '' ) ,
413419 fontSize ,
414420 fontWeight ,
415421 fontStyle ,
0 commit comments