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-06-15 12:02:42 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cb8916605844ea961fc6fffcb0d204af06d5c94c
cb891660
1 parent
a5c35a08
Do not modify the TTF font streams
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
9 deletions
pdf/CHANGELOG.md
pdf/lib/src/ttf_parser.dart
pdf/lib/src/ttf_writer.dart
pdf/lib/widgets/font.dart
pdf/pubspec.yaml
pdf/CHANGELOG.md
View file @
cb89166
# 1.3.13
*
Do not modify the TTF font streams
# 1.3.12
*
Fix TextStyle constructor
...
...
pdf/lib/src/ttf_parser.dart
View file @
cb89166
...
...
@@ -16,19 +16,28 @@
part of
pdf
;
@immutable
class
TtfGlyphInfo
{
TtfGlyphInfo
(
this
.
index
,
this
.
data
,
this
.
compounds
);
const
TtfGlyphInfo
(
this
.
index
,
this
.
data
,
this
.
compounds
);
final
int
index
;
final
Uint8List
data
;
final
List
<
int
>
compounds
;
TtfGlyphInfo
copy
()
{
return
TtfGlyphInfo
(
index
,
Uint8List
.
fromList
(
data
),
List
<
int
>.
from
(
compounds
),
);
}
@override
String
toString
()
=>
'Glyph
$index
$compounds
'
;
}
class
TtfParser
{
TtfParser
(
this
.
bytes
)
{
TtfParser
(
ByteData
bytes
)
:
bytes
=
UnmodifiableByteDataView
(
bytes
)
{
final
int
numTables
=
bytes
.
getUint16
(
4
);
for
(
int
i
=
0
;
i
<
numTables
;
i
++)
{
...
...
@@ -54,7 +63,7 @@ class TtfParser {
static
const
String
loca_table
=
'loca'
;
static
const
String
glyf_table
=
'glyf'
;
final
ByteData
bytes
;
final
UnmodifiableByteDataView
bytes
;
final
Map
<
String
,
int
>
tableOffsets
=
<
String
,
int
>{};
final
Map
<
String
,
int
>
tableSize
=
<
String
,
int
>{};
String
_fontName
;
...
...
@@ -284,7 +293,7 @@ class TtfParser {
return
TtfGlyphInfo
(
glyph
,
Uint8List
.
view
(
bytes
.
buffer
,
start
,
offset
-
start
),
<
int
>[],
const
<
int
>[],
);
}
...
...
@@ -322,7 +331,7 @@ class TtfParser {
return
TtfGlyphInfo
(
glyph
,
Uint8List
.
view
(
bytes
.
buffer
,
start
,
offset
-
start
),
<
int
>[],
const
<
int
>[],
);
}
...
...
pdf/lib/src/ttf_writer.dart
View file @
cb89166
...
...
@@ -62,13 +62,14 @@ class TtfWriter {
for
(
int
index
=
0
;
index
<
chars
.
length
;
index
++)
{
if
(
chars
[
index
]
==
32
)
{
final
TtfGlyphInfo
glyph
=
TtfGlyphInfo
(
32
,
Uint8List
(
0
),
<
int
>[]);
final
TtfGlyphInfo
glyph
=
TtfGlyphInfo
(
32
,
Uint8List
(
0
),
const
<
int
>[]);
glyphsInfo
.
add
(
glyph
);
continue
;
}
final
TtfGlyphInfo
glyph
=
ttf
.
readGlyph
(
ttf
.
charToGlyphIndexMap
[
chars
[
index
]]
??
0
);
ttf
.
readGlyph
(
ttf
.
charToGlyphIndexMap
[
chars
[
index
]]
??
0
)
.
copy
()
;
for
(
int
g
in
glyph
.
compounds
)
{
compounds
[
g
]
=
null
;
}
...
...
@@ -92,7 +93,7 @@ class TtfWriter {
}
// Add one last empty glyph
final
TtfGlyphInfo
glyph
=
TtfGlyphInfo
(
32
,
Uint8List
(
0
),
<
int
>[]);
final
TtfGlyphInfo
glyph
=
TtfGlyphInfo
(
32
,
Uint8List
(
0
),
const
<
int
>[]);
glyphsInfo
.
add
(
glyph
);
// update compound indices
...
...
pdf/lib/widgets/font.dart
View file @
cb89166
...
...
@@ -131,6 +131,9 @@ class Font {
_pdfFont
=
buildFont
(
pdfDocument
);
}
assert
(
_pdfFont
.
pdfDocument
==
context
.
document
,
'Do not reuse a Font object across multiple documents'
);
return
_pdfFont
;
}
...
...
pdf/pubspec.yaml
View file @
cb89166
...
...
@@ -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.1
2
version
:
1.3.1
3
environment
:
sdk
:
"
>=2.1.0
<3.0.0"
...
...
Please
register
or
login
to post a comment