예제 #1
0
static NameRecordMatchers*
CreateCanonicalU16Matchers(const BigEndianUint16& aNameID)
{
  NameRecordMatchers *matchers = new NameRecordMatchers();

  // First, look for the English name (this will normally succeed).
  matchers->append(
    [=](const NameRecord *aNameRecord) {
        return aNameRecord->nameID == aNameID &&
               aNameRecord->languageID == CANONICAL_LANG_ID &&
               aNameRecord->platformID == PLATFORM_ID &&
               IsUTF16Encoding(aNameRecord);
    });

  // Second, look for all languages.
  matchers->append(
    [=](const NameRecord *aNameRecord) {
        return aNameRecord->nameID == aNameID &&
               aNameRecord->platformID == PLATFORM_ID &&
               IsUTF16Encoding(aNameRecord);
    });

#if defined(XP_MACOSX)
  // On Mac may be dealing with font that only has Microsoft name entries.
  matchers->append(
    [=](const NameRecord *aNameRecord) {
        return aNameRecord->nameID == aNameID &&
               aNameRecord->languageID == LANG_ID_MICROSOFT_EN_US &&
               aNameRecord->platformID == PLATFORM_ID_MICROSOFT &&
               IsUTF16Encoding(aNameRecord);
    });
  matchers->append(
    [=](const NameRecord *aNameRecord) {
        return aNameRecord->nameID == aNameID &&
               aNameRecord->platformID == PLATFORM_ID_MICROSOFT &&
               IsUTF16Encoding(aNameRecord);
    });
#endif

  return matchers;
}
예제 #2
0
static NameRecordMatchers *CreateCanonicalMatchers(
    const BigEndianUint16 &aNameID) {
  // For Windows, we return only Microsoft platform name record
  // matchers. On Mac, we return matchers for both Microsoft platform
  // records and Mac platform records.
  NameRecordMatchers *matchers = new NameRecordMatchers();

#if defined(XP_MACOSX)
  // First, look for the English name.
  if (!matchers->append([=](const NameRecord *aNameRecord) {
        if (aNameRecord->nameID == aNameID &&
            aNameRecord->languageID == LANG_ID_MAC_ENGLISH &&
            aNameRecord->platformID == PLATFORM_ID_MAC &&
            IsMacRomanEncoding(aNameRecord)) {
          return eNameDecoderMacRoman;
        } else {
          return eNameDecoderNone;
        }
      })) {
    MOZ_CRASH();
  }

  // Second, look for all languages.
  if (!matchers->append([=](const NameRecord *aNameRecord) {
        if (aNameRecord->nameID == aNameID &&
            aNameRecord->platformID == PLATFORM_ID_MAC &&
            IsMacRomanEncoding(aNameRecord)) {
          return eNameDecoderMacRoman;
        } else {
          return eNameDecoderNone;
        }
      })) {
    MOZ_CRASH();
  }
#endif /* defined(XP_MACOSX) */

  // First, look for the English name (this will normally succeed).
  if (!matchers->append([=](const NameRecord *aNameRecord) {
        if (aNameRecord->nameID == aNameID &&
            aNameRecord->languageID == LANG_ID_MICROSOFT_EN_US &&
            aNameRecord->platformID == PLATFORM_ID_MICROSOFT &&
            IsUTF16Encoding(aNameRecord)) {
          return eNameDecoderUTF16;
        } else {
          return eNameDecoderNone;
        }
      })) {
    MOZ_CRASH();
  }

  // Second, look for all languages.
  if (!matchers->append([=](const NameRecord *aNameRecord) {
        if (aNameRecord->nameID == aNameID &&
            aNameRecord->platformID == PLATFORM_ID_MICROSOFT &&
            IsUTF16Encoding(aNameRecord)) {
          return eNameDecoderUTF16;
        } else {
          return eNameDecoderNone;
        }
      })) {
    MOZ_CRASH();
  }

  return matchers;
}