@@ -2303,7 +2303,8 @@ export class StaticLayout {
2303
2303
nsAttributedString . addAttributeValueRange ( NSParagraphStyleAttributeName , paragraphStyle , fullRange ) ;
2304
2304
}
2305
2305
draw ( canvas : Canvas , maxHeight = Number . MAX_VALUE ) {
2306
- canvas . startApplyPaint ( this . paint ) ;
2306
+ const paint = this . paint ;
2307
+ canvas . startApplyPaint ( paint ) ;
2307
2308
const ctx = canvas . ctx ;
2308
2309
this . createAttributedStringToDraw ( canvas ) ;
2309
2310
// const attributes = this.paint.getDrawTextAttribs();
@@ -2334,14 +2335,24 @@ export class StaticLayout {
2334
2335
// UIDrawingText.drawAttributedStringXYWidthHeightWithAttributes(this.nsAttributedString, 0, 0, this.width, maxHeight, attributes);
2335
2336
2336
2337
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
+ }
2338
2349
this . mToDraw . drawWithRectOptionsContext (
2339
2350
CGRectMake ( 0 , 0 , this . width , maxHeight ) ,
2340
2351
NSStringDrawingOptions . UsesLineFragmentOrigin | NSStringDrawingOptions . TruncatesLastVisibleLine | NSStringDrawingOptions . UsesFontLeading ,
2341
2352
null
2342
2353
) ;
2343
2354
UIGraphicsPopContext ( ) ;
2344
- canvas . finishApplyPaint ( this . paint ) ;
2355
+ canvas . finishApplyPaint ( paint ) ;
2345
2356
}
2346
2357
getPaint ( ) {
2347
2358
return this . paint ;
0 commit comments