[>64k:glyf] Implement composites for >64k
Implements https://github.com/be-fonts/boring-expansion-spec/issues/42
This commit is contained in:
parent
09de94788b
commit
7549d447ba
|
@ -25,13 +25,16 @@ struct CompositeGlyphRecord
|
||||||
USE_MY_METRICS = 0x0200,
|
USE_MY_METRICS = 0x0200,
|
||||||
OVERLAP_COMPOUND = 0x0400,
|
OVERLAP_COMPOUND = 0x0400,
|
||||||
SCALED_COMPONENT_OFFSET = 0x0800,
|
SCALED_COMPONENT_OFFSET = 0x0800,
|
||||||
UNSCALED_COMPONENT_OFFSET = 0x1000
|
UNSCALED_COMPONENT_OFFSET = 0x1000,
|
||||||
|
GID_IS_24BIT = 0x2000
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
unsigned int get_size () const
|
unsigned int get_size () const
|
||||||
{
|
{
|
||||||
unsigned int size = min_size;
|
unsigned int size = min_size;
|
||||||
|
/* glyphIndex is 24bit instead of 16bit */
|
||||||
|
if (flags & GID_IS_24BIT) size += HBGlyphID24::static_size - HBGlyphID16::static_size;
|
||||||
/* arg1 and 2 are int16 */
|
/* arg1 and 2 are int16 */
|
||||||
if (flags & ARG_1_AND_2_ARE_WORDS) size += 4;
|
if (flags & ARG_1_AND_2_ARE_WORDS) size += 4;
|
||||||
/* arg1 and 2 are int8 */
|
/* arg1 and 2 are int8 */
|
||||||
|
@ -60,7 +63,11 @@ struct CompositeGlyphRecord
|
||||||
bool is_anchored () const { return !(flags & ARGS_ARE_XY_VALUES); }
|
bool is_anchored () const { return !(flags & ARGS_ARE_XY_VALUES); }
|
||||||
void get_anchor_points (unsigned int &point1, unsigned int &point2) const
|
void get_anchor_points (unsigned int &point1, unsigned int &point2) const
|
||||||
{
|
{
|
||||||
const HBUINT8 *p = &StructAfter<const HBUINT8> (glyphIndex);
|
const auto *p = &StructAfter<const HBUINT8> (flags);
|
||||||
|
if (flags & GID_IS_24BIT)
|
||||||
|
p += HBGlyphID24::static_size;
|
||||||
|
else
|
||||||
|
p += HBGlyphID16::static_size;
|
||||||
if (flags & ARG_1_AND_2_ARE_WORDS)
|
if (flags & ARG_1_AND_2_ARE_WORDS)
|
||||||
{
|
{
|
||||||
point1 = ((const HBUINT16 *) p)[0];
|
point1 = ((const HBUINT16 *) p)[0];
|
||||||
|
@ -101,8 +108,12 @@ struct CompositeGlyphRecord
|
||||||
matrix[0] = matrix[3] = 1.f;
|
matrix[0] = matrix[3] = 1.f;
|
||||||
matrix[1] = matrix[2] = 0.f;
|
matrix[1] = matrix[2] = 0.f;
|
||||||
|
|
||||||
|
const auto *p = &StructAfter<const HBINT8> (flags);
|
||||||
|
if (flags & GID_IS_24BIT)
|
||||||
|
p += HBGlyphID24::static_size;
|
||||||
|
else
|
||||||
|
p += HBGlyphID16::static_size;
|
||||||
int tx, ty;
|
int tx, ty;
|
||||||
const HBINT8 *p = &StructAfter<const HBINT8> (glyphIndex);
|
|
||||||
if (flags & ARG_1_AND_2_ARE_WORDS)
|
if (flags & ARG_1_AND_2_ARE_WORDS)
|
||||||
{
|
{
|
||||||
tx = *(const HBINT16 *) p;
|
tx = *(const HBINT16 *) p;
|
||||||
|
@ -145,12 +156,25 @@ struct CompositeGlyphRecord
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
hb_codepoint_t get_gid () const { return glyphIndex; }
|
hb_codepoint_t get_gid () const
|
||||||
void set_gid (hb_codepoint_t gid) { glyphIndex = gid; }
|
{
|
||||||
|
if (flags & GID_IS_24BIT)
|
||||||
|
return StructAfter<const HBGlyphID24> (flags);
|
||||||
|
else
|
||||||
|
return StructAfter<const HBGlyphID16> (flags);
|
||||||
|
}
|
||||||
|
void set_gid (hb_codepoint_t gid)
|
||||||
|
{
|
||||||
|
if (flags & GID_IS_24BIT)
|
||||||
|
StructAfter<HBGlyphID24> (flags) = gid;
|
||||||
|
else
|
||||||
|
/* TODO assert? */
|
||||||
|
StructAfter<HBGlyphID16> (flags) = gid;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HBUINT16 flags;
|
HBUINT16 flags;
|
||||||
HBGlyphID16 glyphIndex;
|
HBUINT24 pad;
|
||||||
public:
|
public:
|
||||||
DEFINE_SIZE_MIN (4);
|
DEFINE_SIZE_MIN (4);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue