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
2019-05-25 18:13:55 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
638e5c3cf1a5219f1935eb9da68c4b1ea440197f
638e5c3c
1 parent
4c439fb9
Assertion for latin decoding error in fonts
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
7 deletions
pdf/lib/src/font.dart
pdf/lib/src/font.dart
View file @
638e5c3
...
...
@@ -137,9 +137,18 @@ abstract class PdfFont extends PdfObject {
return
PdfFontMetrics
.
zero
;
}
final
Uint8List
chars
=
latin1
.
encode
(
s
);
final
Iterable
<
PdfFontMetrics
>
metrics
=
chars
.
map
(
glyphMetrics
);
return
PdfFontMetrics
.
append
(
metrics
);
try
{
final
Uint8List
chars
=
latin1
.
encode
(
s
);
final
Iterable
<
PdfFontMetrics
>
metrics
=
chars
.
map
(
glyphMetrics
);
return
PdfFontMetrics
.
append
(
metrics
);
}
catch
(
e
)
{
assert
(
false
,
'''
\n
---------------------------------------------
Can not decode the string to Latin1.
This font does not support Unicode characters.
If you want to use strings other than Latin strings, use a TrueType (TTF) font instead.
---------------------------------------------'''
);
rethrow
;
}
}
// Use stringMetrics instead
...
...
@@ -155,9 +164,18 @@ abstract class PdfFont extends PdfObject {
String
toString
()
=>
'Font(
$fontName
)'
;
PdfStream
putText
(
String
text
)
{
return
PdfStream
()
..
putBytes
(
latin1
.
encode
(
'('
))
..
putTextBytes
(
latin1
.
encode
(
text
))
..
putBytes
(
latin1
.
encode
(
')'
));
try
{
return
PdfStream
()
..
putBytes
(
latin1
.
encode
(
'('
))
..
putTextBytes
(
latin1
.
encode
(
text
))
..
putBytes
(
latin1
.
encode
(
')'
));
}
catch
(
e
)
{
assert
(
false
,
'''
\n
---------------------------------------------
Can not decode the string to Latin1.
This font does not support Unicode characters.
If you want to use strings other than Latin strings, use a TrueType (TTF) font instead.
---------------------------------------------'''
);
rethrow
;
}
}
}
...
...
Please
register
or
login
to post a comment