File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -155,7 +155,8 @@ export class Text extends Shape {
155155 let fontsize = Math . min ( this . boundingBox . size . y ?? Number . POSITIVE_INFINITY , this . fontsize ?? Number . POSITIVE_INFINITY ) ;
156156 if ( fontsize == Number . POSITIVE_INFINITY ) fontsize = C . DEFAULT_FONTSIZE ;
157157 context . font = Text . buildFont ( this . style , fontsize , this . font ) ;
158- if ( context . measureText ( this . text ) . width >= this . boundingBox . size . x ) fontsize = fontsize * this . boundingBox . size . x / context . measureText ( this . text ) . width ;
158+ const defaultTextWidth = context . measureText ( this . text ) . width ;
159+ if ( defaultTextWidth >= this . boundingBox . size . x ) fontsize = fontsize * this . boundingBox . size . x / defaultTextWidth ;
159160 return fontsize
160161 }
161162
@@ -223,7 +224,13 @@ export class Text extends Shape {
223224 context . resetTransform ( ) ;
224225 context . translate ( origin . x , origin . y ) ;
225226 context . rotate ( Math . PI / 180 * this . orientation ) ;
226- if ( this . isScaled ) context . scale ( Math . abs ( contextMatrix . a ) , Math . abs ( contextMatrix . d ) ) ;
227+ if ( this . isScaled ) {
228+ if ( this . fontsize < 1 ) {
229+ context . scale ( Math . abs ( contextMatrix . a * this . fontsize ) , Math . abs ( contextMatrix . d * this . fontsize ) ) ;
230+ context . font = Text . buildFont ( this . style , 1 , this . font ) ;
231+ }
232+ else context . scale ( Math . abs ( contextMatrix . a ) , Math . abs ( contextMatrix . d ) ) ;
233+ }
227234 this . write ( this . writtenText , context ) ;
228235 }
229236
You can’t perform that action at this time.
0 commit comments