未验证 提交 b8b00fb3 编写于 作者: E Ebrahim Byagowi 提交者: GitHub

[aat] Support Lookup<OffsetTo<>>, needed by just and lcar (#1368)

上级 073d0a9f
......@@ -58,6 +58,11 @@ struct LookupFormat0
TRACE_SANITIZE (this);
return_trace (arrayZ.sanitize (c, c->get_num_glyphs ()));
}
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
TRACE_SANITIZE (this);
return_trace (arrayZ.sanitize (c, c->get_num_glyphs (), base));
}
protected:
HBUINT16 format; /* Format identifier--format = 0 */
......@@ -80,6 +85,11 @@ struct LookupSegmentSingle
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) && value.sanitize (c));
}
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) && value.sanitize (c, base));
}
GlyphID last; /* Last GlyphID in this segment */
GlyphID first; /* First GlyphID in this segment */
......@@ -105,6 +115,11 @@ struct LookupFormat2
TRACE_SANITIZE (this);
return_trace (segments.sanitize (c));
}
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
TRACE_SANITIZE (this);
return_trace (segments.sanitize (c, base));
}
protected:
HBUINT16 format; /* Format identifier--format = 2 */
......@@ -135,6 +150,14 @@ struct LookupSegmentArray
first <= last &&
valuesZ.sanitize (c, base, last - first + 1));
}
template <typename T2>
inline bool sanitize (hb_sanitize_context_t *c, const void *base, T2 user_data) const
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
first <= last &&
valuesZ.sanitize (c, base, last - first + 1, user_data));
}
GlyphID last; /* Last GlyphID in this segment */
GlyphID first; /* First GlyphID in this segment */
......@@ -162,6 +185,11 @@ struct LookupFormat4
TRACE_SANITIZE (this);
return_trace (segments.sanitize (c, this));
}
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
TRACE_SANITIZE (this);
return_trace (segments.sanitize (c, this, base));
}
protected:
HBUINT16 format; /* Format identifier--format = 4 */
......@@ -183,6 +211,11 @@ struct LookupSingle
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) && value.sanitize (c));
}
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) && value.sanitize (c, base));
}
GlyphID glyph; /* Last GlyphID */
T value; /* The lookup value (only one) */
......@@ -207,6 +240,11 @@ struct LookupFormat6
TRACE_SANITIZE (this);
return_trace (entries.sanitize (c));
}
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
TRACE_SANITIZE (this);
return_trace (entries.sanitize (c, base));
}
protected:
HBUINT16 format; /* Format identifier--format = 6 */
......@@ -233,6 +271,11 @@ struct LookupFormat8
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) && valueArrayZ.sanitize (c, glyphCount));
}
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) && valueArrayZ.sanitize (c, glyphCount, base));
}
protected:
HBUINT16 format; /* Format identifier--format = 8 */
......@@ -328,6 +371,20 @@ struct Lookup
default:return_trace (true);
}
}
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
TRACE_SANITIZE (this);
if (!u.format.sanitize (c)) return_trace (false);
switch (u.format) {
case 0: return_trace (u.format0.sanitize (c, base));
case 2: return_trace (u.format2.sanitize (c, base));
case 4: return_trace (u.format4.sanitize (c, base));
case 6: return_trace (u.format6.sanitize (c, base));
case 8: return_trace (u.format8.sanitize (c, base));
case 10: return_trace (false); /* No need to support format10 apparently */
default:return_trace (true);
}
}
protected:
union {
......
......@@ -833,6 +833,17 @@ struct VarSizedBinSearchArrayOf
return_trace (false);
return_trace (true);
}
template <typename T>
inline bool sanitize (hb_sanitize_context_t *c, const void *base, T user_data) const
{
TRACE_SANITIZE (this);
if (unlikely (!sanitize_shallow (c))) return_trace (false);
unsigned int count = header.nUnits;
for (unsigned int i = 0; i < count; i++)
if (unlikely (!(*this)[i].sanitize (c, base, user_data)))
return_trace (false);
return_trace (true);
}
template <typename T>
inline const Type *bsearch (const T &key) const
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册