diff --git a/src/Global.ts b/src/Global.ts index 48e5f686..9996e398 100644 --- a/src/Global.ts +++ b/src/Global.ts @@ -90,6 +90,7 @@ export const Konva = { _mouseDblClickPointerId: null, _touchDblClickPointerId: null, _pointerDblClickPointerId: null, + _fixTextRendering: false, /** * Global pixel ratio configuration. KonvaJS automatically detect pixel ratio of current device. diff --git a/src/shapes/Text.ts b/src/shapes/Text.ts index 1ecdedb5..4703fd33 100644 --- a/src/shapes/Text.ts +++ b/src/shapes/Text.ts @@ -205,10 +205,11 @@ export class Text extends Shape { direction = direction === INHERIT ? context.direction : direction; var translateY = lineHeightPx / 2; - const baseline = this.textBaseline(); - if (baseline === 'alphabetic') { + var baseline = MIDDLE; + if (Konva._fixTextRendering) { var metrics = this.measureSize('M'); // Use a sample character to get the ascent + baseline = 'alphabetic'; translateY = (metrics.fontBoundingBoxAscent - metrics.fontBoundingBoxDescent) / 2 + lineHeightPx / 2; @@ -655,7 +656,6 @@ export class Text extends Shape { direction: GetSet; fontFamily: GetSet; - textBaseline: GetSet; fontSize: GetSet; fontStyle: GetSet; fontVariant: GetSet; @@ -752,8 +752,6 @@ Factory.addGetterSetter(Text, 'direction', INHERIT); */ Factory.addGetterSetter(Text, 'fontFamily', 'Arial'); -Factory.addGetterSetter(Text, 'textBaseline', MIDDLE); - /** * get/set font size in pixels * @name Konva.Text#fontSize diff --git a/test/sandbox.html b/test/sandbox.html index db4dda12..6bdd5256 100644 --- a/test/sandbox.html +++ b/test/sandbox.html @@ -30,6 +30,8 @@