@remotion/web-renderer 4.0.482 → 4.0.484
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.
- package/dist/drawing/text/text-decoration.d.ts +27 -0
- package/dist/esm/index.mjs +135 -1
- package/package.json +10 -10
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type TextDecorationLine = 'underline' | 'overline' | 'line-through';
|
|
2
|
+
export type TextDecoration = {
|
|
3
|
+
lines: TextDecorationLine[];
|
|
4
|
+
color: string;
|
|
5
|
+
thickness: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const parseTextDecoration: ({ onlyBackgroundClipText, style, }: {
|
|
8
|
+
onlyBackgroundClipText: boolean;
|
|
9
|
+
style: CSSStyleDeclaration;
|
|
10
|
+
}) => TextDecoration | null;
|
|
11
|
+
export declare const getTextDecorations: ({ computedStyle, onlyBackgroundClipText, span, }: {
|
|
12
|
+
computedStyle: CSSStyleDeclaration;
|
|
13
|
+
onlyBackgroundClipText: boolean;
|
|
14
|
+
span: HTMLSpanElement;
|
|
15
|
+
}) => TextDecoration[];
|
|
16
|
+
export declare const drawTextDecoration: ({ contextToDraw, fontSizePx, measurements, parentRect, textDecorations, token, y, }: {
|
|
17
|
+
contextToDraw: OffscreenCanvasRenderingContext2D;
|
|
18
|
+
fontSizePx: number;
|
|
19
|
+
measurements: TextMetrics;
|
|
20
|
+
parentRect: DOMRect;
|
|
21
|
+
textDecorations: TextDecoration[];
|
|
22
|
+
token: {
|
|
23
|
+
rect: DOMRect;
|
|
24
|
+
};
|
|
25
|
+
y: number;
|
|
26
|
+
}) => void;
|
|
27
|
+
export {};
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1629,7 +1629,7 @@ var turnSvgIntoDrawable = (svg) => {
|
|
|
1629
1629
|
svg.style.marginBottom = "0";
|
|
1630
1630
|
svg.style.fill = fill;
|
|
1631
1631
|
svg.style.color = color;
|
|
1632
|
-
const svgData = new XMLSerializer().serializeToString(svg);
|
|
1632
|
+
const svgData = new XMLSerializer().serializeToString(svg).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, "");
|
|
1633
1633
|
svg.style.marginLeft = originalMarginLeft;
|
|
1634
1634
|
svg.style.marginRight = originalMarginRight;
|
|
1635
1635
|
svg.style.marginTop = originalMarginTop;
|
|
@@ -4123,6 +4123,126 @@ var parseTextShadow = (textShadowValue) => {
|
|
|
4123
4123
|
return parseShadowValues(textShadowValue);
|
|
4124
4124
|
};
|
|
4125
4125
|
|
|
4126
|
+
// src/drawing/text/text-decoration.ts
|
|
4127
|
+
var textDecorationLines = [
|
|
4128
|
+
"underline",
|
|
4129
|
+
"overline",
|
|
4130
|
+
"line-through"
|
|
4131
|
+
];
|
|
4132
|
+
var currentColorValues = new Set(["currentcolor", "currentColor"]);
|
|
4133
|
+
var getDefaultTextDecorationThickness = (fontSizePx) => {
|
|
4134
|
+
return Math.max(1, Number.isFinite(fontSizePx) ? fontSizePx / 16 : 1);
|
|
4135
|
+
};
|
|
4136
|
+
var parseTextDecoration = ({
|
|
4137
|
+
onlyBackgroundClipText,
|
|
4138
|
+
style
|
|
4139
|
+
}) => {
|
|
4140
|
+
const textDecorationStyle = style.getPropertyValue("text-decoration-style");
|
|
4141
|
+
if (textDecorationStyle && textDecorationStyle !== "solid") {
|
|
4142
|
+
return null;
|
|
4143
|
+
}
|
|
4144
|
+
const textDecorationLine = style.getPropertyValue("text-decoration-line");
|
|
4145
|
+
const lineParts = textDecorationLine.split(/\s+/);
|
|
4146
|
+
const lines = textDecorationLines.filter((line) => lineParts.includes(line));
|
|
4147
|
+
if (lines.length === 0) {
|
|
4148
|
+
return null;
|
|
4149
|
+
}
|
|
4150
|
+
const textDecorationThickness = style.getPropertyValue("text-decoration-thickness");
|
|
4151
|
+
const thicknessValue = parseFloat(textDecorationThickness);
|
|
4152
|
+
const thickness = Number.isFinite(thicknessValue) ? thicknessValue : getDefaultTextDecorationThickness(parseFloat(style.fontSize));
|
|
4153
|
+
if (thickness <= 0) {
|
|
4154
|
+
return null;
|
|
4155
|
+
}
|
|
4156
|
+
const textDecorationColor = style.getPropertyValue("text-decoration-color");
|
|
4157
|
+
return {
|
|
4158
|
+
lines,
|
|
4159
|
+
color: onlyBackgroundClipText || !textDecorationColor || currentColorValues.has(textDecorationColor) ? onlyBackgroundClipText ? "black" : style.color : textDecorationColor,
|
|
4160
|
+
thickness
|
|
4161
|
+
};
|
|
4162
|
+
};
|
|
4163
|
+
var getTextDecorations = ({
|
|
4164
|
+
computedStyle,
|
|
4165
|
+
onlyBackgroundClipText,
|
|
4166
|
+
span
|
|
4167
|
+
}) => {
|
|
4168
|
+
const decorations = [];
|
|
4169
|
+
const spanDecoration = parseTextDecoration({
|
|
4170
|
+
onlyBackgroundClipText,
|
|
4171
|
+
style: computedStyle
|
|
4172
|
+
});
|
|
4173
|
+
if (spanDecoration) {
|
|
4174
|
+
decorations.push(spanDecoration);
|
|
4175
|
+
}
|
|
4176
|
+
let parent = span.parentElement;
|
|
4177
|
+
while (parent) {
|
|
4178
|
+
const parentDecoration = parseTextDecoration({
|
|
4179
|
+
onlyBackgroundClipText,
|
|
4180
|
+
style: getComputedStyle(parent)
|
|
4181
|
+
});
|
|
4182
|
+
if (parentDecoration) {
|
|
4183
|
+
decorations.push(parentDecoration);
|
|
4184
|
+
}
|
|
4185
|
+
parent = parent.parentElement;
|
|
4186
|
+
}
|
|
4187
|
+
return decorations;
|
|
4188
|
+
};
|
|
4189
|
+
var getTextDecorationY = ({
|
|
4190
|
+
line,
|
|
4191
|
+
measurements,
|
|
4192
|
+
y,
|
|
4193
|
+
thickness,
|
|
4194
|
+
fontSizePx
|
|
4195
|
+
}) => {
|
|
4196
|
+
const fontAscent = measurements.fontBoundingBoxAscent || measurements.actualBoundingBoxAscent || fontSizePx;
|
|
4197
|
+
const fontDescent = measurements.fontBoundingBoxDescent || measurements.actualBoundingBoxDescent || fontSizePx * 0.2;
|
|
4198
|
+
const actualAscent = measurements.actualBoundingBoxAscent || fontAscent;
|
|
4199
|
+
if (line === "underline") {
|
|
4200
|
+
return y + Math.max(thickness, fontDescent * 0.4);
|
|
4201
|
+
}
|
|
4202
|
+
if (line === "overline") {
|
|
4203
|
+
return y - fontAscent + thickness / 2;
|
|
4204
|
+
}
|
|
4205
|
+
return y - actualAscent * 0.35;
|
|
4206
|
+
};
|
|
4207
|
+
var drawTextDecoration = ({
|
|
4208
|
+
contextToDraw,
|
|
4209
|
+
fontSizePx,
|
|
4210
|
+
measurements,
|
|
4211
|
+
parentRect,
|
|
4212
|
+
textDecorations,
|
|
4213
|
+
token,
|
|
4214
|
+
y
|
|
4215
|
+
}) => {
|
|
4216
|
+
if (textDecorations.length === 0) {
|
|
4217
|
+
return;
|
|
4218
|
+
}
|
|
4219
|
+
const startX = token.rect.left - parentRect.x;
|
|
4220
|
+
const endX = token.rect.right - parentRect.x;
|
|
4221
|
+
if (endX <= startX) {
|
|
4222
|
+
return;
|
|
4223
|
+
}
|
|
4224
|
+
contextToDraw.save();
|
|
4225
|
+
contextToDraw.lineCap = "butt";
|
|
4226
|
+
for (const textDecoration of textDecorations) {
|
|
4227
|
+
contextToDraw.strokeStyle = textDecoration.color;
|
|
4228
|
+
contextToDraw.lineWidth = textDecoration.thickness;
|
|
4229
|
+
for (const line of textDecoration.lines) {
|
|
4230
|
+
const lineY = getTextDecorationY({
|
|
4231
|
+
line,
|
|
4232
|
+
measurements,
|
|
4233
|
+
y,
|
|
4234
|
+
thickness: textDecoration.thickness,
|
|
4235
|
+
fontSizePx
|
|
4236
|
+
});
|
|
4237
|
+
contextToDraw.beginPath();
|
|
4238
|
+
contextToDraw.moveTo(startX, lineY);
|
|
4239
|
+
contextToDraw.lineTo(endX, lineY);
|
|
4240
|
+
contextToDraw.stroke();
|
|
4241
|
+
}
|
|
4242
|
+
}
|
|
4243
|
+
contextToDraw.restore();
|
|
4244
|
+
};
|
|
4245
|
+
|
|
4126
4246
|
// src/drawing/text/draw-text.ts
|
|
4127
4247
|
var drawText = ({
|
|
4128
4248
|
span,
|
|
@@ -4174,6 +4294,11 @@ var drawText = ({
|
|
|
4174
4294
|
contextToDraw.fillStyle = onlyBackgroundClipText ? "black" : webkitTextFillColor;
|
|
4175
4295
|
contextToDraw.letterSpacing = letterSpacing;
|
|
4176
4296
|
contextToDraw.wordSpacing = wordSpacing;
|
|
4297
|
+
const textDecorations = getTextDecorations({
|
|
4298
|
+
computedStyle,
|
|
4299
|
+
onlyBackgroundClipText,
|
|
4300
|
+
span
|
|
4301
|
+
});
|
|
4177
4302
|
const strokeWidth = parseFloat(webkitTextStrokeWidth);
|
|
4178
4303
|
const hasStroke = strokeWidth > 0;
|
|
4179
4304
|
if (hasStroke) {
|
|
@@ -4224,6 +4349,15 @@ var drawText = ({
|
|
|
4224
4349
|
drawFill();
|
|
4225
4350
|
drawStroke();
|
|
4226
4351
|
}
|
|
4352
|
+
drawTextDecoration({
|
|
4353
|
+
contextToDraw,
|
|
4354
|
+
fontSizePx,
|
|
4355
|
+
measurements,
|
|
4356
|
+
parentRect,
|
|
4357
|
+
textDecorations,
|
|
4358
|
+
token,
|
|
4359
|
+
y
|
|
4360
|
+
});
|
|
4227
4361
|
}
|
|
4228
4362
|
span.textContent = originalText;
|
|
4229
4363
|
finishFilter();
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/web-renderer"
|
|
4
4
|
},
|
|
5
5
|
"name": "@remotion/web-renderer",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.484",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"scripts": {
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
"@mediabunny/mp3-encoder": "1.47.0",
|
|
23
23
|
"@mediabunny/aac-encoder": "1.47.0",
|
|
24
24
|
"@mediabunny/flac-encoder": "1.47.0",
|
|
25
|
-
"@remotion/licensing": "4.0.
|
|
26
|
-
"remotion": "4.0.
|
|
25
|
+
"@remotion/licensing": "4.0.484",
|
|
26
|
+
"remotion": "4.0.484",
|
|
27
27
|
"mediabunny": "1.47.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@react-three/fiber": "9.2.0",
|
|
31
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
32
|
-
"@remotion/paths": "4.0.
|
|
33
|
-
"@remotion/player": "4.0.
|
|
34
|
-
"@remotion/media": "4.0.
|
|
35
|
-
"@remotion/shapes": "4.0.
|
|
36
|
-
"@remotion/three": "4.0.
|
|
37
|
-
"@remotion/transitions": "4.0.
|
|
31
|
+
"@remotion/eslint-config-internal": "4.0.484",
|
|
32
|
+
"@remotion/paths": "4.0.484",
|
|
33
|
+
"@remotion/player": "4.0.484",
|
|
34
|
+
"@remotion/media": "4.0.484",
|
|
35
|
+
"@remotion/shapes": "4.0.484",
|
|
36
|
+
"@remotion/three": "4.0.484",
|
|
37
|
+
"@remotion/transitions": "4.0.484",
|
|
38
38
|
"@types/three": "0.170.0",
|
|
39
39
|
"@typescript/native-preview": "7.0.0-dev.20260217.1",
|
|
40
40
|
"@vitejs/plugin-react": "4.3.4",
|