Skip to content

Commit d82bd80

Browse files
authored
Typography update (#261)
2 parents 174cd6a + 3399a3b commit d82bd80

5 files changed

Lines changed: 32 additions & 22 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ Date format: DD/MM/YYYY
1616
- Long `content` widget no longer overflow in `ContentDialog` ([#242](https://github.com/bdlukaa/fluent_ui/issues/242))
1717
- Content no longer loses state when the pane display mode is changed ([#250](https://github.com/bdlukaa/fluent_ui/pull/250))
1818
- `initiallyExpanded` property on `Expander` works properly ([#252](https://github.com/bdlukaa/fluent_ui/pull/252))
19+
- **BREAKING** Updated typography ([#261](https://github.com/bdlukaa/fluent_ui/pull/261)):
20+
- Renamed `Typography.standart` to `Typography.fromBrightness`
21+
- Renamed `Typography` constructor to `Typography.raw`
22+
- Default color for dark mode is now `const Color(0xE4000000)`
23+
- Updated default font sizes for `display`, `titleLarge`, `title` and `subtitle`
1924

2025
## [3.9.1] - Input Update - [25/02/2022]
2126

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,17 +294,16 @@ ThemeData(
294294

295295
### Font
296296

297-
You should use one font throughout your app's UI, and we recommend sticking with the default font for Windows apps, **Segoe UI**. It's designed to maintain optimal legibility across sizes and pixel densities and offers a clean, light, and open aesthetic that complements the content of the system.
297+
You should use one font throughout your app's UI, and we recommend sticking with the default font for Windows apps, **Segoe UI Variable**. It's designed to maintain optimal legibility across sizes and pixel densities and offers a clean, light, and open aesthetic that complements the content of the system. [Learn more](https://docs.microsoft.com/en-us/windows/apps/design/style/typography#font)
298298

299-
![Font Segoe UI Showcase](https://docs.microsoft.com/en-us/windows/uwp/design/style/images/type/segoe-sample.svg)
299+
![Font Segoe UI Showcase](https://docs.microsoft.com/en-us/windows/apps/design/style/images/type/segoe-sample.svg)
300300

301-
[Learn more](https://docs.microsoft.com/en-us/windows/uwp/design/style/typography#font)
302301

303302
### Type ramp
304303

305-
The Windows type ramp establishes crucial relationships between the type styles on a page, helping users read content easily. [Learn more](https://docs.microsoft.com/en-us/windows/uwp/design/style/typography#type-ramp)
304+
The Windows type ramp establishes crucial relationships between the type styles on a page, helping users read content easily. All sizes are in effective pixels. [Learn more](https://docs.microsoft.com/en-us/windows/apps/design/style/typography#type-ramp)
306305

307-
![Windows Type Ramp](https://docs.microsoft.com/en-us/windows/uwp/design/style/images/type/type-ramp.png)
306+
![Windows Type Ramp](https://docs.microsoft.com/en-us/windows/apps/design/style/images/type/text-block-type-ramp.svg)
308307

309308
## Reveal Focus
310309

example/lib/screens/typography.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ class _TypographyPageState extends State<TypographyPage> {
5454
),
5555
ComboboxItem(
5656
child: Row(children: [
57-
buildColorBox(Colors.black),
57+
buildColorBox(const Color(0xE4000000)),
5858
const SizedBox(width: 10.0),
5959
const Text('Black'),
6060
]),
61-
value: Colors.black,
61+
value: const Color(0xE4000000),
6262
),
6363
...List.generate(Colors.accentColors.length, (index) {
6464
final color = Colors.accentColors[index];

lib/src/styles/theme.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ class ThemeData with Diagnosticable {
341341
: const Color.fromRGBO(255, 255, 255, 0.5442);
342342
menuColor ??= isLight ? const Color(0xFFf9f9f9) : const Color(0xFF2c2c2c);
343343
cardColor ??= isLight ? const Color(0xFFf3f3f3) : const Color(0xFF2e2e2e);
344-
typography = Typography.standard(brightness: brightness)
344+
typography = Typography.fromBrightness(brightness: brightness)
345345
.merge(typography)
346346
.apply(fontFamily: fontFamily);
347347
focusTheme = FocusThemeData.standard(

lib/src/styles/typography.dart

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Typography with Diagnosticable {
4343
final TextStyle? caption;
4444

4545
/// Creates a new [Typography]. To create the default typography, use [Typography.defaultTypography]
46-
const Typography({
46+
const Typography.raw({
4747
this.display,
4848
this.titleLarge,
4949
this.title,
@@ -54,33 +54,39 @@ class Typography with Diagnosticable {
5454
this.caption,
5555
});
5656

57-
/// The default typography.
57+
/// The default typography according to a brightness or color.
5858
///
59-
/// If [color] is null, uses [Colors.black] if [brightness] is [Brightness.dark], otherwise uses [Colors.white]
60-
factory Typography.standard({
59+
/// If [color] is null, [Colors.black] is used if [brightness] is light,
60+
/// otherwise [Colors.white] is used. If it's not null, [color] will be used.
61+
factory Typography.fromBrightness({
6162
Brightness? brightness,
6263
Color? color,
6364
}) {
64-
assert(brightness != null || color != null);
65-
color ??= brightness == Brightness.light ? Colors.black : Colors.white;
66-
return Typography(
65+
assert(
66+
brightness != null || color != null,
67+
'Either brightness or color must be provided',
68+
);
69+
// If color is null, brightness will not be null
70+
color ??=
71+
brightness == Brightness.light ? const Color(0xE4000000) : Colors.white;
72+
return Typography.raw(
6773
display: TextStyle(
68-
fontSize: 42,
74+
fontSize: 68,
6975
color: color,
7076
fontWeight: FontWeight.w600,
7177
),
7278
titleLarge: TextStyle(
73-
fontSize: 34,
79+
fontSize: 40,
7480
color: color,
7581
fontWeight: FontWeight.w500,
7682
),
7783
title: TextStyle(
78-
fontSize: 22,
84+
fontSize: 28,
7985
color: color,
8086
fontWeight: FontWeight.w600,
8187
),
8288
subtitle: TextStyle(
83-
fontSize: 28,
89+
fontSize: 20,
8490
color: color,
8591
fontWeight: FontWeight.w500,
8692
),
@@ -108,7 +114,7 @@ class Typography with Diagnosticable {
108114
}
109115

110116
static Typography lerp(Typography? a, Typography? b, double t) {
111-
return Typography(
117+
return Typography.raw(
112118
display: TextStyle.lerp(a?.display, b?.display, t),
113119
titleLarge: TextStyle.lerp(a?.titleLarge, b?.titleLarge, t),
114120
title: TextStyle.lerp(a?.title, b?.title, t),
@@ -123,7 +129,7 @@ class Typography with Diagnosticable {
123129
/// Copy this with a new [typography]
124130
Typography merge(Typography? typography) {
125131
if (typography == null) return this;
126-
return Typography(
132+
return Typography.raw(
127133
display: typography.display ?? display,
128134
titleLarge: typography.titleLarge ?? titleLarge,
129135
title: typography.title ?? title,
@@ -144,7 +150,7 @@ class Typography with Diagnosticable {
144150
Color? decorationColor,
145151
TextDecorationStyle? decorationStyle,
146152
}) {
147-
return Typography(
153+
return Typography.raw(
148154
display: display?.apply(
149155
color: displayColor,
150156
decoration: decoration,

0 commit comments

Comments
 (0)