@@ -21,6 +21,7 @@ public class TextLayer extends AbstractLayer<TextLayer> {
2121 protected String letterSpacing = null ;
2222 protected Integer lineSpacing = null ;
2323 protected String text = null ;
24+ protected Object textStyle = null ;
2425
2526 @ Override
2627 TextLayer getThis () {
@@ -118,6 +119,28 @@ public TextLayer text(String text) {
118119 return getThis ();
119120 }
120121
122+ /**
123+ * Sets a text style identifier,
124+ * Note: If this is used, all other style attributes are ignored in favor of this identifier
125+ * @param textStyleIdentifier A variable string or an explicit style (e.g. "Arial_17_bold_antialias_best")
126+ * @return Itself for chaining
127+ */
128+ public TextLayer textStyle (String textStyleIdentifier ) {
129+ this .textStyle = textStyleIdentifier ;
130+ return getThis ();
131+ }
132+
133+ /**
134+ * Sets a text style identifier using an expression.
135+ * Note: If this is used, all other style attributes are ignored in favor of this identifier
136+ * @param textStyleIdentifier An expression instance referencing the style.
137+ * @return Itself for chaining
138+ */
139+ public TextLayer textStyle (Expression textStyleIdentifier ) {
140+ this .textStyle = textStyleIdentifier ;
141+ return getThis ();
142+ }
143+
121144 @ Override
122145 public String toString () {
123146 if (this .publicId == null && this .text == null ) {
@@ -144,6 +167,11 @@ public String toString() {
144167 }
145168
146169 protected String textStyleIdentifier () {
170+ // Note: if a text-style argument is provided as a whole, it overrides everything else, no mix and match.
171+ if (StringUtils .isNotBlank (this .textStyle )) {
172+ return textStyle .toString ();
173+ }
174+
147175 ArrayList <String > components = new ArrayList <String >();
148176
149177 if (StringUtils .isNotBlank (this .fontWeight ) && !this .fontWeight .equals ("normal" ))
@@ -181,6 +209,5 @@ protected String textStyleIdentifier() {
181209 components .add (0 , this .fontFamily );
182210
183211 return StringUtils .join (components , "_" );
184-
185212 }
186213}
0 commit comments