Bug 1121448 - Ignore negative values in the OS/2 table sxHeight field. r=jdaggett

This commit is contained in:
Jonathan Kew 2015-01-19 10:03:54 +00:00
Родитель a9696ebf44
Коммит c64244245f
1 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -3232,12 +3232,12 @@ gfxFont::InitMetricsFromSfntTables(Metrics& aMetrics)
if (os2Table) {
const OS2Table *os2 =
reinterpret_cast<const OS2Table*>(hb_blob_get_data(os2Table, &len));
// although sxHeight is a signed field, we consider negative values to
// be erroneous and just ignore them
if (len >= offsetof(OS2Table, sxHeight) + sizeof(int16_t) &&
uint16_t(os2->version) >= 2) {
uint16_t(os2->version) >= 2 && int16_t(os2->sxHeight) > 0) {
// version 2 and later includes the x-height field
SET_SIGNED(xHeight, os2->sxHeight);
// Abs because of negative xHeight seen in Kokonor (Tibetan) font
aMetrics.xHeight = Abs(aMetrics.xHeight);
}
// this should always be present in any valid OS/2 of any version
if (len >= offsetof(OS2Table, sTypoLineGap) + sizeof(int16_t)) {