mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Fix RTL
This commit is contained in:
parent
bb7ebe0d24
commit
f3991edc0a
1 changed files with 11 additions and 2 deletions
|
@ -123,8 +123,11 @@ var PointText = TextItem.extend(/** @lends PointText# */{
|
||||||
width, numLines * leading);
|
width, numLines * leading);
|
||||||
},
|
},
|
||||||
_getDrawnTextSize: function() {
|
_getDrawnTextSize: function() {
|
||||||
var numLines = this._lines.length;
|
var style = this._style;
|
||||||
var leading = this._style.getLeading();
|
var lines = this._lines;
|
||||||
|
var numLines = lines.length;
|
||||||
|
var leading = style.getLeading();
|
||||||
|
var justification = style.getJustification();
|
||||||
|
|
||||||
// Create SVG dom element from text
|
// Create SVG dom element from text
|
||||||
var svg = SvgElement.create('svg', {
|
var svg = SvgElement.create('svg', {
|
||||||
|
@ -173,6 +176,12 @@ var PointText = TextItem.extend(/** @lends PointText# */{
|
||||||
var x = bbox.x - halfStrokeWidth;
|
var x = bbox.x - halfStrokeWidth;
|
||||||
var y = bbox.y - halfStrokeWidth;
|
var y = bbox.y - halfStrokeWidth;
|
||||||
|
|
||||||
|
// Adjust for different justifications.
|
||||||
|
if (justification !== 'left') {
|
||||||
|
var eltWidth = this.getView().getTextWidth(style.getFontStyle(), lines);
|
||||||
|
x -= eltWidth / (justification === 'center' ? 2: 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Add 1 to give space for text cursor
|
// Add 1 to give space for text cursor
|
||||||
return new Rectangle(x, y, width + 1, Math.max(height, numLines * leading));
|
return new Rectangle(x, y, width + 1, Math.max(height, numLines * leading));
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue