Resolve codepoints:glyph ids. Does not compile; undefined reference to OT::_hb_NullPool

pull/743/merge
Rod Sheeter 7 years ago committed by Behdad Esfahbod
parent 6a45e5df24
commit d0ce3c66e2
  1. 25
      src/hb-subset-plan.cc
  2. 2
      src/hb-subset-plan.hh
  3. 17
      src/hb-subset-private.hh
  4. 13
      src/hb-subset.cc

@ -21,17 +21,30 @@
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
* *
* Google Author(s): Garret Rieger * Google Author(s): Garret Rieger, Roderick Sheeter
*/ */
#include "hb-subset-plan.hh" #include "hb-subset-plan.hh"
#include "hb-subset-private.hh" #include "hb-subset-private.hh"
// TODO(Q1) map from old:new gid
hb_set_t * hb_set_t *
get_glyph_ids_from_cmap (hb_face_t *face, glyph_ids_to_retain (hb_subset_face_t *face,
hb_set_t *codepoints) hb_set_t *codepoints)
{ {
return hb_set_get_empty (); hb_codepoint_t cp = -1;
hb_set_t *gids = hb_set_create();
while (hb_set_next(codepoints, &cp)) {
hb_codepoint_t gid;
if (face->cmap.get_nominal_glyph(cp, &gid)) {
// TODO(Q1) a nice way to turn on/off logs
fprintf(stderr, "gid for U+%04X is %d\n", cp, gid);
hb_set_add(gids, cp);
} else {
fprintf(stderr, "Unable to resolve gid for U+%04X\n", cp);
}
}
return gids;
} }
/** /**
@ -45,12 +58,12 @@ get_glyph_ids_from_cmap (hb_face_t *face,
* Since: 1.7.5 * Since: 1.7.5
**/ **/
hb_subset_plan_t * hb_subset_plan_t *
hb_subset_plan_create (hb_face_t *face, hb_subset_plan_create (hb_subset_face_t *face,
hb_subset_profile_t *profile, hb_subset_profile_t *profile,
hb_subset_input_t *input) hb_subset_input_t *input)
{ {
hb_subset_plan_t *plan = hb_object_create<hb_subset_plan_t> (); hb_subset_plan_t *plan = hb_object_create<hb_subset_plan_t> ();
plan->glyphs_to_retain = get_glyph_ids_from_cmap (face, input->codepoints); plan->glyphs_to_retain = glyph_ids_to_retain (face, input->codepoints);
return plan; return plan;
} }

@ -40,7 +40,7 @@ struct hb_subset_plan_t {
typedef struct hb_subset_plan_t hb_subset_plan_t; typedef struct hb_subset_plan_t hb_subset_plan_t;
hb_subset_plan_t * hb_subset_plan_t *
hb_subset_plan_create (hb_face_t *face, hb_subset_plan_create (hb_subset_face_t *face,
hb_subset_profile_t *profile, hb_subset_profile_t *profile,
hb_subset_input_t *input); hb_subset_input_t *input);

@ -21,15 +21,21 @@
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
* *
* Google Author(s): Garret Rieger * Google Author(s): Garret Rieger, Roderick Sheeter
*/ */
#ifndef HB_SUBSET_PRIVATE_HH #ifndef HB_SUBSET_PRIVATE_HH
#define HB_SUBSET_PRIVATE_HH #define HB_SUBSET_PRIVATE_HH
#include "hb-object-private.hh"
#include "hb-private.hh" #include "hb-private.hh"
#include "hb-ot.h"
#include "hb-font-private.hh"
#include "hb-ot-cmap-table.hh"
struct hb_subset_input_t { struct hb_subset_input_t {
hb_object_header_t header; hb_object_header_t header;
ASSERT_POD (); ASSERT_POD ();
@ -37,4 +43,11 @@ struct hb_subset_input_t {
hb_set_t *codepoints; hb_set_t *codepoints;
}; };
struct hb_subset_face_t {
hb_object_header_t header;
hb_face_t *face;
OT::cmap::accelerator_t cmap;
};
#endif /* HB_SUBSET_PRIVATE_HH */ #endif /* HB_SUBSET_PRIVATE_HH */

@ -27,6 +27,7 @@
#include "hb-object-private.hh" #include "hb-object-private.hh"
#include "hb-private.hh" #include "hb-private.hh"
#include "hb-subset-glyf.hh" #include "hb-subset-glyf.hh"
#include "hb-subset-private.hh" #include "hb-subset-private.hh"
#include "hb-subset-plan.hh" #include "hb-subset-plan.hh"
@ -38,14 +39,6 @@ struct hb_subset_profile_t {
ASSERT_POD (); ASSERT_POD ();
}; };
struct hb_subset_face_t {
hb_object_header_t header;
ASSERT_POD ();
hb_face_t *face;
};
/** /**
* hb_subset_profile_create: * hb_subset_profile_create:
* *
@ -119,6 +112,7 @@ hb_subset_face_create (hb_face_t *face)
hb_subset_face_t *subset_face = hb_object_create<hb_subset_face_t> (); hb_subset_face_t *subset_face = hb_object_create<hb_subset_face_t> ();
subset_face->face = hb_face_reference (face); subset_face->face = hb_face_reference (face);
subset_face->cmap.init(face);
return subset_face; return subset_face;
} }
@ -133,6 +127,7 @@ hb_subset_face_destroy (hb_subset_face_t *subset_face)
{ {
if (!hb_object_destroy (subset_face)) return; if (!hb_object_destroy (subset_face)) return;
subset_face->cmap.fini();
hb_face_destroy(subset_face->face); hb_face_destroy(subset_face->face);
free (subset_face); free (subset_face);
} }
@ -154,7 +149,7 @@ hb_subset (hb_subset_profile_t *profile,
{ {
if (!profile || !input || !face) return false; if (!profile || !input || !face) return false;
hb_subset_plan_t *plan = hb_subset_plan_create (face->face, profile, input); hb_subset_plan_t *plan = hb_subset_plan_create (face, profile, input);
// TODO: // TODO:
// - Create initial header + table directory // - Create initial header + table directory

Loading…
Cancel
Save