Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

sheet-sizing.ts

33 lines1.0 KB

1export const maximumColumnWidth = 255;
2export const maximumRowHeight = (409.5 * 4) / 3;
3export const minimumTrackSize = 16;
4​
5// BetterOffice's screen geometry uses these digit advances at 96 DPI. Its
6// workbook API exposes widths in characters and cell rectangles in pixels.
7const digitAdvances = new Map([
8 ["arial", 0.5562],
9 ["helvetica", 0.5562],
10 ["liberation sans", 0.5562],
11 ["arimo", 0.5562],
12 ["times new roman", 0.5],
13 ["liberation serif", 0.5],
14 ["tinos", 0.5],
15 ["courier new", 0.6001],
16 ["liberation mono", 0.6001],
17 ["cousine", 0.6001],
18 ["cambria", 0.554],
19 ["caladea", 0.554],
20 ["aptos", 0.534],
21 ["verdana", 0.6362],
22 ["tahoma", 0.5464],
23 ["trebuchet ms", 0.524],
24 ["century gothic", 0.554],
25 ["arial narrow", 0.456],
26 ["consolas", 0.5498],
27]);
28​
29export function columnDigitWidth(family = "", points = 11) {
30 const advance = digitAdvances.get(family.trim().toLowerCase()) ?? 1038 / 2048;
31 const size = Number.isFinite(points) && points > 0 ? points : 11;
32 return Math.max(1, Math.round(advance * size * (4 / 3)));