mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 06:31:15 +08:00
rename fix apply
This commit is contained in:
parent
2587e0708f
commit
7d5ba3e429
@ -90,6 +90,7 @@ export const Konva = {
|
|||||||
_mouseDblClickPointerId: null,
|
_mouseDblClickPointerId: null,
|
||||||
_touchDblClickPointerId: null,
|
_touchDblClickPointerId: null,
|
||||||
_pointerDblClickPointerId: null,
|
_pointerDblClickPointerId: null,
|
||||||
|
_fixTextRendering: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global pixel ratio configuration. KonvaJS automatically detect pixel ratio of current device.
|
* Global pixel ratio configuration. KonvaJS automatically detect pixel ratio of current device.
|
||||||
|
@ -205,10 +205,11 @@ export class Text extends Shape<TextConfig> {
|
|||||||
direction = direction === INHERIT ? context.direction : direction;
|
direction = direction === INHERIT ? context.direction : direction;
|
||||||
|
|
||||||
var translateY = lineHeightPx / 2;
|
var translateY = lineHeightPx / 2;
|
||||||
const baseline = this.textBaseline();
|
var baseline = MIDDLE;
|
||||||
if (baseline === 'alphabetic') {
|
if (Konva._fixTextRendering) {
|
||||||
var metrics = this.measureSize('M'); // Use a sample character to get the ascent
|
var metrics = this.measureSize('M'); // Use a sample character to get the ascent
|
||||||
|
|
||||||
|
baseline = 'alphabetic';
|
||||||
translateY =
|
translateY =
|
||||||
(metrics.fontBoundingBoxAscent - metrics.fontBoundingBoxDescent) / 2 +
|
(metrics.fontBoundingBoxAscent - metrics.fontBoundingBoxDescent) / 2 +
|
||||||
lineHeightPx / 2;
|
lineHeightPx / 2;
|
||||||
@ -655,7 +656,6 @@ export class Text extends Shape<TextConfig> {
|
|||||||
|
|
||||||
direction: GetSet<string, this>;
|
direction: GetSet<string, this>;
|
||||||
fontFamily: GetSet<string, this>;
|
fontFamily: GetSet<string, this>;
|
||||||
textBaseline: GetSet<string, this>;
|
|
||||||
fontSize: GetSet<number, this>;
|
fontSize: GetSet<number, this>;
|
||||||
fontStyle: GetSet<string, this>;
|
fontStyle: GetSet<string, this>;
|
||||||
fontVariant: GetSet<string, this>;
|
fontVariant: GetSet<string, this>;
|
||||||
@ -752,8 +752,6 @@ Factory.addGetterSetter(Text, 'direction', INHERIT);
|
|||||||
*/
|
*/
|
||||||
Factory.addGetterSetter(Text, 'fontFamily', 'Arial');
|
Factory.addGetterSetter(Text, 'fontFamily', 'Arial');
|
||||||
|
|
||||||
Factory.addGetterSetter(Text, 'textBaseline', MIDDLE);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get/set font size in pixels
|
* get/set font size in pixels
|
||||||
* @name Konva.Text#fontSize
|
* @name Konva.Text#fontSize
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
<script type="module">
|
<script type="module">
|
||||||
import Konva from '../src/index.ts';
|
import Konva from '../src/index.ts';
|
||||||
|
|
||||||
|
Konva._fixTextRendering = true;
|
||||||
|
|
||||||
var stageWidth = window.innerWidth;
|
var stageWidth = window.innerWidth;
|
||||||
var stageHeight = window.innerHeight;
|
var stageHeight = window.innerHeight;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user