[cbdt] More sanitize work
This commit is contained in:
parent
70eb2ff682
commit
ce09e90e15
@ -72,32 +72,6 @@ struct SBitLineMetrics
|
|||||||
DEFINE_SIZE_STATIC(12);
|
DEFINE_SIZE_STATIC(12);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BitmapSizeTable
|
|
||||||
{
|
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
||||||
{
|
|
||||||
TRACE_SANITIZE (this);
|
|
||||||
return_trace (c->check_struct (this) &&
|
|
||||||
horizontal.sanitize (c) &&
|
|
||||||
vertical.sanitize (c));
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG indexSubtableArrayOffset;
|
|
||||||
ULONG indexTablesSize;
|
|
||||||
ULONG numberOfIndexSubtables;
|
|
||||||
ULONG colorRef;
|
|
||||||
SBitLineMetrics horizontal;
|
|
||||||
SBitLineMetrics vertical;
|
|
||||||
USHORT startGlyphIndex;
|
|
||||||
USHORT endGlyphIndex;
|
|
||||||
BYTE ppemX;
|
|
||||||
BYTE ppemY;
|
|
||||||
BYTE bitDepth;
|
|
||||||
CHAR flags;
|
|
||||||
|
|
||||||
DEFINE_SIZE_STATIC(48);
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Index Subtables.
|
* Index Subtables.
|
||||||
*/
|
*/
|
||||||
@ -142,6 +116,12 @@ struct GlyphBitmapDataFormat17
|
|||||||
|
|
||||||
struct IndexSubtableArray
|
struct IndexSubtableArray
|
||||||
{
|
{
|
||||||
|
inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
|
||||||
|
{
|
||||||
|
TRACE_SANITIZE (this);
|
||||||
|
return_trace (c->check_struct (this)); // XXX
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const IndexSubtable* find_table (hb_codepoint_t glyph, unsigned int numTables) const
|
const IndexSubtable* find_table (hb_codepoint_t glyph, unsigned int numTables) const
|
||||||
{
|
{
|
||||||
@ -158,6 +138,37 @@ struct IndexSubtableArray
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
IndexSubtable indexSubtablesZ[VAR];
|
IndexSubtable indexSubtablesZ[VAR];
|
||||||
|
|
||||||
|
public:
|
||||||
|
DEFINE_SIZE_ARRAY(0, indexSubtablesZ);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BitmapSizeTable
|
||||||
|
{
|
||||||
|
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||||
|
{
|
||||||
|
TRACE_SANITIZE (this);
|
||||||
|
return_trace (c->check_struct (this) &&
|
||||||
|
indexSubtableArrayOffset.sanitize (c, base, numberOfIndexSubtables) &&
|
||||||
|
c->check_range (&(base+indexSubtableArrayOffset), indexTablesSize) &&
|
||||||
|
horizontal.sanitize (c) &&
|
||||||
|
vertical.sanitize (c));
|
||||||
|
}
|
||||||
|
|
||||||
|
OffsetTo<IndexSubtableArray, ULONG> indexSubtableArrayOffset;
|
||||||
|
ULONG indexTablesSize;
|
||||||
|
ULONG numberOfIndexSubtables;
|
||||||
|
ULONG colorRef;
|
||||||
|
SBitLineMetrics horizontal;
|
||||||
|
SBitLineMetrics vertical;
|
||||||
|
USHORT startGlyphIndex;
|
||||||
|
USHORT endGlyphIndex;
|
||||||
|
BYTE ppemX;
|
||||||
|
BYTE ppemY;
|
||||||
|
BYTE bitDepth;
|
||||||
|
CHAR flags;
|
||||||
|
|
||||||
|
DEFINE_SIZE_STATIC(48);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -175,7 +186,7 @@ struct CBLC
|
|||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
return_trace (c->check_struct (this) &&
|
return_trace (c->check_struct (this) &&
|
||||||
likely (version.major == 2 || version.major == 3) &&
|
likely (version.major == 2 || version.major == 3) &&
|
||||||
sizeTables.sanitize (c));
|
sizeTables.sanitize (c, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -262,30 +262,34 @@ struct hb_ot_face_cbdt_accelerator_t
|
|||||||
OT::StructAtOffset<OT::IndexSubHeader> (this->cblc, offsetToSubtable);
|
OT::StructAtOffset<OT::IndexSubHeader> (this->cblc, offsetToSubtable);
|
||||||
|
|
||||||
unsigned int imageDataOffset = header.imageDataOffset;
|
unsigned int imageDataOffset = header.imageDataOffset;
|
||||||
switch (header.indexFormat) {
|
switch (header.indexFormat)
|
||||||
case 1: {
|
{
|
||||||
const OT::IndexSubtableFormat1& format1 =
|
case 1:
|
||||||
OT::StructAtOffset<OT::IndexSubtableFormat1> (this->cblc, offsetToSubtable);
|
{
|
||||||
imageDataOffset += format1.offsetArrayZ[glyph - subtable->firstGlyphIndex];
|
const OT::IndexSubtableFormat1& format1 =
|
||||||
switch (header.imageFormat) {
|
OT::StructAtOffset<OT::IndexSubtableFormat1> (this->cblc, offsetToSubtable);
|
||||||
case 17: {
|
imageDataOffset += format1.offsetArrayZ[glyph - subtable->firstGlyphIndex];
|
||||||
const OT::GlyphBitmapDataFormat17& glyphFormat17 =
|
}
|
||||||
OT::StructAtOffset<OT::GlyphBitmapDataFormat17> (this->cbdt, imageDataOffset);
|
break;
|
||||||
extents->x_bearing = glyphFormat17.glyphMetrics.bearingX;
|
default:
|
||||||
extents->y_bearing = glyphFormat17.glyphMetrics.bearingY;
|
// TODO: Support other index subtable format.
|
||||||
extents->width = glyphFormat17.glyphMetrics.width;
|
return false;
|
||||||
extents->height = -glyphFormat17.glyphMetrics.height;
|
}
|
||||||
}
|
|
||||||
break;
|
switch (header.imageFormat)
|
||||||
default:
|
{
|
||||||
// TODO: Support other image formats.
|
case 17: {
|
||||||
return false;
|
const OT::GlyphBitmapDataFormat17& glyphFormat17 =
|
||||||
}
|
OT::StructAtOffset<OT::GlyphBitmapDataFormat17> (this->cbdt, imageDataOffset);
|
||||||
|
extents->x_bearing = glyphFormat17.glyphMetrics.bearingX;
|
||||||
|
extents->y_bearing = glyphFormat17.glyphMetrics.bearingY;
|
||||||
|
extents->width = glyphFormat17.glyphMetrics.width;
|
||||||
|
extents->height = -glyphFormat17.glyphMetrics.height;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// TODO: Support other index subtable format.
|
// TODO: Support other image formats.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert to the font units. */
|
/* Convert to the font units. */
|
||||||
|
Loading…
Reference in New Issue
Block a user