@@ -103,8 +103,6 @@ function text2d(p5, fn) {
103
103
textLeading : { default : 15 } ,
104
104
textSize : { default : 12 } ,
105
105
textWrap : { default : fn . WORD } ,
106
-
107
- // added v2.0
108
106
fontStretch : { default : fn . NORMAL , isShorthand : true } , // font-stretch: { default: normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded }
109
107
fontWeight : { default : fn . NORMAL , isShorthand : true } , // font-stretch: { default: normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded }
110
108
lineHeight : { default : fn . NORMAL , isShorthand : true } , // line-height: { default: normal | number | length | percentage }
@@ -456,17 +454,28 @@ function text2d(p5, fn) {
456
454
return this . _pInst ;
457
455
}
458
456
459
- // getter: get props from this.textDrawingContext()
457
+ // getter: get props from drawingContext
458
+ let context = this . textDrawingContext ( ) ;
460
459
properties = ContextTextProps . reduce ( ( props , p ) => {
461
- props [ p ] = this . textDrawingContext ( ) [ p ] ;
460
+ props [ p ] = context [ p ] ;
462
461
return props ;
463
462
} , { } ) ;
464
463
465
- // add renderer.states props
464
+ // add renderer props
466
465
Object . keys ( RendererTextProps ) . forEach ( p => {
467
- properties [ p ] = this . states [ p ] ;
468
466
if ( RendererTextProps [ p ] ?. type === 'Context2d' ) {
469
- properties [ p ] = this . textDrawingContext ( ) [ p ] ;
467
+ properties [ p ] = context [ p ] ;
468
+ }
469
+ else { // a renderer.states property
470
+ if ( p === 'textFont' ) {
471
+ // avoid circular ref. inside textFont
472
+ properties [ p ] = Object . assign ( { } , this . _currentTextFont ( ) ) ;
473
+ delete properties [ p ] . _pInst ;
474
+ console . log ( 'textFont: ' , properties [ p ] ) ;
475
+ }
476
+ else {
477
+ properties [ p ] = this . states [ p ] ;
478
+ }
470
479
}
471
480
} ) ;
472
481
0 commit comments