@@ -45,19 +45,15 @@ import {
4545} from "./settingsSearch" ;
4646
4747function useFontDefaultFamilies ( ) {
48- const t = useT ( ) ;
4948 const settings = useScopedSettings ( ) ;
50- // The family resolution probes canvas metrics, so run it once per mount.
51- const [ resolved ] = useState ( ( ) => ( {
52- sans : resolveDefaultFamilyLabel ( DEFAULT_SANS_FONT_STACK ) ,
53- code : resolveDefaultFamilyLabel ( DEFAULT_CODE_FONT_STACK ) ,
49+ const [ defaults ] = useState ( ( ) => ( {
50+ sans : resolveDefaultFamilyLabel ( DEFAULT_SANS_FONT_STACK ) ?? "System default" ,
51+ code : resolveDefaultFamilyLabel ( DEFAULT_CODE_FONT_STACK ) ?? "System monospace" ,
5452 } ) ) ;
55- const sans = resolved . sans ?? t ( "settings.typography.systemDefault" ) ;
56- const code = resolved . code ?? t ( "settings.typography.systemMonospace" ) ;
5753 return {
58- sans,
59- code,
60- interfaceFamily : settings . fontFamilySans . trim ( ) || sans ,
54+ sans : defaults . sans ,
55+ code : defaults . code ,
56+ interfaceFamily : settings . fontFamilySans . trim ( ) || defaults . sans ,
6157 } ;
6258}
6359
@@ -71,8 +67,7 @@ function InterfaceFontRow({ preview }: { preview?: ReactNode }) {
7167 { ...searchableSetting ( "interface-font" ) }
7268 title = { t ( "settings.typography.interfaceFont.title" ) }
7369 description = { t ( "settings.typography.interfaceFont.description" ) }
74- familyAriaLabel = { t ( "settings.typography.interfaceFont.familyA11y" ) }
75- resetLabel = "interface font"
70+ familyA11yLabel = { t ( "settings.typography.interfaceFont.familyA11y" ) }
7671 defaultFamily = { defaults . sans }
7772 defaultValue = { DEFAULT_UNIFIED_SETTINGS . fontFamilySans }
7873 value = { settings . fontFamilySans }
@@ -106,8 +101,7 @@ function PromptFontRow() {
106101 { ...searchableSetting ( "prompt-font" ) }
107102 title = { t ( "settings.typography.promptFont.title" ) }
108103 description = { t ( "settings.typography.promptFont.description" ) }
109- familyAriaLabel = { t ( "settings.typography.promptFont.familyA11y" ) }
110- resetLabel = "prompt font"
104+ familyA11yLabel = { t ( "settings.typography.promptFont.familyA11y" ) }
111105 defaultFamily = { defaults . interfaceFamily }
112106 defaultValue = { DEFAULT_UNIFIED_SETTINGS . fontFamilyComposer }
113107 value = { settings . fontFamilyComposer }
@@ -134,10 +128,12 @@ function PromptFontRow() {
134128function CodeFontRow ( {
135129 title,
136130 description,
131+ familyA11yLabel,
137132 preview,
138133} : {
139134 title ?: string ;
140135 description ?: string ;
136+ familyA11yLabel ?: string ;
141137 preview ?: ReactNode ;
142138} ) {
143139 const t = useT ( ) ;
@@ -147,10 +143,9 @@ function CodeFontRow({
147143 return (
148144 < FontFamilySettingsRow
149145 { ...searchableSetting ( "code-font" ) }
150- title = { title ?? t ( "settings.typography.codeFont. title" ) }
146+ { ... ( title !== undefined ? { title } : { } ) }
151147 description = { description ?? t ( "settings.typography.codeFont.description" ) }
152- familyAriaLabel = { t ( "settings.typography.codeFont.familyA11y" ) }
153- resetLabel = "code font"
148+ familyA11yLabel = { familyA11yLabel ?? t ( "settings.typography.codeFont.familyA11y" ) }
154149 defaultFamily = { defaults . code }
155150 defaultValue = { DEFAULT_UNIFIED_SETTINGS . fontFamilyCode }
156151 value = { settings . fontFamilyCode }
@@ -185,8 +180,7 @@ function TerminalFontRow() {
185180 { ...searchableSetting ( "terminal-font" ) }
186181 title = { t ( "settings.typography.terminalFont.title" ) }
187182 description = { t ( "settings.typography.terminalFont.description" ) }
188- familyAriaLabel = { t ( "settings.typography.terminalFont.familyA11y" ) }
189- resetLabel = "terminal font"
183+ familyA11yLabel = { t ( "settings.typography.terminalFont.familyA11y" ) }
190184 defaultFamily = { defaults . code }
191185 defaultValue = { DEFAULT_UNIFIED_SETTINGS . fontFamilyTerminal }
192186 value = { settings . fontFamilyTerminal }
@@ -323,6 +317,7 @@ function SimpleFontRows() {
323317 < CodeFontRow
324318 title = { t ( "settings.typography.monospaceFont.title" ) }
325319 description = { t ( "settings.typography.monospaceFont.description" ) }
320+ familyA11yLabel = { t ( "settings.typography.monospaceFont.familyA11y" ) }
326321 preview = {
327322 < >
328323 < CodeFontPreview />
@@ -379,9 +374,8 @@ export function TypographySection() {
379374function FontFamilySettingsRow ( {
380375 id,
381376 title,
377+ familyA11yLabel,
382378 description,
383- familyAriaLabel,
384- resetLabel,
385379 defaultFamily,
386380 defaultValue,
387381 preview,
@@ -393,9 +387,8 @@ function FontFamilySettingsRow({
393387} : {
394388 id ?: string ;
395389 title : string ;
390+ familyA11yLabel : string ;
396391 description : string ;
397- familyAriaLabel : string ;
398- resetLabel : string ;
399392 defaultFamily : string ;
400393 defaultValue : string ;
401394 preview ?: ReactNode ;
@@ -461,14 +454,14 @@ function FontFamilySettingsRow({
461454 } ;
462455 const resetAction =
463456 value !== defaultValue || size . value !== size . defaultValue ? (
464- < SettingResetButton label = { resetLabel } onClick = { resetToDefault } />
457+ < SettingResetButton label = { title . toLowerCase ( ) } onClick = { resetToDefault } />
465458 ) : null ;
466459 const fontEnumeration = useFontEnumeration ( ) ;
467460 const [ inputFocused , setInputFocused ] = useState ( false ) ;
468461 const familyControl =
469462 fontEnumeration . status === "granted" ? (
470463 < FontFamilyPicker
471- ariaLabel = { familyAriaLabel }
464+ ariaLabel = { familyA11yLabel }
472465 defaultFamily = { defaultFamily }
473466 selectedFamily = { trimmed }
474467 requireMonospace = { requireMonospace }
@@ -478,7 +471,7 @@ function FontFamilySettingsRow({
478471 ) : (
479472 < Input
480473 size = "sm"
481- aria-label = { familyAriaLabel }
474+ aria-label = { familyA11yLabel }
482475 aria-invalid = { draftPending || undefined }
483476 autoCapitalize = "off"
484477 autoComplete = "off"
0 commit comments