diff options
Diffstat (limited to 'test/subsetter_impl.cc')
-rw-r--r-- | test/subsetter_impl.cc | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/test/subsetter_impl.cc b/test/subsetter_impl.cc index 572f00e..f82a674 100644 --- a/test/subsetter_impl.cc +++ b/test/subsetter_impl.cc @@ -28,6 +28,7 @@ #include "sfntly/table/truetype/loca_table.h" #include "sfntly/tag.h" #include "sfntly/data/memory_byte_array.h" +#include "sfntly/port/memory_input_stream.h" #include "sfntly/port/memory_output_stream.h" namespace sfntly { @@ -81,14 +82,14 @@ SubsetterImpl::~SubsetterImpl() { bool SubsetterImpl::LoadFont(const char* font_name, const unsigned char* original_font, size_t font_size) { - ByteArrayPtr raw_font = - new MemoryByteArray((byte_t*)original_font, font_size); + MemoryInputStream mis; + mis.Attach(original_font, font_size); if (factory_ == NULL) { factory_.Attach(FontFactory::GetInstance()); } FontArray font_array; - factory_->LoadFonts(raw_font, &font_array); + factory_->LoadFonts(&mis, &font_array); font_ = FindFont(font_name, font_array); if (font_ == NULL) { return false; @@ -223,7 +224,7 @@ bool SubsetterImpl::ResolveCompositeGlyphs(const unsigned int* glyph_ids, IntegerSet comp_glyph_id; for (IntegerSet::iterator i = glyph_id_remaining.begin(), e = glyph_id_remaining.end(); i != e; ++i) { - if (*i < 0 || *i >= loca_table->NumGlyphs()) { + if (*i < 0 || *i >= loca_table->num_glyphs()) { // Invalid glyph id, ignore. continue; } @@ -285,7 +286,7 @@ CALLER_ATTACH Font* SubsetterImpl::Subset(const IntegerSet& glyph_ids) { // Extract glyphs and setup loca list. IntegerList loca_list; - loca_list.resize(loca_table->NumGlyphs()); + loca_list.resize(loca_table->num_glyphs()); loca_list.push_back(0); int32_t last_glyph_id = 0; int32_t last_offset = 0; @@ -302,7 +303,7 @@ CALLER_ATTACH Font* SubsetterImpl::Subset(const IntegerSet& glyph_ids) { // Add glyph to new glyf table. ReadableFontDataPtr data = glyph->ReadFontData(); WritableFontDataPtr copy_data; - copy_data.Attach(font_builder->GetNewData(data->Length())); + copy_data.Attach(WritableFontData::CreateWritableFontData(data->Length())); data->CopyTo(copy_data); GlyphBuilderPtr glyph_builder; glyph_builder.Attach(glyph_table_builder->GlyphBuilder(copy_data)); @@ -316,14 +317,14 @@ CALLER_ATTACH Font* SubsetterImpl::Subset(const IntegerSet& glyph_ids) { loca_list[*i + 1] = last_offset; last_glyph_id = *i; } - for (int32_t j = last_glyph_id + 1; j <= loca_table->NumGlyphs(); ++j) { + for (int32_t j = last_glyph_id + 1; j <= loca_table->num_glyphs(); ++j) { loca_list[j] = last_offset; } loca_table_builder->SetLocaList(&loca_list); // Setup remaining builders. - for (TableMap::iterator i = font_->Tables()->begin(), - e = font_->Tables()->end(); i != e; ++i) { + for (TableMap::const_iterator i = font_->GetTableMap()->begin(), + e = font_->GetTableMap()->end(); i != e; ++i) { // We already build the builder for glyph and loca. if (i->first != Tag::glyf && i->first != Tag::loca) { font_builder->NewTableBuilder(i->first, i->second->ReadFontData()); |