[glyf] Move a few structs out of Glyph{}
This commit is contained in:
parent
ae75f066b5
commit
ef250eea7e
|
@ -212,20 +212,6 @@ enum phantom_point_index_t
|
|||
PHANTOM_COUNT = 4
|
||||
};
|
||||
|
||||
struct Glyph
|
||||
{
|
||||
enum simple_glyph_flag_t
|
||||
{
|
||||
FLAG_ON_CURVE = 0x01,
|
||||
FLAG_X_SHORT = 0x02,
|
||||
FLAG_Y_SHORT = 0x04,
|
||||
FLAG_REPEAT = 0x08,
|
||||
FLAG_X_SAME = 0x10,
|
||||
FLAG_Y_SAME = 0x20,
|
||||
FLAG_OVERLAP_SIMPLE = 0x40,
|
||||
FLAG_RESERVED2 = 0x80
|
||||
};
|
||||
|
||||
struct GlyphHeader
|
||||
{
|
||||
bool has_data () const { return numberOfContours; }
|
||||
|
@ -259,6 +245,18 @@ struct Glyph
|
|||
|
||||
struct SimpleGlyph
|
||||
{
|
||||
enum simple_glyph_flag_t
|
||||
{
|
||||
FLAG_ON_CURVE = 0x01,
|
||||
FLAG_X_SHORT = 0x02,
|
||||
FLAG_Y_SHORT = 0x04,
|
||||
FLAG_REPEAT = 0x08,
|
||||
FLAG_X_SAME = 0x10,
|
||||
FLAG_Y_SAME = 0x20,
|
||||
FLAG_OVERLAP_SIMPLE = 0x40,
|
||||
FLAG_RESERVED2 = 0x80
|
||||
};
|
||||
|
||||
const GlyphHeader &header;
|
||||
hb_bytes_t bytes;
|
||||
SimpleGlyph (const GlyphHeader &header_, hb_bytes_t bytes_) :
|
||||
|
@ -281,7 +279,7 @@ struct Glyph
|
|||
return instructionLength;
|
||||
}
|
||||
|
||||
const Glyph trim_padding () const
|
||||
const hb_bytes_t trim_padding () const
|
||||
{
|
||||
/* based on FontTools _g_l_y_f.py::trim */
|
||||
const uint8_t *glyph = (uint8_t*) bytes.arrayZ;
|
||||
|
@ -289,7 +287,7 @@ struct Glyph
|
|||
/* simple glyph w/contours, possibly trimmable */
|
||||
glyph += instruction_len_offset ();
|
||||
|
||||
if (unlikely (glyph + 2 >= glyph_end)) return Glyph ();
|
||||
if (unlikely (glyph + 2 >= glyph_end)) return hb_bytes_t ();
|
||||
unsigned int num_coordinates = StructAtOffset<HBUINT16> (glyph - 2, 0) + 1;
|
||||
unsigned int num_instructions = StructAtOffset<HBUINT16> (glyph, 0);
|
||||
|
||||
|
@ -305,7 +303,7 @@ struct Glyph
|
|||
unsigned int repeat = 1;
|
||||
if (flag & FLAG_REPEAT)
|
||||
{
|
||||
if (unlikely (glyph >= glyph_end)) return Glyph ();
|
||||
if (unlikely (glyph >= glyph_end)) return hb_bytes_t ();
|
||||
repeat = *glyph + 1;
|
||||
glyph++;
|
||||
}
|
||||
|
@ -323,8 +321,8 @@ struct Glyph
|
|||
if (coords_with_flags >= num_coordinates) break;
|
||||
}
|
||||
|
||||
if (unlikely (coords_with_flags != num_coordinates)) return Glyph ();
|
||||
return Glyph (bytes.sub_array (0, bytes.length + coord_bytes - (glyph_end - glyph)));
|
||||
if (unlikely (coords_with_flags != num_coordinates)) return hb_bytes_t ();
|
||||
return bytes.sub_array (0, bytes.length + coord_bytes - (glyph_end - glyph));
|
||||
}
|
||||
|
||||
/* zero instruction length */
|
||||
|
@ -455,7 +453,7 @@ struct Glyph
|
|||
|
||||
/* Trimming for composites not implemented.
|
||||
* If removing hints it falls out of that. */
|
||||
const Glyph trim_padding () const { return Glyph (bytes); }
|
||||
const hb_bytes_t trim_padding () const { return bytes; }
|
||||
|
||||
void drop_hints ()
|
||||
{
|
||||
|
@ -477,6 +475,9 @@ struct Glyph
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
struct Glyph
|
||||
{
|
||||
enum glyph_type_t { EMPTY, SIMPLE, COMPOSITE };
|
||||
|
||||
public:
|
||||
|
@ -486,7 +487,7 @@ struct Glyph
|
|||
return CompositeGlyph (*header, bytes).get_iterator ();
|
||||
}
|
||||
|
||||
const Glyph trim_padding () const
|
||||
const hb_bytes_t trim_padding () const
|
||||
{
|
||||
switch (type) {
|
||||
case COMPOSITE: return CompositeGlyph (*header, bytes).trim_padding ();
|
||||
|
|
|
@ -391,7 +391,7 @@ struct glyf_accelerator_t
|
|||
|
||||
Glyph glyph (hb_bytes_t ((const char *) this->glyf_table + start_offset,
|
||||
end_offset - start_offset), gid);
|
||||
return needs_padding_removal ? glyph.trim_padding () : glyph;
|
||||
return needs_padding_removal ? Glyph (glyph.trim_padding ()) : glyph;
|
||||
}
|
||||
|
||||
struct path_builder_t
|
||||
|
@ -425,7 +425,7 @@ struct glyf_accelerator_t
|
|||
* https://stackoverflow.com/a/20772557 */
|
||||
void consume_point (const contour_point_t &point)
|
||||
{
|
||||
bool is_on_curve = point.flag & Glyph::FLAG_ON_CURVE;
|
||||
bool is_on_curve = point.flag & SimpleGlyph::FLAG_ON_CURVE;
|
||||
optional_point_t p (point.x, point.y);
|
||||
if (!first_oncurve.has_data)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue