text_line_spacing
Set line spacing of text globaly. If no value, return current line spacing.
text_line_spacing(
[size]
) -> NULL
Set line spacing of text globaly. If no value, return current line spacing.
Syntaxe
text_line_spacing(size=17);
Arguments
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
size | - | - | Value for line spacing |
Full example
var bg = "#2E2E2E";
var palette = palette_blend("#D0F4DE", "#A4161A", 26);
canvas(width=1200, height=800, background=bg);
grid(xmin=0, xmax=width(), ymin=0, ymax=height(), stepMinor=10, colorMinor="#FFE0B266", weightMinor=0.5, stepMajor=100, colorMajor="#FFB74D66", weightMajor=1.5);
def anchor(x,y) {
circle(x,y,3,fill="#F44336");
}
def drawIt(txt, x, y, size) {
font_default(size=size);
text(txt, x=x, y=y, fill="#FFF");
anchor(x,y);
}
var fontSize = 10;
var y=10;
for (var i=0; i<9; i++) {
drawIt("RichnouLang", 10, y, fontSize);
fontSize += 5;
y += fontSize + 10;
}
font_default(size=20);
var lineSpacing = 10;
var x = 550;
y = 10;
fontSize = 30;
load_font(filename="Arial.ttf", size=fontSize);
text("Autoload system-font (system directory)", x=x, y=y, fill="#FFF");
y+= fontSize+lineSpacing;
load_font(filename="Rockwell.ttc", size=fontSize);
text("Autoload system-font (system directory)", x=x, y=y, fill="#FFF");
y+= fontSize+lineSpacing;
load_font(filename="FuzzyBubbles-Bold.ttf", size=fontSize);
text("Autoload system-font (user directory)", x=x, y=y, fill="#FFF");
y+= fontSize+lineSpacing;
load_font(filename="/Users/richnou/htdocs/data/fonts/AztecsIcons.otf", size=fontSize);
text("Load from an path", x=x, y=y, fill="#FFF");
font_default(size=15);
text("(Loaded from an path /Users/richnou/...)", x=x+280, y=y, fill="#FFF");
y+= fontSize+lineSpacing;
load_font(filename="http://localhost/data/fonts/ILoveYOUForever.ttf", size=fontSize);
text("Load from an URI", x=x, y=y, fill="#FFF");
y+= fontSize+lineSpacing;
def drawItAlign(txt, x, y, ax, ay) {
text(txt, x=x, y=y, ax=ax, ay=ay, fill="#FFF");
anchor(x,y);
}
font_default(size=15);
lineSpacing = 35;
x = 380;
y = 10;
drawItAlign("START/START", x=x, y=y, ax=START, ay=START); y += lineSpacing;
drawItAlign("START/MIDDLE", x=x, y=y, ax=START, ay=MIDDLE); y += lineSpacing;
drawItAlign("START/END", x=x, y=y, ax=START, ay=END); y += lineSpacing;
drawItAlign("MIDDLE/START", x=x, y=y, ax=MIDDLE, ay=START); y += lineSpacing;
drawItAlign("MIDDLE/MIDDLE", x=x, y=y, ax=MIDDLE, ay=MIDDLE); y += lineSpacing;
drawItAlign("MIDDLE/END", x=x, y=y, ax=MIDDLE, ay=END); y += lineSpacing;
drawItAlign("END/START", x=x, y=y, ax=END, ay=START); y += lineSpacing;
drawItAlign("END/MIDDLE", x=x, y=y, ax=END, ay=MIDDLE); y += lineSpacing;
drawItAlign("END/END", x=x, y=y, ax=END, ay=END); y += lineSpacing;
// console( randlorem() );
// console( randlorem(100, true) );
// console( randlorem(100, false) );
// console( randlorem(100, true, 50) );
font_default(size=10);
text_wrap(randlorem(70, true), x=10,y=420, width=400, ax=START, ay=START, linespacing=0.5, alignment=START, fill="#FFF");
text_wrap(randlorem(70, true), x=10,y=500, width=400, ax=START, ay=START, linespacing=0.7, alignment=START, fill="#FFF");
text_wrap(randlorem(70, true), x=10,y=600, width=400, ax=START, ay=START, linespacing=1, alignment=START, fill="#FFF");
var cx = 900;
var cy = 330 ;
var spistep = 30;
for (var angle=spistep; angle<=360; angle+=spistep) {
coord_open();
coord_translate(cx,cy);
coord_rotate(angle=radians(angle));
var size = map(angle,0,360,30,90);
load_font("Arial.ttf", size);
text("Hello", 0,0, fill="#fffD", ax=START, ay=MIDDLE);
coord_close();
}
var phrase = string_to_list("Something with trigonometry ?");
load_font("MonospaceTypewriter.ttf", 25);
cx = 10;
cy = 750;
var offset = 5; // amplitude
var wavelength = 150; // onde
var px=cx;
var py = cy + offset * sin(0);
var dx = 20;
var k = 2 * PI / wavelength;
for (var i = 0; i < length(phrase); i++) {
var letter = phrase[i];
var xi = i * dx;
x = cx + xi;
y = cy + offset * sin(xi * k);
var dy = offset * k * cos(xi * k);
var angle = atan(dy);
coord_open();
coord_translate(x, y);
coord_rotate(angle = angle);
var c = randlist(["#F5D216","#0177E1","#FD3502"]);
text(letter, x = 0, y = 0, stroke = c);
coord_close();
if (i > 0) {
px = cx + (i - 1) * dx;
py = cy + offset * sin((i - 1) * dx * k);
line(px, py, x, y, stroke="FFF");
line(px, py+30, x, y+30, stroke="FFF");
}
}
def drawContour(contours, tolerance) {
var nb = 0;
for (var i=0; i < length(contours); i++) {
var contour = contours[i];
polygon(points=contour, stroke="#FFF", weight=3, fill="");
for(var j=0; j < length(contour); j+=2) {
x = contour[j];
y = contour[j+1];
var col = randlist(["#F5D216","#0177E1","#FD3502"]);
circle(x=x, y=y, radius=5,fill=col);
nb += 1;
}
}
}
var contours = text_contours(
filename="/Users/richnou/htdocs/data/fonts/Arial.ttf",
size=200,
x=450, y=580,
text="Richnou",
precision=1
);
drawContour(contours, 100);
contours = text_contours(
filename="/Users/richnou/htdocs/data/fonts/Arial.ttf",
size=200,
x=737, y=740,
text="Lang",
precision=1
);
drawContour(contours, 100);
save(whoami(png=true));
