2
2
3
3
import com .itextpdf .io .IOException ;
4
4
import com .itextpdf .io .source .RandomAccessFileOrArray ;
5
+ import com .itextpdf .io .util .GenericArray ;
5
6
6
7
import java .util .ArrayList ;
7
8
import java .util .HashMap ;
@@ -68,11 +69,11 @@ public class CFFFontSubset extends CFFFont {
68
69
/**
69
70
* A Maps array for keeping the subroutines used in each FontDict
70
71
*/
71
- Map < Integer , int []>[] hSubrsUsed ;
72
+ GenericArray < HashMap < Integer , int []>> hSubrsUsed ;
72
73
/**
73
74
* The SubroutinesUsed Maps as lists
74
75
*/
75
- List <Integer >[] lSubrsUsed ;
76
+ GenericArray < List <Integer >> lSubrsUsed ;
76
77
/**
77
78
* A Map for keeping the Global subroutines used in the font
78
79
*/
@@ -390,8 +391,8 @@ protected void BuildNewLGSubrs(int Font) throws java.io.IOException {
390
391
if (fonts [Font ].isCID ) {
391
392
// Init the Map-array and the list-array to hold the subrs used
392
393
// in each private dict.
393
- hSubrsUsed = new HashMap [ fonts [Font ].fdprivateOffsets .length ] ;
394
- lSubrsUsed = new ArrayList [ fonts [Font ].fdprivateOffsets .length ] ;
394
+ hSubrsUsed = new GenericArray <>( fonts [Font ].fdprivateOffsets .length ) ;
395
+ lSubrsUsed = new GenericArray <>( fonts [Font ].fdprivateOffsets .length ) ;
395
396
// A [][] which will store the byte array for each new FD Array lsubs index
396
397
NewLSubrsIndex = new byte [fonts [Font ].fdprivateOffsets .length ][];
397
398
// An array to hold the offset for each Lsubr index
@@ -405,18 +406,18 @@ protected void BuildNewLGSubrs(int Font) throws java.io.IOException {
405
406
for (int j = 0 ; j < FDInList .size (); j ++) {
406
407
// The FDArray index, Map, List to work on
407
408
int FD = FDInList .get (j );
408
- hSubrsUsed [ FD ] = new HashMap <>( );
409
- lSubrsUsed [ FD ] = new ArrayList <>( );
409
+ hSubrsUsed . set ( FD , new HashMap <Integer , int []>() );
410
+ lSubrsUsed . set ( FD , new ArrayList <Integer >() );
410
411
//Reads the private dicts looking for the subr operator and
411
412
// store both the offset for the index and its offset array
412
413
BuildFDSubrsOffsets (Font , FD );
413
414
// Verify that FDPrivate has a LSubrs index
414
415
if (fonts [Font ].PrivateSubrsOffset [FD ] >= 0 ) {
415
416
//Scans the Charstring data storing the used Local and Global subroutines
416
417
// by the glyphs. Scans the Subrs recursively.
417
- BuildSubrUsed (Font , FD , fonts [Font ].PrivateSubrsOffset [FD ], fonts [Font ].PrivateSubrsOffsetsArray [FD ], hSubrsUsed [ FD ] , lSubrsUsed [ FD ] );
418
+ BuildSubrUsed (Font , FD , fonts [Font ].PrivateSubrsOffset [FD ], fonts [Font ].PrivateSubrsOffsetsArray [FD ], hSubrsUsed . get ( FD ) , lSubrsUsed . get ( FD ) );
418
419
// Builds the New Local Subrs index
419
- NewLSubrsIndex [FD ] = BuildNewIndex (fonts [Font ].PrivateSubrsOffsetsArray [FD ], hSubrsUsed [ FD ] , RETURN_OP );
420
+ NewLSubrsIndex [FD ] = BuildNewIndex (fonts [Font ].PrivateSubrsOffsetsArray [FD ], hSubrsUsed . get ( FD ) , RETURN_OP );
420
421
}
421
422
}
422
423
}
@@ -614,7 +615,7 @@ protected void ReadASubr(int begin, int end, int GBias, int LBias, Map<Integer,
614
615
// If the subr isn't in the Map -> Put in
615
616
if (!hGSubrsUsed .containsKey (Subr )) {
616
617
hGSubrsUsed .put (Subr , null );
617
- boolean add = lGSubrsUsed .add (Integer . valueOf ( Subr ) );
618
+ lGSubrsUsed .add (Subr );
618
619
}
619
620
CalcHints (gsubrOffsets [Subr ], gsubrOffsets [Subr + 1 ], LBias , GBias , LSubrsOffsets );
620
621
seek (pos );
@@ -949,8 +950,10 @@ protected byte[] AssembleIndex(int[] NewOffsets, byte[] NewObjects) {
949
950
// The counter for writing
950
951
int Place = 0 ;
951
952
// Write the count field
952
- NewIndex [Place ++] = (byte ) (Count >>> 8 & 0xff );
953
- NewIndex [Place ++] = (byte ) (Count >>> 0 & 0xff );
953
+ // There is no sense in >>> for char
954
+ // NewIndex[Place++] = (byte) (Count >>> 8 & 0xff);
955
+ NewIndex [Place ++] = (byte ) (Count >> 8 & 0xff );
956
+ NewIndex [Place ++] = (byte ) (Count & 0xff );
954
957
// Write the offsize field
955
958
NewIndex [Place ++] = Offsize ;
956
959
// Write the offset array according to the offsize
@@ -1036,7 +1039,7 @@ protected byte[] BuildNewFile(int Font) {
1036
1039
) {
1037
1040
} else {
1038
1041
//OtherWise copy key "as is" to the output list
1039
- OutputList .add (new RangeItem (buf , p1 , p2 - p1 ));
1042
+ OutputList .addLast (new RangeItem (buf , p1 , p2 - p1 ));
1040
1043
}
1041
1044
}
1042
1045
// Create the FDArray, FDSelect, Charset and CharStrings Keys
0 commit comments