Fix TTC header handling
Also change the Version type to avoid similar bugs in the future. Reported by Grigori Goronzy.
This commit is contained in:
parent
21deab2bdc
commit
4f28fbdd80
|
@ -152,7 +152,7 @@ struct TTCHeader
|
||||||
|
|
||||||
inline unsigned int get_face_count (void) const
|
inline unsigned int get_face_count (void) const
|
||||||
{
|
{
|
||||||
switch (u.header.version) {
|
switch (u.header.version.major) {
|
||||||
case 2: /* version 2 is compatible with version 1 */
|
case 2: /* version 2 is compatible with version 1 */
|
||||||
case 1: return u.version1.get_face_count ();
|
case 1: return u.version1.get_face_count ();
|
||||||
default:return 0;
|
default:return 0;
|
||||||
|
@ -160,7 +160,7 @@ struct TTCHeader
|
||||||
}
|
}
|
||||||
inline const OpenTypeFontFace& get_face (unsigned int i) const
|
inline const OpenTypeFontFace& get_face (unsigned int i) const
|
||||||
{
|
{
|
||||||
switch (u.header.version) {
|
switch (u.header.version.major) {
|
||||||
case 2: /* version 2 is compatible with version 1 */
|
case 2: /* version 2 is compatible with version 1 */
|
||||||
case 1: return u.version1.get_face (i);
|
case 1: return u.version1.get_face (i);
|
||||||
default:return Null(OpenTypeFontFace);
|
default:return Null(OpenTypeFontFace);
|
||||||
|
@ -170,7 +170,7 @@ struct TTCHeader
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) {
|
inline bool sanitize (hb_sanitize_context_t *c) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
if (unlikely (!u.header.version.sanitize (c))) return false;
|
if (unlikely (!u.header.version.sanitize (c))) return false;
|
||||||
switch (u.header.version) {
|
switch (u.header.version.major) {
|
||||||
case 2: /* version 2 is compatible with version 1 */
|
case 2: /* version 2 is compatible with version 1 */
|
||||||
case 1: return u.version1.sanitize (c);
|
case 1: return u.version1.sanitize (c);
|
||||||
default:return true;
|
default:return true;
|
||||||
|
|
|
@ -488,7 +488,7 @@ struct CheckSum : ULONG
|
||||||
|
|
||||||
struct FixedVersion
|
struct FixedVersion
|
||||||
{
|
{
|
||||||
inline operator uint32_t (void) const { return (major << 16) + minor; }
|
inline uint32_t to_int (void) const { return (major << 16) + minor; }
|
||||||
|
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) {
|
inline bool sanitize (hb_sanitize_context_t *c) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
|
|
|
@ -360,9 +360,9 @@ struct GDEF
|
||||||
hb_position_t *caret_array /* OUT */) const
|
hb_position_t *caret_array /* OUT */) const
|
||||||
{ return (this+ligCaretList).get_lig_carets (font, direction, glyph_id, start_offset, caret_count, caret_array); }
|
{ return (this+ligCaretList).get_lig_carets (font, direction, glyph_id, start_offset, caret_count, caret_array); }
|
||||||
|
|
||||||
inline bool has_mark_sets (void) const { return version >= 0x00010002 && markGlyphSetsDef[0] != 0; }
|
inline bool has_mark_sets (void) const { return version.to_int () >= 0x00010002 && markGlyphSetsDef[0] != 0; }
|
||||||
inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const
|
inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const
|
||||||
{ return version >= 0x00010002 && (this+markGlyphSetsDef[0]).covers (set_index, glyph_id); }
|
{ return version.to_int () >= 0x00010002 && (this+markGlyphSetsDef[0]).covers (set_index, glyph_id); }
|
||||||
|
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) {
|
inline bool sanitize (hb_sanitize_context_t *c) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
|
@ -371,7 +371,7 @@ struct GDEF
|
||||||
&& attachList.sanitize (c, this)
|
&& attachList.sanitize (c, this)
|
||||||
&& ligCaretList.sanitize (c, this)
|
&& ligCaretList.sanitize (c, this)
|
||||||
&& markAttachClassDef.sanitize (c, this)
|
&& markAttachClassDef.sanitize (c, this)
|
||||||
&& (version < 0x00010002 || markGlyphSetsDef[0].sanitize (c, this));
|
&& (version.to_int () < 0x00010002 || markGlyphSetsDef[0].sanitize (c, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue