From 0bfdbd288d577cc6b9773b912a45cc9478fcafab Mon Sep 17 00:00:00 2001 From: EthanHealy01 Date: Mon, 22 Sep 2025 12:35:47 +0100 Subject: [PATCH] changed the chinese characters to temporarily default to 30 so it fits on the page, same as V1 --- .../tools/addStamp/StampPreviewUtils.ts | 18 +++++++++++------- .../tools/addStamp/useAddStampParameters.ts | 2 +- frontend/src/tools/AddStamp.tsx | 8 +++++++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/tools/addStamp/StampPreviewUtils.ts b/frontend/src/components/tools/addStamp/StampPreviewUtils.ts index 5fffdedea..0001aec45 100644 --- a/frontend/src/components/tools/addStamp/StampPreviewUtils.ts +++ b/frontend/src/components/tools/addStamp/StampPreviewUtils.ts @@ -52,18 +52,22 @@ export type StampPreviewStyle = { container: any; item: any }; // Unified per-alphabet preview adjustments export type Alphabet = 'roman' | 'arabic' | 'japanese' | 'korean' | 'chinese' | 'thai'; -export type AlphabetTweaks = { scale: number; rowOffsetRem: [number, number, number]; lineHeight: number; capHeightRatio: number }; +export type AlphabetTweaks = { scale: number; rowOffsetRem: [number, number, number]; lineHeight: number; capHeightRatio: number; defaultFontSize: number }; export const ALPHABET_PREVIEW_TWEAKS: Record = { // [top, middle, bottom] row offsets in rem - roman: { scale: 1.0/1.18, rowOffsetRem: [0, 1, 2.2], lineHeight: 1.28, capHeightRatio: 0.70 }, - arabic: { scale: 1.2, rowOffsetRem: [0, 1.5, 2.5], lineHeight: 1, capHeightRatio: 0.68 }, - japanese: { scale: 1/1.2, rowOffsetRem: [-0.1, 1, 2], lineHeight: 1, capHeightRatio: 0.72 }, - korean: { scale: 1.0/1.05, rowOffsetRem: [-0.2, 0.5, 1.4], lineHeight: 1, capHeightRatio: 0.72 }, - chinese: { scale: 1/1.2, rowOffsetRem: [0, 2, 2.8], lineHeight: 1, capHeightRatio: 0.72 }, - thai: { scale: 1/1.2, rowOffsetRem: [-1, 0, .8], lineHeight: 1, capHeightRatio: 0.66 }, + roman: { scale: 1.0/1.18, rowOffsetRem: [0, 1, 2.2], lineHeight: 1.28, capHeightRatio: 0.70, defaultFontSize: 80 }, + arabic: { scale: 1.2, rowOffsetRem: [0, 1.5, 2.5], lineHeight: 1, capHeightRatio: 0.68, defaultFontSize: 80 }, + japanese: { scale: 1/1.2, rowOffsetRem: [-0.1, 1, 2], lineHeight: 1, capHeightRatio: 0.72, defaultFontSize: 80 }, + korean: { scale: 1.0/1.05, rowOffsetRem: [-0.2, 0.5, 1.4], lineHeight: 1, capHeightRatio: 0.72, defaultFontSize: 80 }, + chinese: { scale: 1/1.2, rowOffsetRem: [0, 2, 2.8], lineHeight: 1, capHeightRatio: 0.72, defaultFontSize: 30 }, // temporary default font size so that it fits on the PDF + thai: { scale: 1/1.2, rowOffsetRem: [-1, 0, .8], lineHeight: 1, capHeightRatio: 0.66, defaultFontSize: 80 }, }; export const getAlphabetPreviewScale = (alphabet: string): number => (ALPHABET_PREVIEW_TWEAKS as any)[alphabet]?.scale ?? 1.0; +export const getDefaultFontSizeForAlphabet = (alphabet: string): number => { + return (ALPHABET_PREVIEW_TWEAKS as any)[alphabet]?.defaultFontSize ?? 80; +}; + export function computeStampPreviewStyle( parameters: AddStampParameters, imageMeta: ImageMeta, diff --git a/frontend/src/components/tools/addStamp/useAddStampParameters.ts b/frontend/src/components/tools/addStamp/useAddStampParameters.ts index f11d33d5a..3df4900f8 100644 --- a/frontend/src/components/tools/addStamp/useAddStampParameters.ts +++ b/frontend/src/components/tools/addStamp/useAddStampParameters.ts @@ -22,7 +22,7 @@ export const defaultParameters: AddStampParameters = { stampType: 'text', stampText: '', alphabet: 'roman', - fontSize: 100, + fontSize: 80, rotation: 0, opacity: 50, position: 5, diff --git a/frontend/src/tools/AddStamp.tsx b/frontend/src/tools/AddStamp.tsx index fd580bc62..ef1d8544e 100644 --- a/frontend/src/tools/AddStamp.tsx +++ b/frontend/src/tools/AddStamp.tsx @@ -14,6 +14,7 @@ import { Tooltip } from "../components/shared/Tooltip"; import ButtonSelector from "../components/shared/ButtonSelector"; import { useAccordionSteps } from "../hooks/tools/shared/useAccordionSteps"; import ObscuredOverlay from "../components/shared/ObscuredOverlay"; +import { getDefaultFontSizeForAlphabet } from "../components/tools/addStamp/StampPreviewUtils"; const AddStamp = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => { const { t } = useTranslation(); @@ -124,7 +125,12 @@ const AddStamp = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {