rendering fixes for letter spacing. fix #942

This commit is contained in:
Anton Lavrenov
2020-07-02 17:27:30 -05:00
parent f4ed8a485a
commit 4e1b1c7812
6 changed files with 84 additions and 16 deletions

View File

@@ -308,7 +308,7 @@ export abstract class Container<ChildType extends Node> extends Node<
* because it performs very poorly. Please use the {@link Konva.Stage#getIntersection} method if at all possible
* because it performs much better
* @method
* @name Konva.Container#getIntersection
* @name Konva.Container#getAllIntersections
* @param {Object} pos
* @param {Number} pos.x
* @param {Number} pos.y

View File

@@ -13,8 +13,7 @@ import { _registerNode } from './Global';
import * as PointerEvents from './PointerEvents';
import { GetSet, Vector2d } from './types';
import { HitCanvas, SceneCanvas, Canvas } from './Canvas';
import { Container } from './Container';
import { HitCanvas, SceneCanvas } from './Canvas';
// hack from here https://stackoverflow.com/questions/52667959/what-is-the-purpose-of-bivariancehack-in-typescript-types/52668133#52668133
export type ShapeConfigHandler<TTarget> = {

View File

@@ -267,9 +267,7 @@ export class Text extends Shape<TextConfig> {
var letter = text[li];
// skip justify for the last line
if (letter === ' ' && n !== textArrLen - 1 && align === JUSTIFY) {
lineTranslateX += Math.floor(
(totalWidth - padding * 2 - width) / spacesNumber
);
lineTranslateX += (totalWidth - padding * 2 - width) / spacesNumber;
// context.translate(
// Math.floor((totalWidth - padding * 2 - width) / spacesNumber),
// 0
@@ -279,8 +277,7 @@ export class Text extends Shape<TextConfig> {
this._partialTextY = translateY + lineTranslateY;
this._partialText = letter;
context.fillStrokeShape(this);
lineTranslateX +=
Math.round(this.measureSize(letter).width) + letterSpacing;
lineTranslateX += this.measureSize(letter).width + letterSpacing;
}
} else {
this._partialTextX = lineTranslateX;