mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
fix: text position for form elements and list markers (#2588)
This commit is contained in:
parent
fa60716d07
commit
cd99f11b1b
@ -376,7 +376,7 @@ export class CanvasRenderer {
|
|||||||
this.ctx.font = fontFamily;
|
this.ctx.font = fontFamily;
|
||||||
this.ctx.fillStyle = asString(styles.color);
|
this.ctx.fillStyle = asString(styles.color);
|
||||||
|
|
||||||
this.ctx.textBaseline = 'middle';
|
this.ctx.textBaseline = 'alphabetic';
|
||||||
this.ctx.textAlign = canvasTextAlign(container.styles.textAlign);
|
this.ctx.textAlign = canvasTextAlign(container.styles.textAlign);
|
||||||
|
|
||||||
const bounds = contentBox(container);
|
const bounds = contentBox(container);
|
||||||
@ -409,7 +409,7 @@ export class CanvasRenderer {
|
|||||||
baseline
|
baseline
|
||||||
);
|
);
|
||||||
this.ctx.restore();
|
this.ctx.restore();
|
||||||
this.ctx.textBaseline = 'bottom';
|
this.ctx.textBaseline = 'alphabetic';
|
||||||
this.ctx.textAlign = 'left';
|
this.ctx.textAlign = 'left';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,7 +427,7 @@ export class CanvasRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (paint.listValue && container.styles.listStyleType !== LIST_STYLE_TYPE.NONE) {
|
} else if (paint.listValue && container.styles.listStyleType !== LIST_STYLE_TYPE.NONE) {
|
||||||
const [fontFamily, fontSize] = this.createFontStyle(styles);
|
const [fontFamily] = this.createFontStyle(styles);
|
||||||
|
|
||||||
this.ctx.font = fontFamily;
|
this.ctx.font = fontFamily;
|
||||||
this.ctx.fillStyle = asString(styles.color);
|
this.ctx.fillStyle = asString(styles.color);
|
||||||
@ -441,12 +441,10 @@ export class CanvasRenderer {
|
|||||||
computeLineHeight(styles.lineHeight, styles.fontSize.number) / 2 + 1
|
computeLineHeight(styles.lineHeight, styles.fontSize.number) / 2 + 1
|
||||||
);
|
);
|
||||||
|
|
||||||
const {baseline} = this.fontMetrics.getMetrics(fontFamily, fontSize);
|
|
||||||
|
|
||||||
this.renderTextWithLetterSpacing(
|
this.renderTextWithLetterSpacing(
|
||||||
new TextBounds(paint.listValue, bounds),
|
new TextBounds(paint.listValue, bounds),
|
||||||
styles.letterSpacing,
|
styles.letterSpacing,
|
||||||
baseline
|
computeLineHeight(styles.lineHeight, styles.fontSize.number) / 2 + 2
|
||||||
);
|
);
|
||||||
this.ctx.textBaseline = 'bottom';
|
this.ctx.textBaseline = 'bottom';
|
||||||
this.ctx.textAlign = 'left';
|
this.ctx.textAlign = 'left';
|
||||||
|
Loading…
Reference in New Issue
Block a user