+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;
+}
+