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
2018-11-29 09:06:32 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e2e21a649cbecf882635571323552685d13d6a64
e2e21a64
1 parent
0d31f547
Fix ttf loading problem with Roboto Mono
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
2 deletions
Makefile
pdf/lib/src/ttffont.dart
pdf/test/ttf_test.dart
Makefile
View file @
e2e21a6
...
...
@@ -17,11 +17,14 @@
DART_SRC
=
$(
shell
find . -name
'*.dart'
)
CLNG_SRC
=
$(
shell
find . -name
'*.java'
-o -name
'*.m'
-o -name
'*.h'
)
all
:
pdf/open-sans.ttf format
all
:
pdf/open-sans.ttf
pdf/roboto.ttf
format
pdf/open-sans.ttf
:
curl -L
"https://github.com/google/fonts/raw/master/apache/opensans/OpenSans-Regular.ttf"
>
$@
pdf/roboto.ttf
:
curl -L
"https://github.com/google/fonts/raw/master/apache/robotomono/RobotoMono-Regular.ttf"
>
$@
format
:
format-dart format-clang
format-dart
:
$(DART_SRC)
...
...
pdf/lib/src/ttffont.dart
View file @
e2e21a6
...
...
@@ -58,7 +58,8 @@ class PDFTTFFont extends PDFFont {
return
super
.
glyphAdvance
(
charCode
);
}
return
(
font
.
advanceWidth
[
g
])
??
super
.
glyphAdvance
(
charCode
);
return
(
g
<
font
.
advanceWidth
.
length
?
font
.
advanceWidth
[
g
]
:
null
)
??
super
.
glyphAdvance
(
charCode
);
}
@override
...
...
pdf/test/ttf_test.dart
View file @
e2e21a6
...
...
@@ -30,6 +30,20 @@ void main() {
g
.
setColor
(
new
PDFColor
(
0.3
,
0.3
,
0.3
));
g
.
drawString
(
ttf
,
FS
,
s
,
50.0
,
30.0
);
var
roboto
=
new
PDFTTFFont
(
pdf
,
(
new
File
(
"roboto.ttf"
).
readAsBytesSync
()
as
Uint8List
)
.
buffer
.
asByteData
());
r
=
roboto
.
stringBounds
(
s
);
print
(
r
);
g
.
setColor
(
new
PDFColor
(
0.0
,
1.0
,
1.0
));
g
.
drawRect
(
50.0
+
r
.
x
*
FS
,
130.0
+
r
.
y
*
FS
,
r
.
w
*
FS
,
r
.
h
*
FS
);
g
.
fillPath
();
g
.
setColor
(
new
PDFColor
(
0.3
,
0.3
,
0.3
));
g
.
drawString
(
roboto
,
FS
,
s
,
50.0
,
130.0
);
var
file
=
new
File
(
'file2.pdf'
);
file
.
writeAsBytesSync
(
pdf
.
save
());
});
...
...
Please
register
or
login
to post a comment