File tree Expand file tree Collapse file tree 4 files changed +43
-1
lines changed
__TESTS__/unit/values/TextStyle Expand file tree Collapse file tree 4 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import {FontWeight} from "../../../../src/qualifiers/fontWeight";
55import { FontHinting } from "../../../../src/qualifiers/fontHinting" ;
66import { TextDecoration } from "../../../../src/qualifiers/textDecoration" ;
77import { TextAlignment } from "../../../../src/qualifiers/textAlignment" ;
8+ import { Stroke } from "../../../../src/qualifiers/textStroke" ;
9+ import { Color } from "../../../../src/qualifiers/color" ;
810
911describe ( 'Text Style tests' , ( ) => {
1012 it ( 'Create a new instance' , ( ) => {
@@ -35,6 +37,14 @@ describe('Text Style tests', () => {
3537 expect ( res ) . toBe ( 'arial_50_bold_italic_strikethrough_justify_stroke_letter_spacing_10_line_spacing_20_antialias_good_hinting_full' ) ;
3638 } ) ;
3739
40+ it ( 'Create a new instance with stroke solid' , ( ) => {
41+ const res = new TextStyle ( 'arial' , 50 )
42+ . stroke ( Stroke . solid ( 2 , Color . WHITE ) )
43+ . toString ( ) ;
44+ expect ( res ) . toBe ( 'arial_50_stroke_bo_2px_solid_white' ) ;
45+ } ) ;
46+
47+
3848 it ( 'Ensure normal is not included in the URL(this is the default)' , ( ) => {
3949 const res = new TextStyle ( 'arial' , 50 )
4050 . fontWeight ( FontWeight . normal ( ) )
Original file line number Diff line number Diff line change @@ -31,11 +31,13 @@ import {StreamingProfile} from "./qualifiers/streamingProfile";
3131import { TextAlignment } from "./qualifiers/textAlignment" ;
3232import { TextDecoration } from "./qualifiers/textDecoration" ;
3333import { GradientFade } from "./qualifiers/GradientFade" ;
34+ import { Stroke } from "./qualifiers/textStroke" ;
3435
3536
3637const Qualifiers = {
3738 TextDecoration,
3839 TextAlignment,
40+ Stroke,
3941 StreamingProfile,
4042 SimulateColorBlind,
4143 RotationMode,
Original file line number Diff line number Diff line change 1+ import { SystemColors } from "./color" ;
2+ import { ExpressionQualifier } from "./expression/ExpressionQualifier" ;
3+ /**
4+ * @description Contains function to set the outline stroke.
5+ * <b>Learn more</b>: {@link https://cloudinary.com/documentation/image_transformations#adding_text_overlays | Adding text overlays to images}
6+ * <b>Learn more</b>: {@link https://cloudinary.com/documentation/video_manipulation_and_delivery#adding_text_captions | Adding text overlays to videos}
7+ * @memberOf Qualifiers
8+ * @namespace TextAlignment
9+ * @see To be used with {@link Qualifiers.TextStyle|Text Style}
10+ */
11+
12+
13+ /**
14+ * @summary qualifier Adding a Border-like qualifier to the same action.
15+ * @memberOf Qualifiers.Stroke
16+ * @param {number|string|ExpressionQualifier } width The width in pixels.
17+ * @param {number|string|SystemColors } color The color of the border.
18+ */
19+ function solid ( width : number | string | ExpressionQualifier , color : number | string | SystemColors ) : string {
20+ return `bo_${ width } px_solid_${ color } ` ;
21+ }
22+
23+ const Stroke = { solid} ;
24+
25+ export { Stroke , solid } ;
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ class TextStyle {
2323 private _textDecoration : string ;
2424 private _textAlignment : string ;
2525 private _stroke : boolean ;
26+ private _strokeStyle : string ;
2627 private _fontHinting : string ;
2728
2829 /**
@@ -127,7 +128,10 @@ class TextStyle {
127128 /**
128129 * @description Whether to include an outline stroke. Set the color and weight of the stroke
129130 */
130- stroke ( ) : this {
131+ stroke ( textStroke ?: string ) : this {
132+ if ( textStroke ) {
133+ this . _strokeStyle = textStroke ;
134+ }
131135 this . _stroke = true ;
132136 return this ;
133137 }
@@ -140,6 +144,7 @@ class TextStyle {
140144 this . _textDecoration !== normalTextDecoration ( ) && this . _textDecoration ,
141145 this . _textAlignment ,
142146 this . _stroke && 'stroke' ,
147+ this . _strokeStyle ,
143148 this . _letterSpacing && `letter_spacing_${ this . _letterSpacing } ` ,
144149 this . _lineSpacing && `line_spacing_${ this . _lineSpacing } ` ,
145150 this . _fontAntialias && `antialias_${ this . _fontAntialias } ` ,
You can’t perform that action at this time.
0 commit comments