2024年5月4日发(作者:)
45 private boolean strip = false;
46 private String subsetString = null;
47 private boolean woff = false;
48 private boolean eot = false;
49 private boolean mtx = false;
50
51 public static void main(String[] args) throws IOException {
52 SfntTool tool = new SfntTool();
53 File fontFile = null;
54 File outputFile = null;
55 boolean bench = false;
56 int nIters = 1;
57
58 for (int i = 0; i < ; i++) {
59 String option = null;
60 if (args[i].charAt(0) == '-') {
61 option = args[i].substring(1);
62 }
63
64 if (option != null) {
65 if (("help") || ("?")) {
66 printUsage();
67 (0);
68 } else if (("b") || ("bench")) {
69 nIters = 10000;
70 } else if (("h") || ("hints")) {
71 = true;
72 } else if (("s") || ("string")) {
73 File filename = new File(args[i + 1]);
74 InputStreamReader reader = new InputStreamReader(new FileInputStream(filename));
75 BufferedReader br = new BufferedReader(reader);
76 String line = ne();
77 String = line;
78 ();
79 // String = args[i + 1];
80 i++;
81 } else if (("w") || ("woff")) {
82 = true;
83 } else if (("e") || ("eot")) {
84 = true;
85 } else if (("x") || ("mtx")) {
86 = true;
87 } else {
88 printUsage();
89 (1);
90 }
91 } else {
92 if (fontFile == null) {
93 fontFile = new File(args[i]);
94 } else {
95 outputFile = new File(args[i]);
96 break;
97 }
98 }
99 }
100
101 if ( && ) {
102 n("WOFF and EOT options are mutually exclusive");
103 (1);
104 }
105
106 if (fontFile != null && outputFile != null) {
107 FontFile(fontFile, outputFile, nIters);
108 } else {
109 printUsage();
110 }
111 }
112
113 private static final void printUsage() {
114 n("Subset [-?|-h|-help] [-b] [-s string] fontfile outfile");
115 n("Prototype font subsetter");
116 n("t-?,-helptprint this help information");
117 n("t-s,-stringt String to subset");
118 n("t-b,-bencht Benchmark (run 10000 iterations)");
119 n("t-h,-hintst Strip hints");
120 n("t-w,-wofft Output WOFF format");
121 n("t-e,-eott Output EOT format");
122 n("t-x,-mtxt Enable Microtype Express compression for EOT format");
123 }
124
125 public void subsetFontFile(File fontFile, File outputFile, int nIters) throws IOException {
126 FontFactory fontFactory = tance();
127 FileInputStream fis = null;
128 try {
129 fis = new FileInputStream(fontFile);
130 byte[] fontBytes = new byte[(int) ()];
131 (fontBytes);
132 Font[] fontArray = null;
133 fontArray = nts(fontBytes);
134 Font font = fontArray[0];
135 List<> cmapIds = new ArrayList<>();
136 (S_BMP);
137 byte[] newFontData = null;
138 for (int i = 0; i < nIters; i++) {
139 Font newFont = font;
140 if (subsetString != null) {
141 Subsetter subsetter = new RenumberingSubsetter(newFont, fontFactory);
142 ps(cmapIds, 1);
143 List
144 phs(glyphs);
145 Set
146 // Most of the following are valid tables, but we don't renumber them yet, so strip
147 ();
148 ();
149 ();
150 ();
151 ();
152 ();
153 ();
154 ();
155 ();
156 ();
157 // AAT tables, not yet defined in sfntly Tag class
158 (ue(new byte[] { 'm', 'o', 'r', 't' }));
159 (ue(new byte[] { 'm', 'o', 'r', 'x' }));
160 oveTables(removeTables);
161 newFont = ().build();
162 }
163 if (strip) {
164 Subsetter hintStripper = new HintStripper(newFont, fontFactory);
165 Set
166 ();
167 ();
发布评论