@@ -17,14 +17,6 @@ export const MIN_GLOSS_LINE_GAP_PX = 0;
1717export const MAX_GLOSS_LINE_GAP_PX = 80 ;
1818export const DEFAULT_TOKEN_SPLIT_CHARS = '.-' ;
1919
20- /** Scales with the smaller of the two line sizes (same rule as in-app gloss preview). */
21- export function defaultGlossFontSizePx ( s : {
22- sourceTextSizePx : number ;
23- targetTextSizePx : number ;
24- } ) : number {
25- return Math . max ( 12 , Math . round ( 0.75 * Math . min ( s . sourceTextSizePx , s . targetTextSizePx ) ) ) ;
26- }
27-
2820/** Normalize theme from shared `?data=` payloads to BeerCSS body class `light` | `dark`. */
2921export function normalizeUiTheme ( theme : string ) : UiTheme {
3022 const t = theme . toLowerCase ( ) ;
@@ -37,6 +29,8 @@ export interface VisualSettingsV1 {
3729 theme : UiTheme ;
3830 sourceTextSizePx : number ;
3931 targetTextSizePx : number ;
32+ /** Interlinear gloss (preview, editor, export) — independent of line sizes. */
33+ glossTextSizePx : number ;
4034 gapWordPx : number ;
4135 gapLinePx : number ;
4236 /** Vertical gap between a gloss row and its sentence line (preview + export layout). */
@@ -89,6 +83,7 @@ export function defaultVisualSettings(): VisualSettingsV1 {
8983 theme : 'light' ,
9084 sourceTextSizePx : size ,
9185 targetTextSizePx : size ,
86+ glossTextSizePx : Math . max ( 12 , Math . round ( 0.75 * size ) ) ,
9287 gapWordPx : 14 ,
9388 gapLinePx : 120 ,
9489 glossLineGapPx : MIN_GLOSS_LINE_GAP_PX ,
@@ -164,11 +159,25 @@ export function normalizeVisualSettings(
164159 legacyLineSize !== undefined ? legacyLineSize : d . targetTextSizePx
165160 ) ;
166161
162+ const pickGlossTextSize = ( v : unknown , fallback : number ) =>
163+ typeof v === 'number' && Number . isFinite ( v )
164+ ? Math . max ( MIN_TEXT_SIZE_PX , Math . min ( MAX_TEXT_SIZE_PX , v ) )
165+ : fallback ;
166+
167+ const glossTextSizePx = pickGlossTextSize (
168+ rawRest . glossTextSizePx ,
169+ Math . max (
170+ MIN_TEXT_SIZE_PX ,
171+ Math . min ( MAX_TEXT_SIZE_PX , Math . round ( 0.75 * Math . min ( sourceTextSizePx , targetTextSizePx ) ) )
172+ )
173+ ) ;
174+
167175 return {
168176 ...d ,
169177 ...rawRest ,
170178 sourceTextSizePx,
171179 targetTextSizePx,
180+ glossTextSizePx,
172181 theme : normalizeUiTheme ( String ( rawRest . theme ?? d . theme ) ) ,
173182 sourceFontFamily :
174183 typeof rawRest . sourceFontFamily === 'string'
0 commit comments