@@ -2303,7 +2303,8 @@ export class StaticLayout {
23032303 nsAttributedString . addAttributeValueRange ( NSParagraphStyleAttributeName , paragraphStyle , fullRange ) ;
23042304 }
23052305 draw ( canvas : Canvas , maxHeight = Number . MAX_VALUE ) {
2306- canvas . startApplyPaint ( this . paint ) ;
2306+ const paint = this . paint ;
2307+ canvas . startApplyPaint ( paint ) ;
23072308 const ctx = canvas . ctx ;
23082309 this . createAttributedStringToDraw ( canvas ) ;
23092310 // const attributes = this.paint.getDrawTextAttribs();
@@ -2334,14 +2335,24 @@ export class StaticLayout {
23342335 // UIDrawingText.drawAttributedStringXYWidthHeightWithAttributes(this.nsAttributedString, 0, 0, this.width, maxHeight, attributes);
23352336
23362337 UIGraphicsPushContext ( ctx ) ;
2337-
2338+ if ( paint . align !== Align . LEFT ) {
2339+ let offsetx = 0 ;
2340+ const width = this . getBounds ( ) . size . width ;
2341+ if ( paint . align === Align . RIGHT ) {
2342+ offsetx -= width ;
2343+ }
2344+ else {
2345+ offsetx -= width / 2 ;
2346+ }
2347+ CGContextTranslateCTM ( ctx , offsetx , 0 ) ;
2348+ }
23382349 this . mToDraw . drawWithRectOptionsContext (
23392350 CGRectMake ( 0 , 0 , this . width , maxHeight ) ,
23402351 NSStringDrawingOptions . UsesLineFragmentOrigin | NSStringDrawingOptions . TruncatesLastVisibleLine | NSStringDrawingOptions . UsesFontLeading ,
23412352 null
23422353 ) ;
23432354 UIGraphicsPopContext ( ) ;
2344- canvas . finishApplyPaint ( this . paint ) ;
2355+ canvas . finishApplyPaint ( paint ) ;
23452356 }
23462357 getPaint ( ) {
23472358 return this . paint ;
0 commit comments