[VarComposites] More ifdef guards

This commit is contained in:
Behdad Esfahbod 2023-04-20 18:17:14 -06:00
parent 1e9a0511f3
commit d1f49ba6d2
1 changed files with 28 additions and 5 deletions

View File

@ -29,7 +29,14 @@ enum phantom_point_index_t
struct Glyph struct Glyph
{ {
enum glyph_type_t { EMPTY, SIMPLE, COMPOSITE, VAR_COMPOSITE }; enum glyph_type_t {
EMPTY,
SIMPLE,
COMPOSITE,
#ifndef HB_NO_VAR_COMPOSITES
VAR_COMPOSITE,
#endif
};
public: public:
composite_iter_t get_composite_iterator () const composite_iter_t get_composite_iterator () const
@ -39,14 +46,20 @@ struct Glyph
} }
var_composite_iter_t get_var_composite_iterator () const var_composite_iter_t get_var_composite_iterator () const
{ {
#ifndef HB_NO_VAR_COMPOSITES
if (type != VAR_COMPOSITE) return var_composite_iter_t (); if (type != VAR_COMPOSITE) return var_composite_iter_t ();
return VarCompositeGlyph (*header, bytes).iter (); return VarCompositeGlyph (*header, bytes).iter ();
#else
return var_composite_iter_t ();
#endif
} }
const hb_bytes_t trim_padding () const const hb_bytes_t trim_padding () const
{ {
switch (type) { switch (type) {
#ifndef HB_NO_VAR_COMPOSITES
case VAR_COMPOSITE: return bytes; // TODO case VAR_COMPOSITE: return bytes; // TODO
#endif
case COMPOSITE: return CompositeGlyph (*header, bytes).trim_padding (); case COMPOSITE: return CompositeGlyph (*header, bytes).trim_padding ();
case SIMPLE: return SimpleGlyph (*header, bytes).trim_padding (); case SIMPLE: return SimpleGlyph (*header, bytes).trim_padding ();
case EMPTY: return bytes; case EMPTY: return bytes;
@ -57,7 +70,9 @@ struct Glyph
void drop_hints () void drop_hints ()
{ {
switch (type) { switch (type) {
#ifndef HB_NO_VAR_COMPOSITES
case VAR_COMPOSITE: return; case VAR_COMPOSITE: return;
#endif
case COMPOSITE: CompositeGlyph (*header, bytes).drop_hints (); return; case COMPOSITE: CompositeGlyph (*header, bytes).drop_hints (); return;
case SIMPLE: SimpleGlyph (*header, bytes).drop_hints (); return; case SIMPLE: SimpleGlyph (*header, bytes).drop_hints (); return;
case EMPTY: return; case EMPTY: return;
@ -67,7 +82,9 @@ struct Glyph
void set_overlaps_flag () void set_overlaps_flag ()
{ {
switch (type) { switch (type) {
#ifndef HB_NO_VAR_COMPOSITES
case VAR_COMPOSITE: return; case VAR_COMPOSITE: return;
#endif
case COMPOSITE: CompositeGlyph (*header, bytes).set_overlaps_flag (); return; case COMPOSITE: CompositeGlyph (*header, bytes).set_overlaps_flag (); return;
case SIMPLE: SimpleGlyph (*header, bytes).set_overlaps_flag (); return; case SIMPLE: SimpleGlyph (*header, bytes).set_overlaps_flag (); return;
case EMPTY: return; case EMPTY: return;
@ -77,7 +94,9 @@ struct Glyph
void drop_hints_bytes (hb_bytes_t &dest_start, hb_bytes_t &dest_end) const void drop_hints_bytes (hb_bytes_t &dest_start, hb_bytes_t &dest_end) const
{ {
switch (type) { switch (type) {
#ifndef HB_NO_VAR_COMPOSITES
case VAR_COMPOSITE: return; case VAR_COMPOSITE: return;
#endif
case COMPOSITE: CompositeGlyph (*header, bytes).drop_hints_bytes (dest_start); return; case COMPOSITE: CompositeGlyph (*header, bytes).drop_hints_bytes (dest_start); return;
case SIMPLE: SimpleGlyph (*header, bytes).drop_hints_bytes (dest_start, dest_end); return; case SIMPLE: SimpleGlyph (*header, bytes).drop_hints_bytes (dest_start, dest_end); return;
case EMPTY: return; case EMPTY: return;
@ -218,9 +237,11 @@ struct Glyph
{ {
switch (type) switch (type)
{ {
#ifndef HB_NO_VAR_COMPOSITES
case VAR_COMPOSITE: case VAR_COMPOSITE:
// TODO // TODO
return false; return false;
#endif
case COMPOSITE: case COMPOSITE:
if (!CompositeGlyph (*header, bytes).compile_bytes_with_deltas (dest_start, if (!CompositeGlyph (*header, bytes).compile_bytes_with_deltas (dest_start,
@ -303,13 +324,13 @@ struct Glyph
if (unlikely (!points.resize (num_points))) return false; if (unlikely (!points.resize (num_points))) return false;
break; break;
} }
#ifndef HB_NO_VAR_COMPOSITES
case VAR_COMPOSITE: case VAR_COMPOSITE:
{ {
#ifndef HB_NO_VAR_COMPOSITES
for (auto &item : get_var_composite_iterator ()) for (auto &item : get_var_composite_iterator ())
if (unlikely (!item.get_points (points))) return false; if (unlikely (!item.get_points (points))) return false;
#endif
} }
#endif
case EMPTY: case EMPTY:
break; break;
} }
@ -437,9 +458,9 @@ struct Glyph
} }
all_points.extend (phantoms); all_points.extend (phantoms);
} break; } break;
#ifndef HB_NO_VAR_COMPOSITES
case VAR_COMPOSITE: case VAR_COMPOSITE:
{ {
#ifndef HB_NO_VAR_COMPOSITES
contour_point_vector_t comp_points; contour_point_vector_t comp_points;
hb_array_t<contour_point_t> points_left = points.as_array (); hb_array_t<contour_point_t> points_left = points.as_array ();
for (auto &item : get_var_composite_iterator ()) for (auto &item : get_var_composite_iterator ())
@ -486,8 +507,8 @@ struct Glyph
points_left += item.get_num_points (); points_left += item.get_num_points ();
} }
all_points.extend (phantoms); all_points.extend (phantoms);
#endif
} break; } break;
#endif
case EMPTY: case EMPTY:
all_points.extend (phantoms); all_points.extend (phantoms);
break; break;
@ -531,7 +552,9 @@ struct Glyph
int num_contours = header->numberOfContours; int num_contours = header->numberOfContours;
if (unlikely (num_contours == 0)) type = EMPTY; if (unlikely (num_contours == 0)) type = EMPTY;
else if (num_contours > 0) type = SIMPLE; else if (num_contours > 0) type = SIMPLE;
#ifndef HB_NO_VAR_COMPOSITES
else if (num_contours == -2) type = VAR_COMPOSITE; else if (num_contours == -2) type = VAR_COMPOSITE;
#endif
else type = COMPOSITE; /* negative numbers */ else type = COMPOSITE; /* negative numbers */
} }