2022-06-26 00:38:50 +02:00
|
|
|
#ifndef OT_GLYF_GLYPH_HH
|
|
|
|
#define OT_GLYF_GLYPH_HH
|
|
|
|
|
|
|
|
|
2022-06-26 01:05:18 +02:00
|
|
|
#include "../../hb-open-type.hh"
|
2022-06-26 00:38:50 +02:00
|
|
|
|
2022-06-26 01:53:13 +02:00
|
|
|
#include "GlyphHeader.hh"
|
2022-06-26 01:55:16 +02:00
|
|
|
#include "SimpleGlyph.hh"
|
2022-06-26 02:03:15 +02:00
|
|
|
#include "CompositeGlyph.hh"
|
2022-10-13 19:25:29 +02:00
|
|
|
#include "VarCompositeGlyph.hh"
|
2022-10-17 20:53:58 +02:00
|
|
|
#include "coord-setter.hh"
|
2022-06-26 01:53:13 +02:00
|
|
|
|
2022-06-26 00:38:50 +02:00
|
|
|
|
|
|
|
namespace OT {
|
|
|
|
|
|
|
|
struct glyf_accelerator_t;
|
|
|
|
|
2022-06-26 01:50:44 +02:00
|
|
|
namespace glyf_impl {
|
|
|
|
|
|
|
|
|
2022-10-26 21:11:47 +02:00
|
|
|
#ifndef HB_GLYF_MAX_POINTS
|
|
|
|
#define HB_GLYF_MAX_POINTS 10000
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2022-06-26 00:38:50 +02:00
|
|
|
enum phantom_point_index_t
|
|
|
|
{
|
|
|
|
PHANTOM_LEFT = 0,
|
|
|
|
PHANTOM_RIGHT = 1,
|
|
|
|
PHANTOM_TOP = 2,
|
|
|
|
PHANTOM_BOTTOM = 3,
|
|
|
|
PHANTOM_COUNT = 4
|
|
|
|
};
|
|
|
|
|
2022-06-26 01:37:59 +02:00
|
|
|
struct Glyph
|
|
|
|
{
|
2022-08-22 17:49:30 +02:00
|
|
|
enum glyph_type_t { EMPTY, SIMPLE, COMPOSITE, VAR_COMPOSITE };
|
2022-06-26 00:38:50 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
composite_iter_t get_composite_iterator () const
|
|
|
|
{
|
|
|
|
if (type != COMPOSITE) return composite_iter_t ();
|
2022-06-26 02:31:31 +02:00
|
|
|
return CompositeGlyph (*header, bytes).iter ();
|
2022-06-26 00:38:50 +02:00
|
|
|
}
|
2022-10-17 20:12:40 +02:00
|
|
|
var_composite_iter_t get_var_composite_iterator () const
|
|
|
|
{
|
|
|
|
if (type != VAR_COMPOSITE) return var_composite_iter_t ();
|
|
|
|
return VarCompositeGlyph (*header, bytes).iter ();
|
|
|
|
}
|
2022-06-26 00:38:50 +02:00
|
|
|
|
2022-06-26 01:37:59 +02:00
|
|
|
const hb_bytes_t trim_padding () const
|
2022-06-26 00:38:50 +02:00
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case COMPOSITE: return CompositeGlyph (*header, bytes).trim_padding ();
|
|
|
|
case SIMPLE: return SimpleGlyph (*header, bytes).trim_padding ();
|
|
|
|
default: return bytes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void drop_hints ()
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case COMPOSITE: CompositeGlyph (*header, bytes).drop_hints (); return;
|
|
|
|
case SIMPLE: SimpleGlyph (*header, bytes).drop_hints (); return;
|
|
|
|
default: return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_overlaps_flag ()
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case COMPOSITE: CompositeGlyph (*header, bytes).set_overlaps_flag (); return;
|
|
|
|
case SIMPLE: SimpleGlyph (*header, bytes).set_overlaps_flag (); return;
|
|
|
|
default: return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void drop_hints_bytes (hb_bytes_t &dest_start, hb_bytes_t &dest_end) const
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case COMPOSITE: CompositeGlyph (*header, bytes).drop_hints_bytes (dest_start); return;
|
|
|
|
case SIMPLE: SimpleGlyph (*header, bytes).drop_hints_bytes (dest_start, dest_end); return;
|
|
|
|
default: return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-22 18:37:09 +02:00
|
|
|
void update_mtx (const hb_subset_plan_t *plan,
|
|
|
|
int xMin, int yMax,
|
|
|
|
const contour_point_vector_t &all_points) const
|
|
|
|
{
|
|
|
|
hb_codepoint_t new_gid = 0;
|
|
|
|
if (!plan->new_gid_for_old_gid (gid, &new_gid))
|
|
|
|
return;
|
|
|
|
|
|
|
|
unsigned len = all_points.length;
|
|
|
|
float leftSideX = all_points[len - 4].x;
|
|
|
|
float rightSideX = all_points[len - 3].x;
|
|
|
|
float topSideY = all_points[len - 2].y;
|
|
|
|
float bottomSideY = all_points[len - 1].y;
|
|
|
|
|
|
|
|
int hori_aw = roundf (rightSideX - leftSideX);
|
|
|
|
if (hori_aw < 0) hori_aw = 0;
|
|
|
|
int lsb = roundf (xMin - leftSideX);
|
|
|
|
plan->hmtx_map->set (new_gid, hb_pair (hori_aw, lsb));
|
|
|
|
|
|
|
|
int vert_aw = roundf (topSideY - bottomSideY);
|
|
|
|
if (vert_aw < 0) vert_aw = 0;
|
|
|
|
int tsb = roundf (topSideY - yMax);
|
|
|
|
plan->vmtx_map->set (new_gid, hb_pair (vert_aw, tsb));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool compile_header_bytes (const hb_subset_plan_t *plan,
|
|
|
|
const contour_point_vector_t &all_points,
|
|
|
|
hb_bytes_t &dest_bytes /* OUT */) const
|
|
|
|
{
|
2022-08-24 23:16:55 +02:00
|
|
|
GlyphHeader *glyph_header = nullptr;
|
2022-09-14 20:26:32 +02:00
|
|
|
if (type != EMPTY && all_points.length > 4)
|
2022-07-22 18:37:09 +02:00
|
|
|
{
|
2022-08-24 23:16:55 +02:00
|
|
|
glyph_header = (GlyphHeader *) hb_calloc (1, GlyphHeader::static_size);
|
|
|
|
if (unlikely (!glyph_header)) return false;
|
2022-07-22 18:37:09 +02:00
|
|
|
}
|
|
|
|
|
2022-11-23 20:20:51 +01:00
|
|
|
float xMin = 0, xMax = 0;
|
|
|
|
float yMin = 0, yMax = 0;
|
2022-09-14 20:26:32 +02:00
|
|
|
if (all_points.length > 4)
|
|
|
|
{
|
2022-11-23 20:20:51 +01:00
|
|
|
xMin = xMax = all_points[0].x;
|
|
|
|
yMin = yMax = all_points[0].y;
|
2022-09-14 20:26:32 +02:00
|
|
|
}
|
2022-07-22 18:37:09 +02:00
|
|
|
|
|
|
|
for (unsigned i = 1; i < all_points.length - 4; i++)
|
|
|
|
{
|
2022-11-23 20:20:51 +01:00
|
|
|
float x = all_points[i].x;
|
|
|
|
float y = all_points[i].y;
|
|
|
|
xMin = hb_min (xMin, x);
|
|
|
|
xMax = hb_max (xMax, x);
|
|
|
|
yMin = hb_min (yMin, y);
|
|
|
|
yMax = hb_max (yMax, y);
|
2022-07-22 18:37:09 +02:00
|
|
|
}
|
|
|
|
|
2022-11-23 20:20:51 +01:00
|
|
|
update_mtx (plan, roundf (xMin), roundf (yMax), all_points);
|
2022-07-22 18:37:09 +02:00
|
|
|
|
2022-08-24 23:16:55 +02:00
|
|
|
/*for empty glyphs: all_points only include phantom points.
|
|
|
|
*just update metrics and then return */
|
2022-09-14 20:26:32 +02:00
|
|
|
if (!glyph_header)
|
2022-08-24 23:16:55 +02:00
|
|
|
return true;
|
|
|
|
|
2022-07-22 18:37:09 +02:00
|
|
|
glyph_header->numberOfContours = header->numberOfContours;
|
2022-11-23 20:20:51 +01:00
|
|
|
glyph_header->xMin = roundf (xMin);
|
|
|
|
glyph_header->yMin = roundf (yMin);
|
|
|
|
glyph_header->xMax = roundf (xMax);
|
|
|
|
glyph_header->yMax = roundf (yMax);
|
2022-07-22 18:37:09 +02:00
|
|
|
|
|
|
|
dest_bytes = hb_bytes_t ((const char *)glyph_header, GlyphHeader::static_size);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool compile_bytes_with_deltas (const hb_subset_plan_t *plan,
|
|
|
|
hb_font_t *font,
|
|
|
|
const glyf_accelerator_t &glyf,
|
|
|
|
hb_bytes_t &dest_start, /* IN/OUT */
|
2022-09-14 20:26:32 +02:00
|
|
|
hb_bytes_t &dest_end /* OUT */)
|
2022-07-22 18:37:09 +02:00
|
|
|
{
|
|
|
|
contour_point_vector_t all_points, deltas;
|
2022-09-20 22:14:26 +02:00
|
|
|
if (!get_points (font, glyf, all_points, &deltas, false, false))
|
|
|
|
return false;
|
2022-09-14 20:26:32 +02:00
|
|
|
|
|
|
|
// .notdef, set type to empty so we only update metrics and don't compile bytes for
|
|
|
|
// it
|
|
|
|
if (gid == 0 &&
|
|
|
|
!(plan->flags & HB_SUBSET_FLAGS_NOTDEF_OUTLINE))
|
|
|
|
type = EMPTY;
|
2022-07-22 18:37:09 +02:00
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case COMPOSITE:
|
|
|
|
if (!CompositeGlyph (*header, bytes).compile_bytes_with_deltas (dest_start,
|
|
|
|
deltas,
|
|
|
|
dest_end))
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case SIMPLE:
|
|
|
|
if (!SimpleGlyph (*header, bytes).compile_bytes_with_deltas (all_points,
|
|
|
|
plan->flags & HB_SUBSET_FLAGS_NO_HINTING,
|
|
|
|
dest_end))
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
default:
|
2022-08-24 23:16:55 +02:00
|
|
|
/* set empty bytes for empty glyph
|
|
|
|
* do not use source glyph's pointers */
|
|
|
|
dest_start = hb_bytes_t ();
|
|
|
|
dest_end = hb_bytes_t ();
|
|
|
|
break;
|
2022-07-22 18:37:09 +02:00
|
|
|
}
|
|
|
|
|
2022-09-20 22:14:26 +02:00
|
|
|
if (!compile_header_bytes (plan, all_points, dest_start))
|
|
|
|
{
|
|
|
|
dest_end.fini ();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2022-07-22 18:37:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-06-26 00:38:50 +02:00
|
|
|
/* Note: Recursively calls itself.
|
|
|
|
* all_points includes phantom points
|
|
|
|
*/
|
|
|
|
template <typename accelerator_t>
|
|
|
|
bool get_points (hb_font_t *font, const accelerator_t &glyf_accelerator,
|
|
|
|
contour_point_vector_t &all_points /* OUT */,
|
2022-07-22 18:37:09 +02:00
|
|
|
contour_point_vector_t *deltas = nullptr, /* OUT */
|
2022-09-14 20:26:32 +02:00
|
|
|
bool shift_points_hori = true,
|
2022-08-26 17:24:19 +02:00
|
|
|
bool use_my_metrics = true,
|
2022-06-26 00:38:50 +02:00
|
|
|
bool phantom_only = false,
|
2022-12-10 02:42:46 +01:00
|
|
|
hb_array_t<int> coords = hb_array_t<int> (),
|
2022-06-26 00:38:50 +02:00
|
|
|
unsigned int depth = 0) const
|
|
|
|
{
|
|
|
|
if (unlikely (depth > HB_MAX_NESTING_LEVEL)) return false;
|
2022-12-10 02:42:46 +01:00
|
|
|
|
|
|
|
if (!coords)
|
|
|
|
coords = hb_array (font->coords, font->num_coords);
|
|
|
|
|
2022-06-27 00:09:32 +02:00
|
|
|
contour_point_vector_t stack_points;
|
|
|
|
bool inplace = type == SIMPLE && all_points.length == 0;
|
2022-06-27 21:07:39 +02:00
|
|
|
/* Load into all_points if it's empty, as an optimization. */
|
2022-06-27 00:09:32 +02:00
|
|
|
contour_point_vector_t &points = inplace ? all_points : stack_points;
|
2022-06-26 00:38:50 +02:00
|
|
|
|
|
|
|
switch (type) {
|
2022-10-17 20:12:40 +02:00
|
|
|
case SIMPLE:
|
|
|
|
if (unlikely (!SimpleGlyph (*header, bytes).get_contour_points (points, phantom_only)))
|
|
|
|
return false;
|
|
|
|
break;
|
2022-06-26 00:38:50 +02:00
|
|
|
case COMPOSITE:
|
|
|
|
{
|
|
|
|
/* pseudo component points for each component in composite glyph */
|
2022-06-26 02:31:31 +02:00
|
|
|
unsigned num_points = hb_len (CompositeGlyph (*header, bytes).iter ());
|
2022-06-26 00:38:50 +02:00
|
|
|
if (unlikely (!points.resize (num_points))) return false;
|
|
|
|
break;
|
|
|
|
}
|
2022-12-10 02:59:43 +01:00
|
|
|
#ifndef HB_NO_VAR_COMPOSITES
|
2022-10-17 20:12:40 +02:00
|
|
|
case VAR_COMPOSITE:
|
|
|
|
{
|
2022-10-17 20:48:24 +02:00
|
|
|
for (auto &item : get_var_composite_iterator ())
|
|
|
|
if (unlikely (!item.get_points (points))) return false;
|
2022-10-17 20:12:40 +02:00
|
|
|
}
|
2022-12-10 02:59:43 +01:00
|
|
|
#endif
|
2022-10-17 20:12:40 +02:00
|
|
|
default:
|
2022-06-26 00:38:50 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Init phantom points */
|
|
|
|
if (unlikely (!points.resize (points.length + PHANTOM_COUNT))) return false;
|
2022-11-17 05:22:43 +01:00
|
|
|
hb_array_t<contour_point_t> phantoms = points.as_array ().sub_array (points.length - PHANTOM_COUNT, PHANTOM_COUNT);
|
2022-06-26 00:38:50 +02:00
|
|
|
{
|
2022-07-03 23:32:32 +02:00
|
|
|
int lsb = 0;
|
|
|
|
int h_delta = glyf_accelerator.hmtx->get_leading_bearing_without_var_unscaled (gid, &lsb) ?
|
|
|
|
(int) header->xMin - lsb : 0;
|
2022-11-24 20:59:55 +01:00
|
|
|
HB_UNUSED int tsb = 0;
|
2022-06-26 00:38:50 +02:00
|
|
|
int v_orig = (int) header->yMax +
|
|
|
|
#ifndef HB_NO_VERTICAL
|
2022-07-03 23:32:32 +02:00
|
|
|
((void) glyf_accelerator.vmtx->get_leading_bearing_without_var_unscaled (gid, &tsb), tsb)
|
2022-06-26 00:38:50 +02:00
|
|
|
#else
|
|
|
|
0
|
|
|
|
#endif
|
|
|
|
;
|
2022-07-03 20:54:17 +02:00
|
|
|
unsigned h_adv = glyf_accelerator.hmtx->get_advance_without_var_unscaled (gid);
|
2022-06-26 00:38:50 +02:00
|
|
|
unsigned v_adv =
|
|
|
|
#ifndef HB_NO_VERTICAL
|
2022-07-03 20:54:17 +02:00
|
|
|
glyf_accelerator.vmtx->get_advance_without_var_unscaled (gid)
|
2022-06-26 00:38:50 +02:00
|
|
|
#else
|
|
|
|
- font->face->get_upem ()
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
phantoms[PHANTOM_LEFT].x = h_delta;
|
|
|
|
phantoms[PHANTOM_RIGHT].x = h_adv + h_delta;
|
|
|
|
phantoms[PHANTOM_TOP].y = v_orig;
|
|
|
|
phantoms[PHANTOM_BOTTOM].y = v_orig - (int) v_adv;
|
|
|
|
}
|
|
|
|
|
2022-07-22 18:37:09 +02:00
|
|
|
if (deltas != nullptr && depth == 0 && type == COMPOSITE)
|
|
|
|
{
|
|
|
|
if (unlikely (!deltas->resize (points.length))) return false;
|
2022-09-20 22:14:26 +02:00
|
|
|
deltas->copy_vector (points);
|
2022-07-22 18:37:09 +02:00
|
|
|
}
|
|
|
|
|
2022-06-26 00:38:50 +02:00
|
|
|
#ifndef HB_NO_VAR
|
2022-12-10 02:35:30 +01:00
|
|
|
glyf_accelerator.gvar->apply_deltas_to_points (gid,
|
2022-12-10 02:42:46 +01:00
|
|
|
coords,
|
2022-12-10 02:35:30 +01:00
|
|
|
points.as_array ());
|
2022-06-26 00:38:50 +02:00
|
|
|
#endif
|
|
|
|
|
2022-07-22 18:37:09 +02:00
|
|
|
// mainly used by CompositeGlyph calculating new X/Y offset value so no need to extend it
|
|
|
|
// with child glyphs' points
|
|
|
|
if (deltas != nullptr && depth == 0 && type == COMPOSITE)
|
|
|
|
{
|
|
|
|
for (unsigned i = 0 ; i < points.length; i++)
|
|
|
|
{
|
|
|
|
deltas->arrayZ[i].x = points.arrayZ[i].x - deltas->arrayZ[i].x;
|
|
|
|
deltas->arrayZ[i].y = points.arrayZ[i].y - deltas->arrayZ[i].y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-26 00:38:50 +02:00
|
|
|
switch (type) {
|
|
|
|
case SIMPLE:
|
2022-06-27 00:09:32 +02:00
|
|
|
if (!inplace)
|
|
|
|
all_points.extend (points.as_array ());
|
2022-06-26 00:38:50 +02:00
|
|
|
break;
|
|
|
|
case COMPOSITE:
|
|
|
|
{
|
2022-06-27 20:24:20 +02:00
|
|
|
contour_point_vector_t comp_points;
|
2022-06-26 00:38:50 +02:00
|
|
|
unsigned int comp_index = 0;
|
|
|
|
for (auto &item : get_composite_iterator ())
|
|
|
|
{
|
2022-06-27 20:24:20 +02:00
|
|
|
comp_points.reset ();
|
2022-08-22 17:49:30 +02:00
|
|
|
|
2022-07-11 23:08:22 +02:00
|
|
|
if (unlikely (!glyf_accelerator.glyph_for_gid (item.get_gid ())
|
2022-12-10 02:42:46 +01:00
|
|
|
.get_points (font,
|
|
|
|
glyf_accelerator,
|
|
|
|
comp_points,
|
|
|
|
deltas,
|
|
|
|
shift_points_hori,
|
|
|
|
use_my_metrics,
|
|
|
|
phantom_only,
|
|
|
|
coords,
|
|
|
|
depth + 1)))
|
2022-06-26 00:38:50 +02:00
|
|
|
return false;
|
|
|
|
|
2022-12-11 20:00:54 +01:00
|
|
|
/* Copy phantom points from component if USE_MY_METRICS flag set */
|
|
|
|
if (use_my_metrics && item.is_use_my_metrics ())
|
|
|
|
for (unsigned int i = 0; i < PHANTOM_COUNT; i++)
|
|
|
|
phantoms[i] = comp_points[comp_points.length - PHANTOM_COUNT + i];
|
|
|
|
|
2022-06-26 00:38:50 +02:00
|
|
|
/* Apply component transformation & translation */
|
|
|
|
item.transform_points (comp_points);
|
|
|
|
|
|
|
|
/* Apply translation from gvar */
|
|
|
|
comp_points.translate (points[comp_index]);
|
|
|
|
|
|
|
|
if (item.is_anchored ())
|
|
|
|
{
|
|
|
|
unsigned int p1, p2;
|
|
|
|
item.get_anchor_points (p1, p2);
|
|
|
|
if (likely (p1 < all_points.length && p2 < comp_points.length))
|
|
|
|
{
|
|
|
|
contour_point_t delta;
|
|
|
|
delta.init (all_points[p1].x - comp_points[p2].x,
|
|
|
|
all_points[p1].y - comp_points[p2].y);
|
|
|
|
|
|
|
|
comp_points.translate (delta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-11 20:00:54 +01:00
|
|
|
all_points.extend (comp_points.as_array ().sub_array (0, comp_points.length - PHANTOM_COUNT));
|
2022-10-14 01:18:19 +02:00
|
|
|
|
2022-10-26 21:11:47 +02:00
|
|
|
if (all_points.length > HB_GLYF_MAX_POINTS)
|
|
|
|
return false;
|
|
|
|
|
2022-06-26 00:38:50 +02:00
|
|
|
comp_index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
all_points.extend (phantoms);
|
|
|
|
} break;
|
2022-12-10 02:59:43 +01:00
|
|
|
#ifndef HB_NO_VAR_COMPOSITES
|
2022-10-17 20:12:40 +02:00
|
|
|
case VAR_COMPOSITE:
|
|
|
|
{
|
|
|
|
contour_point_vector_t comp_points;
|
2022-10-17 20:48:24 +02:00
|
|
|
hb_array_t<contour_point_t> points_left = points.as_array ();
|
2022-10-17 20:12:40 +02:00
|
|
|
for (auto &item : get_var_composite_iterator ())
|
|
|
|
{
|
2022-10-17 20:48:24 +02:00
|
|
|
hb_array_t<contour_point_t> record_points = points_left.sub_array (0, item.get_num_points ());
|
|
|
|
|
2022-10-17 20:12:40 +02:00
|
|
|
comp_points.reset ();
|
|
|
|
|
2022-12-10 02:45:37 +01:00
|
|
|
coord_setter_t coord_setter (coords);
|
2022-10-18 19:00:35 +02:00
|
|
|
item.set_variations (coord_setter, record_points);
|
2022-10-17 20:48:24 +02:00
|
|
|
|
2022-10-17 20:12:40 +02:00
|
|
|
if (unlikely (!glyf_accelerator.glyph_for_gid (item.get_gid ())
|
2022-12-10 02:42:46 +01:00
|
|
|
.get_points (font,
|
|
|
|
glyf_accelerator,
|
|
|
|
comp_points,
|
|
|
|
deltas,
|
|
|
|
shift_points_hori,
|
|
|
|
use_my_metrics,
|
|
|
|
phantom_only,
|
2022-12-10 02:45:37 +01:00
|
|
|
coord_setter.get_coords (),
|
2022-12-10 02:42:46 +01:00
|
|
|
depth + 1)))
|
2022-10-17 20:12:40 +02:00
|
|
|
return false;
|
|
|
|
|
2022-10-17 20:48:24 +02:00
|
|
|
/* Apply component transformation */
|
|
|
|
item.transform_points (record_points, comp_points);
|
2022-10-17 20:12:40 +02:00
|
|
|
|
|
|
|
/* Copy phantom points from component if USE_MY_METRICS flag set */
|
|
|
|
if (use_my_metrics && item.is_use_my_metrics ())
|
|
|
|
for (unsigned int i = 0; i < PHANTOM_COUNT; i++)
|
|
|
|
phantoms[i] = comp_points[comp_points.length - PHANTOM_COUNT + i];
|
|
|
|
|
2022-12-09 22:48:41 +01:00
|
|
|
all_points.extend (comp_points.as_array ().sub_array (0, comp_points.length - PHANTOM_COUNT));
|
2022-10-17 20:48:24 +02:00
|
|
|
|
2022-12-11 20:00:54 +01:00
|
|
|
if (all_points.length > HB_GLYF_MAX_POINTS)
|
|
|
|
return false;
|
|
|
|
|
2022-10-17 20:48:24 +02:00
|
|
|
points_left += item.get_num_points ();
|
2022-10-17 20:12:40 +02:00
|
|
|
}
|
|
|
|
all_points.extend (phantoms);
|
|
|
|
} break;
|
2022-12-10 02:59:43 +01:00
|
|
|
#endif
|
2022-06-26 00:38:50 +02:00
|
|
|
default:
|
|
|
|
all_points.extend (phantoms);
|
2022-10-17 20:12:40 +02:00
|
|
|
break;
|
2022-06-26 00:38:50 +02:00
|
|
|
}
|
|
|
|
|
2022-09-14 20:26:32 +02:00
|
|
|
if (depth == 0 && shift_points_hori) /* Apply at top level */
|
2022-06-26 00:38:50 +02:00
|
|
|
{
|
|
|
|
/* Undocumented rasterizer behavior:
|
|
|
|
* Shift points horizontally by the updated left side bearing
|
|
|
|
*/
|
|
|
|
contour_point_t delta;
|
|
|
|
delta.init (-phantoms[PHANTOM_LEFT].x, 0.f);
|
|
|
|
if (delta.x) all_points.translate (delta);
|
|
|
|
}
|
|
|
|
|
2022-06-27 18:57:51 +02:00
|
|
|
return !all_points.in_error ();
|
2022-06-26 00:38:50 +02:00
|
|
|
}
|
|
|
|
|
2022-07-03 21:21:06 +02:00
|
|
|
bool get_extents_without_var_scaled (hb_font_t *font, const glyf_accelerator_t &glyf_accelerator,
|
|
|
|
hb_glyph_extents_t *extents) const
|
2022-06-26 00:38:50 +02:00
|
|
|
{
|
|
|
|
if (type == EMPTY) return true; /* Empty glyph; zero extents. */
|
2022-07-03 21:21:06 +02:00
|
|
|
return header->get_extents_without_var_scaled (font, glyf_accelerator, gid, extents);
|
2022-06-26 00:38:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hb_bytes_t get_bytes () const { return bytes; }
|
|
|
|
|
2022-09-28 00:50:54 +02:00
|
|
|
Glyph () : bytes (),
|
|
|
|
header (bytes.as<GlyphHeader> ()),
|
|
|
|
gid (-1),
|
|
|
|
type(EMPTY)
|
|
|
|
{}
|
|
|
|
|
|
|
|
Glyph (hb_bytes_t bytes_,
|
|
|
|
hb_codepoint_t gid_ = (unsigned) -1) : bytes (bytes_),
|
|
|
|
header (bytes.as<GlyphHeader> ()),
|
|
|
|
gid (gid_)
|
2022-06-26 00:38:50 +02:00
|
|
|
{
|
|
|
|
int num_contours = header->numberOfContours;
|
|
|
|
if (unlikely (num_contours == 0)) type = EMPTY;
|
|
|
|
else if (num_contours > 0) type = SIMPLE;
|
2022-08-22 17:49:30 +02:00
|
|
|
else if (num_contours == -2) type = VAR_COMPOSITE;
|
2022-06-26 00:38:50 +02:00
|
|
|
else type = COMPOSITE; /* negative numbers */
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
hb_bytes_t bytes;
|
|
|
|
const GlyphHeader *header;
|
2022-06-27 20:41:46 +02:00
|
|
|
hb_codepoint_t gid;
|
2022-06-26 00:38:50 +02:00
|
|
|
unsigned type;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-06-26 01:50:44 +02:00
|
|
|
} /* namespace glyf_impl */
|
2022-06-26 00:38:50 +02:00
|
|
|
} /* namespace OT */
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* OT_GLYF_GLYPH_HH */
|