Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getAlignOffset () {
const { align } = this.options;
let offset = 0;
if (align === Text.alignments.center) {
offset = 0.5;
}
else if (align === Text.alignments.right) {
offset = 1;
}
else if (align === Text.alignments.start || align === Text.alignments.end) {
const root = this.getRoot();
if (root.isScene) {
const dir = textDirection(root.ctx.canvas);
if ((align === Text.alignments.start && dir === "rtl") ||
(align === Text.alignments.end && dir === "ltr")) {
offset = 1;
}
}
}
return offset;
}