-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.py
More file actions
82 lines (67 loc) · 1.89 KB
/
generator.py
File metadata and controls
82 lines (67 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import os
from fontTools import ttLib
tt = ttLib.TTFont("./lib/font/materialdesignicons-webfont.ttf")
a = tt.getBestCmap()
if os.path.exists("lib/flutter_mdi_icons.dart"):
os.remove("lib/flutter_mdi_icons.dart")
f = open("lib/flutter_mdi_icons.dart", "a")
f.write("""// ignore_for_file: constant_identifier_names
library flutter_mdi_icons;
import 'package:flutter/widgets.dart';
import './icon_data.dart';
/// Abstract class Mdi
///
/// provide IconData for Material Design Icons 7.4.47
///
/// Example:
/// ```dart
/// import 'package:flutter_mdi_icons/flutter_mdi_icons.dart'
/// ...
/// @override
/// Widget build(BuildContext context) {
/// return const Scaffold(
/// body: Center(
/// child: Icon(Mdi.accessPoint),
/// ),
/// );
/// }
/// ...
/// ```
abstract class Mdi {
Mdi._();
""")
temp = {}
for codePoint,iconName in a.items():
# newIconName = iconName.replace("-","_")
newIconName = iconName.replace("-", " ").title().replace(" ", "")
newIconName = newIconName[0].lower() + newIconName[1:]
if iconName == 'switch':
newIconName = 'switchIcon'
elif iconName == 'null':
newIconName = 'nullIcon'
if newIconName in temp:
duplicateIconName = newIconName+'1'
if duplicateIconName in temp:
temp[newIconName+'2'] = {
'iconName': newIconName+'2',
'oldName': iconName,
'codePoint': codePoint
}
else:
temp[duplicateIconName] = {
'iconName': duplicateIconName,
'oldName': iconName,
'codePoint': codePoint
}
else:
temp[newIconName] = {
'iconName': newIconName,
'oldName': iconName,
'codePoint': codePoint
}
for iconName,data in temp.items():
f.write(f" /// Icon for mdi-{data['oldName']}\n")
f.write(f" static const IconData {iconName} = MdiconData({hex(data['codePoint']).upper()});\n")
f.write("}\n")
f.close()
print(f"Success parse {len(temp)} icons.")