@@ -2261,7 +2261,6 @@ function lineBreakToLineBreakMode(value: string) {
2261
2261
export class StaticLayout {
2262
2262
rect : CGRect ;
2263
2263
nsAttributedString : NSAttributedString ;
2264
- lineBreak : string ;
2265
2264
mToDraw : NSMutableAttributedString ;
2266
2265
public constructor (
2267
2266
private text : any ,
@@ -2301,23 +2300,57 @@ export class StaticLayout {
2301
2300
break ;
2302
2301
}
2303
2302
2304
- if ( this . lineBreak ) {
2305
- paragraphStyle . lineBreakMode = lineBreakToLineBreakMode ( this . lineBreak ) ;
2303
+ if ( this . ellipsize ) {
2304
+ // for now we only support end because we cant get NSLineBreakStrategy.Standard to work with
2305
+ // others
2306
+ // paragraphStyle.lineBreakMode = lineBreakToLineBreakMode(this.ellipsize);
2307
+ paragraphStyle . lineBreakStrategy = NSLineBreakStrategy . Standard ;
2306
2308
}
2307
2309
const fullRange = { location : 0 , length : nsAttributedString . length } ;
2308
- nsAttributedString . addAttributeValueRange ( NSParagraphStyleAttributeName , paragraphStyle , fullRange ) ;
2309
2310
this . mToDraw = nsAttributedString ;
2310
2311
this . nsAttributedString . enumerateAttributesInRangeOptionsUsingBlock ( fullRange , 0 as any , ( attributes : NSDictionary < string , any > , range : NSRange , p3 : any ) => {
2311
2312
nsAttributedString . addAttributesRange ( attributes , range ) ;
2312
2313
} ) ;
2314
+ nsAttributedString . addAttributeValueRange ( NSParagraphStyleAttributeName , paragraphStyle , fullRange ) ;
2313
2315
}
2314
2316
draw ( canvas : Canvas , maxHeight = Number . MAX_VALUE ) {
2315
2317
canvas . startApplyPaint ( this . paint ) ;
2316
2318
const ctx = canvas . ctx ;
2317
2319
this . createAttributedStringToDraw ( ) ;
2320
+ // const attributes = this.paint.getDrawTextAttribs();
2321
+ // if (this.align || this.ellipsize) {
2322
+ // let paragraphStyle = attributes.objectForKey(NSParagraphStyleAttributeName) as NSMutableParagraphStyle;
2323
+ // if (!paragraphStyle) {
2324
+ // paragraphStyle = NSMutableParagraphStyle.alloc().init();
2325
+ // attributes.setObjectForKey(paragraphStyle, NSParagraphStyleAttributeName);
2326
+ // }
2327
+ // switch (this.align) {
2328
+ // case LayoutAlignment.ALIGN_CENTER:
2329
+ // paragraphStyle.alignment = NSTextAlignment.Center;
2330
+ // break;
2331
+ // case LayoutAlignment.ALIGN_NORMAL:
2332
+ // paragraphStyle.alignment = NSTextAlignment.Left;
2333
+ // break;
2334
+ // case LayoutAlignment.ALIGN_OPPOSITE:
2335
+ // paragraphStyle.alignment = NSTextAlignment.Right;
2336
+ // break;
2337
+ // }
2338
+ // if (this.ellipsize) {
2339
+ // paragraphStyle.lineBreakMode = lineBreakToLineBreakMode(this.ellipsize);
2340
+ // }
2341
+ // }
2342
+ // console.log('this.nsAttributedString', this.nsAttributedString);
2343
+ // console.log('attributes', attributes);
2344
+ // UIGraphicsPushContext(ctx);
2345
+ // UIDrawingText.drawAttributedStringXYWidthHeightWithAttributes(this.nsAttributedString, 0, 0, this.width, maxHeight, attributes);
2318
2346
2319
2347
UIGraphicsPushContext ( ctx ) ;
2320
- this . mToDraw . drawWithRectOptionsContext ( CGRectMake ( 0 , 0 , this . width , maxHeight ) , NSStringDrawingOptions . UsesLineFragmentOrigin | NSStringDrawingOptions . UsesFontLeading , null ) ;
2348
+
2349
+ this . mToDraw . drawWithRectOptionsContext (
2350
+ CGRectMake ( 0 , 0 , this . width , maxHeight ) ,
2351
+ NSStringDrawingOptions . UsesLineFragmentOrigin | NSStringDrawingOptions . TruncatesLastVisibleLine | NSStringDrawingOptions . UsesFontLeading ,
2352
+ null
2353
+ ) ;
2321
2354
UIGraphicsPopContext ( ) ;
2322
2355
canvas . finishApplyPaint ( this . paint ) ;
2323
2356
}
0 commit comments