Commit 14545051 by Tomas Alabes

Merge pull request #719 from tomasAlabes/master

Line spacing added to Paper.print
parents 4812c47a c08125b1
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -5040,13 +5040,15 @@ ...@@ -5040,13 +5040,15 @@
- size (number) #optional size of the font, default is `16` - size (number) #optional size of the font, default is `16`
- origin (string) #optional could be `"baseline"` or `"middle"`, default is `"middle"` - origin (string) #optional could be `"baseline"` or `"middle"`, default is `"middle"`
- letter_spacing (number) #optional number in range `-1..1`, default is `0` - letter_spacing (number) #optional number in range `-1..1`, default is `0`
- line_spacing (number) #optional number in range `1..3`, default is `1`
= (object) resulting path element, which consist of all letters = (object) resulting path element, which consist of all letters
> Usage > Usage
| var txt = r.print(10, 50, "print", r.getFont("Museo"), 30).attr({fill: "#fff"}); | var txt = r.print(10, 50, "print", r.getFont("Museo"), 30).attr({fill: "#fff"});
\*/ \*/
paperproto.print = function (x, y, string, font, size, origin, letter_spacing) { paperproto.print = function (x, y, string, font, size, origin, letter_spacing, line_spacing) {
origin = origin || "middle"; // baseline|middle origin = origin || "middle"; // baseline|middle
letter_spacing = mmax(mmin(letter_spacing || 0, 1), -1); letter_spacing = mmax(mmin(letter_spacing || 0, 1), -1);
line_spacing = mmax(mmin(line_spacing || 1, 3), 1);
var letters = Str(string)[split](E), var letters = Str(string)[split](E),
shift = 0, shift = 0,
notfirst = 0, notfirst = 0,
...@@ -5065,7 +5067,7 @@ ...@@ -5065,7 +5067,7 @@
shift = 0; shift = 0;
curr = 0; curr = 0;
notfirst = 0; notfirst = 0;
shifty += lineHeight; shifty += lineHeight * line_spacing;
} else { } else {
var prev = notfirst && font.glyphs[letters[i - 1]] || {}, var prev = notfirst && font.glyphs[letters[i - 1]] || {},
curr = font.glyphs[letters[i]]; curr = font.glyphs[letters[i]];
......
...@@ -5420,13 +5420,15 @@ ...@@ -5420,13 +5420,15 @@
- size (number) #optional size of the font, default is `16` - size (number) #optional size of the font, default is `16`
- origin (string) #optional could be `"baseline"` or `"middle"`, default is `"middle"` - origin (string) #optional could be `"baseline"` or `"middle"`, default is `"middle"`
- letter_spacing (number) #optional number in range `-1..1`, default is `0` - letter_spacing (number) #optional number in range `-1..1`, default is `0`
- line_spacing (number) #optional number in range `1..3`, default is `1`
= (object) resulting path element, which consist of all letters = (object) resulting path element, which consist of all letters
> Usage > Usage
| var txt = r.print(10, 50, "print", r.getFont("Museo"), 30).attr({fill: "#fff"}); | var txt = r.print(10, 50, "print", r.getFont("Museo"), 30).attr({fill: "#fff"});
\*/ \*/
paperproto.print = function (x, y, string, font, size, origin, letter_spacing) { paperproto.print = function (x, y, string, font, size, origin, letter_spacing, line_spacing) {
origin = origin || "middle"; // baseline|middle origin = origin || "middle"; // baseline|middle
letter_spacing = mmax(mmin(letter_spacing || 0, 1), -1); letter_spacing = mmax(mmin(letter_spacing || 0, 1), -1);
line_spacing = mmax(mmin(line_spacing || 1, 3), 1);
var letters = Str(string)[split](E), var letters = Str(string)[split](E),
shift = 0, shift = 0,
notfirst = 0, notfirst = 0,
...@@ -5445,7 +5447,7 @@ ...@@ -5445,7 +5447,7 @@
shift = 0; shift = 0;
curr = 0; curr = 0;
notfirst = 0; notfirst = 0;
shifty += lineHeight; shifty += lineHeight * line_spacing;
} else { } else {
var prev = notfirst && font.glyphs[letters[i - 1]] || {}, var prev = notfirst && font.glyphs[letters[i - 1]] || {},
curr = font.glyphs[letters[i]]; curr = font.glyphs[letters[i]];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment