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
2021-06-19 09:20:34 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5915230949c43dfed4bfb066ad29ff3ef9b61483
59152309
1 parent
8119fbdf
Add Google Fonts fallback to Helvetica
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
13 deletions
printing/lib/src/cache.dart
printing/lib/src/fonts/font.dart
printing/lib/src/cache.dart
View file @
5915230
...
...
@@ -70,7 +70,7 @@ abstract class PdfBaseCache {
final
bytes
=
await
_download
(
uri
,
headers:
headers
);
if
(
bytes
==
null
)
{
throw
FlutterError
(
'Unable to
find the asset
$name
'
);
throw
FlutterError
(
'Unable to
download
$uri
'
);
}
if
(
cache
)
{
...
...
printing/lib/src/fonts/font.dart
View file @
5915230
...
...
@@ -19,7 +19,7 @@ class DownloadbleFont {
static
var
cache
=
PdfBaseCache
.
defaultCache
;
/// Get the font to use in a Pdf document
Future
<
Ttf
Font
>
getFont
({
Future
<
Font
>
getFont
({
PdfBaseCache
?
pdfCache
,
bool
protect
=
false
,
Map
<
String
,
String
>?
headers
,
...
...
@@ -38,16 +38,22 @@ class DownloadbleFont {
}
pdfCache
??=
PdfBaseCache
.
defaultCache
;
final
bytes
=
await
pdfCache
.
resolve
(
name:
name
,
uri:
Uri
.
parse
(
url
),
headers:
headers
,
cache:
cache
,
);
return
TtfFont
(
bytes
.
buffer
.
asByteData
(
bytes
.
offsetInBytes
,
bytes
.
lengthInBytes
),
protect:
protect
,
);
try
{
final
bytes
=
await
pdfCache
.
resolve
(
name:
name
,
uri:
Uri
.
parse
(
url
),
headers:
headers
,
cache:
cache
,
);
return
TtfFont
(
bytes
.
buffer
.
asByteData
(
bytes
.
offsetInBytes
,
bytes
.
lengthInBytes
),
protect:
protect
,
);
}
catch
(
e
)
{
print
(
'
$e
\n
Error loading
$name
, fallback to Helvetica.'
);
return
Font
.
helvetica
();
}
}
}
...
...
Please
register
or
login
to post a comment