Skip to content

Commit cec285c

Browse files
committed
wip: adjust text optical size AND width
1 parent e45951e commit cec285c

File tree

4 files changed

+103
-69
lines changed

4 files changed

+103
-69
lines changed

packages/webui/src/client/styles/countdown/director.scss

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ $hold-status-color: $liveline-timecode-color;
7070
display: grid;
7171
grid-template:
7272
24em
73-
50em
73+
70em
7474
30em / #{'min(13vw, 27vh)'} auto;
7575
white-space: nowrap;
7676

@@ -79,13 +79,22 @@ $hold-status-color: $liveline-timecode-color;
7979
grid-column: 1 / -1;
8080
text-align: left;
8181
padding-left: 10px;
82-
font-size: 20em;
83-
font-weight: 500;
84-
line-height: 120%;
85-
letter-spacing: 0%;
8682
vertical-align: middle;
87-
color: #fff;
8883
position: relative;
84+
/* PartNameWide */
85+
font-family: 'Roboto Flex';
86+
font-style: normal;
87+
font-weight: 700;
88+
font-size: 99px;
89+
line-height: 110%;
90+
letter-spacing: 0.01em;
91+
font-feature-settings: 'pnum' on, 'lnum' on;
92+
93+
color: #FFFFFF;
94+
font-stretch: 100;
95+
font-variation-settings: 'GRAD' -90, 'XOPQ' 96, 'XTRA' 372, 'YOPQ' 79, 'YTAS' 750, 'YTDE' -203, 'YTFI' 738, 'YTLC' 514, 'YTUC' 712, 'slnt' 0, 'opsz' 38;
96+
97+
text-shadow: 0px 0px 4px rgba(0, 0, 0, 0.5);
8998
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.5);
9099
z-index: 1;
91100

