[subset] Set the new number of glyphs in maxp.
This commit is contained in:
parent
427f9e4b90
commit
83e1ef9215
|
@ -48,6 +48,11 @@ struct maxp
|
||||||
return numGlyphs;
|
return numGlyphs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void set_num_glyphs (uint16_t count)
|
||||||
|
{
|
||||||
|
numGlyphs.set (count);
|
||||||
|
}
|
||||||
|
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) const
|
inline bool sanitize (hb_sanitize_context_t *c) const
|
||||||
{
|
{
|
||||||
TRACE_SANITIZE (this);
|
TRACE_SANITIZE (this);
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
#include "hb-open-file-private.hh"
|
#include "hb-open-file-private.hh"
|
||||||
#include "hb-ot-cmap-table.hh"
|
#include "hb-ot-cmap-table.hh"
|
||||||
#include "hb-ot-glyf-table.hh"
|
#include "hb-ot-glyf-table.hh"
|
||||||
|
#include "hb-ot-head-table.hh"
|
||||||
|
#include "hb-ot-maxp-table.hh"
|
||||||
|
|
||||||
|
|
||||||
#ifndef HB_NO_VISIBILITY
|
#ifndef HB_NO_VISIBILITY
|
||||||
|
@ -265,19 +267,42 @@ _add_head_and_set_loca_version (hb_face_t *source, bool use_short_loca, hb_face_
|
||||||
|
|
||||||
hb_blob_t *head_prime_blob = hb_blob_create ((const char*) head_prime,
|
hb_blob_t *head_prime_blob = hb_blob_create ((const char*) head_prime,
|
||||||
OT::head::static_size,
|
OT::head::static_size,
|
||||||
HB_MEMORY_MODE_WRITABLE,
|
HB_MEMORY_MODE_READONLY,
|
||||||
head_prime,
|
head_prime,
|
||||||
free);
|
free);
|
||||||
has_head = has_head && hb_subset_face_add_table (dest, HB_OT_TAG_head, head_prime_blob);
|
has_head = hb_subset_face_add_table (dest, HB_OT_TAG_head, head_prime_blob);
|
||||||
|
|
||||||
hb_blob_destroy (head_prime_blob);
|
hb_blob_destroy (head_prime_blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
hb_blob_destroy (head_blob);
|
hb_blob_destroy (head_blob);
|
||||||
|
|
||||||
return has_head;
|
return has_head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
_add_maxp_and_set_glyph_count (hb_subset_plan_t *plan, hb_face_t *source, hb_face_t *dest)
|
||||||
|
{
|
||||||
|
hb_blob_t *maxp_blob = OT::Sanitizer<OT::maxp>().sanitize (hb_face_reference_table (source, HB_OT_TAG_maxp));
|
||||||
|
const OT::maxp *maxp = OT::Sanitizer<OT::maxp>::lock_instance (maxp_blob);
|
||||||
|
bool has_maxp = (maxp != nullptr);
|
||||||
|
if (has_maxp) {
|
||||||
|
unsigned int length = hb_blob_get_length (maxp_blob);
|
||||||
|
OT::maxp *maxp_prime = (OT::maxp *) calloc (length, 1);
|
||||||
|
memcpy (maxp_prime, maxp, length);
|
||||||
|
maxp_prime->set_num_glyphs (plan->gids_to_retain_sorted.len);
|
||||||
|
|
||||||
|
hb_blob_t *maxp_prime_blob = hb_blob_create ((const char*) maxp_prime,
|
||||||
|
length,
|
||||||
|
HB_MEMORY_MODE_READONLY,
|
||||||
|
maxp_prime,
|
||||||
|
free);
|
||||||
|
has_maxp = hb_subset_face_add_table (dest, HB_OT_TAG_maxp, maxp_prime_blob);
|
||||||
|
hb_blob_destroy (maxp_prime_blob);
|
||||||
|
}
|
||||||
|
|
||||||
|
hb_blob_destroy (maxp_blob);
|
||||||
|
return has_maxp;
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
_subset_glyf (hb_subset_plan_t *plan, hb_face_t *source, hb_face_t *dest)
|
_subset_glyf (hb_subset_plan_t *plan, hb_face_t *source, hb_face_t *dest)
|
||||||
{
|
{
|
||||||
|
@ -316,6 +341,8 @@ _subset_table (hb_subset_plan_t *plan,
|
||||||
case HB_OT_TAG_head:
|
case HB_OT_TAG_head:
|
||||||
// SKIP head, it's handled by glyf
|
// SKIP head, it's handled by glyf
|
||||||
return true;
|
return true;
|
||||||
|
case HB_OT_TAG_maxp:
|
||||||
|
return _add_maxp_and_set_glyph_count (plan, source, dest);
|
||||||
case HB_OT_TAG_loca:
|
case HB_OT_TAG_loca:
|
||||||
// SKIP loca, it's handle by glyf
|
// SKIP loca, it's handle by glyf
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue