You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-11
Original file line number
Diff line number
Diff line change
@@ -6,24 +6,24 @@ Add Fontsource fonts to your flutter app. Direct access to Fontsource API.
6
6
7
7
To start, create a config in either your `pubspec.yaml` file under the `fontsource` key or in the `fontsource.yaml` file.
8
8
9
-
The `fontsource` config is a map of font ids to font configs. Each font config can have a `version`, `subsets`, `weights`, and `styles` key. The default is `latest` for the `version`, and `all` for the rest of the keys. This config will tell `fontsource` what to download and bundle into your flutter app. To ensure everything is downloaded, execute `dart run fontsource` after your config is modified. Also make sure to run it whenever your repository is cloned.
10
-
11
-
`fontsource.yaml`:
12
-
13
9
```yaml
14
-
alex-brush:
15
-
subsets: [latin, latin-ext]
16
-
weights: [400]
17
-
styles: [normal]
10
+
fonts:
11
+
alex-brush: # This can be any font id
12
+
version: 4.5.3 # Defaults to latest
13
+
subsets: [latin, latin-ext] # Defaults to all
14
+
weights: [400] # Defaults to all
15
+
styles: [normal] # Defaults to all
18
16
```
19
17
18
+
The config will tell `fontsource` what to download and bundle into your flutter app. To ensure everything is downloaded, execute `dart run fontsource` after your config is modified. Also make sure to run it whenever your repository is cloned. This will generate a local package in the `.fontsource` directory.
19
+
20
20
You can then import the `fontsource` package:
21
21
22
22
```dart
23
23
import 'package:fontsource/fontsource.dart';
24
24
```
25
25
26
-
Use `FontsourceTextStyle` to use a Fontsource font:
26
+
Use [`FontsourceTextStyle`](https://pub.dev/documentation/fontsource/latest/fontsource/FontsourceTextStyle-class.html) to use a Fontsource font:
27
27
28
28
```dart
29
29
const Text(
@@ -32,6 +32,8 @@ const Text(
32
32
),
33
33
```
34
34
35
-
`FontsourceTextStyle`extends the `TextStyle` class, so any styling properties can be used to change the way the text looks.
35
+
[`FontsourceTextStyle`](https://pub.dev/documentation/fontsource/latest/fontsource/FontsourceTextStyle-class.html) extends the `TextStyle` class, so any styling properties can be used to change the way the text looks.
36
+
37
+
## Fontsource API
36
38
37
-
Alternatively, you can use the normal `TextStyle` class by specifying the `package` as `fontsource_gen`. This package is automatically added to your dependencies and generated locally when `dart run fontsource` is executed.
39
+
The Fontsource API also has a dart interface that can be accessed through [`fontsource/api.dart`](https://pub.dev/documentation/fontsource/latest/api/api-library.html).
0 commit comments