@@ -100,6 +109,7 @@ $hold-status-color: $liveline-timecode-color;
100109
}
101110
.director-screen__body__segment__countdown {
102111
position: absolute;
112+
font-size: 120px;
103113
top: 0;
104114
right: 0;
105115
height: 100%;
Lines changed: 64 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
.counter-component__over-under {
22
color: black;
3-
font-family: Roboto Flex;
4-
font-weight: 400;
5-
font-size: 2em;
3+
font-family: 'Roboto Flex';
4+
margin-top: 4px;
5+
margin-bottom: 4px;
6+
font-style: normal;
7+
font-weight: 500;
8+
font-size: 90px;
69
line-height: 100%;
7-
letter-spacing: 0%;
10+
/* identical to box height, or 120px */
11+
text-align: right;
12+
font-feature-settings: 'liga' off;
13+
14+
font-stretch: 57;
15+
font-variation-settings: 'GRAD' 0, 'XOPQ' 96, 'XTRA' 468, 'YOPQ' 79, 'YTAS' 750, 'YTDE' -203, 'YTFI' 738, 'YTLC' 548, 'YTUC' 712, 'slnt' 0, 'opsz' 44;
16+
817

918
.under {
1019
background-color: #ff0;
@@ -27,31 +36,67 @@
2736
}
2837

2938
.counter-component__planned-end {
30-
color: #fff;
31-
font-family: Roboto Flex;
39+
/* TimeOfDay */
40+
font-family: 'Roboto Flex';
41+
font-style: normal;
3242
font-weight: 400;
33-
font-style: italic;
34-
font-size: 2em;
43+
font-size: 90px;
3544
line-height: 100%;
3645
letter-spacing: 0%;
46+
/* identical to box height, or 120px */
47+
font-feature-settings: 'liga' off;
48+
49+
color: #FFFFFF;
50+
font-stretch: 70;
51+
font-variation-settings: 'GRAD' 0, 'XOPQ' 96, 'XTRA' 468, 'YOPQ' 79, 'YTAS' 750, 'YTDE' -203, 'YTFI' 738, 'YTLC' 548, 'YTUC' 712, 'slnt' -7, 'opsz' 44;
52+
53+
54+
/* Inside auto layout */
55+
flex: none;
56+
order: 0;
57+
flex-grow: 0;
58+
3759
}
3860

3961
.counter-component__time-to-planned-end {
4062
color:#ff0;
41-
font-family: Roboto Flex;
42-
font-weight: 500;
43-
font-size: 2em;
44-
line-height: 100%;
4563
letter-spacing: 0%;
46-
text-align: center;
64+
/* CounterUnder */
65+
font-family: 'Roboto Flex';
66+
font-style: normal;
67+
font-weight: 500;
68+
font-size: 90px;
69+
line-height: 100%;
70+
/* identical to box height, or 120px */
71+
text-align: right;
72+
font-feature-settings: 'liga' off;
73+
74+
color: #000000;
75+
font-stretch: 57;
76+
font-variation-settings: 'GRAD' 0, 'XOPQ' 96, 'XTRA' 468, 'YOPQ' 79, 'YTAS' 750, 'YTDE' -203, 'YTFI' 738, 'YTLC' 548, 'YTUC' 712, 'slnt' 0, 'opsz' 44;
77+
78+
79+
/* Inside auto layout */
80+
flex: none;
81+
order: 0;
82+
flex-grow: 0;
83+
4784
}
4885

4986
.counter-component__time-since-planned-end {
5087
color: #FF5218;
51-
font-family: Roboto Flex;
52-
font-weight: 630;
53-
font-size: 2em;
54-
line-height: 100%;
55-
letter-spacing: -3.5%;
56-
text-align: center;
88+
89+
font-family: 'Roboto Flex';
90+
font-style: normal;
91+
font-weight: 500;
92+
font-size: 90px;
93+
line-height: 100%;
94+
/* identical to box height, or 120px */
95+
text-align: right;
96+
font-feature-settings: 'liga' off;
97+
98+
font-stretch: 57;
99+
font-variation-settings: 'GRAD' 0, 'XOPQ' 96, 'XTRA' 468, 'YOPQ' 79, 'YTAS' 750, 'YTDE' -203, 'YTFI' 738, 'YTLC' 548, 'YTUC' 712, 'slnt' 0, 'opsz' 44;
100+
101+
57102
}

packages/webui/src/client/ui/ClockView/DirectorScreen.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,9 @@ function DirectorScreenRender({
401401
label={currentSegment?.name || ''}
402402
width={'80vw'}
403403
fontFamily="Roboto Flex"
404-
fontSize="1em"
405-
minFontSize={70}
406-
maxFontSize={100}
404+
fontSize="0.8em"
405+
minFontWidth={70}
406+
maxFontWidth={90}
407407
minLetterSpacing={0}
408408
hardCutText={true}
409409
/>
@@ -437,8 +437,8 @@ function DirectorScreenRender({
437437
width: '90vw',
438438
fontFamily: 'Roboto Flex',
439439
fontSize: '2em',
440-
minFontSize: 70,
441-
maxFontSize: 100,
440+
minFontWidth: 20,
441+
maxFontWidth: 90,
442442
minLetterSpacing: 2,
443443
}}
444444
/>
@@ -484,9 +484,9 @@ function DirectorScreenRender({
484484
label={nextSegment?.name || ''}
485485
width={'80vw'}
486486
fontFamily="Roboto Flex"
487-
fontSize="1em"
488-
minFontSize={70}
489-
maxFontSize={100}
487+
fontSize="0.8em"
488+
minFontWidth={70}
489+
maxFontWidth={90}
490490
minLetterSpacing={0}
491491
hardCutText={true}
492492
/>
@@ -522,8 +522,8 @@ function DirectorScreenRender({
522522
width: '90vw',
523523
fontFamily: 'Roboto Flex',
524524
fontSize: '2em',
525-
minFontSize: 70,
526-
maxFontSize: 100,
525+
minFontWidth: 20,
526+
maxFontWidth: 90,
527527
minLetterSpacing: 2,
528528
}}
529529
/>

packages/webui/src/client/ui/util/AdjustLabelFit.tsx

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ export interface AdjustLabelFitProps {
2424
fontSize?: string | number
2525

2626
/**
27-
* Minimum font size in percentage relative to fontSize (for auto-scaling)
27+
* Minimum font width in percentage relative to normal (for auto-scaling)
2828
* Default is 50
2929
*/
30-
minFontSize?: number
30+
minFontWidth?: number
3131

3232
/**
33-
* Maximum font size in percentage relative to fontSize (for auto-scaling)
33+
* Maximum font size in percentage relative to normal (for auto-scaling)
3434
* Default is 120
3535
*/
36-
maxFontSize?: number
36+
maxFontWidth?: number
3737

3838
/**
3939
* Minimum letter spacing in pixels
@@ -72,8 +72,8 @@ export const AdjustLabelFit: React.FC<AdjustLabelFitProps> = ({
7272
width,
7373
fontFamily,
7474
fontSize,
75-
minFontSize = 50,
76-
maxFontSize = 120,
75+
minFontWidth = 50,
76+
maxFontWidth = 120,
7777
minLetterSpacing = -1,
7878
containerStyle = {},
7979
labelStyle = {},
@@ -109,9 +109,11 @@ export const AdjustLabelFit: React.FC<AdjustLabelFitProps> = ({
109109
if (!labelElement || !containerElement) return
110110

111111
const DEFAULT_WIDTH = 100
112+
const DEFAULT_OPTICAL_SIZE = 10
112113
labelElement.style.letterSpacing = '0px'
113114

114-
labelElement.style.fontVariationSettings = `'wdth' ${DEFAULT_WIDTH}`
115+
// Apply the new width setting
116+
labelElement.style.fontVariationSettings = `'opsz' ${DEFAULT_OPTICAL_SIZE}, 'wdth' ${DEFAULT_WIDTH}`
115117

116118
// Reset label content if it was cut
117119
labelElement.textContent = label
@@ -131,25 +133,6 @@ export const AdjustLabelFit: React.FC<AdjustLabelFitProps> = ({
131133

132134
// Measure the container and text widths
133135
const containerWidth = containerElement.clientWidth
134-
const textWidth = labelElement.getBoundingClientRect().width
135-
136-
if (textWidth <= containerWidth) {
137-
const currentFontSize = parseFloat(window.getComputedStyle(labelElement).fontSize)
138-
const scaleFactor = containerWidth / textWidth
139-
const newFontSize = Math.min(currentFontSize * scaleFactor, maxFontSize)
140-
141-
labelElement.style.fontSize = `${newFontSize}px`
142-
143-
// Re-center text vertically if needed
144-
labelElement.style.lineHeight = '1'
145-
146-
return
147-
}
148-
149-
const currentFontSize = parseFloat(window.getComputedStyle(labelElement).fontSize)
150-
const scaleFactor = containerWidth / textWidth
151-
const newFontSize = Math.max(currentFontSize * scaleFactor, minFontSize)
152-
labelElement.style.fontSize = `${newFontSize}px`
153136

154137
// Remeasure after font size adjustment
155138
void labelElement.offsetWidth
@@ -162,10 +145,10 @@ export const AdjustLabelFit: React.FC<AdjustLabelFitProps> = ({
162145
let currentWidth = DEFAULT_WIDTH * widthRatio
163146

164147
// Use a reasonable range for width variation
165-
currentWidth = Math.max(currentWidth, 75) // minimum 75%
166-
currentWidth = Math.min(currentWidth, 110) // maximum 110%
148+
currentWidth = Math.max(currentWidth, minFontWidth)
149+
currentWidth = Math.min(currentWidth, maxFontWidth)
167150

168-
labelElement.style.fontVariationSettings = `'wdth' ${currentWidth}`
151+
labelElement.style.fontVariationSettings = `'opsz' ${100 - minFontWidth}, 'wdth' ${currentWidth}`
169152

170153
// Remeasure text width after adjustment:
171154
void labelElement.offsetWidth
@@ -194,10 +177,6 @@ export const AdjustLabelFit: React.FC<AdjustLabelFitProps> = ({
194177
void labelElement.offsetWidth
195178
const finalTextWidth = labelElement.getBoundingClientRect().width
196179
if (finalTextWidth > containerWidth) {
197-
const currentFontSize = parseFloat(window.getComputedStyle(labelElement).fontSize)
198-
const minFontSizeValue = currentFontSize * (minFontSize / 100)
199-
labelElement.style.fontSize = `${minFontSizeValue}px`
200-
201180
labelElement.textContent = ''
202181

203182
for (let i = 0; i < label.length; i++) {
@@ -247,7 +226,7 @@ export const AdjustLabelFit: React.FC<AdjustLabelFitProps> = ({
247226
cancelAnimationFrame(adjustmentTimer)
248227
cancelAnimationFrame(resizeTimer)
249228
}
250-
}, [label, width, fontFamily, fontSize, minFontSize, maxFontSize, minLetterSpacing])
229+
}, [label, width, fontFamily, fontSize, minFontWidth, maxFontWidth, minLetterSpacing])
251230

252231
return (
253232
<div ref={containerRef} className={`adjust-label-fit ${className}`} style={finalContainerStyle}>

0 commit comments

Comments
 (0)