Skip to content

Commit 4312233

Browse files
lib: implement setTextScale functionality.
- fixes #172
1 parent e971037 commit 4312233

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

lib/project-data.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const {
1010
CharacterBasedDurationError,
1111
DurationGreaterThanMaxPossibleError,
1212
IconAdjustableError,
13+
InvalidTextScaleValue,
1314
LowerThirdAdjustableError,
1415
NotImageAreaError,
1516
NotTextAreaError,
@@ -427,8 +428,9 @@ class ProjectData {
427428
constructArea (area) {
428429
const {
429430
id, fileName, height, width, value, cords, title, wordCount, originalHeight, originalWidth, order, type,
430-
mimeType, webpPath, fileType, thumbnailPath, imageCropParams, videoCropParams
431+
mimeType, webpPath, fileType, thumbnailPath, imageCropParams, videoCropParams, font
431432
} = area
433+
const self = this
432434

433435
const result = {
434436
id,
@@ -440,6 +442,7 @@ class ProjectData {
440442
wordCount,
441443
order,
442444
type,
445+
font,
443446
/**
444447
* Returns area type.
445448
* @return {String}
@@ -449,11 +452,26 @@ class ProjectData {
449452
* Checks if area type is `text`, then sets the given value.
450453
* @param {String} text - The text value to set.
451454
* @throws {NotTextAreaError}
455+
* @return {result}
452456
*/
453-
setText: (text) => {
457+
setText: function (text) {
454458
checkAreaType(area, 'text')(NotTextAreaError.of(`Area with id: ${id} is not text.`))
455459
area.value = text
456-
this.patchProperties.push('screens')
460+
self.patchProperties.push('screens')
461+
return this
462+
},
463+
/**
464+
*
465+
* @param scale
466+
* @return {result}
467+
*/
468+
setTextScale: function (scale) {
469+
checkAreaType(area, 'text')(NotTextAreaError.of(`Area with id: ${id} is not text.`))
470+
if (scale < 80 || scale > 120) {
471+
throw new InvalidTextScaleValue('The text scale value must be between 80 and 120.')
472+
}
473+
font.scale = scale
474+
return this
457475
},
458476
/**
459477
* Checks if area is `text`, then returns recommended character count.

0 commit comments

Comments
 (0)