parent
c0383c6bb7
commit
b11830c09e
|
@ -528,24 +528,22 @@ struct StateTable
|
||||||
|
|
||||||
struct ClassTable
|
struct ClassTable
|
||||||
{
|
{
|
||||||
inline unsigned int get_class (hb_codepoint_t glyph_id) const
|
inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int outOfRange=0) const
|
||||||
{
|
{
|
||||||
return firstGlyph <= glyph_id && glyph_id - firstGlyph < glyphCount ? classArrayZ[glyph_id - firstGlyph] : 1;
|
unsigned int i = glyph_id - firstGlyph;
|
||||||
|
return i >= classArray.len ? outOfRange : classArray.arrayZ[i];
|
||||||
}
|
}
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) const
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||||
{
|
{
|
||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
return_trace (c->check_struct (this) && classArrayZ.sanitize (c, glyphCount));
|
return_trace (c->check_struct (this) && classArray.sanitize (c));
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
GlyphID firstGlyph; /* First glyph index included in the trimmed array. */
|
GlyphID firstGlyph; /* First glyph index included in the trimmed array. */
|
||||||
HBUINT16 glyphCount; /* Total number of glyphs (equivalent to the last
|
ArrayOf<HBUINT8> classArray; /* The class codes (indexed by glyph index minus
|
||||||
* glyph minus the value of firstGlyph plus 1). */
|
* firstGlyph). */
|
||||||
UnsizedArrayOf<HBUINT8>
|
|
||||||
classArrayZ; /* The class codes (indexed by glyph index minus
|
|
||||||
* firstGlyph). */
|
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_ARRAY (4, classArrayZ);
|
DEFINE_SIZE_ARRAY (4, classArray);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MortTypes
|
struct MortTypes
|
||||||
|
@ -557,7 +555,7 @@ struct MortTypes
|
||||||
{
|
{
|
||||||
inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int num_glyphs HB_UNUSED) const
|
inline unsigned int get_class (hb_codepoint_t glyph_id, unsigned int num_glyphs HB_UNUSED) const
|
||||||
{
|
{
|
||||||
return ClassTable::get_class (glyph_id);
|
return ClassTable::get_class (glyph_id, 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -319,44 +319,21 @@ struct KernSubTableFormat1
|
||||||
DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 10);
|
DEFINE_SIZE_STATIC (KernSubTableHeader::static_size + 10);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct KernClassTable
|
|
||||||
{
|
|
||||||
inline unsigned int get_class (hb_codepoint_t g) const { return classes[g - firstGlyph]; }
|
|
||||||
|
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) const
|
|
||||||
{
|
|
||||||
TRACE_SANITIZE (this);
|
|
||||||
return_trace (c->check_struct (this) &&
|
|
||||||
classes.sanitize (c));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
HBUINT16 firstGlyph; /* First glyph in class range. */
|
|
||||||
ArrayOf<HBUINT16> classes; /* Glyph classes. */
|
|
||||||
public:
|
|
||||||
DEFINE_SIZE_ARRAY (4, classes);
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename KernSubTableHeader>
|
template <typename KernSubTableHeader>
|
||||||
struct KernSubTableFormat2
|
struct KernSubTableFormat2
|
||||||
{
|
{
|
||||||
inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right,
|
inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right,
|
||||||
AAT::hb_aat_apply_context_t *c) const
|
AAT::hb_aat_apply_context_t *c) const
|
||||||
{
|
{
|
||||||
/* This subtable is disabled. It's not cleaer to me *exactly* where the offests are
|
/* Disabled until we find a font to test this. Note that OT vs AAT specify
|
||||||
* based from. I *think* they should be based from beginning of kern subtable wrapper,
|
* different ClassTable. OT's has 16bit entries, while AAT has 8bit entries.
|
||||||
* *NOT* "this". Since we know of no fonts that use this subtable, we are disabling
|
* I've not seen any in the wild. */
|
||||||
* it. Someday fix it and re-enable. */
|
|
||||||
return 0;
|
return 0;
|
||||||
unsigned int l = (this+leftClassTable).get_class (left);
|
unsigned int l = (this+leftClassTable).get_class (left);
|
||||||
unsigned int r = (this+rightClassTable).get_class (right);
|
unsigned int r = (this+rightClassTable).get_class (right);
|
||||||
unsigned int offset = l + r;
|
unsigned int offset = l + r;
|
||||||
const FWORD *v = &StructAtOffset<FWORD> (&(this+array), offset);
|
const FWORD *v = &StructAtOffset<FWORD> (&(this+array), offset);
|
||||||
#if 0
|
if (unlikely (!v->sanitize (&c->sanitizer))) return 0;
|
||||||
if (unlikely ((const char *) v < (const char *) &array ||
|
|
||||||
(const char *) v > (const char *) end - 2))
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
return *v;
|
return *v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,9 +377,9 @@ struct KernSubTableFormat2
|
||||||
protected:
|
protected:
|
||||||
KernSubTableHeader header;
|
KernSubTableHeader header;
|
||||||
HBUINT16 rowWidth; /* The width, in bytes, of a row in the table. */
|
HBUINT16 rowWidth; /* The width, in bytes, of a row in the table. */
|
||||||
OffsetTo<KernClassTable> leftClassTable; /* Offset from beginning of this subtable to
|
OffsetTo<AAT::ClassTable> leftClassTable; /* Offset from beginning of this subtable to
|
||||||
* left-hand class table. */
|
* left-hand class table. */
|
||||||
OffsetTo<KernClassTable> rightClassTable;/* Offset from beginning of this subtable to
|
OffsetTo<AAT::ClassTable> rightClassTable;/* Offset from beginning of this subtable to
|
||||||
* right-hand class table. */
|
* right-hand class table. */
|
||||||
OffsetTo<FWORD> array; /* Offset from beginning of this subtable to
|
OffsetTo<FWORD> array; /* Offset from beginning of this subtable to
|
||||||
* the start of the kerning array. */
|
* the start of the kerning array. */
|
||||||
|
|
Loading…
Reference in New Issue