diff options
Diffstat (limited to 'Build/source/libs/icu-xetex/test/letest/PortableFontInstance.cpp')
-rw-r--r-- | Build/source/libs/icu-xetex/test/letest/PortableFontInstance.cpp | 45 |
1 files changed, 43 insertions, 2 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); |