David PHAM-VAN

Add bold TTF test font

@@ -15,13 +15,16 @@ @@ -15,13 +15,16 @@
15 DART_SRC=$(shell find . -name '*.dart') 15 DART_SRC=$(shell find . -name '*.dart')
16 CLNG_SRC=$(shell find printing/ios -name '*.java' -o -name '*.m' -o -name '*.h') $(shell find printing/android -name '*.java' -o -name '*.m' -o -name '*.h') 16 CLNG_SRC=$(shell find printing/ios -name '*.java' -o -name '*.m' -o -name '*.h') $(shell find printing/android -name '*.java' -o -name '*.m' -o -name '*.h')
17 SWFT_SRC=$(shell find . -name '*.swift') 17 SWFT_SRC=$(shell find . -name '*.swift')
18 - FONTS=pdf/open-sans.ttf pdf/roboto.ttf pdf/noto-sans.ttf pdf/genyomintw.ttf 18 + FONTS=pdf/open-sans.ttf pdf/open-sans-bold.ttf pdf/roboto.ttf pdf/noto-sans.ttf pdf/genyomintw.ttf
19 19
20 all: $(FONTS) format 20 all: $(FONTS) format
21 21
22 pdf/open-sans.ttf: 22 pdf/open-sans.ttf:
23 curl -L "https://github.com/google/fonts/raw/master/apache/opensans/OpenSans-Regular.ttf" > $@ 23 curl -L "https://github.com/google/fonts/raw/master/apache/opensans/OpenSans-Regular.ttf" > $@
24 24
  25 +pdf/open-sans-bold.ttf:
  26 + curl -L "https://github.com/google/fonts/raw/master/apache/opensans/OpenSans-Bold.ttf" > $@
  27 +
25 pdf/roboto.ttf: 28 pdf/roboto.ttf:
26 curl -L "https://github.com/google/fonts/raw/master/apache/robotomono/RobotoMono-Regular.ttf" > $@ 29 curl -L "https://github.com/google/fonts/raw/master/apache/robotomono/RobotoMono-Regular.ttf" > $@
27 30
@@ -68,6 +68,7 @@ void main() { @@ -68,6 +68,7 @@ void main() {
68 const String s = 'Hello Lukáča '; 68 const String s = 'Hello Lukáča ';
69 69
70 printTextTtf(g, s, File('open-sans.ttf'), 30.0 + 30.0 * top++); 70 printTextTtf(g, s, File('open-sans.ttf'), 30.0 + 30.0 * top++);
  71 + printTextTtf(g, s, File('open-sans-bold.ttf'), 30.0 + 30.0 * top++);
71 printTextTtf(g, s, File('roboto.ttf'), 30.0 + 30.0 * top++); 72 printTextTtf(g, s, File('roboto.ttf'), 30.0 + 30.0 * top++);
72 printTextTtf(g, s, File('noto-sans.ttf'), 30.0 + 30.0 * top++); 73 printTextTtf(g, s, File('noto-sans.ttf'), 30.0 + 30.0 * top++);
73 printTextTtf(g, '你好 檯號 ', File('genyomintw.ttf'), 30.0 + 30.0 * top++); 74 printTextTtf(g, '你好 檯號 ', File('genyomintw.ttf'), 30.0 + 30.0 * top++);
@@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
16 16
17 import 'dart:convert'; 17 import 'dart:convert';
18 import 'dart:io'; 18 import 'dart:io';
  19 +import 'dart:typed_data';
19 20
20 import 'package:pdf/pdf.dart'; 21 import 'package:pdf/pdf.dart';
21 import 'package:pdf/widgets.dart'; 22 import 'package:pdf/widgets.dart';
@@ -25,7 +26,16 @@ void main() { @@ -25,7 +26,16 @@ void main() {
25 test('Pdf Widgets', () { 26 test('Pdf Widgets', () {
26 Document.debug = true; 27 Document.debug = true;
27 28
28 - final Document pdf = Document(title: 'Widgets Test'); 29 + final Uint8List defaultFont = File('open-sans.ttf').readAsBytesSync();
  30 + final Uint8List defaultFontBold =
  31 + File('open-sans-bold.ttf').readAsBytesSync();
  32 +
  33 + final Document pdf = Document(
  34 + title: 'Widgets Test',
  35 + theme: Theme.withFont(
  36 + Font.ttf(defaultFont.buffer.asByteData()),
  37 + Font.ttf(defaultFontBold.buffer.asByteData()),
  38 + ));
29 39
30 final TextStyle symbol = TextStyle(font: Font.zapfDingbats()); 40 final TextStyle symbol = TextStyle(font: Font.zapfDingbats());
31 41