ReadCMAPTableFormat4(PRUint8* aBuf, PRInt32 aLength, PRUint32* aMap, PRUint8* aIsSpace, PRUint32 aMaxGlyph)
ReadCMAPTableFormat4(PRUint8* aBuf, PRInt32 aLength, PRUint32* aMap, PRBool aIsCFFOutline, PRUint8* aIsSpace, PRUint32 aMaxGlyph)
ReadCMAPTableFormat4(PRUint8* aBuf, PRInt32 aLength, PRUint32* aMap, PRUint8* aIsSpace, PRUint32 aMaxGlyph) {  PRUint8* p = aBuf;  PRUint8* end = aBuf + aLength;  PRUint32 i;  // XXX byte swapping only required for little endian (ifdef?)  while (p < end) {    PRUint8 tmp = p[0];    p[0] = p[1];    p[1] = tmp;    p += 2; // every two bytes  }  PRUint16* s = (PRUint16*) aBuf;  PRUint16 segCount = s[3] / 2;  PRUint16* endCode = &s[7];  PRUint16* startCode = endCode + segCount + 1;  PRUint16* idDelta = startCode + segCount;  PRUint16* idRangeOffset = idDelta + segCount;  for (i = 0; i < segCount; ++i) {    if (idRangeOffset[i]) {      PRUint16 startC = startCode[i];      PRUint16 endC = endCode[i];      for (PRUint32 c = startC; c <= endC; ++c) {        PRUint16* g =          (idRangeOffset[i]/2 + (c - startC) + &idRangeOffset[i]);        if ((PRUint8*) g < end) {          if (*g) {            PRUint16 glyph = idDelta[i] + *g;            if (glyph < aMaxGlyph) {              if (aIsSpace[glyph]) {                if (SHOULD_BE_SPACE_CHAR(c)) {                  ADD_GLYPH(aMap, c);                }               }              else {                ADD_GLYPH(aMap, c);              }            }          }          else {            // index 0 also applies to space character            if (SHOULD_BE_SPACE_CHAR(c))              ADD_GLYPH(aMap, c);          }        }        else {          // XXX should we trust this font at all if it does this?        }      }      //printf("0x%04X-0x%04X ", startC, endC);    }    else {      PRUint16 endC = endCode[i];      for (PRUint32 c = startCode[i]; c <= endC; ++c) {        PRUint16 glyph = idDelta[i] + c;        if (glyph < aMaxGlyph) {          if (aIsSpace[glyph]) {            if (SHOULD_BE_SPACE_CHAR(c)) {              ADD_GLYPH(aMap, c);            }          }          else {            ADD_GLYPH(aMap, c);          }        }      }      //printf("0x%04X-0x%04X ", startCode[i], endC);    }  }  //printf("\n");}