#include "name.h" #include "../reader/buffer.h" #include NameTable::NameTable(reader *rd, uint16_t length){ read(rd, length); } void NameTable::readHeader(reader* rd){ header.read(rd); } void NameTable::read(reader* rd, uint16_t length){ header.read(rd); //read header for(auto i = 0; iseek(header.getStorageOffset())){ throw "file len too low"; } auto len = length - header.getStorageOffset(); auto data = rd->readString(len); buffer storageReader(data); for(auto it : header.getNameRecords()){ readName(&storageReader, it); } } void NameTable::readRecord(reader* rd){ nameRecord nr; nr.platformId = rd->readUint16(); nr.encodingId = rd->readUint16(); nr.languageId = rd->readUint16(); nr.nameId = rd->readUint16(); nr.length = rd->readUint16(); nr.offset = rd->readUint16(); nr.display(); header.addNameRecord(nr); } void NameTable::readName(reader* rd, nameRecord nr){ if(!rd->seek(nr.offset)){ return; } std::string s = rd->readString(nr.length); names[nr.nameId] = s; } void NameTable::display(){ std::cout<<"this is the name infomation of the font:"<