mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
rendering fixes for letter spacing. fix #942
This commit is contained in:
@@ -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
|
||||
|
@@ -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> = {
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user