1 | /* | |
2 | * $Id: CFFFontSubset.java 3573 2008-07-21 15:08:04Z blowagie $ | |
3 | * | |
4 | * Copyright 2004 Oren Manor and Ygal Blum | |
5 | * | |
6 | * The contents of this file are subject to the Mozilla Public License Version 1.1 | |
7 | * (the "License"); you may not use this file except in compliance with the License. | |
8 | * You may obtain a copy of the License at http://www.mozilla.org/MPL/ | |
9 | * | |
10 | * Software distributed under the License is distributed on an "AS IS" basis, | |
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
12 | * for the specific language governing rights and limitations under the License. | |
13 | * | |
14 | * The Original Code is 'iText, a free JAVA-PDF library'. | |
15 | * | |
16 | * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by | |
17 | * the Initial Developer are Copyright (C) 1999-2005 by Bruno Lowagie. | |
18 | * All Rights Reserved. | |
19 | * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer | |
20 | * are Copyright (C) 2000-2005 by Paulo Soares. All Rights Reserved. | |
21 | * | |
22 | * Contributor(s): all the names of the contributors are added in the source code | |
23 | * where applicable. | |
24 | * | |
25 | * Alternatively, the contents of this file may be used under the terms of the | |
26 | * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the | |
27 | * provisions of LGPL are applicable instead of those above. If you wish to | |
28 | * allow use of your version of this file only under the terms of the LGPL | |
29 | * License and not to allow others to use your version of this file under | |
30 | * the MPL, indicate your decision by deleting the provisions above and | |
31 | * replace them with the notice and other provisions required by the LGPL. | |
32 | * If you do not delete the provisions above, a recipient may use your version | |
33 | * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE. | |
34 | * | |
35 | * This library is free software; you can redistribute it and/or modify it | |
36 | * under the terms of the MPL as stated above or under the terms of the GNU | |
37 | * Library General Public License as published by the Free Software Foundation; | |
38 | * either version 2 of the License, or any later version. | |
39 | * | |
40 | * This library is distributed in the hope that it will be useful, but WITHOUT | |
41 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
42 | * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more | |
43 | * details. | |
44 | * | |
45 | * If you didn't download this code from the following link, you should check if | |
46 | * you aren't using an obsolete version: | |
47 | * http://www.lowagie.com/iText/ | |
48 | */ | |
49 | package com.lowagie.text.pdf; | |
50 | ||
51 | import java.io.IOException; | |
52 | import java.util.*; | |
53 | ||
54 | /** | |
55 | * This Class subsets a CFF Type Font. The subset is preformed for CID fonts and NON CID fonts. | |
56 | * The Charstring is subsetted for both types. For CID fonts only the FDArray which are used are embedded. | |
57 | * The Lsubroutines of the FDArrays used are subsetted as well. The Subroutine subset supports both Type1 and Type2 | |
58 | * formatting although only tested on Type2 Format. | |
59 | * For Non CID the Lsubroutines are subsetted. On both types the Gsubroutines is subsetted. | |
60 | * A font which was not of CID type is transformed into CID as a part of the subset process. | |
61 | * The CID synthetic creation was written by Sivan Toledo (sivan@math.tau.ac.il) | |
62 | * @author Oren Manor (manorore@post.tau.ac.il) and Ygal Blum (blumygal@post.tau.ac.il) | |
63 | */ | |
64 | public class CFFFontSubset extends CFFFont { | |
65 | ||
66 | /** | |
67 | * The Strings in this array represent Type1/Type2 operator names | |
68 | */ | |
69 | static final String[] SubrsFunctions = { | |
70 | "RESERVED_0", "hstem", "RESERVED_2", "vstem", "vmoveto", "rlineto", "hlineto", "vlineto", | |
71 | "rrcurveto", "RESERVED_9", "callsubr", "return", "escape", "RESERVED_13", | |
72 | "endchar", "RESERVED_15", "RESERVED_16", "RESERVED_17", "hstemhm", "hintmask", | |
73 | "cntrmask", "rmoveto", "hmoveto", "vstemhm", "rcurveline", "rlinecurve", "vvcurveto", | |
74 | "hhcurveto", "shortint", "callgsubr", "vhcurveto", "hvcurveto" | |
75 | }; | |
76 | /** | |
77 | * The Strings in this array represent Type1/Type2 escape operator names | |
78 | */ | |
79 | static final String[] SubrsEscapeFuncs = { | |
80 | "RESERVED_0", "RESERVED_1", "RESERVED_2", "and", "or", "not", "RESERVED_6", | |
81 | "RESERVED_7", "RESERVED_8", "abs", "add", "sub", "div", "RESERVED_13", "neg", | |
82 | "eq", "RESERVED_16", "RESERVED_17", "drop", "RESERVED_19", "put", "get", "ifelse", | |
83 | "random", "mul", "RESERVED_25", "sqrt", "dup", "exch", "index", "roll", "RESERVED_31", | |
84 | "RESERVED_32", "RESERVED_33", "hflex", "flex", "hflex1", "flex1", "RESERVED_REST" | |
85 | }; | |
86 | | |
87 | /** | |
88 | * Operator codes for unused CharStrings and unused local and global Subrs | |
89 | */ | |
90 | static final byte ENDCHAR_OP = 14; | |
91 | static final byte RETURN_OP = 11; | |
92 | | |
93 | /** | |
94 | * A HashMap containing the glyphs used in the text after being converted | |
95 | * to glyph number by the CMap | |
96 | */ | |
97 | HashMap GlyphsUsed; | |
98 | /** | |
99 | * The GlyphsUsed keys as an ArrayList | |
100 | */ | |
101 | ArrayList glyphsInList; | |
102 | /** | |
103 | * A HashMap for keeping the FDArrays being used by the font | |
104 | */ | |
105 | HashMap FDArrayUsed = new HashMap(); | |
106 | /** | |
107 | * A HashMaps array for keeping the subroutines used in each FontDict | |
108 | */ | |
109 | HashMap[] hSubrsUsed; | |
110 | /** | |
111 | * The SubroutinesUsed HashMaps as ArrayLists | |
112 | */ | |
113 | ArrayList[] lSubrsUsed; | |
114 | /** | |
115 | * A HashMap for keeping the Global subroutines used in the font | |
116 | */ | |
117 | HashMap hGSubrsUsed = new HashMap(); | |
118 | /** | |
119 | * The Global SubroutinesUsed HashMaps as ArrayLists | |
120 | */ | |
121 | ArrayList lGSubrsUsed = new ArrayList(); | |
122 | /** | |
123 | * A HashMap for keeping the subroutines used in a non-cid font | |
124 | */ | |
125 | HashMap hSubrsUsedNonCID = new HashMap(); | |
126 | /** | |
127 | * The SubroutinesUsed HashMap as ArrayList | |
128 | */ | |
129 | ArrayList lSubrsUsedNonCID = new ArrayList(); | |
130 | /** | |
131 | * An array of the new Indexes for the local Subr. One index for each FontDict | |
132 | */ | |
133 | byte[][] NewLSubrsIndex; | |
134 | /** | |
135 | * The new subroutines index for a non-cid font | |
136 | */ | |
137 | byte[] NewSubrsIndexNonCID; | |
138 | /** | |
139 | * The new global subroutines index of the font | |
140 | */ | |
141 | byte[] NewGSubrsIndex; | |
142 | /** | |
143 | * The new CharString of the font | |
144 | */ | |
145 | byte[] NewCharStringsIndex; | |
146 | | |
147 | /** | |
148 | * The bias for the global subroutines | |
149 | */ | |
150 | int GBias = 0; | |
151 | | |
152 | /** | |
153 | * The linked list for generating the new font stream | |
154 | */ | |
155 | LinkedList OutputList; | |
156 | | |
157 | /** | |
158 | * Number of arguments to the stem operators in a subroutine calculated recursively | |
159 | */ | |
160 | int NumOfHints=0; | |
161 | ||
162 | | |
163 | /** | |
164 | * C'tor for CFFFontSubset | |
165 | * @param rf - The font file | |
166 | * @param GlyphsUsed - a HashMap that contains the glyph used in the subset | |
167 | */ | |
168 | public CFFFontSubset(RandomAccessFileOrArray rf,HashMap GlyphsUsed){ | |
169 | // Use CFFFont c'tor in order to parse the font file. | |
170 | super(rf); | |
171 | this.GlyphsUsed = GlyphsUsed; | |
172 | //Put the glyphs into a list | |
173 | glyphsInList = new ArrayList(GlyphsUsed.keySet()); | |
174 | | |
175 | | |
176 |
2
1. 2. |
for (int i=0;i<fonts.length;++i) |
177 | { | |
178 | // Read the number of glyphs in the font | |
179 |
1
1. |
seek(fonts[i].charstringsOffset); |
180 | fonts[i].nglyphs = getCard16(); | |
181 | | |
182 | // Jump to the count field of the String Index | |
183 |
1
1. |
seek(stringIndexOffset); |
184 |
1
1. |
fonts[i].nstrings = getCard16()+standardStrings.length; |
185 | | |
186 | // For each font save the offset array of the charstring | |
187 | fonts[i].charstringsOffsets = getIndex(fonts[i].charstringsOffset); | |
188 | | |
189 | // Process the FDSelect if exist | |
190 |
2
1. 2. |
if (fonts[i].fdselectOffset>=0) |
191 | { | |
192 | // Process the FDSelect | |
193 |
1
1. |
readFDSelect(i); |
194 | // Build the FDArrayUsed hashmap | |
195 |
1
1. |
BuildFDArrayUsed(i); |
196 | } | |
197 |
1
1. |
if (fonts[i].isCID) |
198 | // Build the FD Array used Hash Map | |
199 |
1
1. |
ReadFDArray(i); |
200 | // compute the charset length | |
201 | fonts[i].CharsetLength = CountCharset(fonts[i].charsetOffset,fonts[i].nglyphs); | |
202 | } | |
203 | } | |
204 | ||
205 | /** | |
206 | * Calculates the length of the charset according to its format | |
207 | * @param Offset The Charset Offset | |
208 | * @param NumofGlyphs Number of glyphs in the font | |
209 | * @return the length of the Charset | |
210 | */ | |
211 | int CountCharset(int Offset,int NumofGlyphs){ | |
212 | int format; | |
213 | int Length=0; | |
214 |
1
1. CountCharset : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(Offset); |
215 | // Read the format | |
216 | format = getCard8(); | |
217 | // Calc according to format | |
218 | switch (format){ | |
219 | case 0: | |
220 |
2
1. CountCharset : Replaced integer multiplication with division → NO_COVERAGE 2. CountCharset : Replaced integer addition with subtraction → NO_COVERAGE |
Length = 1+2*NumofGlyphs; |
221 | break; | |
222 | case 1: | |
223 |
2
1. CountCharset : Replaced integer multiplication with division → NO_COVERAGE 2. CountCharset : Replaced integer addition with subtraction → NO_COVERAGE |
Length = 1+3*CountRange(NumofGlyphs,1); |
224 | break; | |
225 | case 2: | |
226 |
2
1. CountCharset : Replaced integer multiplication with division → NO_COVERAGE 2. CountCharset : Replaced integer addition with subtraction → NO_COVERAGE |
Length = 1+4*CountRange(NumofGlyphs,2); |
227 | break; | |
228 | default: | |
229 | break; | |
230 | } | |
231 |
1
1. CountCharset : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return Length; |
232 | } | |
233 | | |
234 | /** | |
235 | * Function calculates the number of ranges in the Charset | |
236 | * @param NumofGlyphs The number of glyphs in the font | |
237 | * @param Type The format of the Charset | |
238 | * @return The number of ranges in the Charset data structure | |
239 | */ | |
240 | int CountRange(int NumofGlyphs,int Type){ | |
241 | int num=0; | |
242 | char Sid; | |
243 | int i=1,nLeft; | |
244 |
2
1. CountRange : changed conditional boundary → NO_COVERAGE 2. CountRange : negated conditional → NO_COVERAGE |
while (i<NumofGlyphs){ |
245 |
1
1. CountRange : Changed increment from 1 to -1 → NO_COVERAGE |
num++; |
246 | Sid = getCard16(); | |
247 |
1
1. CountRange : negated conditional → NO_COVERAGE |
if (Type==1) |
248 | nLeft = getCard8(); | |
249 | else | |
250 | nLeft = getCard16(); | |
251 |
2
1. CountRange : Replaced integer addition with subtraction → NO_COVERAGE 2. CountRange : Replaced integer addition with subtraction → NO_COVERAGE |
i += nLeft+1; |
252 | } | |
253 |
1
1. CountRange : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return num; |
254 | } | |
255 | ||
256 | ||
257 | /** | |
258 | * Read the FDSelect of the font and compute the array and its length | |
259 | * @param Font The index of the font being processed | |
260 | */ | |
261 | protected void readFDSelect(int Font) | |
262 | { | |
263 | // Restore the number of glyphs | |
264 | int NumOfGlyphs = fonts[Font].nglyphs; | |
265 | int[] FDSelect = new int[NumOfGlyphs]; | |
266 | // Go to the beginning of the FDSelect | |
267 |
1
1. readFDSelect : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(fonts[Font].fdselectOffset); |
268 | // Read the FDSelect's format | |
269 | fonts[Font].FDSelectFormat = getCard8(); | |
270 | | |
271 | switch(fonts[Font].FDSelectFormat){ | |
272 | // Format==0 means each glyph has an entry that indicated | |
273 | // its FD. | |
274 | case 0: | |
275 |
3
1. readFDSelect : changed conditional boundary → NO_COVERAGE 2. readFDSelect : Changed increment from 1 to -1 → NO_COVERAGE 3. readFDSelect : negated conditional → NO_COVERAGE |
for (int i=0;i<NumOfGlyphs;i++) |
276 | { | |
277 | FDSelect[i] = getCard8(); | |
278 | } | |
279 | // The FDSelect's Length is one for each glyph + the format | |
280 | // for later use | |
281 |
1
1. readFDSelect : Replaced integer addition with subtraction → NO_COVERAGE |
fonts[Font].FDSelectLength = fonts[Font].nglyphs+1; |
282 | break; | |
283 | case 3: | |
284 | // Format==3 means the ranges version | |
285 | // The number of ranges | |
286 | int nRanges = getCard16(); | |
287 | int l=0; | |
288 | // Read the first in the first range | |
289 | int first = getCard16(); | |
290 |
3
1. readFDSelect : changed conditional boundary → NO_COVERAGE 2. readFDSelect : Changed increment from 1 to -1 → NO_COVERAGE 3. readFDSelect : negated conditional → NO_COVERAGE |
for (int i=0;i<nRanges;i++) |
291 | { | |
292 | // Read the FD index | |
293 | int fd = getCard8(); | |
294 | // Read the first of the next range | |
295 | int last = getCard16(); | |
296 | // Calc the steps and write to the array | |
297 |
1
1. readFDSelect : Replaced integer subtraction with addition → NO_COVERAGE |
int steps = last-first; |
298 |
3
1. readFDSelect : changed conditional boundary → NO_COVERAGE 2. readFDSelect : Changed increment from 1 to -1 → NO_COVERAGE 3. readFDSelect : negated conditional → NO_COVERAGE |
for (int k=0;k<steps;k++) |
299 | { | |
300 | FDSelect[l] = fd; | |
301 |
1
1. readFDSelect : Changed increment from 1 to -1 → NO_COVERAGE |
l++; |
302 | } | |
303 | // The last from this iteration is the first of the next | |
304 | first = last; | |
305 | } | |
306 | // Store the length for later use | |
307 |
3
1. readFDSelect : Replaced integer multiplication with division → NO_COVERAGE 2. readFDSelect : Replaced integer addition with subtraction → NO_COVERAGE 3. readFDSelect : Replaced integer addition with subtraction → NO_COVERAGE |
fonts[Font].FDSelectLength = 1+2+nRanges*3+2; |
308 | break; | |
309 | default: | |
310 | break; | |
311 | } | |
312 | // Save the FDSelect of the font | |
313 | fonts[Font].FDSelect = FDSelect; | |
314 | } | |
315 | | |
316 | /** | |
317 | * Function reads the FDSelect and builds the FDArrayUsed HashMap According to the glyphs used | |
318 | * @param Font the Number of font being processed | |
319 | */ | |
320 | protected void BuildFDArrayUsed(int Font) | |
321 | { | |
322 | int[] FDSelect = fonts[Font].FDSelect; | |
323 | // For each glyph used | |
324 | for (Object o : glyphsInList) { | |
325 | // Pop the glyphs index | |
326 | int glyph = (Integer) o; | |
327 | // Pop the glyph's FD | |
328 | int FD = FDSelect[glyph]; | |
329 | // Put the FD index into the FDArrayUsed HashMap | |
330 | FDArrayUsed.put(FD, null); | |
331 | } | |
332 | } | |
333 | ||
334 | /** | |
335 | * Read the FDArray count, offsize and Offset array | |
336 | * @param Font | |
337 | */ | |
338 | protected void ReadFDArray(int Font) | |
339 | { | |
340 |
1
1. ReadFDArray : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(fonts[Font].fdarrayOffset); |
341 | fonts[Font].FDArrayCount = getCard16(); | |
342 | fonts[Font].FDArrayOffsize = getCard8(); | |
343 | // Since we will change values inside the FDArray objects | |
344 | // We increase its offsize to prevent errors | |
345 |
2
1. ReadFDArray : changed conditional boundary → NO_COVERAGE 2. ReadFDArray : negated conditional → NO_COVERAGE |
if (fonts[Font].FDArrayOffsize < 4) |
346 |
1
1. ReadFDArray : Replaced integer addition with subtraction → NO_COVERAGE |
fonts[Font].FDArrayOffsize++; |
347 | fonts[Font].FDArrayOffsets = getIndex(fonts[Font].fdarrayOffset); | |
348 | } | |
349 | ||
350 | | |
351 | /** | |
352 | * The Process function extracts one font out of the CFF file and returns a | |
353 | * subset version of the original. | |
354 | * @param fontName - The name of the font to be taken out of the CFF | |
355 | * @return The new font stream | |
356 | * @throws IOException | |
357 | */ | |
358 | public byte[] Process(String fontName)throws IOException{ | |
359 | try | |
360 | { | |
361 | // Verify that the file is open | |
362 |
1
1. Process : removed call to com/lowagie/text/pdf/RandomAccessFileOrArray::reOpen → NO_COVERAGE |
buf.reOpen(); |
363 | // Find the Font that we will be dealing with | |
364 | int j; | |
365 |
2
1. Process : changed conditional boundary → NO_COVERAGE 2. Process : negated conditional → NO_COVERAGE |
for (j=0; j<fonts.length; j++) |
366 |
1
1. Process : negated conditional → NO_COVERAGE |
if (fontName.equals(fonts[j].name)) break; |
367 |
2
1. Process : negated conditional → NO_COVERAGE 2. Process : mutated return of Object value for com/lowagie/text/pdf/CFFFontSubset::Process to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
if (j==fonts.length) return null; |
368 | | |
369 | // Calc the bias for the global subrs | |
370 |
2
1. Process : changed conditional boundary → NO_COVERAGE 2. Process : negated conditional → NO_COVERAGE |
if (gsubrIndexOffset >= 0) |
371 | GBias = CalcBias(gsubrIndexOffset,j); | |
372 | ||
373 | // Prepare the new CharStrings Index | |
374 |
1
1. Process : removed call to com/lowagie/text/pdf/CFFFontSubset::BuildNewCharString → NO_COVERAGE |
BuildNewCharString(j); |
375 | // Prepare the new Global and Local Subrs Indices | |
376 |
1
1. Process : removed call to com/lowagie/text/pdf/CFFFontSubset::BuildNewLGSubrs → NO_COVERAGE |
BuildNewLGSubrs(j); |
377 | // Build the new file | |
378 | byte[] Ret = BuildNewFile(j); | |
379 |
1
1. Process : mutated return of Object value for com/lowagie/text/pdf/CFFFontSubset::Process to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return Ret; |
380 | } | |
381 | finally { | |
382 | try { | |
383 |
1
1. Process : removed call to com/lowagie/text/pdf/RandomAccessFileOrArray::close → NO_COVERAGE |
buf.close(); |
384 | } | |
385 | catch (Exception e) { | |
386 | // empty on purpose | |
387 | } | |
388 | } | |
389 | } | |
390 | ||
391 | /** | |
392 | * Function calcs bias according to the CharString type and the count | |
393 | * of the subrs | |
394 | * @param Offset The offset to the relevant subrs index | |
395 | * @param Font the font | |
396 | * @return The calculated Bias | |
397 | */ | |
398 | protected int CalcBias(int Offset,int Font) | |
399 | { | |
400 |
1
1. CalcBias : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(Offset); |
401 | int nSubrs = getCard16(); | |
402 | // If type==1 -> bias=0 | |
403 |
1
1. CalcBias : negated conditional → NO_COVERAGE |
if (fonts[Font].CharstringType == 1) |
404 |
1
1. CalcBias : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 0; |
405 | // else calc according to the count | |
406 |
2
1. CalcBias : changed conditional boundary → NO_COVERAGE 2. CalcBias : negated conditional → NO_COVERAGE |
else if (nSubrs < 1240) |
407 |
1
1. CalcBias : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 107; |
408 |
2
1. CalcBias : changed conditional boundary → NO_COVERAGE 2. CalcBias : negated conditional → NO_COVERAGE |
else if (nSubrs < 33900) |
409 |
1
1. CalcBias : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 1131; |
410 | else | |
411 |
1
1. CalcBias : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 32768; |
412 | } | |
413 | ||
414 | /** | |
415 | *Function uses BuildNewIndex to create the new index of the subset charstrings | |
416 | * @param FontIndex the font | |
417 | * @throws IOException | |
418 | */ | |
419 | protected void BuildNewCharString(int FontIndex) throws IOException | |
420 | { | |
421 | NewCharStringsIndex = BuildNewIndex(fonts[FontIndex].charstringsOffsets,GlyphsUsed,ENDCHAR_OP); | |
422 | } | |
423 | | |
424 | /** | |
425 | * Function builds the new local & global subsrs indices. IF CID then All of | |
426 | * the FD Array lsubrs will be subsetted. | |
427 | * @param Font the font | |
428 | * @throws IOException | |
429 | */ | |
430 | protected void BuildNewLGSubrs(int Font)throws IOException | |
431 | { | |
432 | // If the font is CID then the lsubrs are divided into FontDicts. | |
433 | // for each FD array the lsubrs will be subsetted. | |
434 |
1
1. BuildNewLGSubrs : negated conditional → NO_COVERAGE |
if(fonts[Font].isCID) |
435 | { | |
436 | // Init the hashmap-array and the arraylist-array to hold the subrs used | |
437 | // in each private dict. | |
438 | hSubrsUsed = new HashMap[fonts[Font].fdprivateOffsets.length]; | |
439 | lSubrsUsed = new ArrayList[fonts[Font].fdprivateOffsets.length]; | |
440 | // A [][] which will store the byte array for each new FD Array lsubs index | |
441 | NewLSubrsIndex = new byte[fonts[Font].fdprivateOffsets.length][]; | |
442 | // An array to hold the offset for each Lsubr index | |
443 | fonts[Font].PrivateSubrsOffset = new int[fonts[Font].fdprivateOffsets.length]; | |
444 | // A [][] which will store the offset array for each lsubr index | |
445 | fonts[Font].PrivateSubrsOffsetsArray = new int[fonts[Font].fdprivateOffsets.length][]; | |
446 | | |
447 | // Put the FDarrayUsed into a list | |
448 | ArrayList FDInList = new ArrayList(FDArrayUsed.keySet()); | |
449 | // For each FD array which is used subset the lsubr | |
450 | for (Object o : FDInList) { | |
451 | // The FDArray index, Hash Map, Array List to work on | |
452 | int FD = (Integer) o; | |
453 | hSubrsUsed[FD] = new HashMap(); | |
454 | lSubrsUsed[FD] = new ArrayList(); | |
455 | //Reads the private dicts looking for the subr operator and | |
456 | // store both the offset for the index and its offset array | |
457 |
1
1. BuildNewLGSubrs : removed call to com/lowagie/text/pdf/CFFFontSubset::BuildFDSubrsOffsets → NO_COVERAGE |
BuildFDSubrsOffsets(Font, FD); |
458 | // Verify that FDPrivate has a LSubrs index | |
459 |
2
1. BuildNewLGSubrs : changed conditional boundary → NO_COVERAGE 2. BuildNewLGSubrs : negated conditional → NO_COVERAGE |
if (fonts[Font].PrivateSubrsOffset[FD] >= 0) { |
460 | //Scans the Charstring data storing the used Local and Global subroutines | |
461 | // by the glyphs. Scans the Subrs recursively. | |
462 |
1
1. BuildNewLGSubrs : removed call to com/lowagie/text/pdf/CFFFontSubset::BuildSubrUsed → NO_COVERAGE |
BuildSubrUsed(Font, FD, fonts[Font].PrivateSubrsOffset[FD], fonts[Font].PrivateSubrsOffsetsArray[FD], hSubrsUsed[FD], lSubrsUsed[FD]); |
463 | // Builds the New Local Subrs index | |
464 | NewLSubrsIndex[FD] = BuildNewIndex(fonts[Font].PrivateSubrsOffsetsArray[FD], hSubrsUsed[FD], RETURN_OP); | |
465 | } | |
466 | } | |
467 | } | |
468 | // If the font is not CID && the Private Subr exists then subset: | |
469 |
2
1. BuildNewLGSubrs : changed conditional boundary → NO_COVERAGE 2. BuildNewLGSubrs : negated conditional → NO_COVERAGE |
else if (fonts[Font].privateSubrs>=0) |
470 | { | |
471 | // Build the subrs offsets; | |
472 | fonts[Font].SubrsOffsets = getIndex(fonts[Font].privateSubrs); | |
473 | //Scans the Charstring data storing the used Local and Global subroutines | |
474 | // by the glyphs. Scans the Subrs recursively. | |
475 |
1
1. BuildNewLGSubrs : removed call to com/lowagie/text/pdf/CFFFontSubset::BuildSubrUsed → NO_COVERAGE |
BuildSubrUsed(Font,-1,fonts[Font].privateSubrs,fonts[Font].SubrsOffsets,hSubrsUsedNonCID,lSubrsUsedNonCID); |
476 | } | |
477 | // For all fonts subset the Global Subroutines | |
478 | // Scan the Global Subr Hashmap recursively on the Gsubrs | |
479 |
1
1. BuildNewLGSubrs : removed call to com/lowagie/text/pdf/CFFFontSubset::BuildGSubrsUsed → NO_COVERAGE |
BuildGSubrsUsed(Font); |
480 |
2
1. BuildNewLGSubrs : changed conditional boundary → NO_COVERAGE 2. BuildNewLGSubrs : negated conditional → NO_COVERAGE |
if (fonts[Font].privateSubrs>=0) |
481 | // Builds the New Local Subrs index | |
482 | NewSubrsIndexNonCID = BuildNewIndex(fonts[Font].SubrsOffsets,hSubrsUsedNonCID,RETURN_OP); | |
483 | //Builds the New Global Subrs index | |
484 | NewGSubrsIndex = BuildNewIndex(gsubrOffsets,hGSubrsUsed,RETURN_OP); | |
485 | } | |
486 | ||
487 | /** | |
488 | * The function finds for the FD array processed the local subr offset and its | |
489 | * offset array. | |
490 | * @param Font the font | |
491 | * @param FD The FDARRAY processed | |
492 | */ | |
493 | protected void BuildFDSubrsOffsets(int Font,int FD) | |
494 | { | |
495 | // Initiate to -1 to indicate lsubr operator present | |
496 | fonts[Font].PrivateSubrsOffset[FD] = -1; | |
497 | // Goto beginning of objects | |
498 |
1
1. BuildFDSubrsOffsets : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(fonts[Font].fdprivateOffsets[FD]); |
499 | // While in the same object: | |
500 |
3
1. BuildFDSubrsOffsets : changed conditional boundary → NO_COVERAGE 2. BuildFDSubrsOffsets : Replaced integer addition with subtraction → NO_COVERAGE 3. BuildFDSubrsOffsets : negated conditional → NO_COVERAGE |
while (getPosition() < fonts[Font].fdprivateOffsets[FD]+fonts[Font].fdprivateLengths[FD]) |
501 | { | |
502 |
1
1. BuildFDSubrsOffsets : removed call to com/lowagie/text/pdf/CFFFontSubset::getDictItem → NO_COVERAGE |
getDictItem(); |
503 | // If the dictItem is the "Subrs" then find and store offset, | |
504 |
1
1. BuildFDSubrsOffsets : negated conditional → NO_COVERAGE |
if (Objects.equals(key, "Subrs")) |
505 |
1
1. BuildFDSubrsOffsets : Replaced integer addition with subtraction → NO_COVERAGE |
fonts[Font].PrivateSubrsOffset[FD] = (Integer) args[0] +fonts[Font].fdprivateOffsets[FD]; |
506 | } | |
507 | //Read the lsubr index if the lsubr was found | |
508 |
2
1. BuildFDSubrsOffsets : changed conditional boundary → NO_COVERAGE 2. BuildFDSubrsOffsets : negated conditional → NO_COVERAGE |
if (fonts[Font].PrivateSubrsOffset[FD] >= 0) |
509 | fonts[Font].PrivateSubrsOffsetsArray[FD] = getIndex(fonts[Font].PrivateSubrsOffset[FD]); | |
510 | } | |
511 | ||
512 | /** | |
513 | * Function uses ReadAsubr on the glyph used to build the LSubr & Gsubr HashMap. | |
514 | * The HashMap (of the lsubr only) is then scanned recursively for Lsubr & Gsubrs | |
515 | * calls. | |
516 | * @param Font the font | |
517 | * @param FD FD array processed. 0 indicates function was called by non CID font | |
518 | * @param SubrOffset the offset to the subr index to calc the bias | |
519 | * @param SubrsOffsets the offset array of the subr index | |
520 | * @param hSubr HashMap of the subrs used | |
521 | * @param lSubr ArrayList of the subrs used | |
522 | */ | |
523 | protected void BuildSubrUsed(int Font,int FD,int SubrOffset,int[] SubrsOffsets,HashMap hSubr,ArrayList lSubr) | |
524 | { | |
525 | ||
526 | // Calc the Bias for the subr index | |
527 | int LBias = CalcBias(SubrOffset,Font); | |
528 | | |
529 | // For each glyph used find its GID, start & end pos | |
530 | for (Object o : glyphsInList) { | |
531 | int glyph = (Integer) o; | |
532 | int Start = fonts[Font].charstringsOffsets[glyph]; | |
533 |
1
1. BuildSubrUsed : Replaced integer addition with subtraction → NO_COVERAGE |
int End = fonts[Font].charstringsOffsets[glyph + 1]; |
534 | ||
535 | // IF CID: | |
536 |
2
1. BuildSubrUsed : changed conditional boundary → NO_COVERAGE 2. BuildSubrUsed : negated conditional → NO_COVERAGE |
if (FD >= 0) { |
537 |
1
1. BuildSubrUsed : removed call to com/lowagie/text/pdf/CFFFontSubset::EmptyStack → NO_COVERAGE |
EmptyStack(); |
538 | NumOfHints = 0; | |
539 | // Using FDSELECT find the FD Array the glyph belongs to. | |
540 | int GlyphFD = fonts[Font].FDSelect[glyph]; | |
541 | // If the Glyph is part of the FD being processed | |
542 |
1
1. BuildSubrUsed : negated conditional → NO_COVERAGE |
if (GlyphFD == FD) |
543 | // Find the Subrs called by the glyph and insert to hash: | |
544 |
1
1. BuildSubrUsed : removed call to com/lowagie/text/pdf/CFFFontSubset::ReadASubr → NO_COVERAGE |
ReadASubr(Start, End, GBias, LBias, hSubr, lSubr, SubrsOffsets); |
545 | } else | |
546 | // If the font is not CID | |
547 | //Find the Subrs called by the glyph and insert to hash: | |
548 |
1
1. BuildSubrUsed : removed call to com/lowagie/text/pdf/CFFFontSubset::ReadASubr → NO_COVERAGE |
ReadASubr(Start, End, GBias, LBias, hSubr, lSubr, SubrsOffsets); |
549 | } | |
550 | // For all Lsubrs used, check recursively for Lsubr & Gsubr used | |
551 |
3
1. BuildSubrUsed : changed conditional boundary → NO_COVERAGE 2. BuildSubrUsed : Changed increment from 1 to -1 → NO_COVERAGE 3. BuildSubrUsed : negated conditional → NO_COVERAGE |
for (int i=0;i<lSubr.size();i++) |
552 | { | |
553 | // Pop the subr value from the hash | |
554 | int Subr = (Integer) lSubr.get(i); | |
555 | // Ensure the Lsubr call is valid | |
556 |
5
1. BuildSubrUsed : changed conditional boundary → NO_COVERAGE 2. BuildSubrUsed : changed conditional boundary → NO_COVERAGE 3. BuildSubrUsed : Replaced integer subtraction with addition → NO_COVERAGE 4. BuildSubrUsed : negated conditional → NO_COVERAGE 5. BuildSubrUsed : negated conditional → NO_COVERAGE |
if (Subr < SubrsOffsets.length-1 && Subr>=0) |
557 | { | |
558 | // Read and process the subr | |
559 | int Start = SubrsOffsets[Subr]; | |
560 |
1
1. BuildSubrUsed : Replaced integer addition with subtraction → NO_COVERAGE |
int End = SubrsOffsets[Subr+1]; |
561 |
1
1. BuildSubrUsed : removed call to com/lowagie/text/pdf/CFFFontSubset::ReadASubr → NO_COVERAGE |
ReadASubr(Start,End,GBias,LBias,hSubr,lSubr,SubrsOffsets); |
562 | } | |
563 | } | |
564 | } | |
565 | | |
566 | /** | |
567 | * Function scans the Glsubr used ArrayList to find recursive calls | |
568 | * to Gsubrs and adds to Hashmap & ArrayList | |
569 | * @param Font the font | |
570 | */ | |
571 | protected void BuildGSubrsUsed(int Font) | |
572 | { | |
573 | int LBias = 0; | |
574 | int SizeOfNonCIDSubrsUsed = 0; | |
575 |
2
1. BuildGSubrsUsed : changed conditional boundary → NO_COVERAGE 2. BuildGSubrsUsed : negated conditional → NO_COVERAGE |
if (fonts[Font].privateSubrs>=0) |
576 | { | |
577 | LBias = CalcBias(fonts[Font].privateSubrs,Font); | |
578 | SizeOfNonCIDSubrsUsed = lSubrsUsedNonCID.size(); | |
579 | } | |
580 | | |
581 | // For each global subr used | |
582 |
3
1. BuildGSubrsUsed : changed conditional boundary → NO_COVERAGE 2. BuildGSubrsUsed : Changed increment from 1 to -1 → NO_COVERAGE 3. BuildGSubrsUsed : negated conditional → NO_COVERAGE |
for (int i=0;i<lGSubrsUsed.size();i++) |
583 | { | |
584 | //Pop the value + check valid | |
585 | int Subr = (Integer) lGSubrsUsed.get(i); | |
586 |
5
1. BuildGSubrsUsed : changed conditional boundary → NO_COVERAGE 2. BuildGSubrsUsed : changed conditional boundary → NO_COVERAGE 3. BuildGSubrsUsed : Replaced integer subtraction with addition → NO_COVERAGE 4. BuildGSubrsUsed : negated conditional → NO_COVERAGE 5. BuildGSubrsUsed : negated conditional → NO_COVERAGE |
if (Subr < gsubrOffsets.length-1 && Subr>=0) |
587 | { | |
588 | // Read the subr and process | |
589 | int Start = gsubrOffsets[Subr]; | |
590 |
1
1. BuildGSubrsUsed : Replaced integer addition with subtraction → NO_COVERAGE |
int End = gsubrOffsets[Subr+1]; |
591 | | |
592 |
1
1. BuildGSubrsUsed : negated conditional → NO_COVERAGE |
if (fonts[Font].isCID) |
593 |
1
1. BuildGSubrsUsed : removed call to com/lowagie/text/pdf/CFFFontSubset::ReadASubr → NO_COVERAGE |
ReadASubr(Start,End,GBias,0,hGSubrsUsed,lGSubrsUsed,null); |
594 | else | |
595 | { | |
596 |
1
1. BuildGSubrsUsed : removed call to com/lowagie/text/pdf/CFFFontSubset::ReadASubr → NO_COVERAGE |
ReadASubr(Start,End,GBias,LBias,hSubrsUsedNonCID,lSubrsUsedNonCID,fonts[Font].SubrsOffsets); |
597 |
2
1. BuildGSubrsUsed : changed conditional boundary → NO_COVERAGE 2. BuildGSubrsUsed : negated conditional → NO_COVERAGE |
if (SizeOfNonCIDSubrsUsed < lSubrsUsedNonCID.size()) |
598 | { | |
599 |
3
1. BuildGSubrsUsed : changed conditional boundary → NO_COVERAGE 2. BuildGSubrsUsed : Changed increment from 1 to -1 → NO_COVERAGE 3. BuildGSubrsUsed : negated conditional → NO_COVERAGE |
for (int j=SizeOfNonCIDSubrsUsed;j<lSubrsUsedNonCID.size();j++) |
600 | { | |
601 | //Pop the value + check valid | |
602 | int LSubr = (Integer) lSubrsUsedNonCID.get(j); | |
603 |
5
1. BuildGSubrsUsed : changed conditional boundary → NO_COVERAGE 2. BuildGSubrsUsed : changed conditional boundary → NO_COVERAGE 3. BuildGSubrsUsed : Replaced integer subtraction with addition → NO_COVERAGE 4. BuildGSubrsUsed : negated conditional → NO_COVERAGE 5. BuildGSubrsUsed : negated conditional → NO_COVERAGE |
if (LSubr < fonts[Font].SubrsOffsets.length-1 && LSubr>=0) |
604 | { | |
605 | // Read the subr and process | |
606 | int LStart = fonts[Font].SubrsOffsets[LSubr]; | |
607 |
1
1. BuildGSubrsUsed : Replaced integer addition with subtraction → NO_COVERAGE |
int LEnd = fonts[Font].SubrsOffsets[LSubr+1]; |
608 |
1
1. BuildGSubrsUsed : removed call to com/lowagie/text/pdf/CFFFontSubset::ReadASubr → NO_COVERAGE |
ReadASubr(LStart,LEnd,GBias,LBias,hSubrsUsedNonCID,lSubrsUsedNonCID,fonts[Font].SubrsOffsets); |
609 | } | |
610 | } | |
611 | SizeOfNonCIDSubrsUsed = lSubrsUsedNonCID.size(); | |
612 | } | |
613 | } | |
614 | } | |
615 | } | |
616 | } | |
617 | ||
618 | /** | |
619 | * The function reads a subrs (glyph info) between begin and end. | |
620 | * Adds calls to a Lsubr to the hSubr and lSubrs. | |
621 | * Adds calls to a Gsubr to the hGSubr and lGSubrs. | |
622 | * @param begin the start point of the subr | |
623 | * @param end the end point of the subr | |
624 | * @param GBias the bias of the Global Subrs | |
625 | * @param LBias the bias of the Local Subrs | |
626 | * @param hSubr the HashMap for the lSubrs | |
627 | * @param lSubr the ArrayList for the lSubrs | |
628 | */ | |
629 | protected void ReadASubr(int begin,int end,int GBias,int LBias,HashMap hSubr,ArrayList lSubr,int[] LSubrsOffsets) | |
630 | { | |
631 | // Clear the stack for the subrs | |
632 |
1
1. ReadASubr : removed call to com/lowagie/text/pdf/CFFFontSubset::EmptyStack → NO_COVERAGE |
EmptyStack(); |
633 | NumOfHints = 0; | |
634 | // Goto beginning of the subr | |
635 |
1
1. ReadASubr : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(begin); |
636 |
2
1. ReadASubr : changed conditional boundary → NO_COVERAGE 2. ReadASubr : negated conditional → NO_COVERAGE |
while (getPosition() < end) |
637 | { | |
638 | // Read the next command | |
639 |
1
1. ReadASubr : removed call to com/lowagie/text/pdf/CFFFontSubset::ReadCommand → NO_COVERAGE |
ReadCommand(); |
640 | int pos = getPosition(); | |
641 | Object TopElement=null; | |
642 |
2
1. ReadASubr : changed conditional boundary → NO_COVERAGE 2. ReadASubr : negated conditional → NO_COVERAGE |
if (arg_count > 0) |
643 |
1
1. ReadASubr : Replaced integer subtraction with addition → NO_COVERAGE |
TopElement = args[arg_count-1]; |
644 | int NumOfArgs = arg_count; | |
645 | // Check the modification needed on the Argument Stack according to key; | |
646 |
1
1. ReadASubr : removed call to com/lowagie/text/pdf/CFFFontSubset::HandelStack → NO_COVERAGE |
HandelStack(); |
647 | // a call to a Lsubr | |
648 |
1
1. ReadASubr : negated conditional → NO_COVERAGE |
if (Objects.equals(key, "callsubr")) |
649 | { | |
650 | // Verify that arguments are passed | |
651 |
2
1. ReadASubr : changed conditional boundary → NO_COVERAGE 2. ReadASubr : negated conditional → NO_COVERAGE |
if (NumOfArgs > 0) |
652 | { | |
653 | // Calc the index of the Subrs | |
654 |
1
1. ReadASubr : Replaced integer addition with subtraction → NO_COVERAGE |
int Subr = (Integer) TopElement + LBias; |
655 | // If the subr isn't in the HashMap -> Put in | |
656 |
1
1. ReadASubr : negated conditional → NO_COVERAGE |
if (!hSubr.containsKey(Subr)) |
657 | { | |
658 | hSubr.put(Subr,null); | |
659 | lSubr.add(Subr); | |
660 | } | |
661 |
1
1. ReadASubr : Replaced integer addition with subtraction → NO_COVERAGE |
CalcHints(LSubrsOffsets[Subr],LSubrsOffsets[Subr+1],LBias,GBias,LSubrsOffsets); |
662 |
1
1. ReadASubr : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(pos); |
663 | } | |
664 | } | |
665 | // a call to a Gsubr | |
666 |
1
1. ReadASubr : negated conditional → NO_COVERAGE |
else if (Objects.equals(key, "callgsubr")) |
667 | { | |
668 | // Verify that arguments are passed | |
669 |
2
1. ReadASubr : changed conditional boundary → NO_COVERAGE 2. ReadASubr : negated conditional → NO_COVERAGE |
if (NumOfArgs > 0) |
670 | { | |
671 | // Calc the index of the Subrs | |
672 |
1
1. ReadASubr : Replaced integer addition with subtraction → NO_COVERAGE |
int Subr = (Integer) TopElement + GBias; |
673 | // If the subr isn't in the HashMap -> Put in | |
674 |
1
1. ReadASubr : negated conditional → NO_COVERAGE |
if (!hGSubrsUsed.containsKey(Subr)) |
675 | { | |
676 | hGSubrsUsed.put(Subr,null); | |
677 | lGSubrsUsed.add(Subr); | |
678 | } | |
679 |
1
1. ReadASubr : Replaced integer addition with subtraction → NO_COVERAGE |
CalcHints(gsubrOffsets[Subr],gsubrOffsets[Subr+1],LBias,GBias,LSubrsOffsets); |
680 |
1
1. ReadASubr : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(pos); |
681 | } | |
682 | } | |
683 | // A call to "stem" | |
684 |
4
1. ReadASubr : negated conditional → NO_COVERAGE 2. ReadASubr : negated conditional → NO_COVERAGE 3. ReadASubr : negated conditional → NO_COVERAGE 4. ReadASubr : negated conditional → NO_COVERAGE |
else if (Objects.equals(key, "hstem") || Objects.equals(key, "vstem") || Objects.equals(key, "hstemhm") || Objects.equals(key, "vstemhm")) |
685 | // Increment the NumOfHints by the number couples of of arguments | |
686 |
2
1. ReadASubr : Replaced integer division with multiplication → NO_COVERAGE 2. ReadASubr : Replaced integer addition with subtraction → NO_COVERAGE |
NumOfHints += NumOfArgs/2; |
687 | // A call to "mask" | |
688 |
2
1. ReadASubr : negated conditional → NO_COVERAGE 2. ReadASubr : negated conditional → NO_COVERAGE |
else if (Objects.equals(key, "hintmask") || Objects.equals(key, "cntrmask")) |
689 | { | |
690 | // Compute the size of the mask | |
691 |
1
1. ReadASubr : Replaced integer division with multiplication → NO_COVERAGE |
int SizeOfMask = NumOfHints/8; |
692 |
3
1. ReadASubr : Replaced integer modulus with multiplication → NO_COVERAGE 2. ReadASubr : negated conditional → NO_COVERAGE 3. ReadASubr : negated conditional → NO_COVERAGE |
if (NumOfHints%8 != 0 || SizeOfMask == 0) |
693 |
1
1. ReadASubr : Changed increment from 1 to -1 → NO_COVERAGE |
SizeOfMask++; |
694 | // Continue the pointer in SizeOfMask steps | |
695 |
3
1. ReadASubr : changed conditional boundary → NO_COVERAGE 2. ReadASubr : Changed increment from 1 to -1 → NO_COVERAGE 3. ReadASubr : negated conditional → NO_COVERAGE |
for (int i=0;i<SizeOfMask;i++) |
696 | getCard8(); | |
697 | } | |
698 | } | |
699 | } | |
700 | ||
701 | /** | |
702 | * Function Checks how the current operator effects the run time stack after being run | |
703 | * An operator may increase or decrease the stack size | |
704 | */ | |
705 | protected void HandelStack() | |
706 | { | |
707 | // Find out what the operator does to the stack | |
708 | int StackHandel = StackOpp(); | |
709 |
2
1. HandelStack : changed conditional boundary → NO_COVERAGE 2. HandelStack : negated conditional → NO_COVERAGE |
if (StackHandel < 2) |
710 | { | |
711 | // The operators that enlarge the stack by one | |
712 |
1
1. HandelStack : negated conditional → NO_COVERAGE |
if (StackHandel==1) |
713 |
1
1. HandelStack : removed call to com/lowagie/text/pdf/CFFFontSubset::PushStack → NO_COVERAGE |
PushStack(); |
714 | // The operators that pop the stack | |
715 | else | |
716 | { | |
717 | // Abs value for the for loop | |
718 |
1
1. HandelStack : Replaced integer multiplication with division → NO_COVERAGE |
StackHandel *= -1; |
719 |
3
1. HandelStack : changed conditional boundary → NO_COVERAGE 2. HandelStack : Changed increment from 1 to -1 → NO_COVERAGE 3. HandelStack : negated conditional → NO_COVERAGE |
for (int i=0;i<StackHandel;i++) |
720 |
1
1. HandelStack : removed call to com/lowagie/text/pdf/CFFFontSubset::PopStack → NO_COVERAGE |
PopStack(); |
721 | } | |
722 | | |
723 | } | |
724 | // All other flush the stack | |
725 | else | |
726 |
1
1. HandelStack : removed call to com/lowagie/text/pdf/CFFFontSubset::EmptyStack → NO_COVERAGE |
EmptyStack(); |
727 | } | |
728 | | |
729 | /** | |
730 | * Function checks the key and return the change to the stack after the operator | |
731 | * @return The change in the stack. 2-> flush the stack | |
732 | */ | |
733 | protected int StackOpp() | |
734 | { | |
735 |
1
1. StackOpp : negated conditional → NO_COVERAGE |
if (Objects.equals(key, "ifelse")) |
736 |
1
1. StackOpp : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return -3; |
737 |
2
1. StackOpp : negated conditional → NO_COVERAGE 2. StackOpp : negated conditional → NO_COVERAGE |
if (Objects.equals(key, "roll") || Objects.equals(key, "put")) |
738 |
1
1. StackOpp : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return -2; |
739 |
4
1. StackOpp : negated conditional → NO_COVERAGE 2. StackOpp : negated conditional → NO_COVERAGE 3. StackOpp : negated conditional → NO_COVERAGE 4. StackOpp : negated conditional → NO_COVERAGE |
if (Objects.equals(key, "callsubr") || Objects.equals(key, "callgsubr") || Objects.equals(key, "add") || Objects.equals(key, "sub") || |
740 |
4
1. StackOpp : negated conditional → NO_COVERAGE 2. StackOpp : negated conditional → NO_COVERAGE 3. StackOpp : negated conditional → NO_COVERAGE 4. StackOpp : negated conditional → NO_COVERAGE |
Objects.equals(key, "div") || Objects.equals(key, "mul") || Objects.equals(key, "drop") || Objects.equals(key, "and") || |
741 |
2
1. StackOpp : negated conditional → NO_COVERAGE 2. StackOpp : negated conditional → NO_COVERAGE |
Objects.equals(key, "or") || Objects.equals(key, "eq")) |
742 |
1
1. StackOpp : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return -1; |
743 |
4
1. StackOpp : negated conditional → NO_COVERAGE 2. StackOpp : negated conditional → NO_COVERAGE 3. StackOpp : negated conditional → NO_COVERAGE 4. StackOpp : negated conditional → NO_COVERAGE |
if (Objects.equals(key, "abs") || Objects.equals(key, "neg") || Objects.equals(key, "sqrt") || Objects.equals(key, "exch") || |
744 |
4
1. StackOpp : negated conditional → NO_COVERAGE 2. StackOpp : negated conditional → NO_COVERAGE 3. StackOpp : negated conditional → NO_COVERAGE 4. StackOpp : negated conditional → NO_COVERAGE |
Objects.equals(key, "index") || Objects.equals(key, "get") || Objects.equals(key, "not") || Objects.equals(key, "return")) |
745 |
1
1. StackOpp : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 0; |
746 |
2
1. StackOpp : negated conditional → NO_COVERAGE 2. StackOpp : negated conditional → NO_COVERAGE |
if (Objects.equals(key, "random") || Objects.equals(key, "dup")) |
747 |
1
1. StackOpp : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 1; |
748 |
1
1. StackOpp : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 2; |
749 | } | |
750 | | |
751 | /** | |
752 | * Empty the Type2 Stack | |
753 | * | |
754 | */ | |
755 | protected void EmptyStack() | |
756 | { | |
757 | // Null the arguments | |
758 |
3
1. EmptyStack : changed conditional boundary → NO_COVERAGE 2. EmptyStack : Changed increment from 1 to -1 → NO_COVERAGE 3. EmptyStack : negated conditional → NO_COVERAGE |
for (int i=0; i<arg_count; i++) args[i]=null; |
759 | arg_count = 0; | |
760 | } | |
761 | | |
762 | /** | |
763 | * Pop one element from the stack | |
764 | * | |
765 | */ | |
766 | protected void PopStack() | |
767 | { | |
768 |
2
1. PopStack : changed conditional boundary → NO_COVERAGE 2. PopStack : negated conditional → NO_COVERAGE |
if (arg_count>0) |
769 | { | |
770 |
1
1. PopStack : Replaced integer subtraction with addition → NO_COVERAGE |
args[arg_count-1]=null; |
771 |
1
1. PopStack : Replaced integer subtraction with addition → NO_COVERAGE |
arg_count--; |
772 | } | |
773 | } | |
774 | | |
775 | /** | |
776 | * Add an item to the stack | |
777 | * | |
778 | */ | |
779 | protected void PushStack() | |
780 | { | |
781 |
1
1. PushStack : Replaced integer addition with subtraction → NO_COVERAGE |
arg_count++; |
782 | } | |
783 | | |
784 | /** | |
785 | * The function reads the next command after the file pointer is set | |
786 | */ | |
787 | protected void ReadCommand() | |
788 | { | |
789 | key = null; | |
790 | boolean gotKey = false; | |
791 | // Until a key is found | |
792 |
1
1. ReadCommand : negated conditional → NO_COVERAGE |
while (!gotKey) { |
793 | // Read the first Char | |
794 | char b0 = getCard8(); | |
795 | // decode according to the type1/type2 format | |
796 |
1
1. ReadCommand : negated conditional → NO_COVERAGE |
if (b0 == 28) // the two next bytes represent a short int; |
797 | { | |
798 | int first = getCard8(); | |
799 | int second = getCard8(); | |
800 |
2
1. ReadCommand : Replaced Shift Left with Shift Right → NO_COVERAGE 2. ReadCommand : Replaced bitwise OR with AND → NO_COVERAGE |
args[arg_count] = first << 8 | second; |
801 |
1
1. ReadCommand : Replaced integer addition with subtraction → NO_COVERAGE |
arg_count++; |
802 | continue; | |
803 | } | |
804 |
4
1. ReadCommand : changed conditional boundary → NO_COVERAGE 2. ReadCommand : changed conditional boundary → NO_COVERAGE 3. ReadCommand : negated conditional → NO_COVERAGE 4. ReadCommand : negated conditional → NO_COVERAGE |
if (b0 >= 32 && b0 <= 246) // The byte read is the byte; |
805 | { | |
806 |
1
1. ReadCommand : Replaced integer subtraction with addition → NO_COVERAGE |
args[arg_count] = b0 - 139; |
807 |
1
1. ReadCommand : Replaced integer addition with subtraction → NO_COVERAGE |
arg_count++; |
808 | continue; | |
809 | } | |
810 |
4
1. ReadCommand : changed conditional boundary → NO_COVERAGE 2. ReadCommand : changed conditional boundary → NO_COVERAGE 3. ReadCommand : negated conditional → NO_COVERAGE 4. ReadCommand : negated conditional → NO_COVERAGE |
if (b0 >= 247 && b0 <= 250) // The byte read and the next byte constitute a short int |
811 | { | |
812 | int w = getCard8(); | |
813 |
4
1. ReadCommand : Replaced integer subtraction with addition → NO_COVERAGE 2. ReadCommand : Replaced integer multiplication with division → NO_COVERAGE 3. ReadCommand : Replaced integer addition with subtraction → NO_COVERAGE 4. ReadCommand : Replaced integer addition with subtraction → NO_COVERAGE |
args[arg_count] = (b0 - 247) * 256 + w + 108; |
814 |
1
1. ReadCommand : Replaced integer addition with subtraction → NO_COVERAGE |
arg_count++; |
815 | continue; | |
816 | } | |
817 |
4
1. ReadCommand : changed conditional boundary → NO_COVERAGE 2. ReadCommand : changed conditional boundary → NO_COVERAGE 3. ReadCommand : negated conditional → NO_COVERAGE 4. ReadCommand : negated conditional → NO_COVERAGE |
if (b0 >= 251 && b0 <= 254)// Same as above except negative |
818 | { | |
819 | int w = getCard8(); | |
820 |
5
1. ReadCommand : removed negation → NO_COVERAGE 2. ReadCommand : Replaced integer subtraction with addition → NO_COVERAGE 3. ReadCommand : Replaced integer multiplication with division → NO_COVERAGE 4. ReadCommand : Replaced integer subtraction with addition → NO_COVERAGE 5. ReadCommand : Replaced integer subtraction with addition → NO_COVERAGE |
args[arg_count] = -(b0 - 251) * 256 - w - 108; |
821 |
1
1. ReadCommand : Replaced integer addition with subtraction → NO_COVERAGE |
arg_count++; |
822 | continue; | |
823 | } | |
824 |
1
1. ReadCommand : negated conditional → NO_COVERAGE |
if (b0 == 255)// The next for bytes represent a double. |
825 | { | |
826 | int first = getCard8(); | |
827 | int second = getCard8(); | |
828 | int third = getCard8(); | |
829 | int fourth = getCard8(); | |
830 |
6
1. ReadCommand : Replaced Shift Left with Shift Right → NO_COVERAGE 2. ReadCommand : Replaced Shift Left with Shift Right → NO_COVERAGE 3. ReadCommand : Replaced bitwise OR with AND → NO_COVERAGE 4. ReadCommand : Replaced Shift Left with Shift Right → NO_COVERAGE 5. ReadCommand : Replaced bitwise OR with AND → NO_COVERAGE 6. ReadCommand : Replaced bitwise OR with AND → NO_COVERAGE |
args[arg_count] = first << 24 | second << 16 | third << 8 | fourth; |
831 |
1
1. ReadCommand : Replaced integer addition with subtraction → NO_COVERAGE |
arg_count++; |
832 | continue; | |
833 | } | |
834 |
3
1. ReadCommand : changed conditional boundary → NO_COVERAGE 2. ReadCommand : negated conditional → NO_COVERAGE 3. ReadCommand : negated conditional → NO_COVERAGE |
if (b0<=31 && b0 != 28) // An operator was found.. Set Key. |
835 | { | |
836 | gotKey=true; | |
837 | // 12 is an escape command therefore the next byte is a part | |
838 | // of this command | |
839 |
1
1. ReadCommand : negated conditional → NO_COVERAGE |
if (b0 == 12) |
840 | { | |
841 | int b1 = getCard8(); | |
842 |
3
1. ReadCommand : changed conditional boundary → NO_COVERAGE 2. ReadCommand : Replaced integer subtraction with addition → NO_COVERAGE 3. ReadCommand : negated conditional → NO_COVERAGE |
if (b1>SubrsEscapeFuncs.length-1) |
843 |
1
1. ReadCommand : Replaced integer subtraction with addition → NO_COVERAGE |
b1 = SubrsEscapeFuncs.length-1; |
844 | key = SubrsEscapeFuncs[b1]; | |
845 | } | |
846 | else | |
847 | key = SubrsFunctions[b0]; | |
848 | continue; | |
849 | } | |
850 | } | |
851 | } | |
852 | | |
853 | /** | |
854 | * The function reads the subroutine and returns the number of the hint in it. | |
855 | * If a call to another subroutine is found the function calls recursively. | |
856 | * @param begin the start point of the subr | |
857 | * @param end the end point of the subr | |
858 | * @param LBias the bias of the Local Subrs | |
859 | * @param GBias the bias of the Global Subrs | |
860 | * @param LSubrsOffsets The Offsets array of the subroutines | |
861 | * @return The number of hints in the subroutine read. | |
862 | */ | |
863 | protected int CalcHints(int begin,int end,int LBias,int GBias,int[] LSubrsOffsets) | |
864 | { | |
865 | // Goto beginning of the subr | |
866 |
1
1. CalcHints : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(begin); |
867 |
2
1. CalcHints : changed conditional boundary → NO_COVERAGE 2. CalcHints : negated conditional → NO_COVERAGE |
while (getPosition() < end) |
868 | { | |
869 | // Read the next command | |
870 |
1
1. CalcHints : removed call to com/lowagie/text/pdf/CFFFontSubset::ReadCommand → NO_COVERAGE |
ReadCommand(); |
871 | int pos = getPosition(); | |
872 | Object TopElement = null; | |
873 |
2
1. CalcHints : changed conditional boundary → NO_COVERAGE 2. CalcHints : negated conditional → NO_COVERAGE |
if (arg_count>0) |
874 |
1
1. CalcHints : Replaced integer subtraction with addition → NO_COVERAGE |
TopElement = args[arg_count-1]; |
875 | int NumOfArgs = arg_count; | |
876 | //Check the modification needed on the Argument Stack according to key; | |
877 |
1
1. CalcHints : removed call to com/lowagie/text/pdf/CFFFontSubset::HandelStack → NO_COVERAGE |
HandelStack(); |
878 | // a call to a Lsubr | |
879 |
1
1. CalcHints : negated conditional → NO_COVERAGE |
if (Objects.equals(key, "callsubr")) |
880 | { | |
881 |
2
1. CalcHints : changed conditional boundary → NO_COVERAGE 2. CalcHints : negated conditional → NO_COVERAGE |
if (NumOfArgs>0) |
882 | { | |
883 |
1
1. CalcHints : Replaced integer addition with subtraction → NO_COVERAGE |
int Subr = (Integer) TopElement + LBias; |
884 |
1
1. CalcHints : Replaced integer addition with subtraction → NO_COVERAGE |
CalcHints(LSubrsOffsets[Subr],LSubrsOffsets[Subr+1],LBias,GBias,LSubrsOffsets); |
885 |
1
1. CalcHints : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(pos); |
886 | } | |
887 | } | |
888 | // a call to a Gsubr | |
889 |
1
1. CalcHints : negated conditional → NO_COVERAGE |
else if (Objects.equals(key, "callgsubr")) |
890 | { | |
891 |
2
1. CalcHints : changed conditional boundary → NO_COVERAGE 2. CalcHints : negated conditional → NO_COVERAGE |
if (NumOfArgs>0) |
892 | { | |
893 |
1
1. CalcHints : Replaced integer addition with subtraction → NO_COVERAGE |
int Subr = (Integer) TopElement + GBias; |
894 |
1
1. CalcHints : Replaced integer addition with subtraction → NO_COVERAGE |
CalcHints(gsubrOffsets[Subr],gsubrOffsets[Subr+1],LBias,GBias,LSubrsOffsets); |
895 |
1
1. CalcHints : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(pos); |
896 | } | |
897 | } | |
898 | // A call to "stem" | |
899 |
4
1. CalcHints : negated conditional → NO_COVERAGE 2. CalcHints : negated conditional → NO_COVERAGE 3. CalcHints : negated conditional → NO_COVERAGE 4. CalcHints : negated conditional → NO_COVERAGE |
else if (Objects.equals(key, "hstem") || Objects.equals(key, "vstem") || Objects.equals(key, "hstemhm") || Objects.equals(key, "vstemhm")) |
900 | // Increment the NumOfHints by the number couples of of arguments | |
901 |
2
1. CalcHints : Replaced integer division with multiplication → NO_COVERAGE 2. CalcHints : Replaced integer addition with subtraction → NO_COVERAGE |
NumOfHints += NumOfArgs/2; |
902 | // A call to "mask" | |
903 |
2
1. CalcHints : negated conditional → NO_COVERAGE 2. CalcHints : negated conditional → NO_COVERAGE |
else if (Objects.equals(key, "hintmask") || Objects.equals(key, "cntrmask")) |
904 | { | |
905 | // Compute the size of the mask | |
906 |
1
1. CalcHints : Replaced integer division with multiplication → NO_COVERAGE |
int SizeOfMask = NumOfHints/8; |
907 |
3
1. CalcHints : Replaced integer modulus with multiplication → NO_COVERAGE 2. CalcHints : negated conditional → NO_COVERAGE 3. CalcHints : negated conditional → NO_COVERAGE |
if (NumOfHints%8 != 0 || SizeOfMask == 0) |
908 |
1
1. CalcHints : Changed increment from 1 to -1 → NO_COVERAGE |
SizeOfMask++; |
909 | // Continue the pointer in SizeOfMask steps | |
910 |
3
1. CalcHints : changed conditional boundary → NO_COVERAGE 2. CalcHints : Changed increment from 1 to -1 → NO_COVERAGE 3. CalcHints : negated conditional → NO_COVERAGE |
for (int i=0;i<SizeOfMask;i++) |
911 | getCard8(); | |
912 | } | |
913 | } | |
914 |
1
1. CalcHints : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return NumOfHints; |
915 | } | |
916 | ||
917 | ||
918 | /** | |
919 | * Function builds the new offset array, object array and assembles the index. | |
920 | * used for creating the glyph and subrs subsetted index | |
921 | * @param Offsets the offset array of the original index | |
922 | * @param Used the hashmap of the used objects | |
923 | * @param OperatorForUnusedEntries the operator inserted into the data stream for unused entries | |
924 | * @return the new index subset version | |
925 | * @throws IOException | |
926 | */ | |
927 | protected byte[] BuildNewIndex(int[] Offsets,HashMap Used,byte OperatorForUnusedEntries) throws IOException | |
928 | { | |
929 | int unusedCount = 0; | |
930 | int Offset=0; | |
931 | int[] NewOffsets = new int[Offsets.length]; | |
932 | // Build the Offsets Array for the Subset | |
933 |
3
1. BuildNewIndex : changed conditional boundary → NO_COVERAGE 2. BuildNewIndex : Changed increment from 1 to -1 → NO_COVERAGE 3. BuildNewIndex : negated conditional → NO_COVERAGE |
for (int i=0;i<Offsets.length;++i) |
934 | { | |
935 | NewOffsets[i] = Offset; | |
936 | // If the object in the offset is also present in the used | |
937 | // HashMap then increment the offset var by its size | |
938 |
1
1. BuildNewIndex : negated conditional → NO_COVERAGE |
if (Used.containsKey(i)) { |
939 |
3
1. BuildNewIndex : Replaced integer addition with subtraction → NO_COVERAGE 2. BuildNewIndex : Replaced integer subtraction with addition → NO_COVERAGE 3. BuildNewIndex : Replaced integer addition with subtraction → NO_COVERAGE |
Offset += Offsets[i+1] - Offsets[i]; |
940 | } else { | |
941 | // Else the same offset is kept in i+1. | |
942 |
1
1. BuildNewIndex : Changed increment from 1 to -1 → NO_COVERAGE |
unusedCount++; |
943 | } | |
944 | } | |
945 | // Offset var determines the size of the object array | |
946 |
1
1. BuildNewIndex : Replaced integer addition with subtraction → NO_COVERAGE |
byte[] NewObjects = new byte[Offset+unusedCount]; |
947 | // Build the new Object array | |
948 | int unusedOffset = 0; | |
949 |
4
1. BuildNewIndex : changed conditional boundary → NO_COVERAGE 2. BuildNewIndex : Changed increment from 1 to -1 → NO_COVERAGE 3. BuildNewIndex : Replaced integer subtraction with addition → NO_COVERAGE 4. BuildNewIndex : negated conditional → NO_COVERAGE |
for (int i=0;i<Offsets.length-1;++i) |
950 | { | |
951 | int start = NewOffsets[i]; | |
952 |
1
1. BuildNewIndex : Replaced integer addition with subtraction → NO_COVERAGE |
int end = NewOffsets[i+1]; |
953 |
1
1. BuildNewIndex : Replaced integer addition with subtraction → NO_COVERAGE |
NewOffsets[i] = start+unusedOffset; |
954 | // If start != End then the Object is used | |
955 | // So, we will copy the object data from the font file | |
956 |
1
1. BuildNewIndex : negated conditional → NO_COVERAGE |
if (start != end) |
957 | { | |
958 | // All offsets are Global Offsets relative to the beginning of the font file. | |
959 | // Jump the file pointer to the start address to read from. | |
960 |
1
1. BuildNewIndex : removed call to com/lowagie/text/pdf/RandomAccessFileOrArray::seek → NO_COVERAGE |
buf.seek(Offsets[i]); |
961 | // Read from the buffer and write into the array at start. | |
962 |
3
1. BuildNewIndex : Replaced integer addition with subtraction → NO_COVERAGE 2. BuildNewIndex : Replaced integer subtraction with addition → NO_COVERAGE 3. BuildNewIndex : removed call to com/lowagie/text/pdf/RandomAccessFileOrArray::readFully → NO_COVERAGE |
buf.readFully(NewObjects, start+unusedOffset, end-start); |
963 | } else { | |
964 |
1
1. BuildNewIndex : Replaced integer addition with subtraction → NO_COVERAGE |
NewObjects[start+unusedOffset] = OperatorForUnusedEntries; |
965 |
1
1. BuildNewIndex : Changed increment from 1 to -1 → NO_COVERAGE |
unusedOffset++; |
966 | } | |
967 | } | |
968 |
2
1. BuildNewIndex : Replaced integer subtraction with addition → NO_COVERAGE 2. BuildNewIndex : Replaced integer addition with subtraction → NO_COVERAGE |
NewOffsets[Offsets.length-1] += unusedOffset; |
969 | // Use AssembleIndex to build the index from the offset & object arrays | |
970 |
1
1. BuildNewIndex : mutated return of Object value for com/lowagie/text/pdf/CFFFontSubset::BuildNewIndex to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return AssembleIndex(NewOffsets,NewObjects); |
971 | } | |
972 | ||
973 | /** | |
974 | * Function creates the new index, inserting the count,offsetsize,offset array | |
975 | * and object array. | |
976 | * @param NewOffsets the subsetted offset array | |
977 | * @param NewObjects the subsetted object array | |
978 | * @return the new index created | |
979 | */ | |
980 | protected byte[] AssembleIndex(int[] NewOffsets,byte[] NewObjects) | |
981 | { | |
982 | // Calc the index' count field | |
983 |
1
1. AssembleIndex : Replaced integer subtraction with addition → NO_COVERAGE |
char Count = (char)(NewOffsets.length-1); |
984 | // Calc the size of the object array | |
985 |
1
1. AssembleIndex : Replaced integer subtraction with addition → NO_COVERAGE |
int Size = NewOffsets[NewOffsets.length-1]; |
986 | // Calc the Offsize | |
987 | byte Offsize; | |
988 |
2
1. AssembleIndex : changed conditional boundary → NO_COVERAGE 2. AssembleIndex : negated conditional → NO_COVERAGE |
if (Size <= 0xff) Offsize = 1; |
989 |
2
1. AssembleIndex : changed conditional boundary → NO_COVERAGE 2. AssembleIndex : negated conditional → NO_COVERAGE |
else if (Size <= 0xffff) Offsize = 2; |
990 |
2
1. AssembleIndex : changed conditional boundary → NO_COVERAGE 2. AssembleIndex : negated conditional → NO_COVERAGE |
else if (Size <= 0xffffff) Offsize = 3; |
991 | else Offsize = 4; | |
992 | // The byte array for the new index. The size is calc by | |
993 | // Count=2, Offsize=1, OffsetArray = Offsize*(Count+1), The object array | |
994 |
4
1. AssembleIndex : Replaced integer addition with subtraction → NO_COVERAGE 2. AssembleIndex : Replaced integer multiplication with division → NO_COVERAGE 3. AssembleIndex : Replaced integer addition with subtraction → NO_COVERAGE 4. AssembleIndex : Replaced integer addition with subtraction → NO_COVERAGE |
byte[] NewIndex = new byte[2+1+Offsize*(Count+1)+NewObjects.length]; |
995 | // The counter for writing | |
996 | int Place = 0; | |
997 | // Write the count field | |
998 |
3
1. AssembleIndex : Changed increment from 1 to -1 → NO_COVERAGE 2. AssembleIndex : Replaced Unsigned Shift Right with Shift Left → NO_COVERAGE 3. AssembleIndex : Replaced bitwise AND with OR → NO_COVERAGE |
NewIndex[Place++] = (byte) ((Count >>> 8) & 0xff); |
999 |
3
1. AssembleIndex : Changed increment from 1 to -1 → NO_COVERAGE 2. AssembleIndex : Replaced Unsigned Shift Right with Shift Left → NO_COVERAGE 3. AssembleIndex : Replaced bitwise AND with OR → NO_COVERAGE |
NewIndex[Place++] = (byte) ((Count >>> 0) & 0xff); |
1000 | // Write the offsize field | |
1001 |
1
1. AssembleIndex : Changed increment from 1 to -1 → NO_COVERAGE |
NewIndex[Place++] = Offsize; |
1002 | // Write the offset array according to the offsize | |
1003 | for (int newOffset : NewOffsets) { | |
1004 | // The value to be written | |
1005 |
2
1. AssembleIndex : Replaced integer subtraction with addition → NO_COVERAGE 2. AssembleIndex : Replaced integer addition with subtraction → NO_COVERAGE |
int Num = newOffset - NewOffsets[0] + 1; |
1006 | // Write in bytes according to the offsize | |
1007 | switch (Offsize) { | |
1008 | case 4: | |
1009 |
3
1. AssembleIndex : Changed increment from 1 to -1 → NO_COVERAGE 2. AssembleIndex : Replaced Unsigned Shift Right with Shift Left → NO_COVERAGE 3. AssembleIndex : Replaced bitwise AND with OR → NO_COVERAGE |
NewIndex[Place++] = (byte) ((Num >>> 24) & 0xff); |
1010 | case 3: | |
1011 |
3
1. AssembleIndex : Changed increment from 1 to -1 → NO_COVERAGE 2. AssembleIndex : Replaced Unsigned Shift Right with Shift Left → NO_COVERAGE 3. AssembleIndex : Replaced bitwise AND with OR → NO_COVERAGE |
NewIndex[Place++] = (byte) ((Num >>> 16) & 0xff); |
1012 | case 2: | |
1013 |
3
1. AssembleIndex : Changed increment from 1 to -1 → NO_COVERAGE 2. AssembleIndex : Replaced Unsigned Shift Right with Shift Left → NO_COVERAGE 3. AssembleIndex : Replaced bitwise AND with OR → NO_COVERAGE |
NewIndex[Place++] = (byte) ((Num >>> 8) & 0xff); |
1014 | case 1: | |
1015 |
3
1. AssembleIndex : Changed increment from 1 to -1 → NO_COVERAGE 2. AssembleIndex : Replaced Unsigned Shift Right with Shift Left → NO_COVERAGE 3. AssembleIndex : Replaced bitwise AND with OR → NO_COVERAGE |
NewIndex[Place++] = (byte) ((Num >>> 0) & 0xff); |
1016 | } | |
1017 | } | |
1018 | // Write the new object array one by one | |
1019 | for (byte newObject : NewObjects) { | |
1020 |
1
1. AssembleIndex : Changed increment from 1 to -1 → NO_COVERAGE |
NewIndex[Place++] = newObject; |
1021 | } | |
1022 | // Return the new index | |
1023 |
1
1. AssembleIndex : mutated return of Object value for com/lowagie/text/pdf/CFFFontSubset::AssembleIndex to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return NewIndex; |
1024 | } | |
1025 | | |
1026 | /** | |
1027 | * The function builds the new output stream according to the subset process | |
1028 | * @param Font the font | |
1029 | * @return the subsetted font stream | |
1030 | */ | |
1031 | protected byte[] BuildNewFile(int Font) | |
1032 | { | |
1033 | // Prepare linked list for new font components | |
1034 | OutputList = new LinkedList(); | |
1035 | ||
1036 | // copy the header of the font | |
1037 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFontSubset::CopyHeader → NO_COVERAGE |
CopyHeader(); |
1038 | | |
1039 | // create a name index | |
1040 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFontSubset::BuildIndexHeader → NO_COVERAGE |
BuildIndexHeader(1,1,1); |
1041 |
2
1. BuildNewFile : Replaced integer addition with subtraction → NO_COVERAGE 2. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)( 1+fonts[Font].name.length() ))); |
1042 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new StringItem(fonts[Font].name)); |
1043 | | |
1044 | // create the topdict Index | |
1045 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFontSubset::BuildIndexHeader → NO_COVERAGE |
BuildIndexHeader(1,2,1); |
1046 | OffsetItem topdictIndex1Ref = new IndexOffsetItem(2); | |
1047 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(topdictIndex1Ref); |
1048 | IndexBaseItem topdictBase = new IndexBaseItem(); | |
1049 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(topdictBase); |
1050 | | |
1051 | // Initialize the Dict Items for later use | |
1052 | OffsetItem charsetRef = new DictOffsetItem(); | |
1053 | OffsetItem charstringsRef = new DictOffsetItem(); | |
1054 | OffsetItem fdarrayRef = new DictOffsetItem(); | |
1055 | OffsetItem fdselectRef = new DictOffsetItem(); | |
1056 | OffsetItem privateRef = new DictOffsetItem(); | |
1057 | | |
1058 | // If the font is not CID create the following keys | |
1059 |
1
1. BuildNewFile : negated conditional → NO_COVERAGE |
if ( !fonts[Font].isCID ) { |
1060 | // create a ROS key | |
1061 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new DictNumberItem(fonts[Font].nstrings)); |
1062 |
2
1. BuildNewFile : Replaced integer addition with subtraction → NO_COVERAGE 2. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new DictNumberItem(fonts[Font].nstrings+1)); |
1063 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new DictNumberItem(0)); |
1064 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)12)); |
1065 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)30)); |
1066 | // create a CIDCount key | |
1067 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new DictNumberItem(fonts[Font].nglyphs)); |
1068 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)12)); |
1069 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)34)); |
1070 | // Sivan's comments | |
1071 | // What about UIDBase (12,35)? Don't know what is it. | |
1072 | // I don't think we need FontName; the font I looked at didn't have it. | |
1073 | } | |
1074 | // Go to the TopDict of the font being processed | |
1075 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(topdictOffsets[Font]); |
1076 | // Run until the end of the TopDict | |
1077 |
3
1. BuildNewFile : changed conditional boundary → NO_COVERAGE 2. BuildNewFile : Replaced integer addition with subtraction → NO_COVERAGE 3. BuildNewFile : negated conditional → NO_COVERAGE |
while (getPosition() < topdictOffsets[Font+1]) { |
1078 | int p1 = getPosition(); | |
1079 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFontSubset::getDictItem → NO_COVERAGE |
getDictItem(); |
1080 | int p2 = getPosition(); | |
1081 | // The encoding key is disregarded since CID has no encoding | |
1082 |
1
1. BuildNewFile : negated conditional → NO_COVERAGE |
if (Objects.equals(key, "Encoding") |
1083 | // These keys will be added manually by the process. | |
1084 |
1
1. BuildNewFile : negated conditional → NO_COVERAGE |
|| Objects.equals(key, "Private") |
1085 |
1
1. BuildNewFile : negated conditional → NO_COVERAGE |
|| Objects.equals(key, "FDSelect") |
1086 |
1
1. BuildNewFile : negated conditional → NO_COVERAGE |
|| Objects.equals(key, "FDArray") |
1087 |
1
1. BuildNewFile : negated conditional → NO_COVERAGE |
|| Objects.equals(key, "charset") |
1088 |
1
1. BuildNewFile : negated conditional → NO_COVERAGE |
|| Objects.equals(key, "CharStrings") |
1089 | ) { | |
1090 | }else { | |
1091 | //OtherWise copy key "as is" to the output list | |
1092 |
1
1. BuildNewFile : Replaced integer subtraction with addition → NO_COVERAGE |
OutputList.add(new RangeItem(buf,p1,p2-p1)); |
1093 | } | |
1094 | } | |
1095 | // Create the FDArray, FDSelect, Charset and CharStrings Keys | |
1096 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFontSubset::CreateKeys → NO_COVERAGE |
CreateKeys(fdarrayRef,fdselectRef,charsetRef,charstringsRef); |
1097 | | |
1098 | // Mark the end of the top dict area | |
1099 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new IndexMarkerItem(topdictIndex1Ref,topdictBase)); |
1100 | | |
1101 | // Copy the string index | |
1102 | ||
1103 |
1
1. BuildNewFile : negated conditional → NO_COVERAGE |
if (fonts[Font].isCID) |
1104 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(getEntireIndexRange(stringIndexOffset)); |
1105 | // If the font is not CID we need to append new strings. | |
1106 | // We need 3 more strings: Registry, Ordering, and a FontName for one FD. | |
1107 | // The total length is at most "Adobe"+"Identity"+63 = 76 | |
1108 | else | |
1109 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFontSubset::CreateNewStringIndex → NO_COVERAGE |
CreateNewStringIndex(Font); |
1110 | | |
1111 | // copy the new subsetted global subroutine index | |
1112 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new RangeItem(new RandomAccessFileOrArray(NewGSubrsIndex),0,NewGSubrsIndex.length)); |
1113 | | |
1114 | // deal with fdarray, fdselect, and the font descriptors | |
1115 | // If the font is CID: | |
1116 |
1
1. BuildNewFile : negated conditional → NO_COVERAGE |
if (fonts[Font].isCID) { |
1117 | // copy the FDArray, FDSelect, charset | |
1118 | | |
1119 | // Copy FDSelect | |
1120 | // Mark the beginning | |
1121 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new MarkerItem(fdselectRef)); |
1122 | // If an FDSelect exists copy it | |
1123 |
2
1. BuildNewFile : changed conditional boundary → NO_COVERAGE 2. BuildNewFile : negated conditional → NO_COVERAGE |
if (fonts[Font].fdselectOffset>=0) |
1124 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new RangeItem(buf,fonts[Font].fdselectOffset,fonts[Font].FDSelectLength)); |
1125 | // Else create a new one | |
1126 | else | |
1127 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFontSubset::CreateFDSelect → NO_COVERAGE |
CreateFDSelect(fdselectRef,fonts[Font].nglyphs); |
1128 | | |
1129 | // Copy the Charset | |
1130 | // Mark the beginning and copy entirely | |
1131 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new MarkerItem(charsetRef)); |
1132 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new RangeItem(buf,fonts[Font].charsetOffset,fonts[Font].CharsetLength)); |
1133 | | |
1134 | // Copy the FDArray | |
1135 | // If an FDArray exists | |
1136 |
2
1. BuildNewFile : changed conditional boundary → NO_COVERAGE 2. BuildNewFile : negated conditional → NO_COVERAGE |
if (fonts[Font].fdarrayOffset>=0) |
1137 | { | |
1138 | // Mark the beginning | |
1139 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new MarkerItem(fdarrayRef)); |
1140 | // Build a new FDArray with its private dicts and their LSubrs | |
1141 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFontSubset::Reconstruct → NO_COVERAGE |
Reconstruct(Font); |
1142 | } | |
1143 | else | |
1144 | // Else create a new one | |
1145 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFontSubset::CreateFDArray → NO_COVERAGE |
CreateFDArray(fdarrayRef,privateRef,Font); |
1146 | | |
1147 | } | |
1148 | // If the font is not CID | |
1149 | else | |
1150 | { | |
1151 | // create FDSelect | |
1152 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFontSubset::CreateFDSelect → NO_COVERAGE |
CreateFDSelect(fdselectRef,fonts[Font].nglyphs); |
1153 | // recreate a new charset | |
1154 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFontSubset::CreateCharset → NO_COVERAGE |
CreateCharset(charsetRef,fonts[Font].nglyphs); |
1155 | // create a font dict index (fdarray) | |
1156 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFontSubset::CreateFDArray → NO_COVERAGE |
CreateFDArray(fdarrayRef,privateRef,Font); |
1157 | } | |
1158 | | |
1159 | // if a private dict exists insert its subsetted version | |
1160 |
2
1. BuildNewFile : changed conditional boundary → NO_COVERAGE 2. BuildNewFile : negated conditional → NO_COVERAGE |
if (fonts[Font].privateOffset>=0) |
1161 | { | |
1162 | // Mark the beginning of the private dict | |
1163 | IndexBaseItem PrivateBase = new IndexBaseItem(); | |
1164 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(PrivateBase); |
1165 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new MarkerItem(privateRef)); |
1166 | ||
1167 | OffsetItem Subr = new DictOffsetItem(); | |
1168 | // Build and copy the new private dict | |
1169 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFontSubset::CreateNonCIDPrivate → NO_COVERAGE |
CreateNonCIDPrivate(Font,Subr); |
1170 | // Copy the new LSubrs index | |
1171 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFontSubset::CreateNonCIDSubrs → NO_COVERAGE |
CreateNonCIDSubrs(Font,PrivateBase,Subr); |
1172 | } | |
1173 | | |
1174 | // copy the charstring index | |
1175 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new MarkerItem(charstringsRef)); |
1176 | ||
1177 | // Add the subsetted charstring | |
1178 |
1
1. BuildNewFile : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new RangeItem(new RandomAccessFileOrArray(NewCharStringsIndex),0,NewCharStringsIndex.length)); |
1179 | | |
1180 | // now create the new CFF font | |
1181 | int[] currentOffset = new int[1]; | |
1182 | currentOffset[0] = 0; | |
1183 | // Count and save the offset for each item | |
1184 | Iterator listIter = OutputList.iterator(); | |
1185 |
1
1. BuildNewFile : negated conditional → NO_COVERAGE |
while ( listIter.hasNext() ) { |
1186 | Item item = (Item) listIter.next(); | |
1187 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFont$Item::increment → NO_COVERAGE |
item.increment(currentOffset); |
1188 | } | |
1189 | // Compute the Xref for each of the offset items | |
1190 | listIter = OutputList.iterator(); | |
1191 |
1
1. BuildNewFile : negated conditional → NO_COVERAGE |
while ( listIter.hasNext() ) { |
1192 | Item item = (Item) listIter.next(); | |
1193 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFont$Item::xref → NO_COVERAGE |
item.xref(); |
1194 | } | |
1195 | | |
1196 | int size = currentOffset[0]; | |
1197 | byte[] b = new byte[size]; | |
1198 | | |
1199 | // Emit all the items into the new byte array | |
1200 | listIter = OutputList.iterator(); | |
1201 |
1
1. BuildNewFile : negated conditional → NO_COVERAGE |
while ( listIter.hasNext() ) { |
1202 | Item item = (Item) listIter.next(); | |
1203 |
1
1. BuildNewFile : removed call to com/lowagie/text/pdf/CFFFont$Item::emit → NO_COVERAGE |
item.emit(b); |
1204 | } | |
1205 | // Return the new stream | |
1206 |
1
1. BuildNewFile : mutated return of Object value for com/lowagie/text/pdf/CFFFontSubset::BuildNewFile to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return b; |
1207 | } | |
1208 | ||
1209 | /** | |
1210 | * Function Copies the header from the original fileto the output list | |
1211 | */ | |
1212 | protected void CopyHeader() | |
1213 | { | |
1214 |
1
1. CopyHeader : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(0); |
1215 | int major = getCard8(); | |
1216 | int minor = getCard8(); | |
1217 | int hdrSize = getCard8(); | |
1218 | int offSize = getCard8(); | |
1219 | nextIndexOffset = hdrSize; | |
1220 |
1
1. CopyHeader : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new RangeItem(buf,0,hdrSize)); |
1221 | } | |
1222 | ||
1223 | /** | |
1224 | * Function Build the header of an index | |
1225 | * @param Count the count field of the index | |
1226 | * @param Offsize the offsize field of the index | |
1227 | * @param First the first offset of the index | |
1228 | */ | |
1229 | protected void BuildIndexHeader(int Count,int Offsize,int First) | |
1230 | { | |
1231 | // Add the count field | |
1232 |
1
1. BuildIndexHeader : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt16Item((char)Count)); // count |
1233 | // Add the offsize field | |
1234 |
1
1. BuildIndexHeader : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)Offsize)); // offSize |
1235 | // Add the first offset according to the offsize | |
1236 | switch(Offsize){ | |
1237 | case 1: | |
1238 |
1
1. BuildIndexHeader : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)First)); // first offset |
1239 | break; | |
1240 | case 2: | |
1241 |
1
1. BuildIndexHeader : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt16Item((char)First)); // first offset |
1242 | break; | |
1243 | case 3: | |
1244 |
1
1. BuildIndexHeader : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt24Item((char)First)); // first offset |
1245 | break; | |
1246 | case 4: | |
1247 |
1
1. BuildIndexHeader : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt32Item((char)First)); // first offset |
1248 | break; | |
1249 | default: | |
1250 | break; | |
1251 | } | |
1252 | } | |
1253 | | |
1254 | /** | |
1255 | * Function adds the keys into the TopDict | |
1256 | * @param fdarrayRef OffsetItem for the FDArray | |
1257 | * @param fdselectRef OffsetItem for the FDSelect | |
1258 | * @param charsetRef OffsetItem for the CharSet | |
1259 | * @param charstringsRef OffsetItem for the CharString | |
1260 | */ | |
1261 | protected void CreateKeys(OffsetItem fdarrayRef,OffsetItem fdselectRef,OffsetItem charsetRef,OffsetItem charstringsRef) | |
1262 | { | |
1263 | // create an FDArray key | |
1264 |
1
1. CreateKeys : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(fdarrayRef); |
1265 |
1
1. CreateKeys : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)12)); |
1266 |
1
1. CreateKeys : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)36)); |
1267 | // create an FDSelect key | |
1268 |
1
1. CreateKeys : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(fdselectRef); |
1269 |
1
1. CreateKeys : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)12)); |
1270 |
1
1. CreateKeys : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)37)); |
1271 | // create an charset key | |
1272 |
1
1. CreateKeys : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(charsetRef); |
1273 |
1
1. CreateKeys : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)15)); |
1274 | // create a CharStrings key | |
1275 |
1
1. CreateKeys : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(charstringsRef); |
1276 |
1
1. CreateKeys : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)17)); |
1277 | } | |
1278 | | |
1279 | /** | |
1280 | * Function takes the original string item and adds the new strings | |
1281 | * to accommodate the CID rules | |
1282 | * @param Font the font | |
1283 | */ | |
1284 | protected void CreateNewStringIndex(int Font) | |
1285 | { | |
1286 | String fdFontName = fonts[Font].name+"-OneRange"; | |
1287 |
2
1. CreateNewStringIndex : changed conditional boundary → NO_COVERAGE 2. CreateNewStringIndex : negated conditional → NO_COVERAGE |
if (fdFontName.length() > 127) |
1288 | fdFontName = fdFontName.substring(0,127); | |
1289 | String extraStrings = "Adobe"+"Identity"+fdFontName; | |
1290 | | |
1291 |
2
1. CreateNewStringIndex : Replaced integer subtraction with addition → NO_COVERAGE 2. CreateNewStringIndex : Replaced integer subtraction with addition → NO_COVERAGE |
int origStringsLen = stringOffsets[stringOffsets.length-1] |
1292 | - stringOffsets[0]; | |
1293 |
1
1. CreateNewStringIndex : Replaced integer subtraction with addition → NO_COVERAGE |
int stringsBaseOffset = stringOffsets[0]-1; |
1294 | | |
1295 | byte stringsIndexOffSize; | |
1296 |
3
1. CreateNewStringIndex : changed conditional boundary → NO_COVERAGE 2. CreateNewStringIndex : Replaced integer addition with subtraction → NO_COVERAGE 3. CreateNewStringIndex : negated conditional → NO_COVERAGE |
if (origStringsLen+extraStrings.length() <= 0xff) stringsIndexOffSize = 1; |
1297 |
3
1. CreateNewStringIndex : changed conditional boundary → NO_COVERAGE 2. CreateNewStringIndex : Replaced integer addition with subtraction → NO_COVERAGE 3. CreateNewStringIndex : negated conditional → NO_COVERAGE |
else if (origStringsLen+extraStrings.length() <= 0xffff) stringsIndexOffSize = 2; |
1298 |
3
1. CreateNewStringIndex : changed conditional boundary → NO_COVERAGE 2. CreateNewStringIndex : Replaced integer addition with subtraction → NO_COVERAGE 3. CreateNewStringIndex : negated conditional → NO_COVERAGE |
else if (origStringsLen+extraStrings.length() <= 0xffffff) stringsIndexOffSize = 3; |
1299 | else stringsIndexOffSize = 4; | |
1300 | | |
1301 |
3
1. CreateNewStringIndex : Replaced integer subtraction with addition → NO_COVERAGE 2. CreateNewStringIndex : Replaced integer addition with subtraction → NO_COVERAGE 3. CreateNewStringIndex : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt16Item((char)((stringOffsets.length-1)+3))); // count |
1302 |
1
1. CreateNewStringIndex : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)stringsIndexOffSize)); // offSize |
1303 | for (int stringOffset : stringOffsets) | |
1304 |
2
1. CreateNewStringIndex : Replaced integer subtraction with addition → NO_COVERAGE 2. CreateNewStringIndex : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new IndexOffsetItem(stringsIndexOffSize, |
1305 | stringOffset - stringsBaseOffset)); | |
1306 |
2
1. CreateNewStringIndex : Replaced integer subtraction with addition → NO_COVERAGE 2. CreateNewStringIndex : Replaced integer subtraction with addition → NO_COVERAGE |
int currentStringsOffset = stringOffsets[stringOffsets.length-1] |
1307 | - stringsBaseOffset; | |
1308 | //l.addLast(new IndexOffsetItem(stringsIndexOffSize,currentStringsOffset)); | |
1309 |
1
1. CreateNewStringIndex : Replaced integer addition with subtraction → NO_COVERAGE |
currentStringsOffset += "Adobe".length(); |
1310 |
1
1. CreateNewStringIndex : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new IndexOffsetItem(stringsIndexOffSize,currentStringsOffset)); |
1311 |
1
1. CreateNewStringIndex : Replaced integer addition with subtraction → NO_COVERAGE |
currentStringsOffset += "Identity".length(); |
1312 |
1
1. CreateNewStringIndex : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new IndexOffsetItem(stringsIndexOffSize,currentStringsOffset)); |
1313 |
1
1. CreateNewStringIndex : Replaced integer addition with subtraction → NO_COVERAGE |
currentStringsOffset += fdFontName.length(); |
1314 |
1
1. CreateNewStringIndex : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new IndexOffsetItem(stringsIndexOffSize,currentStringsOffset)); |
1315 | | |
1316 |
1
1. CreateNewStringIndex : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new RangeItem(buf,stringOffsets[0],origStringsLen)); |
1317 |
1
1. CreateNewStringIndex : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new StringItem(extraStrings)); |
1318 | } | |
1319 | | |
1320 | /** | |
1321 | * Function creates new FDSelect for non-CID fonts. | |
1322 | * The FDSelect built uses a single range for all glyphs | |
1323 | * @param fdselectRef OffsetItem for the FDSelect | |
1324 | * @param nglyphs the number of glyphs in the font | |
1325 | */ | |
1326 | protected void CreateFDSelect(OffsetItem fdselectRef,int nglyphs) | |
1327 | { | |
1328 |
1
1. CreateFDSelect : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new MarkerItem(fdselectRef)); |
1329 |
1
1. CreateFDSelect : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)3)); // format identifier |
1330 |
1
1. CreateFDSelect : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt16Item((char)1)); // nRanges |
1331 | | |
1332 |
1
1. CreateFDSelect : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt16Item((char)0)); // Range[0].firstGlyph |
1333 |
1
1. CreateFDSelect : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)0)); // Range[0].fd |
1334 | | |
1335 |
1
1. CreateFDSelect : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt16Item((char)nglyphs)); // sentinel |
1336 | } | |
1337 | ||
1338 | /** | |
1339 | * Function creates new CharSet for non-CID fonts. | |
1340 | * The CharSet built uses a single range for all glyphs | |
1341 | * @param charsetRef OffsetItem for the CharSet | |
1342 | * @param nglyphs the number of glyphs in the font | |
1343 | */ | |
1344 | protected void CreateCharset(OffsetItem charsetRef,int nglyphs) | |
1345 | { | |
1346 |
1
1. CreateCharset : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new MarkerItem(charsetRef)); |
1347 |
1
1. CreateCharset : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)2)); // format identifier |
1348 |
1
1. CreateCharset : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt16Item((char)1)); // first glyph in range (ignore .notdef) |
1349 |
2
1. CreateCharset : Replaced integer subtraction with addition → NO_COVERAGE 2. CreateCharset : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt16Item((char)(nglyphs-1))); // nLeft |
1350 | } | |
1351 | | |
1352 | /** | |
1353 | * Function creates new FDArray for non-CID fonts. | |
1354 | * The FDArray built has only the "Private" operator that points to the font's | |
1355 | * original private dict | |
1356 | * @param fdarrayRef OffsetItem for the FDArray | |
1357 | * @param privateRef OffsetItem for the Private Dict | |
1358 | * @param Font the font | |
1359 | */ | |
1360 | protected void CreateFDArray(OffsetItem fdarrayRef,OffsetItem privateRef,int Font) | |
1361 | { | |
1362 |
1
1. CreateFDArray : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new MarkerItem(fdarrayRef)); |
1363 | // Build the header (count=offsize=first=1) | |
1364 |
1
1. CreateFDArray : removed call to com/lowagie/text/pdf/CFFFontSubset::BuildIndexHeader → NO_COVERAGE |
BuildIndexHeader(1,1,1); |
1365 | | |
1366 | // Mark | |
1367 | OffsetItem privateIndex1Ref = new IndexOffsetItem(1); | |
1368 |
1
1. CreateFDArray : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(privateIndex1Ref); |
1369 | IndexBaseItem privateBase = new IndexBaseItem(); | |
1370 | // Insert the private operands and operator | |
1371 |
1
1. CreateFDArray : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(privateBase); |
1372 | // Calc the new size of the private after subsetting | |
1373 | // Origianl size | |
1374 | int NewSize = fonts[Font].privateLength; | |
1375 | // Calc the original size of the Subr offset in the private | |
1376 | int OrgSubrsOffsetSize = CalcSubrOffsetSize(fonts[Font].privateOffset,fonts[Font].privateLength); | |
1377 | // Increase the ptivate's size | |
1378 |
1
1. CreateFDArray : negated conditional → NO_COVERAGE |
if (OrgSubrsOffsetSize != 0) |
1379 |
2
1. CreateFDArray : Replaced integer subtraction with addition → NO_COVERAGE 2. CreateFDArray : Replaced integer addition with subtraction → NO_COVERAGE |
NewSize += 5-OrgSubrsOffsetSize; |
1380 |
1
1. CreateFDArray : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new DictNumberItem(NewSize)); |
1381 |
1
1. CreateFDArray : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(privateRef); |
1382 |
1
1. CreateFDArray : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)18)); // Private |
1383 | | |
1384 |
1
1. CreateFDArray : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new IndexMarkerItem(privateIndex1Ref,privateBase)); |
1385 | } | |
1386 | | |
1387 | /** | |
1388 | * Function reconstructs the FDArray, PrivateDict and LSubr for CID fonts | |
1389 | * @param Font the font | |
1390 | */ | |
1391 | void Reconstruct(int Font) | |
1392 | { | |
1393 | // Init for later use | |
1394 |
1
1. Reconstruct : Replaced integer subtraction with addition → NO_COVERAGE |
OffsetItem[] fdPrivate = new DictOffsetItem[fonts[Font].FDArrayOffsets.length-1]; |
1395 | IndexBaseItem[] fdPrivateBase = new IndexBaseItem[fonts[Font].fdprivateOffsets.length]; | |
1396 | OffsetItem[] fdSubrs = new DictOffsetItem[fonts[Font].fdprivateOffsets.length]; | |
1397 | // Reconstruct each type | |
1398 |
1
1. Reconstruct : removed call to com/lowagie/text/pdf/CFFFontSubset::ReconstructFDArray → NO_COVERAGE |
ReconstructFDArray(Font,fdPrivate); |
1399 |
1
1. Reconstruct : removed call to com/lowagie/text/pdf/CFFFontSubset::ReconstructPrivateDict → NO_COVERAGE |
ReconstructPrivateDict(Font,fdPrivate,fdPrivateBase,fdSubrs); |
1400 |
1
1. Reconstruct : removed call to com/lowagie/text/pdf/CFFFontSubset::ReconstructPrivateSubrs → NO_COVERAGE |
ReconstructPrivateSubrs(Font,fdPrivateBase,fdSubrs); |
1401 | } | |
1402 | ||
1403 | /** | |
1404 | * Function subsets the FDArray and builds the new one with new offsets | |
1405 | * @param Font The font | |
1406 | * @param fdPrivate OffsetItem Array (one for each FDArray) | |
1407 | */ | |
1408 | void ReconstructFDArray(int Font,OffsetItem[] fdPrivate) | |
1409 | { | |
1410 | // Build the header of the index | |
1411 |
1
1. ReconstructFDArray : removed call to com/lowagie/text/pdf/CFFFontSubset::BuildIndexHeader → NO_COVERAGE |
BuildIndexHeader(fonts[Font].FDArrayCount,fonts[Font].FDArrayOffsize,1); |
1412 | ||
1413 | // For each offset create an Offset Item | |
1414 |
1
1. ReconstructFDArray : Replaced integer subtraction with addition → NO_COVERAGE |
OffsetItem[] fdOffsets = new IndexOffsetItem[fonts[Font].FDArrayOffsets.length-1]; |
1415 |
4
1. ReconstructFDArray : changed conditional boundary → NO_COVERAGE 2. ReconstructFDArray : Changed increment from 1 to -1 → NO_COVERAGE 3. ReconstructFDArray : Replaced integer subtraction with addition → NO_COVERAGE 4. ReconstructFDArray : negated conditional → NO_COVERAGE |
for (int i=0;i<fonts[Font].FDArrayOffsets.length-1;i++) |
1416 | { | |
1417 | fdOffsets[i] = new IndexOffsetItem(fonts[Font].FDArrayOffsize); | |
1418 |
1
1. ReconstructFDArray : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(fdOffsets[i]); |
1419 | } | |
1420 | | |
1421 | // Declare beginning of the object array | |
1422 | IndexBaseItem fdArrayBase = new IndexBaseItem(); | |
1423 |
1
1. ReconstructFDArray : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(fdArrayBase); |
1424 | | |
1425 | // For each object check if that FD is used. | |
1426 | // if is used build a new one by changing the private object | |
1427 | // Else do nothing | |
1428 | // At the end of each object mark its ending (Even if wasn't written) | |
1429 |
4
1. ReconstructFDArray : changed conditional boundary → NO_COVERAGE 2. ReconstructFDArray : Changed increment from 1 to -1 → NO_COVERAGE 3. ReconstructFDArray : Replaced integer subtraction with addition → NO_COVERAGE 4. ReconstructFDArray : negated conditional → NO_COVERAGE |
for (int k=0; k<fonts[Font].FDArrayOffsets.length-1; k++) { |
1430 |
1
1. ReconstructFDArray : negated conditional → NO_COVERAGE |
if (FDArrayUsed.containsKey(k)) |
1431 | { | |
1432 | // Goto beginning of objects | |
1433 |
1
1. ReconstructFDArray : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(fonts[Font].FDArrayOffsets[k]); |
1434 |
3
1. ReconstructFDArray : changed conditional boundary → NO_COVERAGE 2. ReconstructFDArray : Replaced integer addition with subtraction → NO_COVERAGE 3. ReconstructFDArray : negated conditional → NO_COVERAGE |
while (getPosition() < fonts[Font].FDArrayOffsets[k+1]) |
1435 | { | |
1436 | int p1 = getPosition(); | |
1437 |
1
1. ReconstructFDArray : removed call to com/lowagie/text/pdf/CFFFontSubset::getDictItem → NO_COVERAGE |
getDictItem(); |
1438 | int p2 = getPosition(); | |
1439 | // If the dictItem is the "Private" then compute and copy length, | |
1440 | // use marker for offset and write operator number | |
1441 |
1
1. ReconstructFDArray : negated conditional → NO_COVERAGE |
if (Objects.equals(key, "Private")) { |
1442 | // Save the original length of the private dict | |
1443 | int NewSize = (Integer) args[0]; | |
1444 | // Save the size of the offset to the subrs in that private | |
1445 | int OrgSubrsOffsetSize = CalcSubrOffsetSize(fonts[Font].fdprivateOffsets[k],fonts[Font].fdprivateLengths[k]); | |
1446 | // Increase the private's length accordingly | |
1447 |
1
1. ReconstructFDArray : negated conditional → NO_COVERAGE |
if (OrgSubrsOffsetSize != 0) |
1448 |
2
1. ReconstructFDArray : Replaced integer subtraction with addition → NO_COVERAGE 2. ReconstructFDArray : Replaced integer addition with subtraction → NO_COVERAGE |
NewSize += 5-OrgSubrsOffsetSize; |
1449 | // Insert the new size, OffsetItem and operator key number | |
1450 |
1
1. ReconstructFDArray : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new DictNumberItem(NewSize)); |
1451 | fdPrivate[k] = new DictOffsetItem(); | |
1452 |
1
1. ReconstructFDArray : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(fdPrivate[k]); |
1453 |
1
1. ReconstructFDArray : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)18)); // Private |
1454 | // Go back to place | |
1455 |
1
1. ReconstructFDArray : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(p2); |
1456 | } | |
1457 | // Else copy the entire range | |
1458 | else // other than private | |
1459 |
2
1. ReconstructFDArray : Replaced integer subtraction with addition → NO_COVERAGE 2. ReconstructFDArray : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new RangeItem(buf,p1,p2-p1)); |
1460 | } | |
1461 | } | |
1462 | // Mark the ending of the object (even if wasn't written) | |
1463 |
1
1. ReconstructFDArray : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new IndexMarkerItem(fdOffsets[k],fdArrayBase)); |
1464 | } | |
1465 | } | |
1466 | /** | |
1467 | * Function Adds the new private dicts (only for the FDs used) to the list | |
1468 | * @param Font the font | |
1469 | * @param fdPrivate OffsetItem array one element for each private | |
1470 | * @param fdPrivateBase IndexBaseItem array one element for each private | |
1471 | * @param fdSubrs OffsetItem array one element for each private | |
1472 | */ | |
1473 | void ReconstructPrivateDict(int Font,OffsetItem[] fdPrivate,IndexBaseItem[] fdPrivateBase, | |
1474 | OffsetItem[] fdSubrs) | |
1475 | { | |
1476 | | |
1477 | // For each fdarray private dict check if that FD is used. | |
1478 | // if is used build a new one by changing the subrs offset | |
1479 | // Else do nothing | |
1480 |
3
1. ReconstructPrivateDict : changed conditional boundary → NO_COVERAGE 2. ReconstructPrivateDict : Changed increment from 1 to -1 → NO_COVERAGE 3. ReconstructPrivateDict : negated conditional → NO_COVERAGE |
for (int i=0;i<fonts[Font].fdprivateOffsets.length;i++) |
1481 | { | |
1482 |
1
1. ReconstructPrivateDict : negated conditional → NO_COVERAGE |
if (FDArrayUsed.containsKey(i)) |
1483 | { | |
1484 | // Mark beginning | |
1485 |
1
1. ReconstructPrivateDict : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new MarkerItem(fdPrivate[i])); |
1486 | fdPrivateBase[i] = new IndexBaseItem(); | |
1487 |
1
1. ReconstructPrivateDict : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(fdPrivateBase[i]); |
1488 | // Goto beginning of objects | |
1489 |
1
1. ReconstructPrivateDict : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(fonts[Font].fdprivateOffsets[i]); |
1490 |
3
1. ReconstructPrivateDict : changed conditional boundary → NO_COVERAGE 2. ReconstructPrivateDict : Replaced integer addition with subtraction → NO_COVERAGE 3. ReconstructPrivateDict : negated conditional → NO_COVERAGE |
while (getPosition() < fonts[Font].fdprivateOffsets[i]+fonts[Font].fdprivateLengths[i]) |
1491 | { | |
1492 | int p1 = getPosition(); | |
1493 |
1
1. ReconstructPrivateDict : removed call to com/lowagie/text/pdf/CFFFontSubset::getDictItem → NO_COVERAGE |
getDictItem(); |
1494 | int p2 = getPosition(); | |
1495 | // If the dictItem is the "Subrs" then, | |
1496 | // use marker for offset and write operator number | |
1497 |
1
1. ReconstructPrivateDict : negated conditional → NO_COVERAGE |
if (Objects.equals(key, "Subrs")) { |
1498 | fdSubrs[i] = new DictOffsetItem(); | |
1499 |
1
1. ReconstructPrivateDict : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(fdSubrs[i]); |
1500 |
1
1. ReconstructPrivateDict : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)19)); // Subrs |
1501 | } | |
1502 | // Else copy the entire range | |
1503 | else | |
1504 |
2
1. ReconstructPrivateDict : Replaced integer subtraction with addition → NO_COVERAGE 2. ReconstructPrivateDict : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new RangeItem(buf,p1,p2-p1)); |
1505 | } | |
1506 | } | |
1507 | } | |
1508 | } | |
1509 | | |
1510 | /** | |
1511 | * Function Adds the new LSubrs dicts (only for the FDs used) to the list | |
1512 | * @param Font The index of the font | |
1513 | * @param fdPrivateBase The IndexBaseItem array for the linked list | |
1514 | * @param fdSubrs OffsetItem array for the linked list | |
1515 | */ | |
1516 | | |
1517 | void ReconstructPrivateSubrs(int Font,IndexBaseItem[] fdPrivateBase, | |
1518 | OffsetItem[] fdSubrs) | |
1519 | { | |
1520 | // For each private dict | |
1521 |
3
1. ReconstructPrivateSubrs : changed conditional boundary → NO_COVERAGE 2. ReconstructPrivateSubrs : Changed increment from 1 to -1 → NO_COVERAGE 3. ReconstructPrivateSubrs : negated conditional → NO_COVERAGE |
for (int i=0;i<fonts[Font].fdprivateLengths.length;i++) |
1522 | { | |
1523 | // If that private dict's Subrs are used insert the new LSubrs | |
1524 | // computed earlier | |
1525 |
3
1. ReconstructPrivateSubrs : changed conditional boundary → NO_COVERAGE 2. ReconstructPrivateSubrs : negated conditional → NO_COVERAGE 3. ReconstructPrivateSubrs : negated conditional → NO_COVERAGE |
if (fdSubrs[i]!= null && fonts[Font].PrivateSubrsOffset[i] >= 0) |
1526 | { | |
1527 |
1
1. ReconstructPrivateSubrs : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new SubrMarkerItem(fdSubrs[i],fdPrivateBase[i])); |
1528 |
1
1. ReconstructPrivateSubrs : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new RangeItem(new RandomAccessFileOrArray(NewLSubrsIndex[i]),0,NewLSubrsIndex[i].length)); |
1529 | } | |
1530 | } | |
1531 | } | |
1532 | ||
1533 | /** | |
1534 | * Calculates how many byte it took to write the offset for the subrs in a specific | |
1535 | * private dict. | |
1536 | * @param Offset The Offset for the private dict | |
1537 | * @param Size The size of the private dict | |
1538 | * @return The size of the offset of the subrs in the private dict | |
1539 | */ | |
1540 | int CalcSubrOffsetSize(int Offset,int Size) | |
1541 | { | |
1542 | // Set the size to 0 | |
1543 | int OffsetSize = 0; | |
1544 | // Go to the beginning of the private dict | |
1545 |
1
1. CalcSubrOffsetSize : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(Offset); |
1546 | // Go until the end of the private dict | |
1547 |
3
1. CalcSubrOffsetSize : changed conditional boundary → NO_COVERAGE 2. CalcSubrOffsetSize : Replaced integer addition with subtraction → NO_COVERAGE 3. CalcSubrOffsetSize : negated conditional → NO_COVERAGE |
while (getPosition() < Offset+Size) |
1548 | { | |
1549 | int p1 = getPosition(); | |
1550 |
1
1. CalcSubrOffsetSize : removed call to com/lowagie/text/pdf/CFFFontSubset::getDictItem → NO_COVERAGE |
getDictItem(); |
1551 | int p2 = getPosition(); | |
1552 | // When reached to the subrs offset | |
1553 |
1
1. CalcSubrOffsetSize : negated conditional → NO_COVERAGE |
if (Objects.equals(key, "Subrs")) { |
1554 | // The Offsize (minus the subrs key) | |
1555 |
2
1. CalcSubrOffsetSize : Replaced integer subtraction with addition → NO_COVERAGE 2. CalcSubrOffsetSize : Replaced integer subtraction with addition → NO_COVERAGE |
OffsetSize = p2-p1-1; |
1556 | } | |
1557 | // All other keys are ignored | |
1558 | } | |
1559 | // return the size | |
1560 |
1
1. CalcSubrOffsetSize : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return OffsetSize; |
1561 | } | |
1562 | | |
1563 | /** | |
1564 | * Function computes the size of an index | |
1565 | * @param indexOffset The offset for the computed index | |
1566 | * @return The size of the index | |
1567 | */ | |
1568 | protected int countEntireIndexRange(int indexOffset) | |
1569 | { | |
1570 | // Go to the beginning of the index | |
1571 |
1
1. countEntireIndexRange : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(indexOffset); |
1572 | // Read the count field | |
1573 | int count = getCard16(); | |
1574 | // If count==0 -> size=2 | |
1575 |
1
1. countEntireIndexRange : negated conditional → NO_COVERAGE |
if (count==0) |
1576 |
1
1. countEntireIndexRange : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 2; |
1577 | else | |
1578 | { | |
1579 | // Read the offsize field | |
1580 | int indexOffSize = getCard8(); | |
1581 | // Go to the last element of the offset array | |
1582 |
5
1. countEntireIndexRange : Replaced integer addition with subtraction → NO_COVERAGE 2. countEntireIndexRange : Replaced integer addition with subtraction → NO_COVERAGE 3. countEntireIndexRange : Replaced integer multiplication with division → NO_COVERAGE 4. countEntireIndexRange : Replaced integer addition with subtraction → NO_COVERAGE 5. countEntireIndexRange : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(indexOffset+2+1+count*indexOffSize); |
1583 | // The size of the object array is the value of the last element-1 | |
1584 |
1
1. countEntireIndexRange : Replaced integer subtraction with addition → NO_COVERAGE |
int size = getOffset(indexOffSize)-1; |
1585 | // Return the size of the entire index | |
1586 |
5
1. countEntireIndexRange : Replaced integer addition with subtraction → NO_COVERAGE 2. countEntireIndexRange : Replaced integer multiplication with division → NO_COVERAGE 3. countEntireIndexRange : Replaced integer addition with subtraction → NO_COVERAGE 4. countEntireIndexRange : Replaced integer addition with subtraction → NO_COVERAGE 5. countEntireIndexRange : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 2+1+(count+1)*indexOffSize+size; |
1587 | } | |
1588 | } | |
1589 | | |
1590 | /** | |
1591 | * The function creates a private dict for a font that was not CID | |
1592 | * All the keys are copied as is except for the subrs key | |
1593 | * @param Font the font | |
1594 | * @param Subr The OffsetItem for the subrs of the private | |
1595 | */ | |
1596 | void CreateNonCIDPrivate(int Font,OffsetItem Subr) | |
1597 | { | |
1598 | // Go to the beginning of the private dict and read until the end | |
1599 |
1
1. CreateNonCIDPrivate : removed call to com/lowagie/text/pdf/CFFFontSubset::seek → NO_COVERAGE |
seek(fonts[Font].privateOffset); |
1600 |
3
1. CreateNonCIDPrivate : changed conditional boundary → NO_COVERAGE 2. CreateNonCIDPrivate : Replaced integer addition with subtraction → NO_COVERAGE 3. CreateNonCIDPrivate : negated conditional → NO_COVERAGE |
while (getPosition() < fonts[Font].privateOffset+fonts[Font].privateLength) |
1601 | { | |
1602 | int p1 = getPosition(); | |
1603 |
1
1. CreateNonCIDPrivate : removed call to com/lowagie/text/pdf/CFFFontSubset::getDictItem → NO_COVERAGE |
getDictItem(); |
1604 | int p2 = getPosition(); | |
1605 | // If the dictItem is the "Subrs" then, | |
1606 | // use marker for offset and write operator number | |
1607 |
1
1. CreateNonCIDPrivate : negated conditional → NO_COVERAGE |
if (Objects.equals(key, "Subrs")) { |
1608 |
1
1. CreateNonCIDPrivate : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(Subr); |
1609 |
1
1. CreateNonCIDPrivate : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new UInt8Item((char)19)); // Subrs |
1610 | } | |
1611 | // Else copy the entire range | |
1612 | else | |
1613 |
2
1. CreateNonCIDPrivate : Replaced integer subtraction with addition → NO_COVERAGE 2. CreateNonCIDPrivate : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new RangeItem(buf,p1,p2-p1)); |
1614 | } | |
1615 | } | |
1616 | | |
1617 | /** | |
1618 | * the function marks the beginning of the subrs index and adds the subsetted subrs | |
1619 | * index to the output list. | |
1620 | * @param Font the font | |
1621 | * @param PrivateBase IndexBaseItem for the private that's referencing to the subrs | |
1622 | * @param Subrs OffsetItem for the subrs | |
1623 | */ | |
1624 | void CreateNonCIDSubrs(int Font,IndexBaseItem PrivateBase,OffsetItem Subrs) | |
1625 | { | |
1626 | // Mark the beginning of the Subrs index | |
1627 |
1
1. CreateNonCIDSubrs : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new SubrMarkerItem(Subrs,PrivateBase)); |
1628 | // Put the subsetted new subrs index | |
1629 |
1
1. CreateNonCIDSubrs : removed call to java/util/LinkedList::addLast → NO_COVERAGE |
OutputList.addLast(new RangeItem(new RandomAccessFileOrArray(NewSubrsIndexNonCID),0,NewSubrsIndexNonCID.length)); |
1630 | } | |
1631 | } | |
Mutations | ||
176 |
1.1 2.2 |
|
179 |
1.1 |
|
183 |
1.1 |
|
184 |
1.1 |
|
190 |
1.1 2.2 |
|
193 |
1.1 |
|
195 |
1.1 |
|
197 |
1.1 |
|
199 |
1.1 |
|
214 |
1.1 |
|
220 |
1.1 2.2 |
|
223 |
1.1 2.2 |
|
226 |
1.1 2.2 |
|
231 |
1.1 |
|
244 |
1.1 2.2 |
|
245 |
1.1 |
|
247 |
1.1 |
|
251 |
1.1 2.2 |
|
253 |
1.1 |
|
267 |
1.1 |
|
275 |
1.1 2.2 3.3 |
|
281 |
1.1 |
|
290 |
1.1 2.2 3.3 |
|
297 |
1.1 |
|
298 |
1.1 2.2 3.3 |
|
301 |
1.1 |
|
307 |
1.1 2.2 3.3 |
|
340 |
1.1 |
|
345 |
1.1 2.2 |
|
346 |
1.1 |
|
362 |
1.1 |
|
365 |
1.1 2.2 |
|
366 |
1.1 |
|
367 |
1.1 2.2 |
|
370 |
1.1 2.2 |
|
374 |
1.1 |
|
376 |
1.1 |
|
379 |
1.1 |
|
383 |
1.1 |
|
400 |
1.1 |
|
403 |
1.1 |
|
404 |
1.1 |
|
406 |
1.1 2.2 |
|
407 |
1.1 |
|
408 |
1.1 2.2 |
|
409 |
1.1 |
|
411 |
1.1 |
|
434 |
1.1 |
|
457 |
1.1 |
|
459 |
1.1 2.2 |
|
462 |
1.1 |
|
469 |
1.1 2.2 |
|
475 |
1.1 |
|
479 |
1.1 |
|
480 |
1.1 2.2 |
|
498 |
1.1 |
|
500 |
1.1 2.2 3.3 |
|
502 |
1.1 |
|
504 |
1.1 |
|
505 |
1.1 |
|
508 |
1.1 2.2 |
|
533 |
1.1 |
|
536 |
1.1 2.2 |
|
537 |
1.1 |
|
542 |
1.1 |
|
544 |
1.1 |
|
548 |
1.1 |
|
551 |
1.1 2.2 3.3 |
|
556 |
1.1 2.2 3.3 4.4 5.5 |
|
560 |
1.1 |
|
561 |
1.1 |
|
575 |
1.1 2.2 |
|
582 |
1.1 2.2 3.3 |
|
586 |
1.1 2.2 3.3 4.4 5.5 |
|
590 |
1.1 |
|
592 |
1.1 |
|
593 |
1.1 |
|
596 |
1.1 |
|
597 |
1.1 2.2 |
|
599 |
1.1 2.2 3.3 |
|
603 |
1.1 2.2 3.3 4.4 5.5 |
|
607 |
1.1 |
|
608 |
1.1 |
|
632 |
1.1 |
|
635 |
1.1 |
|
636 |
1.1 2.2 |
|
639 |
1.1 |
|
642 |
1.1 2.2 |
|
643 |
1.1 |
|
646 |
1.1 |
|
648 |
1.1 |
|
651 |
1.1 2.2 |
|
654 |
1.1 |
|
656 |
1.1 |
|
661 |
1.1 |
|
662 |
1.1 |
|
666 |
1.1 |
|
669 |
1.1 2.2 |
|
672 |
1.1 |
|
674 |
1.1 |
|
679 |
1.1 |
|
680 |
1.1 |
|
684 |
1.1 2.2 3.3 4.4 |
|
686 |
1.1 2.2 |
|
688 |
1.1 2.2 |
|
691 |
1.1 |
|
692 |
1.1 2.2 3.3 |
|
693 |
1.1 |
|
695 |
1.1 2.2 3.3 |
|
709 |
1.1 2.2 |
|
712 |
1.1 |
|
713 |
1.1 |
|
718 |
1.1 |
|
719 |
1.1 2.2 3.3 |
|
720 |
1.1 |
|
726 |
1.1 |
|
735 |
1.1 |
|
736 |
1.1 |
|
737 |
1.1 2.2 |
|
738 |
1.1 |
|
739 |
1.1 2.2 3.3 4.4 |
|
740 |
1.1 2.2 3.3 4.4 |
|
741 |
1.1 2.2 |
|
742 |
1.1 |
|
743 |
1.1 2.2 3.3 4.4 |
|
744 |
1.1 2.2 3.3 4.4 |
|
745 |
1.1 |
|
746 |
1.1 2.2 |
|
747 |
1.1 |
|
748 |
1.1 |
|
758 |
1.1 2.2 3.3 |
|
768 |
1.1 2.2 |
|
770 |
1.1 |
|
771 |
1.1 |
|
781 |
1.1 |
|
792 |
1.1 |
|
796 |
1.1 |
|
800 |
1.1 2.2 |
|
801 |
1.1 |
|
804 |
1.1 2.2 3.3 4.4 |
|
806 |
1.1 |
|
807 |
1.1 |
|
810 |
1.1 2.2 3.3 4.4 |
|
813 |
1.1 2.2 3.3 4.4 |
|
814 |
1.1 |
|
817 |
1.1 2.2 3.3 4.4 |
|
820 |
1.1 2.2 3.3 4.4 5.5 |
|
821 |
1.1 |
|
824 |
1.1 |
|
830 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
831 |
1.1 |
|
834 |
1.1 2.2 3.3 |
|
839 |
1.1 |
|
842 |
1.1 2.2 3.3 |
|
843 |
1.1 |
|
866 |
1.1 |
|
867 |
1.1 2.2 |
|
870 |
1.1 |
|
873 |
1.1 2.2 |
|
874 |
1.1 |
|
877 |
1.1 |
|
879 |
1.1 |
|
881 |
1.1 2.2 |
|
883 |
1.1 |
|
884 |
1.1 |
|
885 |
1.1 |
|
889 |
1.1 |
|
891 |
1.1 2.2 |
|
893 |
1.1 |
|
894 |
1.1 |
|
895 |
1.1 |
|
899 |
1.1 2.2 3.3 4.4 |
|
901 |
1.1 2.2 |
|
903 |
1.1 2.2 |
|
906 |
1.1 |
|
907 |
1.1 2.2 3.3 |
|
908 |
1.1 |
|
910 |
1.1 2.2 3.3 |
|
914 |
1.1 |
|
933 |
1.1 2.2 3.3 |
|
938 |
1.1 |
|
939 |
1.1 2.2 3.3 |
|
942 |
1.1 |
|
946 |
1.1 |
|
949 |
1.1 2.2 3.3 4.4 |
|
952 |
1.1 |
|
953 |
1.1 |
|
956 |
1.1 |
|
960 |
1.1 |
|
962 |
1.1 2.2 3.3 |
|
964 |
1.1 |
|
965 |
1.1 |
|
968 |
1.1 2.2 |
|
970 |
1.1 |
|
983 |
1.1 |
|
985 |
1.1 |
|
988 |
1.1 2.2 |
|
989 |
1.1 2.2 |
|
990 |
1.1 2.2 |
|
994 |
1.1 2.2 3.3 4.4 |
|
998 |
1.1 2.2 3.3 |
|
999 |
1.1 2.2 3.3 |
|
1001 |
1.1 |
|
1005 |
1.1 2.2 |
|
1009 |
1.1 2.2 3.3 |
|
1011 |
1.1 2.2 3.3 |
|
1013 |
1.1 2.2 3.3 |
|
1015 |
1.1 2.2 3.3 |
|
1020 |
1.1 |
|
1023 |
1.1 |
|
1037 |
1.1 |
|
1040 |
1.1 |
|
1041 |
1.1 2.2 |
|
1042 |
1.1 |
|
1045 |
1.1 |
|
1047 |
1.1 |
|
1049 |
1.1 |
|
1059 |
1.1 |
|
1061 |
1.1 |
|
1062 |
1.1 2.2 |
|
1063 |
1.1 |
|
1064 |
1.1 |
|
1065 |
1.1 |
|
1067 |
1.1 |
|
1068 |
1.1 |
|
1069 |
1.1 |
|
1075 |
1.1 |
|
1077 |
1.1 2.2 3.3 |
|
1079 |
1.1 |
|
1082 |
1.1 |
|
1084 |
1.1 |
|
1085 |
1.1 |
|
1086 |
1.1 |
|
1087 |
1.1 |
|
1088 |
1.1 |
|
1092 |
1.1 |
|
1096 |
1.1 |
|
1099 |
1.1 |
|
1103 |
1.1 |
|
1104 |
1.1 |
|
1109 |
1.1 |
|
1112 |
1.1 |
|
1116 |
1.1 |
|
1121 |
1.1 |
|
1123 |
1.1 2.2 |
|
1124 |
1.1 |
|
1127 |
1.1 |
|
1131 |
1.1 |
|
1132 |
1.1 |
|
1136 |
1.1 2.2 |
|
1139 |
1.1 |
|
1141 |
1.1 |
|
1145 |
1.1 |
|
1152 |
1.1 |
|
1154 |
1.1 |
|
1156 |
1.1 |
|
1160 |
1.1 2.2 |
|
1164 |
1.1 |
|
1165 |
1.1 |
|
1169 |
1.1 |
|
1171 |
1.1 |
|
1175 |
1.1 |
|
1178 |
1.1 |
|
1185 |
1.1 |
|
1187 |
1.1 |
|
1191 |
1.1 |
|
1193 |
1.1 |
|
1201 |
1.1 |
|
1203 |
1.1 |
|
1206 |
1.1 |
|
1214 |
1.1 |
|
1220 |
1.1 |
|
1232 |
1.1 |
|
1234 |
1.1 |
|
1238 |
1.1 |
|
1241 |
1.1 |
|
1244 |
1.1 |
|
1247 |
1.1 |
|
1264 |
1.1 |
|
1265 |
1.1 |
|
1266 |
1.1 |
|
1268 |
1.1 |
|
1269 |
1.1 |
|
1270 |
1.1 |
|
1272 |
1.1 |
|
1273 |
1.1 |
|
1275 |
1.1 |
|
1276 |
1.1 |
|
1287 |
1.1 2.2 |
|
1291 |
1.1 2.2 |
|
1293 |
1.1 |
|
1296 |
1.1 2.2 3.3 |
|
1297 |
1.1 2.2 3.3 |
|
1298 |
1.1 2.2 3.3 |
|
1301 |
1.1 2.2 3.3 |
|
1302 |
1.1 |
|
1304 |
1.1 2.2 |
|
1306 |
1.1 2.2 |
|
1309 |
1.1 |
|
1310 |
1.1 |
|
1311 |
1.1 |
|
1312 |
1.1 |
|
1313 |
1.1 |
|
1314 |
1.1 |
|
1316 |
1.1 |
|
1317 |
1.1 |
|
1328 |
1.1 |
|
1329 |
1.1 |
|
1330 |
1.1 |
|
1332 |
1.1 |
|
1333 |
1.1 |
|
1335 |
1.1 |
|
1346 |
1.1 |
|
1347 |
1.1 |
|
1348 |
1.1 |
|
1349 |
1.1 2.2 |
|
1362 |
1.1 |
|
1364 |
1.1 |
|
1368 |
1.1 |
|
1371 |
1.1 |
|
1378 |
1.1 |
|
1379 |
1.1 2.2 |
|
1380 |
1.1 |
|
1381 |
1.1 |
|
1382 |
1.1 |
|
1384 |
1.1 |
|
1394 |
1.1 |
|
1398 |
1.1 |
|
1399 |
1.1 |
|
1400 |
1.1 |
|
1411 |
1.1 |
|
1414 |
1.1 |
|
1415 |
1.1 2.2 3.3 4.4 |
|
1418 |
1.1 |
|
1423 |
1.1 |
|
1429 |
1.1 2.2 3.3 4.4 |
|
1430 |
1.1 |
|
1433 |
1.1 |
|
1434 |
1.1 2.2 3.3 |
|
1437 |
1.1 |
|
1441 |
1.1 |
|
1447 |
1.1 |
|
1448 |
1.1 2.2 |
|
1450 |
1.1 |
|
1452 |
1.1 |
|
1453 |
1.1 |
|
1455 |
1.1 |
|
1459 |
1.1 2.2 |
|
1463 |
1.1 |
|
1480 |
1.1 2.2 3.3 |
|
1482 |
1.1 |
|
1485 |
1.1 |
|
1487 |
1.1 |
|
1489 |
1.1 |
|
1490 |
1.1 2.2 3.3 |
|
1493 |
1.1 |
|
1497 |
1.1 |
|
1499 |
1.1 |
|
1500 |
1.1 |
|
1504 |
1.1 2.2 |
|
1521 |
1.1 2.2 3.3 |
|
1525 |
1.1 2.2 3.3 |
|
1527 |
1.1 |
|
1528 |
1.1 |
|
1545 |
1.1 |
|
1547 |
1.1 2.2 3.3 |
|
1550 |
1.1 |
|
1553 |
1.1 |
|
1555 |
1.1 2.2 |
|
1560 |
1.1 |
|
1571 |
1.1 |
|
1575 |
1.1 |
|
1576 |
1.1 |
|
1582 |
1.1 2.2 3.3 4.4 5.5 |
|
1584 |
1.1 |
|
1586 |
1.1 2.2 3.3 4.4 5.5 |
|
1599 |
1.1 |
|
1600 |
1.1 2.2 3.3 |
|
1603 |
1.1 |
|
1607 |
1.1 |
|
1608 |
1.1 |
|
1609 |
1.1 |
|
1613 |
1.1 2.2 |
|
1627 |
1.1 |
|
1629 |
1.1 |