Skip to content

Commit

Permalink
refactor: replace fonts to assets package
Browse files Browse the repository at this point in the history
  • Loading branch information
ETC\anhlp authored and han2-n committed Dec 5, 2023
1 parent 302f5b0 commit c8ef00e
Show file tree
Hide file tree
Showing 19 changed files with 88 additions and 119 deletions.
123 changes: 46 additions & 77 deletions lib/core/_style/app_text_theme.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
part of 'app_theme.dart';

const kFontFamily = 'Averta';
const kFontPackageName = 'assets';

class AppTextTheme {
final Brightness _brightness;
Expand All @@ -21,109 +22,77 @@ class AppTextTheme {
? Typography.blackMountainView
: Typography.whiteMountainView;

textTheme = typography.merge(TextTheme(
textTheme = typography.merge(const TextTheme(
// headline1
displayLarge: applyFontFamily(
const TextStyle(
fontSize: 64,
letterSpacing: 1.6,
fontWeight: FontWeight.w300,
),
displayLarge: TextStyle(
fontSize: 64,
letterSpacing: 1.6,
fontWeight: FontWeight.w300,
),
// headline2
displayMedium: applyFontFamily(
const TextStyle(
fontSize: 48,
letterSpacing: 1.3,
fontWeight: FontWeight.w300,
),
displayMedium: TextStyle(
fontSize: 48,
letterSpacing: 1.3,
fontWeight: FontWeight.w300,
),
// headline3
displaySmall: applyFontFamily(
const TextStyle(
fontSize: 48,
letterSpacing: 0,
),
displaySmall: TextStyle(
fontSize: 48,
letterSpacing: 0,
),
// headline4
headlineMedium: applyFontFamily(
const TextStyle(
fontSize: 18,
letterSpacing: 1.3,
fontWeight: FontWeight.w300,
),
headlineMedium: TextStyle(
fontSize: 18,
letterSpacing: 1.3,
fontWeight: FontWeight.w300,
),
// headline5
headlineSmall: applyFontFamily(
const TextStyle(
fontSize: 20,
letterSpacing: 1.3,
fontWeight: FontWeight.w300,
),
headlineSmall: TextStyle(
fontSize: 20,
letterSpacing: 1.3,
fontWeight: FontWeight.w300,
),
// headline6
titleLarge: applyFontFamily(
const TextStyle(
fontSize: 20,
letterSpacing: 1.3,
fontWeight: FontWeight.w300,
),
titleLarge: TextStyle(
fontSize: 20,
letterSpacing: 1.3,
fontWeight: FontWeight.w300,
),
// subtitle1
titleMedium: applyFontFamily(
const TextStyle(
fontSize: 16,
letterSpacing: 1,
fontWeight: FontWeight.w300,
),
titleMedium: TextStyle(
fontSize: 16,
letterSpacing: 1,
fontWeight: FontWeight.w300,
),
// subtitle2
titleSmall: applyFontFamily(
const TextStyle(
height: 1.1,
fontSize: 16,
fontWeight: FontWeight.w300,
),
titleSmall: TextStyle(
height: 1.1,
fontSize: 16,
fontWeight: FontWeight.w300,
),
// bodyText1
bodyLarge: applyFontFamily(
const TextStyle(
fontSize: 14,
),
),
bodyMedium: TextStyle(fontSize: 14),
// bodyText2
bodyMedium: applyFontFamily(
const TextStyle(
fontSize: 16,
),
),
bodyLarge: TextStyle(fontSize: 16),
// button
labelLarge: applyFontFamily(
const TextStyle(
fontSize: 16,
letterSpacing: 1.2,
),
labelLarge: TextStyle(
fontSize: 16,
letterSpacing: 1.2,
),
// caption
bodySmall: applyFontFamily(
const TextStyle(
fontSize: 12,
letterSpacing: .4,
),
bodySmall: TextStyle(
fontSize: 12,
letterSpacing: .4,
),
// overline
labelSmall: applyFontFamily(
const TextStyle(
fontSize: 10,
letterSpacing: 1.5,
),
labelSmall: TextStyle(
fontSize: 10,
letterSpacing: 1.5,
),
).apply(
fontSizeDelta: _fontSizeDelta,
fontFamily: kFontFamily,
package: kFontPackageName,
));
}
}

TextStyle applyFontFamily(TextStyle textStyle) {
return textStyle.copyWith(fontFamily: kFontFamily);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions packages/assets/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,45 @@ flutter:
assets:
- assets/images/
- assets/icons/

fonts:
- family: Averta
fonts:
- asset: assets/fonts/Averta-Black.otf
weight: 900
- asset: assets/fonts/Averta-BlackItalic.otf
weight: 900
style: italic
- asset: assets/fonts/Averta-Bold.otf
weight: 700
- asset: assets/fonts/Averta-BoldItalic.otf
weight: 700
style: italic
- asset: assets/fonts/Averta-ExtraBold.otf
weight: 800
- asset: assets/fonts/Averta-ExtraBoldItalic.otf
weight: 800
style: italic
- asset: assets/fonts/Averta-Extrathin.otf
weight: 100
- asset: assets/fonts/Averta-ExtrathinItalic.otf
weight: 100
style: italic
- asset: assets/fonts/Averta-Light.otf
weight: 300
- asset: assets/fonts/Averta-LightItalic.otf
weight: 300
style: italic
- asset: assets/fonts/Averta-Regular.otf
- asset: assets/fonts/Averta-RegularItalic.otf
style: italic
- asset: assets/fonts/Averta-Semibold.otf
weight: 600
- asset: assets/fonts/Averta-SemiboldItalic.otf
weight: 600
style: italic
- asset: assets/fonts/Averta-Thin.otf
weight: 200
- asset: assets/fonts/Averta-ThinItalic.otf
weight: 200
style: italic
42 changes: 0 additions & 42 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,45 +106,3 @@ dev_dependencies:

flutter:
uses-material-design: true

fonts:
- family: Averta
fonts:
- asset: assets/fonts/Averta-Black.otf
weight: 900
- asset: assets/fonts/Averta-BlackItalic.otf
weight: 900
style: italic
- asset: assets/fonts/Averta-Bold.otf
weight: 700
- asset: assets/fonts/Averta-BoldItalic.otf
weight: 700
style: italic
- asset: assets/fonts/Averta-ExtraBold.otf
weight: 800
- asset: assets/fonts/Averta-ExtraBoldItalic.otf
weight: 800
style: italic
- asset: assets/fonts/Averta-Extrathin.otf
weight: 100
- asset: assets/fonts/Averta-ExtrathinItalic.otf
weight: 100
style: italic
- asset: assets/fonts/Averta-Light.otf
weight: 300
- asset: assets/fonts/Averta-LightItalic.otf
weight: 300
style: italic
- asset: assets/fonts/Averta-Regular.otf
- asset: assets/fonts/Averta-RegularItalic.otf
style: italic
- asset: assets/fonts/Averta-Semibold.otf
weight: 600
- asset: assets/fonts/Averta-SemiboldItalic.otf
weight: 600
style: italic
- asset: assets/fonts/Averta-Thin.otf
weight: 200
- asset: assets/fonts/Averta-ThinItalic.otf
weight: 200
style: italic

0 comments on commit c8ef00e

Please sign in to comment.