mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -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);
|
||||
},
|
||||
_getDrawnTextSize: function() {
|
||||
var numLines = this._lines.length;
|
||||
var leading = this._style.getLeading();
|
||||
var style = this._style;
|
||||
var lines = this._lines;
|
||||
var numLines = lines.length;
|
||||
var leading = style.getLeading();
|
||||
var justification = style.getJustification();
|
||||
|
||||
// Create SVG dom element from text
|
||||
var svg = SvgElement.create('svg', {
|
||||
|
@ -173,6 +176,12 @@ var PointText = TextItem.extend(/** @lends PointText# */{
|
|||
var x = bbox.x - 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
|
||||
return new Rectangle(x, y, width + 1, Math.max(height, numLines * leading));
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue