for (constauto& i : tables) { const Font::Table& table = i.second; // This is a transformed table, we will write it together with the // original version. if (table.tag & 0x80808080) { continue;
}
output_order.push_back(table.tag);
}
// Alphabetize then put loca immediately after glyf auto glyf_loc = std::find(output_order.begin(), output_order.end(),
kGlyfTableTag); auto loca_loc = std::find(output_order.begin(), output_order.end(),
kLocaTableTag); if (glyf_loc != output_order.end() && loca_loc != output_order.end()) {
output_order.erase(loca_loc);
output_order.insert(std::find(output_order.begin(), output_order.end(),
kGlyfTableTag) + 1, kLocaTableTag);
}
return output_order;
}
bool ReadTrueTypeFont(Buffer* file, const uint8_t* data, size_t len,
Font* font) { // We don't care about the search_range, entry_selector and range_shift // fields, they will always be computed upon writing the font. if (!file->ReadU16(&font->num_tables) ||
!file->Skip(6)) { return FONT_COMPRESSION_FAILURE();
}
std::map<uint32_t, uint32_t> intervals; for (uint16_t i = 0; i < font->num_tables; ++i) {
Font::Table table;
table.flag_byte = 0;
table.reuse_of = NULL; if (!file->ReadU32(&table.tag) ||
!file->ReadU32(&table.checksum) ||
!file->ReadU32(&table.offset) ||
!file->ReadU32(&table.length)) { return FONT_COMPRESSION_FAILURE();
} if ((table.offset & 3) != 0 ||
table.length > len ||
len - table.length < table.offset) { return FONT_COMPRESSION_FAILURE();
}
intervals[table.offset] = table.length;
table.data = data + table.offset; if (font->tables.find(table.tag) != font->tables.end()) { return FONT_COMPRESSION_FAILURE();
}
font->tables[table.tag] = table;
}
// Check that tables are non-overlapping.
uint32_t last_offset = 12UL + 16UL * font->num_tables; for (constauto& i : intervals) { if (i.first < last_offset || i.first + i.second < i.first) { return FONT_COMPRESSION_FAILURE();
}
last_offset = i.first + i.second;
}
// It's simpler if this just a simple sfnt if (font_collection.flavor != kTtcFontFlavor) { return WriteFont(font_collection.fonts[0], &offset, dst, dst_size);
}
// Offset Table, zeroed for now
size_t offset_table = offset; // where to write offsets later for (size_t i = 0; i < font_collection.fonts.size(); i++) {
StoreU32(0, &offset, dst);
}
// Write fonts and their offsets. for (size_t i = 0; i < font_collection.fonts.size(); i++) { constauto& font = font_collection.fonts[i];
StoreU32(offset, &offset_table, dst); if (!WriteFont(font, &offset, dst, dst_size)) { returnfalse;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.