Modest/source/myfont/maxp.c

70 lines
2.4 KiB
C
Raw Normal View History

2016-08-30 12:07:41 +03:00
/*
Copyright (C) 2016 Alexander Borisov
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Author: lex.borisov@gmail.com (Alexander Borisov)
*/
#include "myfont/maxp.h"
void myfont_load_table_maxp(myfont_font_t *mf)
{
memset(&mf->table_maxp, 0, sizeof(myfont_table_maxp_t));
2016-08-30 12:07:41 +03:00
if(mf->cache.tables_offset[MyFONT_TKEY_maxp] == 0)
return;
2016-08-30 12:07:41 +03:00
myfont_table_maxp_t *tmaxp = &mf->table_maxp;
const uint32_t table_offset = mf->cache.tables_offset[MyFONT_TKEY_maxp];
if((table_offset + 4) > mf->file_size)
return;
/* get current data */
uint8_t *data = &mf->file_data[table_offset];
tmaxp->version = myfont_read_u32_as_net(&data);
if(myfont_table_version_major(tmaxp->version) == 1)
2016-08-30 12:07:41 +03:00
{
if((table_offset + 4 + 28) > mf->file_size)
return;
tmaxp->numGlyphs = myfont_read_u16(&data);
tmaxp->maxPoints = myfont_read_u16(&data);
tmaxp->maxContours = myfont_read_u16(&data);
tmaxp->maxCompositePoints = myfont_read_u16(&data);
tmaxp->maxCompositeContours = myfont_read_u16(&data);
tmaxp->maxZones = myfont_read_u16(&data);
tmaxp->maxTwilightPoints = myfont_read_u16(&data);
tmaxp->maxStorage = myfont_read_u16(&data);
tmaxp->maxFunctionDefs = myfont_read_u16(&data);
tmaxp->maxInstructionDefs = myfont_read_u16(&data);
tmaxp->maxStackElements = myfont_read_u16(&data);
tmaxp->maxSizeOfInstructions = myfont_read_u16(&data);
tmaxp->maxComponentElements = myfont_read_u16(&data);
tmaxp->maxComponentDepth = myfont_read_u16(&data);
2016-08-30 12:07:41 +03:00
}
else {
if((table_offset + 4 + 2) > mf->file_size)
return;
2016-08-30 12:07:41 +03:00
tmaxp->numGlyphs = myfont_read_u16(&data);
2016-08-30 12:07:41 +03:00
}
}