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
2022-01-30 13:40:45 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ba90a8113f50dd21637c7c91c964330d9b9f908c
ba90a811
1 parent
13725093
Update Google Fonts, fixes documentation issues
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
50 deletions
printing/CHANGELOG.md
printing/lib/src/fonts/gfonts.dart
printing/pubspec.yaml
test/build_gfonts.dart
printing/CHANGELOG.md
View file @
ba90a81
# Changelog
## 5.7.1
-
Update Google Fonts, fixes documentation issues
## 5.7.0
-
Fix imports for Dart 2.15
...
...
printing/lib/src/fonts/gfonts.dart
View file @
ba90a81
This diff could not be displayed because it is too large.
printing/pubspec.yaml
View file @
ba90a81
...
...
@@ -6,7 +6,7 @@ description: >
homepage
:
https://github.com/DavBfr/dart_pdf/tree/master/printing
repository
:
https://github.com/DavBfr/dart_pdf
issue_tracker
:
https://github.com/DavBfr/dart_pdf/issues
version
:
5.7.
0
version
:
5.7.
1
environment
:
sdk
:
"
>=2.12.0
<3.0.0"
...
...
test/build_gfonts.dart
View file @
ba90a81
...
...
@@ -27,6 +27,81 @@ String _uncapitalize(String s) {
return
'
${s[0].toLowerCase()}${s.substring(1)}
'
;
}
class
FontDesc
{
FontDesc
({
this
.
family
,
required
this
.
key
,
this
.
sub
,
required
this
.
uri
,
required
this
.
name
,
});
final
String
?
family
;
final
String
?
sub
;
final
String
key
;
final
Uri
uri
;
final
String
name
;
String
get
dartFamily
=>
_uncapitalize
(
family
==
null
?
key
:
family
!.
replaceAll
(
' '
,
''
));
String
get
fontDartName
=>
dartFamily
+
(
sub
??
''
);
String
get
fontName
=>
family
==
null
?
key
:
'
$family
$key
'
;
}
Iterable
<
FontDesc
>
getFonts
(
Map
m
)
sync
*
{
for
(
final
f
in
m
[
'items'
])
{
final
family
=
_uncapitalize
(
f
[
'family'
].
replaceAll
(
' '
,
''
));
for
(
final
s
in
f
[
'files'
].
entries
)
{
var
sub
=
_capitalize
(
s
.
key
);
sub
=
sub
.
replaceAll
(
'100'
,
'Thin '
);
sub
=
sub
.
replaceAll
(
'200'
,
'ExtraLight '
);
sub
=
sub
.
replaceAll
(
'300'
,
'Light '
);
sub
=
sub
.
replaceAll
(
'400'
,
'Regular '
);
sub
=
sub
.
replaceAll
(
'500'
,
'Medium '
);
sub
=
sub
.
replaceAll
(
'600'
,
'SemiBold '
);
sub
=
sub
.
replaceAll
(
'700'
,
'Bold '
);
sub
=
sub
.
replaceAll
(
'800'
,
'ExtraBold '
);
sub
=
sub
.
replaceAll
(
'900'
,
'Black '
);
sub
=
sub
.
split
(
' '
).
map
<
String
>((
String
e
)
=>
_capitalize
(
e
)).
join
(
''
);
final
name
=
_capitalize
(
family
)
+
'-'
+
sub
;
var
uri
=
Uri
.
parse
(
s
.
value
);
if
(
uri
.
isScheme
(
'http'
))
{
uri
=
uri
.
replace
(
scheme:
'https'
);
}
if
(!
uri
.
path
.
endsWith
(
'.ttf'
))
{
continue
;
}
yield
FontDesc
(
family:
f
[
'family'
],
key:
s
.
key
,
sub:
sub
,
uri:
uri
,
name:
name
,
);
}
}
for
(
final
entry
in
<
String
,
String
>{
'CupertinoIcons'
:
'https://github.com/flutter/packages/blob/master/third_party/packages/cupertino_icons/assets/CupertinoIcons.ttf'
,
'MaterialIcons'
:
'https://fonts.gstatic.com/s/materialicons/v98/flUhRq6tzZclQEJ-Vdg-IuiaDsNZ.ttf'
,
'NotoColorEmoji'
:
'https://github.com/googlefonts/noto-emoji/raw/main/fonts/NotoColorEmoji.ttf'
,
}.
entries
)
{
yield
FontDesc
(
key:
entry
.
key
,
uri:
Uri
.
parse
(
entry
.
value
),
name:
entry
.
key
);
}
}
void
main
(
List
<
String
>
args
)
async
{
final
f
=
File
(
'fonts.json'
);
final
d
=
StringBuffer
();
...
...
@@ -84,62 +159,23 @@ void main(List<String> args) async {
output
.
writeln
(
'import
\'
font.dart
\'
;'
);
output
.
writeln
(
''
);
output
.
writeln
(
'/// Google Fonts'
);
output
.
writeln
(
'///'
);
output
.
writeln
(
'/// Available fonts:'
);
for
(
final
f
in
getFonts
(
m
))
{
output
.
writeln
(
'/// -
${f.fontDartName}
(
${f.fontName}
)'
);
}
output
.
writeln
(
'class PdfGoogleFonts extends DownloadbleFont {'
);
output
.
writeln
(
''
);
output
.
writeln
(
'/// Create a Google Font'
);
output
.
writeln
(
'const PdfGoogleFonts._(String url, String name) : super(url, name);'
);
for
(
final
f
in
m
[
'items'
])
{
final
family
=
_uncapitalize
(
f
[
'family'
].
replaceAll
(
' '
,
''
));
for
(
final
s
in
f
[
'files'
].
entries
)
{
var
sub
=
_capitalize
(
s
.
key
);
sub
=
sub
.
replaceAll
(
'100'
,
'Thin '
);
sub
=
sub
.
replaceAll
(
'200'
,
'ExtraLight '
);
sub
=
sub
.
replaceAll
(
'300'
,
'Light '
);
sub
=
sub
.
replaceAll
(
'400'
,
'Regular '
);
sub
=
sub
.
replaceAll
(
'500'
,
'Medium '
);
sub
=
sub
.
replaceAll
(
'600'
,
'SemiBold '
);
sub
=
sub
.
replaceAll
(
'700'
,
'Bold '
);
sub
=
sub
.
replaceAll
(
'800'
,
'ExtraBold '
);
sub
=
sub
.
replaceAll
(
'900'
,
'Black '
);
sub
=
sub
.
split
(
' '
).
map
<
String
>((
String
e
)
=>
_capitalize
(
e
)).
join
(
''
);
final
name
=
_capitalize
(
family
)
+
'-'
+
sub
;
var
uri
=
Uri
.
parse
(
s
.
value
);
if
(
uri
.
isScheme
(
'http'
))
{
uri
=
uri
.
replace
(
scheme:
'https'
);
}
if
(!
uri
.
path
.
endsWith
(
'.ttf'
))
{
continue
;
}
output
.
writeln
(
''
);
output
.
writeln
(
'///
${f['family']}
${s.key}
'
);
output
.
writeln
(
'static Future<Font>
$family$sub
() {'
);
output
.
writeln
(
'const font = PdfGoogleFonts._(
\'
$uri
\'
,
\'
$name
\'
,);'
);
output
.
writeln
(
'return font.getFont();'
);
output
.
writeln
(
'}'
);
}
}
for
(
final
entry
in
<
String
,
String
>{
'CupertinoIcons'
:
'https://github.com/flutter/packages/blob/master/third_party/packages/cupertino_icons/assets/CupertinoIcons.ttf'
,
'MaterialIcons'
:
'https://fonts.gstatic.com/s/materialicons/v98/flUhRq6tzZclQEJ-Vdg-IuiaDsNZ.ttf'
,
'NotoColorEmoji'
:
'https://github.com/googlefonts/noto-emoji/raw/main/fonts/NotoColorEmoji.ttf'
,
}.
entries
)
{
for
(
final
f
in
getFonts
(
m
))
{
output
.
writeln
(
''
);
output
.
writeln
(
'///
${entry.key}
'
);
output
.
writeln
(
'static Future<Font>
${_uncapitalize(entry.key)}
() {'
);
output
.
writeln
(
'/// @nodoc'
);
output
.
writeln
(
'///
${f.fontName}
'
);
output
.
writeln
(
'static Future<Font>
${f.fontDartName}
() {'
);
output
.
writeln
(
'const font = PdfGoogleFonts._(
\'
${
entry.value}
\'
,
\'
${entry.key
}
\'
,);'
);
'const font = PdfGoogleFonts._(
\'
${
f.uri}
\'
,
\'
${f.name
}
\'
,);'
);
output
.
writeln
(
'return font.getFont();'
);
output
.
writeln
(
'}'
);
}
...
...
Please
register
or
login
to post a comment