Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
dart_pdf
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
David PHAM-VAN
2023-03-29 06:49:49 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a726f4b9e7adb55c131208269bd894bedf788ffb
a726f4b9
1 parent
52758a01
Improve gfonts updater
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
6 deletions
test/build_gfonts.dart
test/pubspec.yaml
test/build_gfonts.dart
View file @
a726f4b
...
...
@@ -17,12 +17,14 @@
import
'dart:convert'
;
import
'dart:io'
;
import
'package:args/args.dart'
;
String
_capitalize
(
String
s
)
{
if
(
s
.
isEmpty
)
return
s
;
return
'
${s[0].toUpperCase()}${s.substring(1)}
'
;
}
String
_uncapitalize
(
String
s
)
{
String
_uncapitalize
d
(
String
s
)
{
if
(
s
.
isEmpty
)
return
s
;
return
'
${s[0].toLowerCase()}${s.substring(1)}
'
;
}
...
...
@@ -43,7 +45,7 @@ class FontDesc {
final
String
name
;
String
get
dartFamily
=>
_uncapitalize
(
family
==
null
?
key
:
family
!.
replaceAll
(
' '
,
''
));
_uncapitalize
d
(
family
==
null
?
key
:
family
!.
replaceAll
(
' '
,
''
));
String
get
fontDartName
=>
dartFamily
+
(
sub
??
''
);
...
...
@@ -52,7 +54,7 @@ class FontDesc {
Iterable
<
FontDesc
>
getFonts
(
Map
m
)
sync
*
{
for
(
final
f
in
m
[
'items'
])
{
final
family
=
_uncapitalize
(
f
[
'family'
].
replaceAll
(
' '
,
''
));
final
family
=
_uncapitalize
d
(
f
[
'family'
].
replaceAll
(
' '
,
''
));
for
(
final
s
in
f
[
'files'
].
entries
)
{
var
sub
=
_capitalize
(
s
.
key
);
...
...
@@ -103,13 +105,30 @@ Iterable<FontDesc> getFonts(Map m) sync* {
}
void
main
(
List
<
String
>
args
)
async
{
final
parser
=
ArgParser
();
parser
.
addOption
(
'key'
,
abbr:
'k'
,
mandatory:
true
,
help:
'Google API key, can be generated here: https://console.cloud.google.com/apis/credentials'
,
);
final
ArgResults
results
;
try
{
results
=
parser
.
parse
(
args
);
}
catch
(
e
)
{
print
(
parser
.
usage
);
print
(
e
);
return
;
}
final
f
=
File
(
'fonts.json'
);
final
d
=
StringBuffer
();
if
(
f
.
existsSync
())
{
d
.
write
(
await
f
.
readAsString
());
}
else
{
final
key
=
args
[
0
];
final
key
=
results
[
'key'
];
final
http
=
HttpClient
();
print
(
'Downloading...'
);
final
q
=
await
http
.
getUrl
(
Uri
.
parse
(
...
...
test/pubspec.yaml
View file @
a726f4b
...
...
@@ -6,10 +6,11 @@ issue_tracker: https://github.com/DavBfr/dart_pdf/issues
version
:
1.0.0
environment
:
sdk
:
"
>=2.12.0
<3.0.0"
flutter
:
"
>=1.16.0"
sdk
:
"
>=2.18.0
<3.0.0"
flutter
:
"
>=3.7.0"
dependencies
:
args
:
flutter
:
sdk
:
flutter
markdown
:
...
...
Please
register
or
login
to post a comment