mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-22 19:46:39 +00:00
changed the chinese characters to temporarily default to 30 so it fits on the page, same as V1
This commit is contained in:
parent
2a141a35b0
commit
0bfdbd288d
@ -52,18 +52,22 @@ export type StampPreviewStyle = { container: any; item: any };
|
|||||||
|
|
||||||
// Unified per-alphabet preview adjustments
|
// Unified per-alphabet preview adjustments
|
||||||
export type Alphabet = 'roman' | 'arabic' | 'japanese' | 'korean' | 'chinese' | 'thai';
|
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<Alphabet, AlphabetTweaks> = {
|
export const ALPHABET_PREVIEW_TWEAKS: Record<Alphabet, AlphabetTweaks> = {
|
||||||
// [top, middle, bottom] row offsets in rem
|
// [top, middle, bottom] row offsets in rem
|
||||||
roman: { scale: 1.0/1.18, rowOffsetRem: [0, 1, 2.2], lineHeight: 1.28, capHeightRatio: 0.70 },
|
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 },
|
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 },
|
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 },
|
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 },
|
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 },
|
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 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(
|
export function computeStampPreviewStyle(
|
||||||
parameters: AddStampParameters,
|
parameters: AddStampParameters,
|
||||||
imageMeta: ImageMeta,
|
imageMeta: ImageMeta,
|
||||||
|
@ -22,7 +22,7 @@ export const defaultParameters: AddStampParameters = {
|
|||||||
stampType: 'text',
|
stampType: 'text',
|
||||||
stampText: '',
|
stampText: '',
|
||||||
alphabet: 'roman',
|
alphabet: 'roman',
|
||||||
fontSize: 100,
|
fontSize: 80,
|
||||||
rotation: 0,
|
rotation: 0,
|
||||||
opacity: 50,
|
opacity: 50,
|
||||||
position: 5,
|
position: 5,
|
||||||
|
@ -14,6 +14,7 @@ import { Tooltip } from "../components/shared/Tooltip";
|
|||||||
import ButtonSelector from "../components/shared/ButtonSelector";
|
import ButtonSelector from "../components/shared/ButtonSelector";
|
||||||
import { useAccordionSteps } from "../hooks/tools/shared/useAccordionSteps";
|
import { useAccordionSteps } from "../hooks/tools/shared/useAccordionSteps";
|
||||||
import ObscuredOverlay from "../components/shared/ObscuredOverlay";
|
import ObscuredOverlay from "../components/shared/ObscuredOverlay";
|
||||||
|
import { getDefaultFontSizeForAlphabet } from "../components/tools/addStamp/StampPreviewUtils";
|
||||||
|
|
||||||
const AddStamp = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
|
const AddStamp = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -124,7 +125,12 @@ const AddStamp = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
|
|||||||
<Select
|
<Select
|
||||||
label={t('AddStampRequest.alphabet', 'Alphabet')}
|
label={t('AddStampRequest.alphabet', 'Alphabet')}
|
||||||
value={params.parameters.alphabet}
|
value={params.parameters.alphabet}
|
||||||
onChange={(v) => params.updateParameter('alphabet', (v as any) || 'roman')}
|
onChange={(v) => {
|
||||||
|
const nextAlphabet = (v as any) || 'roman';
|
||||||
|
params.updateParameter('alphabet', nextAlphabet);
|
||||||
|
const nextDefault = getDefaultFontSizeForAlphabet(nextAlphabet);
|
||||||
|
params.updateParameter('fontSize', nextDefault);
|
||||||
|
}}
|
||||||
data={[
|
data={[
|
||||||
{ value: 'roman', label: 'Roman' },
|
{ value: 'roman', label: 'Roman' },
|
||||||
{ value: 'arabic', label: 'العربية' },
|
{ value: 'arabic', label: 'العربية' },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user