aboutsummaryrefslogtreecommitdiffstats
path: root/src/elements/Text.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2023-06-13 01:43:37 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2023-06-13 01:43:37 +0200
commit03322672782a6318b019eff33fe44ec800d6f12c (patch)
tree9d807e1585cf28a1ea98e87b855932dba00f1880 /src/elements/Text.js
parent8e18b4698edd00f83af0be05bb3374f92fecaeb9 (diff)
downloadsvg.js-03322672782a6318b019eff33fe44ec800d6f12c.tar.gz
svg.js-03322672782a6318b019eff33fe44ec800d6f12c.zip
dependency updates, easier formatting
Diffstat (limited to 'src/elements/Text.js')
-rw-r--r--src/elements/Text.js20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/elements/Text.js b/src/elements/Text.js
index f716f83..39371f6 100644
--- a/src/elements/Text.js
+++ b/src/elements/Text.js
@@ -13,7 +13,7 @@ import * as textable from '../modules/core/textable.js'
export default class Text extends Shape {
// Initialize node
- constructor (node, attrs = node) {
+ constructor(node, attrs = node) {
super(nodeOrNew('text', node), attrs)
this.dom.leading = new SVGNumber(1.3) // store leading value for rebuilding
@@ -22,7 +22,7 @@ export default class Text extends Shape {
}
// Set / get leading
- leading (value) {
+ leading(value) {
// act as getter
if (value == null) {
return this.dom.leading
@@ -35,7 +35,7 @@ export default class Text extends Shape {
}
// Rebuild appearance type
- rebuild (rebuild) {
+ rebuild(rebuild) {
// store new rebuild flag if given
if (typeof rebuild === 'boolean') {
this._rebuild = rebuild
@@ -48,7 +48,8 @@ export default class Text extends Shape {
const leading = this.dom.leading
this.each(function (i) {
- const fontSize = globals.window.getComputedStyle(this.node)
+ const fontSize = globals.window
+ .getComputedStyle(this.node)
.getPropertyValue('font-size')
const dy = leading * new SVGNumber(fontSize)
@@ -72,14 +73,14 @@ export default class Text extends Shape {
}
// overwrite method from parent to set data properly
- setData (o) {
+ setData(o) {
this.dom = o
this.dom.leading = new SVGNumber(o.leading || 1.3)
return this
}
// Set the text content
- text (text) {
+ text(text) {
// act as getter
if (text === undefined) {
const children = this.node.childNodes
@@ -94,7 +95,11 @@ export default class Text extends Shape {
}
// add newline if its not the first child and newLined is set to true
- if (i !== firstLine && children[i].nodeType !== 3 && adopt(children[i]).dom.newLined === true) {
+ if (
+ i !== firstLine &&
+ children[i].nodeType !== 3 &&
+ adopt(children[i]).dom.newLined === true
+ ) {
text += '\n'
}
@@ -124,7 +129,6 @@ export default class Text extends Shape {
// disable build mode and rebuild lines
return this.build(false).rebuild()
}
-
}
extend(Text, textable)