main/vcl/source/fontsubset/cff.cxx
// access a CID's FDSelect table
access a CID's FDSelect table
access a CID ' s FDSelect table
int CffSubsetterContext::getFDSelect( int nGlyphIndex) const
{
	assert( nGlyphIndex >= 0);
	assert( nGlyphIndex < mnCharStrCount);
	if( !mbCIDFont)
		return 0;
	const U8* pReadPtr = mpBasePtr + mnFDSelectBase;
	const U8 nFDSelFormat = *(pReadPtr++);
	switch( nFDSelFormat) {
		case 0: { 
				pReadPtr += nGlyphIndex;
				const U8 nFDIdx = *(pReadPtr++);
				return nFDIdx;
			} 
		case 3: { 
				const U16 nRangeCount = (pReadPtr[0]<<8) + pReadPtr[1];
				assert( nRangeCount > 0);
				assert( nRangeCount <= mnCharStrCount);
				U16 nPrev = (pReadPtr[2]<<8) + pReadPtr[3];
				assert( nPrev == 0);
				pReadPtr += 4;
				for( int i = 0; i < nRangeCount; ++i) {
					const U8 nFDIdx = pReadPtr[0];
					const U16 nNext = (pReadPtr[1]<<8) + pReadPtr[2];
					assert( nPrev < nNext);
					if( nGlyphIndex < nNext)
						return nFDIdx;
					pReadPtr += 3;
					nPrev = nNext;
				}
			} break;
		default:	
			fprintf( stderr, "invalid CFF.FdselType=%d\n", nFDSelFormat);
			break;
	}
	assert( false);
	return -1;
}
int CffSubsetterContext :: getFDSelect ( int nGlyphIndex ) const { assert ( nGlyphIndex >= 0 ) ; assert ( nGlyphIndex < mnCharStrCount ) ; if ( ! mbCIDFont ) return 0 ; const U8 * pReadPtr = mpBasePtr + mnFDSelectBase ; const U8 nFDSelFormat = * ( pReadPtr ++ ) ; switch ( nFDSelFormat ) { case 0 : { pReadPtr += nGlyphIndex ; const U8 nFDIdx = * ( pReadPtr ++ ) ; return nFDIdx ; } case 3 : { const U16 nRangeCount = ( pReadPtr [ 0 ] << 8 ) + pReadPtr [ 1 ] ; assert ( nRangeCount > 0 ) ; assert ( nRangeCount <= mnCharStrCount ) ; U16 nPrev = ( pReadPtr [ 2 ] << 8 ) + pReadPtr [ 3 ] ; assert ( nPrev == 0 ) ; pReadPtr += 4 ; for ( int i = 0 ; i < nRangeCount ; ++ i ) { const U8 nFDIdx = pReadPtr [ 0 ] ; const U16 nNext = ( pReadPtr [ 1 ] << 8 ) + pReadPtr [ 2 ] ; assert ( nPrev < nNext ) ; if ( nGlyphIndex < nNext ) return nFDIdx ; pReadPtr += 3 ; nPrev = nNext ; } } break ; default : fprintf ( stderr , " \n " , nFDSelFormat ) ; break ; } assert ( false ) ; return -1 ; }
access a CID's FDSelect table
access a CID ' s FDSelect table
// FDSELECT format 0 //break; // FDSELECT format 3 // TODO? binary search // invalid FDselect format