This commit is contained in:
ct
2025-07-15 01:52:48 +08:00
parent a12fe359d9
commit 593ea61576
3 changed files with 79 additions and 23 deletions

View File

@@ -224,11 +224,17 @@ const useVideoExport = ({ timelineElements, dimensions, totalDuration, watermark
opacity: WATERMARK_CONFIG.opacity,
align: 'center',
verticalAlign: 'middle',
offsetX: 90, // Approximate half-width to center the text
offsetY: 5, // Approximate half-height to center the text
});
layer.add(watermarkText);
// Force text measurement and update offset for proper centering
watermarkText._setTextData();
const textWidth = watermarkText.width();
const textHeight = watermarkText.height();
watermarkText.offsetX(textWidth / 2);
watermarkText.offsetY(textHeight / 2);
layer.draw();
const dataURL = stage.toDataURL({

View File

@@ -331,6 +331,22 @@ const VideoPreview = ({
{watermarked && (
<Text
key={`watermark-${fontsLoaded}`}
ref={(node) => {
if (node && fontsLoaded) {
// Force text measurement after font loading
setTimeout(() => {
node._setTextData();
// Update offset to properly center the text
const textWidth = node.width();
const textHeight = node.height();
node.offsetX(textWidth / 2);
node.offsetY(textHeight / 2);
if (layerRef.current) {
layerRef.current.batchDraw();
}
}, 0);
}
}}
text="memefa.st"
x={dimensions.width / 2}
y={dimensions.height / 2 + dimensions.height * 0.2}
@@ -342,8 +358,6 @@ const VideoPreview = ({
opacity={WATERMARK_CONFIG.opacity}
align="center"
verticalAlign="middle"
offsetX={90} // Approximate half-width to center the text
offsetY={5} // Approximate half-height to center the text
draggable={false}
listening={false} // Prevents any mouse interactions
/>