diff options
Diffstat (limited to 'Build/source/libs/icu-xetex/test/letest')
6 files changed, 109 insertions, 8 deletions
diff --git a/Build/source/libs/icu-xetex/test/letest/PortableFontInstance.cpp b/Build/source/libs/icu-xetex/test/letest/PortableFontInstance.cpp index 9f2fd0008b8..db5bf2fd16d 100644 --- a/Build/source/libs/icu-xetex/test/letest/PortableFontInstance.cpp +++ b/Build/source/libs/icu-xetex/test/letest/PortableFontInstance.cpp @@ -1,7 +1,7 @@ /* ******************************************************************************* * - * Copyright (C) 1999-2007, International Business Machines + * Copyright (C) 1999-2008, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -276,7 +276,7 @@ const char *PortableFontInstance::getNameString(le_uint16 nameID, le_uint16 plat for(le_int32 i = 0; i < fNameCount; i += 1) { const NameRecord *nameRecord = &fNAMETable->nameRecords[i]; - if (SWAPW(nameRecord->platformID) == platformID && SWAPW(nameRecord->encodingID == encodingID) && + if (SWAPW(nameRecord->platformID) == platformID && SWAPW(nameRecord->encodingID) == encodingID && SWAPW(nameRecord->languageID) == languageID && SWAPW(nameRecord->nameID) == nameID) { char *name = ((char *) fNAMETable) + fNameStringOffset + SWAPW(nameRecord->offset); le_uint16 length = SWAPW(nameRecord->length); @@ -292,11 +292,52 @@ const char *PortableFontInstance::getNameString(le_uint16 nameID, le_uint16 plat return NULL; } +const LEUnicode16 *PortableFontInstance::getUnicodeNameString(le_uint16 nameID, le_uint16 platformID, le_uint16 encodingID, le_uint16 languageID) const +{ + if (fNAMETable == NULL) { + LETag nameTag = LE_NAME_TABLE_TAG; + PortableFontInstance *realThis = (PortableFontInstance *) this; + + realThis->fNAMETable = (const NAMETable *) readFontTable(nameTag); + + if (realThis->fNAMETable != NULL) { + realThis->fNameCount = SWAPW(realThis->fNAMETable->count); + realThis->fNameStringOffset = SWAPW(realThis->fNAMETable->stringOffset); + } + } + + for(le_int32 i = 0; i < fNameCount; i += 1) { + const NameRecord *nameRecord = &fNAMETable->nameRecords[i]; + + if (SWAPW(nameRecord->platformID) == platformID && SWAPW(nameRecord->encodingID) == encodingID && + SWAPW(nameRecord->languageID) == languageID && SWAPW(nameRecord->nameID) == nameID) { + LEUnicode16 *name = (LEUnicode16 *) (((char *) fNAMETable) + fNameStringOffset + SWAPW(nameRecord->offset)); + le_uint16 length = SWAPW(nameRecord->length) / 2; + LEUnicode16 *result = NEW_ARRAY(LEUnicode16, length + 2); + + for (le_int32 c = 0; c < length; c += 1) { + result[c] = SWAPW(name[c]); + } + + result[length] = 0; + + return result; + } + } + + return NULL; +} + void PortableFontInstance::deleteNameString(const char *name) const { DELETE_ARRAY(name); } +void PortableFontInstance::deleteNameString(const LEUnicode16 *name) const +{ + DELETE_ARRAY(name); +} + void PortableFontInstance::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const { TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(glyph); diff --git a/Build/source/libs/icu-xetex/test/letest/PortableFontInstance.h b/Build/source/libs/icu-xetex/test/letest/PortableFontInstance.h index 028a861630b..e47cb65b197 100644 --- a/Build/source/libs/icu-xetex/test/letest/PortableFontInstance.h +++ b/Build/source/libs/icu-xetex/test/letest/PortableFontInstance.h @@ -2,7 +2,7 @@ /* ******************************************************************************* * - * Copyright (C) 1999-2007, International Business Machines + * Copyright (C) 1999-2008, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -75,8 +75,12 @@ public: virtual const char *getNameString(le_uint16 nameID, le_uint16 platform, le_uint16 encoding, le_uint16 language) const; + virtual const LEUnicode16 *getUnicodeNameString(le_uint16 nameID, le_uint16 platform, le_uint16 encoding, le_uint16 language) const; + virtual void deleteNameString(const char *name) const; + virtual void deleteNameString(const LEUnicode16 *name) const; + virtual le_int32 getUnitsPerEM() const; virtual le_uint32 getFontChecksum() const; diff --git a/Build/source/libs/icu-xetex/test/letest/gendata.cpp b/Build/source/libs/icu-xetex/test/letest/gendata.cpp index 58f8a1bb4a3..103fb4b6fdd 100644 --- a/Build/source/libs/icu-xetex/test/letest/gendata.cpp +++ b/Build/source/libs/icu-xetex/test/letest/gendata.cpp @@ -1,7 +1,7 @@ /* ******************************************************************************* * - * Copyright (C) 1999-2006, International Business Machines + * Copyright (C) 1999-2008, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -201,6 +201,19 @@ int main(int /*argc*/, char *argv[]) version = pfi->getNameString(NAME_VERSION_STRING, PLATFORM_MACINTOSH, MACINTOSH_ROMAN, MACINTOSH_ENGLISH); + // The standard recommends that the Macintosh Roman/English name string be present, but + // if it's not, try the Microsoft Unicode/English string. + if (version == NULL) { + const LEUnicode16 *uversion = pfi->getUnicodeNameString(NAME_VERSION_STRING, PLATFORM_MICROSOFT, MICROSOFT_UNICODE_BMP, MICROSOFT_ENGLISH); + + if (uversion != NULL) { + const UnicodeString usversion((const UChar *)uversion); + + version = getCString(&usversion); + pfi->deleteNameString(uversion); + } + } + fprintf(outputFile, " <test-font name=\"%s\" version=\"%s\" checksum=\"0x%8.8X\"/>\n\n", fontName, version, pfi->getFontChecksum()); diff --git a/Build/source/libs/icu-xetex/test/letest/gendata.xml b/Build/source/libs/icu-xetex/test/letest/gendata.xml index 7dcc9ac91e2..f4fde3775e9 100644 --- a/Build/source/libs/icu-xetex/test/letest/gendata.xml +++ b/Build/source/libs/icu-xetex/test/letest/gendata.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - Copyright (c) 1999-2007 International Business Machines + Copyright (c) 1999-2008 International Business Machines Corporation and others. All rights reserved. --> @@ -83,4 +83,23 @@ <test-case id="Hangul" script="hang"> <test-text>마만만</test-text> </test-case> -</layout-tests>
\ No newline at end of file + + <test-case id="Hebrew Mark Test" script="hebr"> + <test-font name="SBL_Hbrw.ttf"/> + <test-text>מָשְׁכֵנִיאַחֲרֶיךָנָּרוּצָההֱבִיאַנִיהַמֶּלֶךְחֲדָרָיונָגִילָהוְנִשְׂמְחָהבָּךְנַזְכִּירָהדֹדֶיךָמִיַּיִןמֵישָׁרִיםאֲהֵבוּךָ</test-text> + </test-case> + + <test-case id="Broken Font Test" script="hani" lang="ZHT"> + <test-font name="BMIN00M.TTF"/> + <test-text>中華人民共和國 臺灣</test-text> + </test-case> +</layout-tests> + <test-case id="Not Language Specific" script="latn"> + <test-font name="fp9r8a.otf"/> + <test-text>Ţhiş iş a ţeşţ.</test-text> + </test-case> + + <test-case id="Romaanian Language Specific" script="latn" lang="ROM"> + <test-font name="fp9r8a.otf"/> + <test-text>Ţhiş iş a ţeşţ.</test-text> + </test-case> diff --git a/Build/source/libs/icu-xetex/test/letest/letest.cpp b/Build/source/libs/icu-xetex/test/letest/letest.cpp index 59caf913df2..df9bf8da932 100644 --- a/Build/source/libs/icu-xetex/test/letest/letest.cpp +++ b/Build/source/libs/icu-xetex/test/letest/letest.cpp @@ -1,7 +1,7 @@ /* ******************************************************************************* * - * Copyright (C) 1999-2007, International Business Machines + * Copyright (C) 1999-2008, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -386,6 +386,19 @@ static void checkFontVersion(PortableFontInstance *fontInstance, const char *tes const char *fontVersionString = fontInstance->getNameString(NAME_VERSION_STRING, PLATFORM_MACINTOSH, MACINTOSH_ROMAN, MACINTOSH_ENGLISH); + // The standard recommends that the Macintosh Roman/English name string be present, but + // if it's not, try the Microsoft Unicode/English string. + if (fontVersionString == NULL) { + const LEUnicode16 *uversion = fontInstance->getUnicodeNameString(NAME_VERSION_STRING, PLATFORM_MICROSOFT, MICROSOFT_UNICODE_BMP, MICROSOFT_ENGLISH); + + if (uversion != NULL) { + const UnicodeString usversion((const UChar *)uversion); + + fontVersionString = getCString(&usversion); + fontInstance->deleteNameString(uversion); + } + } + log_info("Test %s: this may not be the same font used to generate the test data.\n", testID); log_info("Your font's version string is \"%s\"\n", fontVersionString); log_info("The expected version string is \"%s\"\n", testVersionString); diff --git a/Build/source/libs/icu-xetex/test/letest/sfnt.h b/Build/source/libs/icu-xetex/test/letest/sfnt.h index b0ffb306890..f83f9212e35 100644 --- a/Build/source/libs/icu-xetex/test/letest/sfnt.h +++ b/Build/source/libs/icu-xetex/test/letest/sfnt.h @@ -1,6 +1,6 @@ /*************************************************************************** * -* Copyright (C) 1998-2007, International Business Machines +* Copyright (C) 1998-2008, International Business Machines * Corporation and others. All Rights Reserved. * ************************************************************************/ @@ -383,6 +383,17 @@ enum MacintoshLanguageID MACINTOSH_ENGLISH = 0 }; +enum MicrosoftEncodingID +{ + MICROSOFT_UNICODE_BMP = 1, + MICROSOFT_UNICODE_FULL = 10 +}; + +enum MicrosoftLanguageID +{ + MICROSOFT_ENGLISH = 0x409 +}; + enum NameID { NAME_COPYRIGHT_NOTICE = 0, |