Skip to content

Commit

Permalink
fix: text position for form elements and list markers (#2588)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasvh authored Jul 15, 2021
1 parent fa60716 commit cd99f11
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/render/canvas/canvas-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export class CanvasRenderer {
this.ctx.font = fontFamily;
this.ctx.fillStyle = asString(styles.color);

this.ctx.textBaseline = 'middle';
this.ctx.textBaseline = 'alphabetic';
this.ctx.textAlign = canvasTextAlign(container.styles.textAlign);

const bounds = contentBox(container);
Expand Down Expand Up @@ -409,7 +409,7 @@ export class CanvasRenderer {
baseline
);
this.ctx.restore();
this.ctx.textBaseline = 'bottom';
this.ctx.textBaseline = 'alphabetic';
this.ctx.textAlign = 'left';
}

Expand All @@ -427,7 +427,7 @@ export class CanvasRenderer {
}
}
} 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.fillStyle = asString(styles.color);
Expand All @@ -441,12 +441,10 @@ export class CanvasRenderer {
computeLineHeight(styles.lineHeight, styles.fontSize.number) / 2 + 1
);

const {baseline} = this.fontMetrics.getMetrics(fontFamily, fontSize);

this.renderTextWithLetterSpacing(
new TextBounds(paint.listValue, bounds),
styles.letterSpacing,
baseline
computeLineHeight(styles.lineHeight, styles.fontSize.number) / 2 + 2
);
this.ctx.textBaseline = 'bottom';
this.ctx.textAlign = 'left';
Expand Down

0 comments on commit cd99f11

Please sign in to comment.