Skip to content

Commit a017910

Browse files
committed
fix: fix text being something else that string
1 parent 8424195 commit a017910

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/canvas.android.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,9 @@ export class StaticLayout {
458458
}
459459
constructor(text: any, paint: android.graphics.Paint, width: number, align = LayoutAlignment.ALIGN_NORMAL, spacingmult = 1, spacingadd = 0, includepad = true) {
460460
paint = paint['_native'] ? (paint as any).getNative() : paint;
461+
if (!(text instanceof java.lang.CharSequence) && !(typeof text === 'string')) {
462+
text = text + '';
463+
}
461464
if (isPostLVar()) {
462465
this._native = android.text.StaticLayout.Builder.obtain(
463466
text,

src/canvas.ios.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,8 +2049,8 @@ export class StaticLayout {
20492049
this.nsAttributedString = text;
20502050
// } else if (!(text instanceof NSMutableAttributedString)) {
20512051
// text = NSMutableAttributedString.alloc().initWithStringAttributes(text, this.paint.getDrawTextAttribs());
2052-
} else if (!(text instanceof NSAttributedString)) {
2053-
this.nsAttributedString = NSAttributedString.alloc().initWithString(text);
2052+
} else {
2053+
this.nsAttributedString = NSAttributedString.alloc().initWithString(text +' ' );
20542054
}
20552055
}
20562056
toDraw: NSMutableAttributedString;

0 commit comments

Comments
 (0)