Skip to content

Commit f0d4447

Browse files
author
Simon
authored
Correct font weight for Cupertino tab label (#90109)
1 parent c7643cf commit f0d4447

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

packages/flutter/lib/src/cupertino/text_theme.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const TextStyle _kDefaultTabLabelTextStyle = TextStyle(
4545
inherit: false,
4646
fontFamily: '.SF Pro Text',
4747
fontSize: 10.0,
48+
fontWeight: FontWeight.w500,
4849
letterSpacing: -0.24,
4950
color: CupertinoColors.inactiveGray,
5051
);
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter/cupertino.dart';
6+
import 'package:flutter_test/flutter_test.dart';
7+
8+
void main() {
9+
test('CupertinoTextTheme matches Apple Design resources', () {
10+
// Check the default cupertino text theme against the style values
11+
// Values derived from https://developer.apple.com/design/resources/.
12+
13+
const CupertinoTextThemeData theme = CupertinoTextThemeData();
14+
const FontWeight normal = FontWeight.normal;
15+
const FontWeight regular = FontWeight.w400;
16+
const FontWeight medium = FontWeight.w500;
17+
const FontWeight semiBold = FontWeight.w600;
18+
const FontWeight bold = FontWeight.w700;
19+
20+
// TextStyle 17 -0.41
21+
expect(theme.textStyle.fontSize, 17);
22+
expect(theme.textStyle.fontFamily, '.SF Pro Text');
23+
expect(theme.textStyle.letterSpacing, -0.41);
24+
expect(theme.textStyle.fontWeight, null);
25+
26+
// ActionTextStyle 17 -0.41
27+
expect(theme.actionTextStyle.fontSize, 17);
28+
expect(theme.actionTextStyle.fontFamily, '.SF Pro Text');
29+
expect(theme.actionTextStyle.letterSpacing, -0.41);
30+
expect(theme.actionTextStyle.fontWeight, null);
31+
32+
// TextStyle 17 -0.41
33+
expect(theme.tabLabelTextStyle.fontSize, 10);
34+
expect(theme.tabLabelTextStyle.fontFamily, '.SF Pro Text');
35+
expect(theme.tabLabelTextStyle.letterSpacing, -0.24);
36+
expect(theme.tabLabelTextStyle.fontWeight, medium);
37+
38+
// NavTitle SemiBold 17 -0.41
39+
expect(theme.navTitleTextStyle.fontSize, 17);
40+
expect(theme.navTitleTextStyle.fontFamily, '.SF Pro Text');
41+
expect(theme.navTitleTextStyle.letterSpacing, -0.41);
42+
expect(theme.navTitleTextStyle.fontWeight, semiBold);
43+
44+
// NavLargeTitle Bold 34 0.41
45+
expect(theme.navLargeTitleTextStyle.fontSize, 34);
46+
expect(theme.navLargeTitleTextStyle.fontFamily, '.SF Pro Display');
47+
expect(theme.navLargeTitleTextStyle.letterSpacing, 0.41);
48+
expect(theme.navLargeTitleTextStyle.fontWeight, bold);
49+
50+
// Picker Regular 21 -0.6
51+
expect(theme.pickerTextStyle.fontSize, 21);
52+
expect(theme.pickerTextStyle.fontFamily, '.SF Pro Display');
53+
expect(theme.pickerTextStyle.letterSpacing, -0.6);
54+
expect(theme.pickerTextStyle.fontWeight, regular);
55+
56+
// DateTimePicker Normal 21
57+
expect(theme.dateTimePickerTextStyle.fontSize, 21);
58+
expect(theme.dateTimePickerTextStyle.fontFamily, '.SF Pro Display');
59+
expect(theme.dateTimePickerTextStyle.letterSpacing, null);
60+
expect(theme.dateTimePickerTextStyle.fontWeight, normal);
61+
});
62+
}

0 commit comments

Comments
 (0)