1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/**
* Resolved font metrics for an ability-line segment (the reference `LineStyles`,
* PORTING.md §8b). The web card is centre-aligned and non-left, matching the
* reference's ability-card `createLines` call; only the Frosthaven/Gloomhaven
* split and the elite color vary. Sizes are in px at `scale` 1 — the renderer
* multiplies by the card's `scale`.
*/
import type { LineStyle } from './types';
export interface ResolvedLine {
/** Font size in px at scale 1. */
size: number;
/** Unitless line-height. */
height: number;
color: string;
}
const WHITE = '#ffffff';
const BLACK = '#000000';
const ELITE = '#ffe600'; // Colors.yellow
export function resolveStyle(
style: LineStyle,
frosthavenStyle: boolean,
left: boolean
): ResolvedLine {
const color = left ? BLACK : WHITE;
switch (style) {
case 'normal':
return { size: frosthavenStyle ? 13.1 : 12.56, height: frosthavenStyle ? 0.84 : 0.85, color };
case 'mid':
return { size: frosthavenStyle ? 9.52 : 8.8, height: frosthavenStyle ? 1.0 : 0.85, color };
case 'midSquished':
return { size: frosthavenStyle ? 9.52 : 8.8, height: 0.8, color };
case 'small':
return { size: 8.0, height: 0.8, color };
case 'elite':
return { size: frosthavenStyle ? 13.1 : 12.56, height: frosthavenStyle ? 0.84 : 0.85, color: ELITE };
case 'eliteSmall':
return { size: 8.0, height: 1.0, color: ELITE };
case 'eliteMid':
return { size: frosthavenStyle ? 9.52 : 8.8, height: frosthavenStyle ? 1.0 : 0.85, color: ELITE };
case 'divider':
return { size: 6.4, height: 0.7, color };
case 'dividerThin':
return { size: 4.8, height: 0.1, color };
case 'special':
// The reference renders this as transparent Majalla text (a spacer).
return { size: 8.8, height: 1.0, color: 'transparent' };
}
}
|