generated from bing/readnotes
90 lines
1.9 KiB
C++
90 lines
1.9 KiB
C++
#include "table.h"
|
|
#include "table_name.h"
|
|
#include "../reader/buffer.h"
|
|
#include <iostream>
|
|
void FontTable::display()
|
|
{
|
|
std::cout<<"table lists:"<<std::endl;
|
|
for(auto it : _tables){
|
|
std::cout<<"table "<<it.name<<" length:"<<it.length<<"\toffset:"<<it.offset<<"\tsum:"<<it.sum<<std::endl;
|
|
auto iter = tableNameMap.find(it.name);
|
|
if (iter == tableNameMap.end())
|
|
{
|
|
continue;
|
|
}
|
|
auto id = (*iter).second;
|
|
switch (id)
|
|
{
|
|
case name:
|
|
_name->display();
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
void FontTable::read(reader *rd, uint16_t count)
|
|
{
|
|
for (auto i = 0; i < count; i++)
|
|
{
|
|
table t;
|
|
t.name = rd->readString(4);
|
|
t.sum = rd->readUint32();
|
|
t.offset = rd->readUint32();
|
|
t.length = rd->readUint32();
|
|
_tables.push_back(t);
|
|
}
|
|
//读取表详情
|
|
for (auto it: _tables)
|
|
{
|
|
auto iter = tableNameMap.find(it.name);
|
|
if (iter == tableNameMap.end())
|
|
{
|
|
continue;
|
|
}
|
|
auto id = (*iter).second;
|
|
switch (id)
|
|
{
|
|
case tableName::name:
|
|
{
|
|
if(!rd->seek(it.offset)){
|
|
throw "seek file failed";
|
|
};
|
|
auto data = rd->readString(it.length);
|
|
buffer nameReader(data);
|
|
_name = new NameTable();
|
|
_name->read(&nameReader, it.length);
|
|
}
|
|
break;
|
|
case tableName::cmap:
|
|
{
|
|
|
|
break;
|
|
}
|
|
case tableName::BASE:
|
|
{
|
|
break;
|
|
}
|
|
case tableName::head:
|
|
{
|
|
break;
|
|
}
|
|
case tableName::maxp:
|
|
{
|
|
break;
|
|
}
|
|
case tableName::glyf:
|
|
{
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
std::vector<table> FontTable::tables(){
|
|
return _tables;
|
|
} |