void FSDefineFont::decodeFromStream(FSInputStream* aStream) { int glyphCount = 0; aStream->startDecoding(className()); FSDefineObject::decodeFromStream(aStream); glyphCount = aStream->scan(FSStream::UnsignedWord, 16) / 2; aStream->setCursor(aStream->getCursor()-16); #ifdef _DEBUG aStream->startDecoding("array"); #endif for (int i=0; i<glyphCount; i++) aStream->read(FSStream::UnsignedWord, 16); #ifdef _DEBUG aStream->endDecoding("array"); aStream->startDecoding("array"); #endif for (int i=0; i<glyphCount; i++) shapes.push_back(FSShape(aStream)); #ifdef _DEBUG aStream->endDecoding("array"); #endif aStream->endDecoding(className()); }
FSDefineShape3::FSDefineShape3(FSInputStream* aStream) : FSDefineObject(DefineShape3, 0), bounds(), fillStyles(), lineStyles(), shape(FSShape()) { decodeFromStream(aStream); }
void FSDefineFont2::decodeFromStream(FSInputStream* aStream) { bool containsWideOffsets = false; bool containsWideCodes = false; bool containsLayout = false; int glyphCount = 0; int kerningCount = 0; int nameLength = 0; int codeOffset = 0; aStream->startDecoding(className()); FSDefineObject::decodeFromStream(aStream); containsLayout = aStream->read(FSStream::UnsignedBit, 1) != 0 ? true : false; int format = aStream->read(FSStream::UnsignedBit, 3); if (format == 1) encoding = FSText::ANSI; else if (format == 2) small = true; else if (format == 4) encoding = FSText::SJIS; containsWideOffsets = aStream->read(FSStream::UnsignedBit, 1) != 0 ? true : false; containsWideCodes = aStream->read(FSStream::UnsignedBit, 1) != 0 ? true : false; aStream->setContext(FSStream::WideCodes, containsWideCodes); italic = aStream->read(FSStream::UnsignedBit, 1) != 0 ? true : false; bold = aStream->read(FSStream::UnsignedBit, 1) != 0 ? true : false; language = aStream->read(FSStream::UnsignedBit, 8); nameLength = aStream->read(FSStream::UnsignedWord, 8); char* dst = new char[nameLength+1]; char* src = (char*)aStream->read(nameLength); if (dst == 0) throw FSAllocationException("Cannot allocate memory for font name."); strncpy(dst, src, nameLength); dst[nameLength] = '\0'; name = dst; delete [] src; delete [] dst; glyphCount = aStream->read(FSStream::UnsignedWord, 16); #ifdef _DEBUG aStream->startDecoding("array"); #endif for (int i=0; i<glyphCount; i++) aStream->read(FSStream::UnsignedWord, (containsWideOffsets) ? 32 : 16); #ifdef _DEBUG aStream->endDecoding("array"); #endif codeOffset = aStream->read(FSStream::UnsignedWord, (containsWideOffsets) ? 32 : 16); #ifdef _DEBUG aStream->startDecoding("array"); #endif for (int i=0; i<glyphCount; i++) shapes.push_back(FSShape(aStream)); #ifdef _DEBUG aStream->endDecoding("array"); aStream->startDecoding("array"); #endif for (int i=0; i<glyphCount; i++) codes.push_back(aStream->read(FSStream::UnsignedWord, (containsWideCodes) ? 16 : 8)); #ifdef _DEBUG aStream->endDecoding("array"); #endif if (containsLayout) { ascent = aStream->read(FSStream::SignedWord, 16); descent = aStream->read(FSStream::SignedWord, 16); leading = aStream->read(FSStream::SignedWord, 16); #ifdef _DEBUG aStream->startDecoding("array"); #endif for (int i=0; i<glyphCount; i++) advances.push_back(aStream->read(FSStream::SignedWord, 16)); #ifdef _DEBUG aStream->endDecoding("array"); aStream->startDecoding("array"); #endif for (int i=0; i<glyphCount; i++) bounds.push_back(FSBounds(aStream)); #ifdef _DEBUG aStream->endDecoding("array"); #endif kerningCount = aStream->read(FSStream::UnsignedWord, 16); #ifdef _DEBUG aStream->startDecoding("array"); #endif for (int i=0; i<kerningCount; i++) kernings.push_back(FSKerning(aStream)); #ifdef _DEBUG aStream->endDecoding("array"); #endif } aStream->setContext(FSStream::WideCodes, 0); aStream->endDecoding(className()); }