NoteStack-Test / backend /app /slides /metrics.py
Muhammad-Mehdi's picture
slide deck and audio implemented
fa8df4c
Raw History Blame Contribute Delete
2.98 kB
"""Advance widths (in em) of the characters slides use most, measured in Chrome with the fonts the slides load
(Space Grotesk bold for headings, Inter regular and bold for text). Text is measured with these before it is placed,
so a line breaks where the browser will break it. Regenerate if the fonts change: draw each character ten times
between two x's at 100px in headless Chrome and subtract the width of "xx"."""
CHARS = "".join(chr(c) for c in range(32, 127)) + "\u2026\u201c\u201d\u2018\u2019\u2013\u2014\u00e9"
_DISPLAY_BOLD = (
0.254, 0.298, 0.514, 0.636, 0.606, 0.758, 0.591, 0.294, 0.398, 0.390, 0.540, 0.620, 0.294, 0.425, 0.298, 0.388,
0.648, 0.452, 0.594, 0.608, 0.636, 0.600, 0.618, 0.554, 0.600, 0.618, 0.298, 0.298, 0.620, 0.620, 0.620, 0.578,
1.014, 0.634, 0.664, 0.644, 0.646, 0.554, 0.534, 0.662, 0.656, 0.264, 0.578, 0.626, 0.542, 0.882, 0.670, 0.676,
0.604, 0.676, 0.632, 0.606, 0.580, 0.672, 0.616, 0.898, 0.644, 0.617, 0.576, 0.358, 0.388, 0.358, 0.620, 0.620,
0.296, 0.577, 0.635, 0.580, 0.635, 0.571, 0.337, 0.635, 0.616, 0.266, 0.268, 0.564, 0.266, 0.854, 0.616, 0.606,
0.635, 0.635, 0.396, 0.522, 0.391, 0.616, 0.548, 0.784, 0.592, 0.616, 0.518, 0.466, 0.258, 0.466, 0.620, 0.798,
0.514, 0.514, 0.294, 0.294, 0.577, 0.881, 0.571,
)
_BODY = (
0.281, 0.288, 0.466, 0.633, 0.642, 0.982, 0.644, 0.300, 0.365, 0.365, 0.501, 0.657, 0.288, 0.455, 0.288, 0.360,
0.631, 0.407, 0.610, 0.618, 0.646, 0.593, 0.620, 0.584, 0.619, 0.620, 0.288, 0.302, 0.662, 0.655, 0.662, 0.511,
0.966, 0.703, 0.654, 0.730, 0.722, 0.601, 0.590, 0.746, 0.743, 0.269, 0.571, 0.672, 0.565, 0.903, 0.753, 0.765,
0.639, 0.765, 0.644, 0.642, 0.633, 0.744, 0.703, 1.007, 0.682, 0.679, 0.629, 0.365, 0.316, 0.365, 0.471, 0.456,
0.323, 0.562, 0.610, 0.567, 0.610, 0.579, 0.337, 0.611, 0.591, 0.242, 0.242, 0.549, 0.242, 0.876, 0.591, 0.595,
0.610, 0.610, 0.392, 0.528, 0.329, 0.591, 0.562, 0.818, 0.546, 0.562, 0.552, 0.426, 0.333, 0.426, 0.657, 0.864,
0.440, 0.440, 0.261, 0.261, 0.500, 1.000, 0.579,
)
_BODY_BOLD = (
0.237, 0.338, 0.551, 0.649, 0.655, 1.015, 0.672, 0.339, 0.377, 0.377, 0.559, 0.674, 0.334, 0.463, 0.334, 0.388,
0.674, 0.431, 0.630, 0.645, 0.676, 0.622, 0.650, 0.599, 0.651, 0.650, 0.334, 0.343, 0.679, 0.672, 0.679, 0.559,
1.016, 0.760, 0.662, 0.740, 0.722, 0.607, 0.587, 0.751, 0.747, 0.281, 0.584, 0.719, 0.565, 0.932, 0.762, 0.770,
0.648, 0.777, 0.657, 0.655, 0.661, 0.732, 0.760, 1.057, 0.738, 0.731, 0.664, 0.377, 0.344, 0.377, 0.487, 0.476,
0.365, 0.580, 0.628, 0.584, 0.628, 0.592, 0.362, 0.630, 0.623, 0.271, 0.271, 0.580, 0.271, 0.912, 0.622, 0.609,
0.628, 0.628, 0.415, 0.560, 0.358, 0.623, 0.600, 0.850, 0.580, 0.602, 0.573, 0.469, 0.372, 0.469, 0.674, 1.002,
0.540, 0.532, 0.311, 0.311, 0.500, 1.000, 0.592,
)
WIDTHS = {name: dict(zip(CHARS, table, strict=True)) for name, table in
(("display_bold", _DISPLAY_BOLD), ("body", _BODY), ("body_bold", _BODY_BOLD))}