David PHAM-VAN

Do not modify the TTF font streams

# 1.3.13
* Do not modify the TTF font streams
# 1.3.12
* Fix TextStyle constructor
... ...
... ... @@ -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>[],
);
}
... ...
... ... @@ -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
... ...
... ... @@ -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;
}
... ...
... ... @@ -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.12
version: 1.3.13
environment:
sdk: ">=2.1.0 <3.0.0"
... ...