fixed off-by-one error with offSize
This commit is contained in:
parent
1499029a96
commit
5b453f77f8
|
@ -42,9 +42,10 @@ template<typename Type>
|
|||
static inline const Type& StructAtOffsetOrNull(const void *P, unsigned int offset)
|
||||
{ return offset? (* reinterpret_cast<const Type*> ((const char *) P + offset)): Null(Type); }
|
||||
|
||||
inline unsigned int calcOffSize(unsigned int offset)
|
||||
inline unsigned int calcOffSize(unsigned int dataSize)
|
||||
{
|
||||
unsigned int size = 1;
|
||||
unsigned int offset = dataSize + 1;
|
||||
while ((offset & ~0xFF) != 0)
|
||||
{
|
||||
size++;
|
||||
|
@ -493,7 +494,7 @@ struct FDArray : CFFIndexOf<COUNT, FontDict>
|
|||
if (!fdmap.excludes (i))
|
||||
dictsSize += FontDict::calculate_serialized_size (fontDicts[i], opszr);
|
||||
|
||||
offSize_ = calcOffSize (dictsSize + 1);
|
||||
offSize_ = calcOffSize (dictsSize);
|
||||
return CFFIndex<COUNT>::calculate_serialized_size (offSize_, fdCount, dictsSize);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -635,7 +635,7 @@ struct cff_subset_plan {
|
|||
if (!fdmap.excludes (i))
|
||||
dictsSize += FontDict::calculate_serialized_size (acc.fontDicts[i], fontSzr);
|
||||
|
||||
offsets.FDArrayInfo.offSize = calcOffSize (dictsSize + 1);
|
||||
offsets.FDArrayInfo.offSize = calcOffSize (dictsSize);
|
||||
final_size += CFF1Index::calculate_serialized_size (offsets.FDArrayInfo.offSize, subset_fdcount, dictsSize);
|
||||
}
|
||||
|
||||
|
@ -650,7 +650,7 @@ struct cff_subset_plan {
|
|||
subset_charstrings.push (str);
|
||||
dataSize += flatstr.len;
|
||||
}
|
||||
offsets.charStringsInfo.offSize = calcOffSize (dataSize + 1);
|
||||
offsets.charStringsInfo.offSize = calcOffSize (dataSize);
|
||||
final_size += CFF1CharStrings::calculate_serialized_size (offsets.charStringsInfo.offSize, plan->glyphs.len, dataSize);
|
||||
}
|
||||
|
||||
|
|
|
@ -269,7 +269,7 @@ struct cff2_subset_plan {
|
|||
subset_charstrings.push (str);
|
||||
dataSize += flatstr.len;
|
||||
}
|
||||
offsets.charStringsInfo.offSize = calcOffSize (dataSize + 1);
|
||||
offsets.charStringsInfo.offSize = calcOffSize (dataSize);
|
||||
final_size += CFF2CharStrings::calculate_serialized_size (offsets.charStringsInfo.offSize, plan->glyphs.len, dataSize);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue