protected void readFDSelect ( int Font ) { // Restore the number of glyphs int NumOfGlyphs = fonts [ Font ] . nglyphs ; int [ ] FDSelect = new int [ NumOfGlyphs ] ; // Go to the beginning of the FDSelect seek ( fonts [ Font ] . fdselectOffset ) ; // Read the FDSelect's format fonts [ Font ] . FDSelectFormat = getCard8 ( ) ; switch ( fonts [ Font ] . FDSelectFormat ) { // Format==0 means each glyph has an entry that indicated // its FD. case 0 : for ( int i = 0 ; i < NumOfGlyphs ; i ++ ) { FDSelect [ i ] = getCard8 ( ) ; } // The FDSelect's Length is one for each glyph + the format // for later use fonts [ Font ] . FDSelectLength = fonts [ Font ] . nglyphs + 1 ; break ; case 3 : // Format==3 means the ranges version // The number of ranges int nRanges = getCard16 ( ) ; int l = 0 ; // Read the first in the first range int first = getCard16 ( ) ; for ( int i = 0 ; i < nRanges ; i ++ ) { // Read the FD index int fd = getCard8 ( ) ; // Read the first of the next range int last = getCard16 ( ) ; // Calc the steps and write to the array int steps = last - first ; for ( int k = 0 ; k < steps ; k ++ ) { FDSelect [ l ] = fd ; l ++ ; } // The last from this iteration is the first of the next first = last ; } // Store the length for later use fonts [ Font ] . FDSelectLength = 1 + 2 + nRanges * 3 + 2 ; break ; default : break ; } // Save the FDSelect of the font fonts [ Font ] . FDSelect = FDSelect ; }
Read the FDSelect of the font and compute the array and its length