mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-28 10:49:41 +02:00
fix: fontstyle after save text signature issue
This commit is contained in:
@@ -53,6 +53,7 @@ function SignPad({
|
||||
const currentUserName = jsonSender && jsonSender.name;
|
||||
//function for clear signature
|
||||
setSignValue(currentUserName);
|
||||
setFontSelect("Fasthand");
|
||||
}, []);
|
||||
//function for clear signature
|
||||
const handleClear = () => {
|
||||
@@ -132,6 +133,22 @@ function SignPad({
|
||||
);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const loadFont = async () => {
|
||||
try {
|
||||
await document.fonts.load(`20px ${fontSelect}`);
|
||||
const selectFontSTyle = fontOptions.find(
|
||||
(font) => font.value === fontSelect
|
||||
);
|
||||
setFontSelect(selectFontSTyle?.value || fontOptions[0].value);
|
||||
} catch (error) {
|
||||
console.error("Error loading font:", error);
|
||||
}
|
||||
};
|
||||
|
||||
loadFont();
|
||||
}, [fontSelect]);
|
||||
|
||||
useEffect(() => {
|
||||
// Load the default signature after the component mounts
|
||||
if (canvasRef.current) {
|
||||
@@ -149,7 +166,8 @@ function SignPad({
|
||||
? fontStyle
|
||||
: fontSelect
|
||||
? fontSelect
|
||||
: fontOptions[0].value;
|
||||
: "Fasthand";
|
||||
console.log("font family", fontfamily);
|
||||
// Calculate the width of the text content
|
||||
const textWidth = getTextWidth(textContent, fontfamily);
|
||||
// Increase pixel ratio for higher resolution
|
||||
|
||||
Reference in New Issue
Block a user