From ac9367a71544bbe53b1214e77bd00040b7eb7fd3 Mon Sep 17 00:00:00 2001 From: RaktimaNXG Date: Wed, 3 Jan 2024 13:46:44 +0530 Subject: [PATCH] fix: fontstyle after save text signature issue --- .../src/Component/component/signPad.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/microfrontends/SignDocuments/src/Component/component/signPad.js b/microfrontends/SignDocuments/src/Component/component/signPad.js index 211ba0a8e..66355fd05 100644 --- a/microfrontends/SignDocuments/src/Component/component/signPad.js +++ b/microfrontends/SignDocuments/src/Component/component/signPad.js @@ -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