Skip to content

Commit 971e501

Browse files
committed
feat(api): add font zip download
1 parent 0a4c2c1 commit 971e501

File tree

10 files changed

+63
-21
lines changed

10 files changed

+63
-21
lines changed

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
- uses: subosito/flutter-action@v2
1414
with:
15-
flutter-version: '2.x'
15+
flutter-version: '3.x'
1616
channel: 'stable'
1717

1818
- run: dart pub get

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.4.0
2+
3+
- Add font zip download to api.
4+
- Upgrade to dart 2.17 and flutter 3.0.
5+
16
## 0.3.1
27

38
- Fix cli version parser error.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fonts:
1616
styles: [normal] # Defaults to all
1717
```
1818
19-
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+
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.
2020

2121
You can then import the `fontsource` package:
2222

example/linux/flutter/generated_plugins.cmake

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
list(APPEND FLUTTER_PLUGIN_LIST
66
)
77

8+
list(APPEND FLUTTER_FFI_PLUGIN_LIST
9+
)
10+
811
set(PLUGIN_BUNDLED_LIBRARIES)
912

1013
foreach(plugin ${FLUTTER_PLUGIN_LIST})
@@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
1316
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
1417
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
1518
endforeach(plugin)
19+
20+
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
21+
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
22+
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
23+
endforeach(ffi_plugin)

example/pubspec.lock

+19-12
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@ packages:
4242
name: collection
4343
url: "https://pub.dartlang.org"
4444
source: hosted
45-
version: "1.15.0"
45+
version: "1.16.0"
4646
cupertino_icons:
4747
dependency: "direct main"
4848
description:
4949
name: cupertino_icons
5050
url: "https://pub.dartlang.org"
5151
source: hosted
52-
version: "1.0.4"
52+
version: "1.0.5"
5353
fake_async:
5454
dependency: transitive
5555
description:
5656
name: fake_async
5757
url: "https://pub.dartlang.org"
5858
source: hosted
59-
version: "1.2.0"
59+
version: "1.3.0"
6060
flutter:
6161
dependency: "direct main"
6262
description: flutter
@@ -68,7 +68,7 @@ packages:
6868
name: flutter_lints
6969
url: "https://pub.dartlang.org"
7070
source: hosted
71-
version: "1.0.4"
71+
version: "2.0.1"
7272
flutter_test:
7373
dependency: "direct dev"
7474
description: flutter
@@ -80,7 +80,7 @@ packages:
8080
path: ".."
8181
relative: true
8282
source: path
83-
version: "0.3.1"
83+
version: "0.4.0"
8484
fontsource_gen:
8585
dependency: "direct main"
8686
description:
@@ -115,14 +115,21 @@ packages:
115115
name: lints
116116
url: "https://pub.dartlang.org"
117117
source: hosted
118-
version: "1.0.1"
118+
version: "2.0.0"
119119
matcher:
120120
dependency: transitive
121121
description:
122122
name: matcher
123123
url: "https://pub.dartlang.org"
124124
source: hosted
125125
version: "0.12.11"
126+
material_color_utilities:
127+
dependency: transitive
128+
description:
129+
name: material_color_utilities
130+
url: "https://pub.dartlang.org"
131+
source: hosted
132+
version: "0.1.4"
126133
meta:
127134
dependency: transitive
128135
description:
@@ -136,7 +143,7 @@ packages:
136143
name: path
137144
url: "https://pub.dartlang.org"
138145
source: hosted
139-
version: "1.8.0"
146+
version: "1.8.1"
140147
progress_bar:
141148
dependency: transitive
142149
description:
@@ -155,7 +162,7 @@ packages:
155162
name: source_span
156163
url: "https://pub.dartlang.org"
157164
source: hosted
158-
version: "1.8.1"
165+
version: "1.8.2"
159166
stack_trace:
160167
dependency: transitive
161168
description:
@@ -190,7 +197,7 @@ packages:
190197
name: test_api
191198
url: "https://pub.dartlang.org"
192199
source: hosted
193-
version: "0.4.3"
200+
version: "0.4.9"
194201
typed_data:
195202
dependency: transitive
196203
description:
@@ -204,7 +211,7 @@ packages:
204211
name: vector_math
205212
url: "https://pub.dartlang.org"
206213
source: hosted
207-
version: "2.1.1"
214+
version: "2.1.2"
208215
version:
209216
dependency: transitive
210217
description:
@@ -220,5 +227,5 @@ packages:
220227
source: hosted
221228
version: "3.1.0"
222229
sdks:
223-
dart: ">=2.15.1 <3.0.0"
224-
flutter: ">=1.17.0"
230+
dart: ">=2.17.0 <3.0.0"
231+
flutter: ">=3.0.0"

example/pubspec.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ description: Fontsource example project.
33
publish_to: 'none'
44

55
environment:
6-
sdk: '>=2.15.1 <3.0.0'
6+
sdk: '>=2.17.0 <3.0.0'
77

88
dependencies:
99
flutter:
1010
sdk: flutter
11-
cupertino_icons: ^1.0.2
11+
cupertino_icons: ^1.0.5
1212
fontsource:
1313
path: ../
1414
fontsource_gen:
@@ -17,7 +17,7 @@ dependencies:
1717
dev_dependencies:
1818
flutter_test:
1919
sdk: flutter
20-
flutter_lints: ^1.0.0
20+
flutter_lints: ^2.0.1
2121

2222
flutter:
2323
uses-material-design: true

example/windows/flutter/generated_plugins.cmake

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
list(APPEND FLUTTER_PLUGIN_LIST
66
)
77

8+
list(APPEND FLUTTER_FFI_PLUGIN_LIST
9+
)
10+
811
set(PLUGIN_BUNDLED_LIBRARIES)
912

1013
foreach(plugin ${FLUTTER_PLUGIN_LIST})
@@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
1316
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
1417
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
1518
endforeach(plugin)
19+
20+
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
21+
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
22+
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
23+
endforeach(ffi_plugin)

lib/src/api/api.dart

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export 'fetch_font_file.dart';
2+
export 'fetch_font_zip.dart';
23
export 'list_font_metadata.dart';
34
export 'list_fonts.dart';

lib/src/api/fetch_font_zip.dart

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import 'dart:typed_data';
2+
3+
import 'package:http/http.dart' as http;
4+
5+
import 'constants.dart';
6+
7+
/// Fetch zip bundle of a font.
8+
Future<Uint8List> fetchFontZip(String fontId, [String? version]) async {
9+
final response = await http.get(Uri.parse(
10+
'$apiUrl/v1/fonts/$fontId/download${version == null ? '' : '?version=$version'}'));
11+
12+
return response.bodyBytes;
13+
}

pubspec.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: fontsource
22
description: Easily add Fontsource fonts to your flutter app. Includes a dart interface for the Fontsource API.
3-
version: 0.3.1
3+
version: 0.4.0
44
repository: https://github.com/fontsource/fontsource-flutter
55

66
environment:
7-
sdk: '>=2.15.1 <3.0.0'
8-
flutter: '>=1.17.0'
7+
sdk: '>=2.17.0 <3.0.0'
8+
flutter: '>=3.0.0'
99

1010
dependencies:
1111
flutter:
@@ -20,7 +20,7 @@ dependencies:
2020
dev_dependencies:
2121
flutter_test:
2222
sdk: flutter
23-
flutter_lints: ^1.0.0
23+
flutter_lints: ^2.0.1
2424

2525
executables:
2626
fontsource:

0 commit comments

Comments
 (0)