David PHAM-VAN

Always use HTTPS to download Google Fonts

1 # Changelog 1 # Changelog
2 2
  3 +## 5.4.1
  4 +
  5 +- Always use HTTPS to download Google Fonts
  6 +
3 ## 5.4.0 7 ## 5.4.0
4 8
5 - Add Google Fonts support 9 - Add Google Fonts support
  1 +/*
  2 + * Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com>
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +
1 import 'package:flutter/services.dart'; 17 import 'package:flutter/services.dart';
2 import 'package:pdf/widgets.dart'; 18 import 'package:pdf/widgets.dart';
3 19
This diff could not be displayed because it is too large.
  1 +/*
  2 + * Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com>
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +
1 import 'dart:async'; 17 import 'dart:async';
2 import 'dart:convert'; 18 import 'dart:convert';
3 19
@@ -7,7 +7,7 @@ description: > @@ -7,7 +7,7 @@ description: >
7 homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing 7 homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing
8 repository: https://github.com/DavBfr/dart_pdf 8 repository: https://github.com/DavBfr/dart_pdf
9 issue_tracker: https://github.com/DavBfr/dart_pdf/issues 9 issue_tracker: https://github.com/DavBfr/dart_pdf/issues
10 -version: 5.4.0 10 +version: 5.4.1
11 11
12 environment: 12 environment:
13 sdk: ">=2.12.0 <3.0.0" 13 sdk: ">=2.12.0 <3.0.0"
  1 +/*
  2 + * Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com>
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +
1 import 'dart:convert'; 17 import 'dart:convert';
2 import 'dart:io'; 18 import 'dart:io';
3 19
@@ -35,9 +51,34 @@ void main(List<String> args) async { @@ -35,9 +51,34 @@ void main(List<String> args) async {
35 print('Converting...'); 51 print('Converting...');
36 final Map m = json.decode(d.toString()); 52 final Map m = json.decode(d.toString());
37 53
38 - final output =  
39 - await File('../printing/lib/src/fonts/gfonts.dart').openWrite(); 54 + final file = File('../printing/lib/src/fonts/gfonts.dart');
  55 + final output = await file.openWrite();
40 56
  57 + output.writeln('/*');
  58 + output.writeln(
  59 + ' * Copyright (C) 2017, David PHAM-VAN <dev.nfet.net@gmail.com>');
  60 + output.writeln(' *');
  61 + output.writeln(
  62 + ' * Licensed under the Apache License, Version 2.0 (the "License");');
  63 + output.writeln(
  64 + ' * you may not use this file except in compliance with the License.');
  65 + output.writeln(' * You may obtain a copy of the License at');
  66 + output.writeln(' *');
  67 + output.writeln(' * http://www.apache.org/licenses/LICENSE-2.0');
  68 + output.writeln(' *');
  69 + output.writeln(
  70 + ' * Unless required by applicable law or agreed to in writing, software');
  71 + output.writeln(
  72 + ' * distributed under the License is distributed on an "AS IS" BASIS,');
  73 + output.writeln(
  74 + ' * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.');
  75 + output.writeln(
  76 + ' * See the License for the specific language governing permissions and');
  77 + output.writeln(' * limitations under the License.');
  78 + output.writeln(' */');
  79 + output.writeln('');
  80 + output.writeln('// Generated file');
  81 + output.writeln('');
41 output.writeln('import \'package:pdf/widgets.dart\';'); 82 output.writeln('import \'package:pdf/widgets.dart\';');
42 output.writeln(''); 83 output.writeln('');
43 output.writeln('import \'font.dart\';'); 84 output.writeln('import \'font.dart\';');
@@ -68,11 +109,15 @@ void main(List<String> args) async { @@ -68,11 +109,15 @@ void main(List<String> args) async {
68 109
69 final name = _capitalize(family) + '-' + sub; 110 final name = _capitalize(family) + '-' + sub;
70 111
  112 + var uri = Uri.parse(s.value);
  113 + if (uri.isScheme('http')) {
  114 + uri = uri.replace(scheme: 'https');
  115 + }
  116 +
71 output.writeln(''); 117 output.writeln('');
72 output.writeln('/// ${f['family']} ${s.key}'); 118 output.writeln('/// ${f['family']} ${s.key}');
73 output.writeln('static Future<Font> $family$sub() {'); 119 output.writeln('static Future<Font> $family$sub() {');
74 - output.writeln(  
75 - 'const font = PdfGoogleFonts._(\'${s.value}\', \'$name\',);'); 120 + output.writeln('const font = PdfGoogleFonts._(\'$uri\', \'$name\',);');
76 output.writeln('return font.getFont();'); 121 output.writeln('return font.getFont();');
77 output.writeln('}'); 122 output.writeln('}');
78 } 123 }
@@ -94,5 +139,7 @@ void main(List<String> args) async { @@ -94,5 +139,7 @@ void main(List<String> args) async {
94 output.writeln('}'); 139 output.writeln('}');
95 140
96 await output.close(); 141 await output.close();
  142 +
  143 + await Process.run('dart', ['format', '--fix', file.absolute.path]);
97 print('Done'); 144 print('Done');
98 } 145 }