@shotstack/shotstack-canvas 1.6.3 → 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -879,42 +879,42 @@ async function buildDrawOps(p) {
879
879
  const scale = p.font.size / upem;
880
880
  const numLines = p.lines.length;
881
881
  const lineHeightPx = p.font.size * p.style.lineHeight;
882
- const textOffsetY = borderWidth + padding.top;
883
882
  let blockY;
884
883
  switch (p.align.vertical) {
885
884
  case "top":
886
- blockY = p.font.size + textOffsetY;
885
+ blockY = p.font.size;
887
886
  break;
888
887
  case "bottom":
889
- blockY = p.textRect.height - (numLines - 1) * lineHeightPx + textOffsetY;
888
+ blockY = p.textRect.height - (numLines - 1) * lineHeightPx;
890
889
  break;
891
890
  case "middle":
892
891
  default:
893
892
  const capHeightRatio = 0.35;
894
893
  const visualOffset = p.font.size * capHeightRatio;
895
- blockY = (p.textRect.height - (numLines - 1) * lineHeightPx) / 2 + visualOffset + textOffsetY;
894
+ blockY = (p.textRect.height - (numLines - 1) * lineHeightPx) / 2 + visualOffset;
896
895
  break;
897
896
  }
897
+ blockY += borderWidth + padding.top;
898
898
  const fill = p.style.gradient ? gradientSpecFrom(p.style.gradient, 1) : { kind: "solid", color: p.font.color, opacity: p.font.opacity };
899
899
  const decoColor = p.style.gradient ? p.style.gradient.stops[p.style.gradient.stops.length - 1]?.color ?? p.font.color : p.font.color;
900
900
  const textOps = [];
901
901
  const highlighterOps = [];
902
902
  let gMinX = Infinity, gMinY = Infinity, gMaxX = -Infinity, gMaxY = -Infinity;
903
903
  for (const line of p.lines) {
904
- const textOffsetX = borderWidth + padding.left;
905
904
  let lineX;
906
905
  switch (p.align.horizontal) {
907
906
  case "left":
908
- lineX = textOffsetX;
907
+ lineX = 0;
909
908
  break;
910
909
  case "right":
911
- lineX = p.textRect.width - line.width + textOffsetX;
910
+ lineX = p.textRect.width - line.width;
912
911
  break;
913
912
  case "center":
914
913
  default:
915
- lineX = (p.textRect.width - line.width) / 2 + textOffsetX;
914
+ lineX = (p.textRect.width - line.width) / 2;
916
915
  break;
917
916
  }
917
+ lineX += borderWidth + padding.left;
918
918
  let xCursor = lineX;
919
919
  const lineIndex = p.lines.indexOf(line);
920
920
  const baselineY = blockY + lineIndex * lineHeightPx;
@@ -840,42 +840,42 @@ async function buildDrawOps(p) {
840
840
  const scale = p.font.size / upem;
841
841
  const numLines = p.lines.length;
842
842
  const lineHeightPx = p.font.size * p.style.lineHeight;
843
- const textOffsetY = borderWidth + padding.top;
844
843
  let blockY;
845
844
  switch (p.align.vertical) {
846
845
  case "top":
847
- blockY = p.font.size + textOffsetY;
846
+ blockY = p.font.size;
848
847
  break;
849
848
  case "bottom":
850
- blockY = p.textRect.height - (numLines - 1) * lineHeightPx + textOffsetY;
849
+ blockY = p.textRect.height - (numLines - 1) * lineHeightPx;
851
850
  break;
852
851
  case "middle":
853
852
  default:
854
853
  const capHeightRatio = 0.35;
855
854
  const visualOffset = p.font.size * capHeightRatio;
856
- blockY = (p.textRect.height - (numLines - 1) * lineHeightPx) / 2 + visualOffset + textOffsetY;
855
+ blockY = (p.textRect.height - (numLines - 1) * lineHeightPx) / 2 + visualOffset;
857
856
  break;
858
857
  }
858
+ blockY += borderWidth + padding.top;
859
859
  const fill = p.style.gradient ? gradientSpecFrom(p.style.gradient, 1) : { kind: "solid", color: p.font.color, opacity: p.font.opacity };
860
860
  const decoColor = p.style.gradient ? p.style.gradient.stops[p.style.gradient.stops.length - 1]?.color ?? p.font.color : p.font.color;
861
861
  const textOps = [];
862
862
  const highlighterOps = [];
863
863
  let gMinX = Infinity, gMinY = Infinity, gMaxX = -Infinity, gMaxY = -Infinity;
864
864
  for (const line of p.lines) {
865
- const textOffsetX = borderWidth + padding.left;
866
865
  let lineX;
867
866
  switch (p.align.horizontal) {
868
867
  case "left":
869
- lineX = textOffsetX;
868
+ lineX = 0;
870
869
  break;
871
870
  case "right":
872
- lineX = p.textRect.width - line.width + textOffsetX;
871
+ lineX = p.textRect.width - line.width;
873
872
  break;
874
873
  case "center":
875
874
  default:
876
- lineX = (p.textRect.width - line.width) / 2 + textOffsetX;
875
+ lineX = (p.textRect.width - line.width) / 2;
877
876
  break;
878
877
  }
878
+ lineX += borderWidth + padding.left;
879
879
  let xCursor = lineX;
880
880
  const lineIndex = p.lines.indexOf(line);
881
881
  const baselineY = blockY + lineIndex * lineHeightPx;
package/dist/entry.web.js CHANGED
@@ -845,42 +845,42 @@ async function buildDrawOps(p) {
845
845
  const scale = p.font.size / upem;
846
846
  const numLines = p.lines.length;
847
847
  const lineHeightPx = p.font.size * p.style.lineHeight;
848
- const textOffsetY = borderWidth + padding.top;
849
848
  let blockY;
850
849
  switch (p.align.vertical) {
851
850
  case "top":
852
- blockY = p.font.size + textOffsetY;
851
+ blockY = p.font.size;
853
852
  break;
854
853
  case "bottom":
855
- blockY = p.textRect.height - (numLines - 1) * lineHeightPx + textOffsetY;
854
+ blockY = p.textRect.height - (numLines - 1) * lineHeightPx;
856
855
  break;
857
856
  case "middle":
858
857
  default:
859
858
  const capHeightRatio = 0.35;
860
859
  const visualOffset = p.font.size * capHeightRatio;
861
- blockY = (p.textRect.height - (numLines - 1) * lineHeightPx) / 2 + visualOffset + textOffsetY;
860
+ blockY = (p.textRect.height - (numLines - 1) * lineHeightPx) / 2 + visualOffset;
862
861
  break;
863
862
  }
863
+ blockY += borderWidth + padding.top;
864
864
  const fill = p.style.gradient ? gradientSpecFrom(p.style.gradient, 1) : { kind: "solid", color: p.font.color, opacity: p.font.opacity };
865
865
  const decoColor = p.style.gradient ? p.style.gradient.stops[p.style.gradient.stops.length - 1]?.color ?? p.font.color : p.font.color;
866
866
  const textOps = [];
867
867
  const highlighterOps = [];
868
868
  let gMinX = Infinity, gMinY = Infinity, gMaxX = -Infinity, gMaxY = -Infinity;
869
869
  for (const line of p.lines) {
870
- const textOffsetX = borderWidth + padding.left;
871
870
  let lineX;
872
871
  switch (p.align.horizontal) {
873
872
  case "left":
874
- lineX = textOffsetX;
873
+ lineX = 0;
875
874
  break;
876
875
  case "right":
877
- lineX = p.textRect.width - line.width + textOffsetX;
876
+ lineX = p.textRect.width - line.width;
878
877
  break;
879
878
  case "center":
880
879
  default:
881
- lineX = (p.textRect.width - line.width) / 2 + textOffsetX;
880
+ lineX = (p.textRect.width - line.width) / 2;
882
881
  break;
883
882
  }
883
+ lineX += borderWidth + padding.left;
884
884
  let xCursor = lineX;
885
885
  const lineIndex = p.lines.indexOf(line);
886
886
  const baselineY = blockY + lineIndex * lineHeightPx;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shotstack/shotstack-canvas",
3
- "version": "1.6.3",
3
+ "version": "1.6.4",
4
4
  "description": "Text layout & animation engine (HarfBuzz) for Node & Web - fully self-contained.",
5
5
  "type": "module",
6
6
  "main": "./dist/entry.node.cjs",