From 71eb308bba68d0b26608944312039a0af7a4af4d Mon Sep 17 00:00:00 2001 From: dohyeons Date: Mon, 13 Oct 2025 10:41:39 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8F=B0=ED=8A=B8=20=ED=81=AC=EA=B8=B0=20?= =?UTF-8?q?=EC=A1=B0=EC=A0=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/designer/SignatureGenerator.tsx | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/frontend/components/report/designer/SignatureGenerator.tsx b/frontend/components/report/designer/SignatureGenerator.tsx index f54c9a7c..db152157 100644 --- a/frontend/components/report/designer/SignatureGenerator.tsx +++ b/frontend/components/report/designer/SignatureGenerator.tsx @@ -125,10 +125,21 @@ export function SignatureGenerator({ onSignatureSelect }: SignatureGeneratorProp // 텍스트 스타일 ctx.fillStyle = "#000000"; - ctx.font = `${font.weight} 124px ${font.style}`; + let fontSize = 124; + ctx.font = `${font.weight} ${fontSize}px ${font.style}`; ctx.textAlign = "center"; ctx.textBaseline = "middle"; + // 텍스트 너비 측정 및 크기 조정 (캔버스 너비의 90% 이내로) + let textWidth = ctx.measureText(name).width; + const maxWidth = canvas.width * 0.9; + + while (textWidth > maxWidth && fontSize > 30) { + fontSize -= 2; + ctx.font = `${font.weight} ${fontSize}px ${font.style}`; + textWidth = ctx.measureText(name).width; + } + // 텍스트 그리기 ctx.fillText(name, canvas.width / 2, canvas.height / 2); @@ -151,7 +162,14 @@ export function SignatureGenerator({ onSignatureSelect }: SignatureGeneratorProp {/* 언어 선택 */}
- { + setLanguage(value); + setName(""); // 언어 변경 시 입력값 초기화 + setGeneratedSignatures([]); // 생성된 서명도 초기화 + }} + > @@ -168,8 +186,21 @@ export function SignatureGenerator({ onSignatureSelect }: SignatureGeneratorProp
setName(e.target.value)} + onChange={(e) => { + const input = e.target.value; + // 국문일 때는 한글, 영문일 때는 영문+숫자+공백만 허용 + if (language === "korean") { + // 한글만 허용 (자음, 모음, 완성된 글자) + const koreanOnly = input.replace(/[^\u3131-\u3163\uac00-\ud7a3\s]/g, ""); + setName(koreanOnly); + } else { + // 영문, 숫자, 공백만 허용 + const englishOnly = input.replace(/[^a-zA-Z\s]/g, ""); + setName(englishOnly); + } + }} placeholder={language === "korean" ? "홍길동" : "John Doe"} + maxLength={14} className="h-8 flex-1" onKeyDown={(e) => { if (e.key === "Enter") { @@ -206,7 +237,7 @@ export function SignatureGenerator({ onSignatureSelect }: SignatureGeneratorProp {`서명

{fonts[index].name}