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
2023-06-06 09:27:26 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7be03d98cd1e6b8b640e348c8dd653d85e5e0ae6
7be03d98
1 parent
1ad1ed5c
Improve TTF writer with multi-compound characters
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
22 deletions
pdf/CHANGELOG.md
pdf/lib/src/pdf/font/ttf_writer.dart
pdf/pubspec.yaml
pdf/CHANGELOG.md
View file @
7be03d9
# Changelog
## 3.10.5
-
Improve TTF writer with multi-compound characters
## 3.10.4
-
Fix Deprecation warning message
...
...
pdf/lib/src/pdf/font/ttf_writer.dart
View file @
7be03d9
...
...
@@ -67,43 +67,56 @@ class TtfWriter {
final
tablesLength
=
<
String
,
int
>{};
// Create the glyphs table
final
glyphsInfo
=
<
TtfGlyphInfo
>[];
final
glyphsMap
=
<
int
,
TtfGlyphInfo
>{};
final
charMap
=
<
int
,
int
>{};
final
overflow
=
<
int
>{};
final
compounds
=
<
int
,
int
>{};
for
(
var
index
=
0
;
index
<
chars
.
length
;
index
++)
{
if
(
chars
[
index
]
==
32
)
{
for
(
final
char
in
chars
)
{
if
(
char
==
32
)
{
final
glyph
=
TtfGlyphInfo
(
32
,
Uint8List
(
0
),
const
<
int
>[]);
glyphsInfo
.
add
(
glyph
);
glyphsMap
[
glyph
.
index
]
=
glyph
;
charMap
[
char
]
=
glyph
.
index
;
continue
;
}
final
glyphIndex
=
ttf
.
charToGlyphIndexMap
[
char
s
[
index
]
]
??
0
;
final
glyphIndex
=
ttf
.
charToGlyphIndexMap
[
char
]
??
0
;
if
(
glyphIndex
>=
ttf
.
glyphOffsets
.
length
)
{
assert
(
true
,
'
$glyphIndex
not in the font'
);
continue
;
}
final
glyph
=
ttf
.
readGlyph
(
glyphIndex
).
copy
();
for
(
final
g
in
glyph
.
compounds
)
{
compounds
[
g
]
=
-
1
;
void
addGlyph
(
glyphIndex
)
{
final
glyph
=
ttf
.
readGlyph
(
glyphIndex
).
copy
();
for
(
final
g
in
glyph
.
compounds
)
{
compounds
[
g
]
=
-
1
;
overflow
.
add
(
g
);
addGlyph
(
g
);
}
glyphsMap
[
glyph
.
index
]
=
glyph
;
}
glyphsInfo
.
add
(
glyph
);
charMap
[
char
]
=
glyphIndex
;
addGlyph
(
glyphIndex
);
}
// Add compound glyphs
for
(
final
compound
in
compounds
.
keys
)
{
final
index
=
glyphsInfo
.
firstWhere
(
(
TtfGlyphInfo
glyph
)
=>
glyph
.
index
==
compound
,
orElse:
()
{
final
glyph
=
ttf
.
readGlyph
(
compound
);
assert
(
glyph
.
compounds
.
isEmpty
,
'This is not a simple glyph'
);
glyphsInfo
.
add
(
glyph
);
final
glyphsInfo
=
<
TtfGlyphInfo
>[];
for
(
final
char
in
chars
)
{
final
glyphsIndex
=
charMap
[
char
]!;
print
(
'
$char
$glyphsIndex
$glyphsMap
$charMap
${ttf.fontName}
'
);
glyphsInfo
.
add
(
glyphsMap
[
glyphsIndex
]
??
glyphsMap
.
values
.
first
);
glyphsMap
.
remove
(
glyphsIndex
);
}
return
glyph
;
},
);
glyphsInfo
.
addAll
(
glyphsMap
.
values
);
// Add compound glyphs
for
(
final
compound
in
compounds
.
keys
)
{
final
index
=
glyphsInfo
.
firstWhere
((
TtfGlyphInfo
glyph
)
=>
glyph
.
index
==
compound
);
compounds
[
compound
]
=
glyphsInfo
.
indexOf
(
index
);
assert
(
compounds
[
compound
]!
>=
0
,
'Unable to find the glyph'
);
assert
(
(
compounds
[
compound
]
??
0
)
>=
0
,
'Unable to find the glyph'
);
}
// update compound indices
...
...
pdf/pubspec.yaml
View file @
7be03d9
...
...
@@ -6,7 +6,7 @@ issue_tracker: https://github.com/DavBfr/dart_pdf/issues
screenshots
:
-
description
:
'
Example
of
a
generated
document'
path
:
example.jpg
version
:
3.10.
4
version
:
3.10.
5
environment
:
sdk
:
"
>=2.18.0
<4.0.0"
...
...
Please
register
or
login
to post a comment