Showing
2 changed files
with
33 additions
and
8 deletions
@@ -18,15 +18,17 @@ | @@ -18,15 +18,17 @@ | ||
18 | 18 | ||
19 | import 'dart:io'; | 19 | import 'dart:io'; |
20 | import 'dart:math' as math; | 20 | import 'dart:math' as math; |
21 | -import 'dart:typed_data'; | ||
22 | 21 | ||
23 | -import 'package:test/test.dart'; | ||
24 | import 'package:pdf/pdf.dart'; | 22 | import 'package:pdf/pdf.dart'; |
25 | import 'package:pdf/widgets.dart'; | 23 | import 'package:pdf/widgets.dart'; |
24 | +import 'package:test/test.dart'; | ||
25 | + | ||
26 | +import 'utils.dart'; | ||
26 | 27 | ||
27 | Document pdf; | 28 | Document pdf; |
28 | Font ttf; | 29 | Font ttf; |
29 | Font ttfBold; | 30 | Font ttfBold; |
31 | +Font asian; | ||
30 | 32 | ||
31 | Iterable<TextDecoration> permute( | 33 | Iterable<TextDecoration> permute( |
32 | List<TextDecoration> prefix, List<TextDecoration> remaining) sync* { | 34 | List<TextDecoration> prefix, List<TextDecoration> remaining) sync* { |
@@ -44,10 +46,10 @@ void main() { | @@ -44,10 +46,10 @@ void main() { | ||
44 | setUpAll(() { | 46 | setUpAll(() { |
45 | Document.debug = true; | 47 | Document.debug = true; |
46 | RichText.debug = true; | 48 | RichText.debug = true; |
47 | - final Uint8List fontData = File('open-sans.ttf').readAsBytesSync(); | ||
48 | - ttf = Font.ttf(fontData.buffer.asByteData()); | ||
49 | - final Uint8List fontDataBold = File('open-sans-bold.ttf').readAsBytesSync(); | ||
50 | - ttfBold = Font.ttf(fontDataBold.buffer.asByteData()); | 49 | + |
50 | + ttf = loadFont('open-sans.ttf'); | ||
51 | + ttfBold = loadFont('open-sans-bold.ttf'); | ||
52 | + asian = loadFont('genyomintw.ttf'); | ||
51 | pdf = Document(); | 53 | pdf = Document(); |
52 | }); | 54 | }); |
53 | 55 | ||
@@ -244,6 +246,29 @@ void main() { | @@ -244,6 +246,29 @@ void main() { | ||
244 | ])); | 246 | ])); |
245 | }); | 247 | }); |
246 | 248 | ||
249 | + test('Text Widgets RichText Multiple lang', () { | ||
250 | + pdf.addPage(Page( | ||
251 | + build: (Context context) => RichText( | ||
252 | + text: TextSpan( | ||
253 | + text: 'Hello ', | ||
254 | + style: TextStyle( | ||
255 | + font: ttf, | ||
256 | + fontSize: 20, | ||
257 | + ), | ||
258 | + children: <InlineSpan>[ | ||
259 | + TextSpan( | ||
260 | + text: '中文', | ||
261 | + style: TextStyle(font: asian), | ||
262 | + ), | ||
263 | + TextSpan( | ||
264 | + text: ' world!', | ||
265 | + ), | ||
266 | + ], | ||
267 | + ), | ||
268 | + ), | ||
269 | + )); | ||
270 | + }); | ||
271 | + | ||
247 | tearDownAll(() { | 272 | tearDownAll(() { |
248 | final File file = File('widgets-text.pdf'); | 273 | final File file = File('widgets-text.pdf'); |
249 | file.writeAsBytesSync(pdf.save()); | 274 | file.writeAsBytesSync(pdf.save()); |
No preview for this file type
-
Please register or login to post a comment