Changeset 328


Ignore:
Timestamp:
Mar 30, 2010, 11:11:05 PM (12 years ago)
Author:
dmik
Message:

branches/kmk: Poppler: Fixed: Decimal unicode char naming scheme was mistakenly treated as hexadecimal (e.g. in the built-in ZapfDingbats? encoding table).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/kmk/poppler/mypoppler/poppler/GfxFont.cc

    r277 r328  
    542542  char *charName;
    543543  GBool missing, hex;
     544  char alpha;
    544545  Unicode toUnicode[256];
    545546  CharCodeToUnicode *utu, *ctu2;
     
    827828
    828829  // pass 1: use the name-to-Unicode mapping table
    829   missing = hex = gFalse;
     830  missing = gFalse;
     831  hex = gTrue;
     832  alpha = -1;
    830833  for (code = 0; code < 256; ++code) {
    831834    if ((charName = enc[code])) {
     
    834837        // if it wasn't in the name-to-Unicode table, check for a
    835838        // name that looks like 'Axx' or 'xx', where 'A' is any letter
    836         // and 'xx' is two hex digits
    837         if ((strlen(charName) == 3 &&
    838              isalpha(charName[0]) &&
    839              isxdigit(charName[1]) && isxdigit(charName[2]) &&
    840              ((charName[1] >= 'a' && charName[1] <= 'f') ||
    841               (charName[1] >= 'A' && charName[1] <= 'F') ||
    842               (charName[2] >= 'a' && charName[2] <= 'f') ||
    843               (charName[2] >= 'A' && charName[2] <= 'F'))) ||
    844             (strlen(charName) == 2 &&
    845              isxdigit(charName[0]) && isxdigit(charName[1]) &&
    846              ((charName[0] >= 'a' && charName[0] <= 'f') ||
    847               (charName[0] >= 'A' && charName[0] <= 'F') ||
    848               (charName[1] >= 'a' && charName[1] <= 'f') ||
    849               (charName[1] >= 'A' && charName[1] <= 'F')))) {
    850           hex = gTrue;
     839        // and 'xx' is two hex digits. Be strict and assume that names are
     840    // consistent (i.e. either all are 'Axx' or 'xx')
     841    if (hex) {
     842      if (strlen(charName) == 3 &&
     843          isalpha(charName[0]) &&
     844          isxdigit(charName[1]) && isxdigit(charName[2]) &&
     845          ((charName[1] >= 'a' && charName[1] <= 'f') ||
     846           (charName[1] >= 'A' && charName[1] <= 'F') ||
     847           (charName[2] >= 'a' && charName[2] <= 'f') ||
     848           (charName[2] >= 'A' && charName[2] <= 'F'))) {
     849        if (alpha == -1)
     850          alpha = charName[0];
     851        else if (alpha != charName[0])
     852          hex = gFalse;
     853      } else
     854      if (strlen(charName) == 2 &&
     855          isxdigit(charName[0]) && isxdigit(charName[1]) &&
     856          ((charName[0] >= 'a' && charName[0] <= 'f') ||
     857           (charName[0] >= 'A' && charName[0] <= 'F') ||
     858           (charName[1] >= 'a' && charName[1] <= 'f') ||
     859           (charName[1] >= 'A' && charName[1] <= 'F'))) {
     860        if (alpha == -1)
     861          alpha = 0;
     862        else if (alpha != 0)
     863          hex = gFalse;
     864      } else {
     865          hex = gFalse;
     866      }
    851867        }
    852868        missing = gTrue;
Note: See TracChangeset for help on using the changeset viewer.