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-03-26 07:29:25 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f9232d6e52d1dca85d419d5e7efd9c08cea5a887
f9232d6e
1 parent
95c021d3
Fix Font Subsetting
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
5 deletions
pdf/CHANGELOG.md
pdf/lib/src/ttf_writer.dart
pdf/pubspec.yaml
pdf/test/ttf_test.dart
pdf/CHANGELOG.md
View file @
f9232d6
# 1.3.6
*
Fix TTF Font SubSetting
# 1.3.5
*
Add some color functions
*
Remove color constants from PdfColor, use PdfColors
...
...
pdf/lib/src/ttf_writer.dart
View file @
f9232d6
...
...
@@ -77,13 +77,16 @@ class TtfWriter {
// Add compound glyphs
for
(
int
compound
in
compounds
.
keys
)
{
final
int
index
=
chars
.
indexOf
(
compound
);
if
(
index
>=
0
)
{
compounds
[
compound
]
=
index
;
final
TtfGlyphInfo
index
=
glyphsInfo
.
firstWhere
(
(
TtfGlyphInfo
glyph
)
=>
glyph
.
index
==
compound
,
orElse:
()
=>
null
);
if
(
index
!=
null
)
{
compounds
[
compound
]
=
glyphsInfo
.
indexOf
(
index
);
assert
(
compounds
[
compound
]
>=
0
,
'Unable to find the glyph'
);
}
else
{
compounds
[
compound
]
=
glyphsInfo
.
length
;
final
TtfGlyphInfo
glyph
=
ttf
.
readGlyph
(
compound
);
assert
(
glyph
.
compounds
.
isEmpty
);
// This is a simple glyph
assert
(
glyph
.
compounds
.
isEmpty
,
'This is not a simple glyph'
);
glyphsInfo
.
add
(
glyph
);
}
}
...
...
pdf/pubspec.yaml
View file @
f9232d6
...
...
@@ -4,7 +4,7 @@ description: A pdf producer for Dart. It can create pdf files for both web or fl
homepage
:
https://github.com/DavBfr/dart_pdf/tree/master/pdf
repository
:
https://github.com/DavBfr/dart_pdf
issue_tracker
:
https://github.com/DavBfr/dart_pdf/issues
version
:
1.3.
5
version
:
1.3.
6
environment
:
sdk
:
"
>=2.1.0
<3.0.0"
...
...
pdf/test/ttf_test.dart
View file @
f9232d6
...
...
@@ -75,4 +75,22 @@ void main() {
final
File
file
=
File
(
'ttf.pdf'
);
file
.
writeAsBytesSync
(
pdf
.
save
());
});
test
(
'Font SubSetting'
,
()
{
final
Uint8List
fontData
=
File
(
'open-sans.ttf'
).
readAsBytesSync
();
final
TtfParser
font
=
TtfParser
(
fontData
.
buffer
.
asByteData
());
final
TtfWriter
ttfWriter
=
TtfWriter
(
font
);
final
Uint8List
data
=
ttfWriter
.
withChars
(
'hçHée'
.
runes
.
toList
());
final
File
output
=
File
(
'
${font.fontName}
.ttf'
);
output
.
writeAsBytesSync
(
data
);
});
test
(
'Font SubSetting CN'
,
()
{
final
Uint8List
fontData
=
File
(
'genyomintw.ttf'
).
readAsBytesSync
();
final
TtfParser
font
=
TtfParser
(
fontData
.
buffer
.
asByteData
());
final
TtfWriter
ttfWriter
=
TtfWriter
(
font
);
final
Uint8List
data
=
ttfWriter
.
withChars
(
'hçHée 你好 檯號 ☃'
.
runes
.
toList
());
final
File
output
=
File
(
'
${font.fontName}
.ttf'
);
output
.
writeAsBytesSync
(
data
);
});
}
...
...
Please
register
or
login
to post a comment