Skip to content

Commit 29eb9f2

Browse files
committed
add new text controls
1 parent 4b1503d commit 29eb9f2

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

share/nip2/start/Image.def

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,37 +1903,39 @@ Pattern_images_item = class
19031903
text = String "Text to paint" "<i>Hello</i> world!";
19041904
font = Fontname "Use font" Workspaces.Preferences.PAINTBOX_FONT;
19051905
fontfile = Pathname "Font file" "";
1906-
width = Expression "Text width" 500;
1906+
width = Expression "Text width" 0;
19071907
height = Expression "Text height" 0;
19081908
align = Option "Alignment" [
19091909
"Left",
19101910
"Centre",
19111911
"Right"
19121912
] 0;
19131913
dpi = Expression "DPI" 300;
1914-
spacing = Expression "Line spacing" 1.1;
1914+
fit = Toggle "Fit text to box" false;
1915+
spacing = Expression "Line spacing" 0;
19151916

19161917
_result
19171918
= Image out
19181919
{
1919-
[out] = vips_call "text" [text.value]
1920-
(base_options ++ fontfile_options);
1921-
19221920
base_options = [
19231921
$font => font.value,
1924-
$width => to_real width,
1925-
$height => to_real height,
1926-
$align => align.value,
1927-
$dpi => to_real dpi,
1928-
$spacing => to_real spacing
1922+
$align => align.value
19291923
];
1930-
1931-
fontfile_options
1932-
= [$fontfile => fontfile.value],
1933-
fontfile.value != ""
1924+
1925+
set_option name default value
1926+
= [name => value], value != default
19341927
= [];
1935-
}
19361928

1929+
options = base_options ++ concat [
1930+
set_option $width 0 (to_real width),
1931+
set_option $height 0 (to_real height),
1932+
set_option $fontfile "" fontfile.value,
1933+
if !fit then set_option $dpi 72 (to_real dpi) else [],
1934+
set_option $spacing 0 (to_real spacing)
1935+
];
1936+
1937+
[out] = vips_call "text" [text.value] options;
1938+
}
19371939
}
19381940
}
19391941

@@ -1977,7 +1979,7 @@ Pattern_images_item = class
19771979
_result
19781980
= build param (to_real nsize)
19791981
{
1980-
param f = f sense.value fc.value 0 0 0 0;
1982+
param f = f sense.value fc.value 0 0 0 0;
19811983
}
19821984
}
19831985
}
@@ -1998,7 +2000,7 @@ Pattern_images_item = class
19982000
_result
19992001
= build param (to_real nsize)
20002002
{
2001-
param f = f (sense.value + 6) fc.value rw.value 0 0 0;
2003+
param f = f (sense.value + 6) fc.value rw.value 0 0 0;
20022004
}
20032005
}
20042006
}
@@ -2020,7 +2022,7 @@ Pattern_images_item = class
20202022
_result
20212023
= build param (to_real nsize)
20222024
{
2023-
param f = f (sense.value + 12) fcx.value fcy.value
2025+
param f = f (sense.value + 12) fcx.value fcy.value
20242026
r.value 0 0;
20252027
}
20262028
}
@@ -2046,7 +2048,7 @@ Pattern_images_item = class
20462048
_result
20472049
= build param (to_real nsize)
20482050
{
2049-
param f = f (sense.value + 4) fc.value ac.value 0 0 0;
2051+
param f = f (sense.value + 4) fc.value ac.value 0 0 0;
20502052
}
20512053
}
20522054
}
@@ -2068,7 +2070,7 @@ Pattern_images_item = class
20682070
_result
20692071
= build param (to_real nsize)
20702072
{
2071-
param f = f (sense.value + 10) fc.value rw.value
2073+
param f = f (sense.value + 10) fc.value rw.value
20722074
ac.value 0 0;
20732075
}
20742076
}
@@ -2092,7 +2094,7 @@ Pattern_images_item = class
20922094
_result
20932095
= build param (to_real nsize)
20942096
{
2095-
param f = f (sense.value + 16) fcx.value fcy.value
2097+
param f = f (sense.value + 16) fcx.value fcy.value
20962098
r.value ac.value 0;
20972099
}
20982100
}
@@ -2119,7 +2121,7 @@ Pattern_images_item = class
21192121
_result
21202122
= build param (to_real nsize)
21212123
{
2122-
param f = f (sense.value + 2) order.value fc.value
2124+
param f = f (sense.value + 2) order.value fc.value
21232125
ac.value 0 0;
21242126
}
21252127
}
@@ -2143,8 +2145,8 @@ Pattern_images_item = class
21432145
_result
21442146
= build param (to_real nsize)
21452147
{
2146-
param f = f (sense.value + 8) order.value fc.value
2147-
rw.value ac.value 0;
2148+
param f = f (sense.value + 8) order.value fc.value
2149+
rw.value ac.value 0;
21482150
}
21492151
}
21502152
}
@@ -2168,8 +2170,8 @@ Pattern_images_item = class
21682170
_result
21692171
= build param (to_real nsize)
21702172
{
2171-
param f = f (sense.value + 14) order.value fcx.value
2172-
fcy.value r.value ac.value;
2173+
param f = f (sense.value + 14) order.value fcx.value
2174+
fcy.value r.value ac.value;
21732175
}
21742176
}
21752177
}

0 commit comments

Comments
 (0)