Skip to content

Commit 16c5f04

Browse files
committed
feat(canvas-label): lineBreak support for spans
1 parent 2b22e82 commit 16c5f04

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/ui-canvaslabel/canvaslabel.common.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export abstract class Span extends Shape {
6868
@stringProperty textAlignment: CoreTypes.TextAlignmentType & 'middle';
6969
@stringProperty textDecoration: CoreTypes.TextDecorationType;
7070
@stringProperty textTransform: CoreTypes.TextTransformType;
71+
@stringProperty lineBreak: string | number;
7172

7273
@percentLengthProperty width: CoreTypes.PercentLengthType;
7374
@percentLengthProperty height: CoreTypes.PercentLengthType;
@@ -214,6 +215,7 @@ export abstract class Span extends Shape {
214215
const fontstyle = this.fontStyle || parent.style.fontStyle || parent.fontStyle;
215216
const fontFamily = this.fontFamily;
216217
const color = this.color || parent.style.color;
218+
const lineBreak = this.lineBreak || parent['lineBreak'];
217219
const xfermode = this.xfermode;
218220
const fontSize = this.fontSize;
219221
const letterSpacing = this.letterSpacing;
@@ -238,7 +240,7 @@ export abstract class Span extends Shape {
238240
if (color) {
239241
cachedPaint.color = color;
240242
}
241-
this.mStaticlayout = new StaticLayout(text, cachedPaint, w, align, 1, 0, true);
243+
this.mStaticlayout = new StaticLayout(text, cachedPaint, w, align, 1, 0, true, lineBreak);
242244
return this.mStaticlayout;
243245
}
244246

@@ -408,7 +410,7 @@ export abstract class Span extends Shape {
408410
}
409411
}
410412
}
411-
staticlayout.draw(canvas);
413+
staticlayout.draw(canvas, h);
412414
}
413415
toNativeString() {}
414416
}

0 commit comments

Comments
 (0)